wp-user-avatar
/
src
/
Admin
/
SettingsPages
/
Membership
/
views
/
subscriptions
/
data-metabox.php
add-edit-subscription.php
4 years ago
data-metabox.php
4 years ago
sub-payments-metabox.php
4 years ago
submit-sidebar.php
4 years ago
subscription-notes-sidebar.php
4 years ago
data-metabox.php
150 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Admin\SettingsPages\Membership\CustomersPage\CustomerWPListTable; |
| 4 | use ProfilePress\Core\Membership\Models\Customer\CustomerFactory; |
| 5 | use ProfilePress\Core\Membership\Models\Order\OrderFactory; |
| 6 | use ProfilePress\Core\Membership\Models\Plan\PlanFactory; |
| 7 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionBillingFrequency; |
| 8 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionEntity; |
| 9 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionStatus; |
| 10 | use ProfilePress\Core\Membership\PaymentMethods\PaymentMethods; |
| 11 | use ProfilePress\Core\Membership\Services\Calculator; |
| 12 | use ProfilePress\Core\Membership\Services\TaxService; |
| 13 | |
| 14 | /** @global SubscriptionEntity $subscription_data */ |
| 15 | /** @global int $subscription_id */ |
| 16 | |
| 17 | $customer = CustomerFactory::fromId($subscription_data->customer_id); |
| 18 | $parent_order_data = OrderFactory::fromId($subscription_data->parent_order_id); |
| 19 | $parent_order_data_currency_symbol = ppress_get_currency_symbol($parent_order_data->currency); |
| 20 | $planInstance = PlanFactory::fromId($subscription_data->plan_id); |
| 21 | |
| 22 | $payment_method_title = ''; |
| 23 | $profile_id = $subscription_data->profile_id; |
| 24 | |
| 25 | if ( ! empty($parent_order_data->payment_method)) { |
| 26 | $payment_method_instance = PaymentMethods::get_instance()->get_by_id($parent_order_data->payment_method); |
| 27 | $profile_id = $payment_method_instance->link_profile_id($profile_id); |
| 28 | $payment_method_title = $payment_method_instance->get_method_title(); |
| 29 | } |
| 30 | |
| 31 | $payment_method_string = ''; |
| 32 | |
| 33 | if ( ! empty($payment_method_title)) { |
| 34 | $payment_method_string .= sprintf(__('Payment via %s', 'wp-user-avatar'), esc_html($payment_method_title)); |
| 35 | } |
| 36 | |
| 37 | if ( ! empty($profile_id)) { |
| 38 | $payment_method_string .= ' (' . wp_kses_post($profile_id) . ')'; |
| 39 | } |
| 40 | |
| 41 | echo '<div class="ppress-membership-subscription-details">'; |
| 42 | |
| 43 | printf('<h2 class="ppress-metabox-data-heading">' . esc_html__('Subscription #%s', 'wp-user-avatar') . '</h2>', $subscription_id); |
| 44 | |
| 45 | if ( ! empty($payment_method_string)) { |
| 46 | echo '<p class="ppress-metabox-meta-data">'; |
| 47 | echo $payment_method_string; |
| 48 | echo '</p>'; |
| 49 | } |
| 50 | ?> |
| 51 | <div class="ppress-metabox-data-column-container"> |
| 52 | <div class="ppress-metabox-data-column"> |
| 53 | |
| 54 | <p class="mb-form-field sub_plan"> |
| 55 | <strong><?php _e('Subscription Plan:', 'wp-user-avatar'); ?></strong> |
| 56 | <a href="<?= $planInstance->get_edit_plan_url() ?>"><?= $planInstance->get_name() ?></a> |
| 57 | </p> |
| 58 | |
| 59 | <p class="mb-form-field sub_terms"> |
| 60 | <strong><?php _e('Terms:', 'wp-user-avatar'); ?></strong> |
| 61 | <?php echo $subscription_data->get_subscription_terms(); ?> |
| 62 | </p> |
| 63 | |
| 64 | <?php if ($subscription_data->get_total_payments() > 0) : ?> |
| 65 | <p class="mb-form-field completed_payments"> |
| 66 | <strong><?php _e('Completed Payments:', 'wp-user-avatar'); ?></strong> |
| 67 | <?php printf('%s / %s', $subscription_data->get_completed_order_count(), $subscription_data->get_total_payments()); ?> |
| 68 | </p> |
| 69 | <?php endif; ?> |
| 70 | |
| 71 | <?php if (TaxService::init()->is_tax_enabled()) : ?> |
| 72 | <p class="mb-form-field sub_initial_amount"> |
| 73 | <label for="sub_initial_amount"><?php printf(esc_html__('Initial Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 74 | <input id="sub_initial_amount" type="text" name="sub_initial_amount" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->initial_amount)); ?>"/> |
| 75 | </p> |
| 76 | |
| 77 | <p class="mb-form-field sub_initial_tax"> |
| 78 | <label for="sub_initial_tax"><?php printf(esc_html__('Initial Tax Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 79 | <input id="sub_initial_tax" type="text" name="sub_initial_tax" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->initial_tax)); ?>"/> |
| 80 | </p> |
| 81 | |
| 82 | <p class="mb-form-field sub_initial_tax_rate"> |
| 83 | <label for="sub_initial_tax_rate"><?php printf(esc_html__('Initial Tax Rate (%s):', 'wp-user-avatar'), '%'); ?></label> |
| 84 | <input id="sub_initial_tax_rate" type="text" name="sub_initial_tax_rate" value="<?php echo esc_attr($subscription_data->initial_tax_rate); ?>"/> |
| 85 | </p> |
| 86 | |
| 87 | <p class="mb-form-field sub_recurring_amount"> |
| 88 | <label for="sub_recurring_amount"><?php printf(esc_html__('Recurring Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 89 | <input id="sub_recurring_amount" type="text" name="sub_recurring_amount" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->recurring_amount)); ?>"/> |
| 90 | </p> |
| 91 | |
| 92 | <p class="mb-form-field sub_recurring_tax"> |
| 93 | <label for="sub_recurring_tax"><?php printf(esc_html__('Recurring Tax Amount (%s):', 'wp-user-avatar'), $parent_order_data_currency_symbol); ?></label> |
| 94 | <input id="sub_recurring_tax" type="text" name="sub_recurring_tax" value="<?php echo esc_attr(ppress_sanitize_amount($subscription_data->recurring_tax)); ?>"/> |
| 95 | </p> |
| 96 | |
| 97 | <p class="mb-form-field sub_recurring_tax_rate"> |
| 98 | <label for="sub_recurring_tax_rate"><?php printf(esc_html__('Recurring Tax Rate (%s):', 'wp-user-avatar'), '%'); ?></label> |
| 99 | <input id="sub_recurring_tax_rate" type="text" name="sub_recurring_tax_rate" value="<?php echo esc_attr($subscription_data->recurring_tax_rate); ?>"/> |
| 100 | </p> |
| 101 | <?php endif; ?> |
| 102 | </div> |
| 103 | <div class="ppress-metabox-data-column"> |
| 104 | |
| 105 | <p class="mb-form-field sub_status"> |
| 106 | <label for="sub_status"><?php _e('Status:', 'wp-user-avatar'); ?></label> |
| 107 | <select id="sub_status" name="sub_status"> |
| 108 | <?php foreach (SubscriptionStatus::get_all() as $id => $label) : ?> |
| 109 | <option value="<?= $id ?>" <?php selected($id, $subscription_data->status) ?>><?= $label ?></option> |
| 110 | <?php endforeach; ?> |
| 111 | </select> |
| 112 | </p> |
| 113 | |
| 114 | <p class="mb-form-field customer_user"> |
| 115 | <label for="sub_customer_user"> |
| 116 | <?php _e('Customer:', 'wp-user-avatar'); ?> |
| 117 | <a href="<?= esc_url(CustomerWPListTable::view_customer_url($subscription_data->customer_id)) ?>"><?= esc_html__('Profile →', 'wp-user-avatar') ?></a> |
| 118 | <a href="<?= add_query_arg(['by_ci' => $subscription_data->customer_id], PPRESS_MEMBERSHIP_SUBSCRIPTIONS_SETTINGS_PAGE) ?>"><?= esc_html__('View all subscriptions →', 'wp-user-avatar') ?></a> |
| 119 | </label> |
| 120 | <select id="sub_customer_user" name="sub_customer_user" class="ppress-select2-field sub_customer_user"> |
| 121 | <option value="<?= $subscription_data->customer_id ?>" selected> |
| 122 | <?php printf(esc_html__('%1$s (%2$s)', 'wp-user-avatar'), $customer->get_name(), $customer->get_email()) ?> |
| 123 | </option> |
| 124 | </select> |
| 125 | </p> |
| 126 | |
| 127 | <p class="mb-form-field sub_date_created"> |
| 128 | <label for="sub_created_date"><?php _e('Date created:', 'wp-user-avatar'); ?></label> |
| 129 | <input id="sub_created_date" type="text" class="ppress_datepicker" name="sub_created_date" value="<?php echo esc_attr(ppress_format_date($subscription_data->created_date, 'Y-m-d')); ?>"/> |
| 130 | </p> |
| 131 | |
| 132 | <p class="mb-form-field sub_expiration_date"> |
| 133 | <label for="sub_expiration_date"><?php _e('Renewal Date:', 'wp-user-avatar'); ?></label> |
| 134 | <?php if ($subscription_data->is_lifetime()) : ?> |
| 135 | <input id="sub_expiration_date" type="text" value="<?= esc_attr(esc_html__('Lifetime', 'wp-user-avatar')) ?>" readonly/> |
| 136 | <?php else : ?> |
| 137 | <input id="sub_expiration_date" type="text" class="ppress_datepicker" name="sub_expiration_date" value="<?php echo esc_attr(ppress_format_date($subscription_data->expiration_date, 'Y-m-d')); ?>"/> |
| 138 | <?php endif; ?> |
| 139 | </p> |
| 140 | |
| 141 | <p class="mb-form-field sub_profile_id"> |
| 142 | <label for="sub_profile_id"><?php printf(esc_html__('%sSubscription ID:', 'wp-user-avatar'), $payment_method_title . ' '); ?></label> |
| 143 | <input id="sub_profile_id" type="text" name="sub_profile_id" value="<?= $subscription_data->get_profile_id() ?>"> |
| 144 | </p> |
| 145 | </div> |
| 146 | |
| 147 | </div> |
| 148 | <?php |
| 149 | |
| 150 | echo '</div>'; |