コード例 #1
0
 /**
  * Prepare html fields.
  *
  * @since  1.0.0
  *
  * @return array
  */
 function prepare_fields()
 {
     $invoice = $this->data['invoice'];
     $currency = MS_Plugin::instance()->settings->currency;
     $user_name = '';
     $transaction_link = '';
     $user_id = 0;
     $user_list = array();
     if ($invoice->id) {
         $member = $invoice->get_member();
         $user_id = $member->id;
         $user_name = $member->name;
         $transaction_link = sprintf('<a href="%s" target="_blank">%s</a>', MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'invoice' => $invoice->id)), __('Show Transactions', 'membership2'));
     } else {
         $user_list = MS_Model_Member::get_usernames(null, MS_Model_Member::SEARCH_ALL_USERS);
     }
     $fields = array('link_transactions' => array('id' => 'link_transactions', 'title' => $transaction_link, 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'wrapper_class' => 'ms-transactions-link'), 'txt_user' => array('id' => 'txt_user', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => sprintf('<a href="%s">%s</a>', MS_Controller_Plugin::get_admin_url('add-member', array('user_id' => $user_id)), $user_name)), 'txt_membership' => array('id' => 'txt_membership', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_created' => array('id' => 'txt_created', 'title' => __('Invoice created on', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'status' => array('id' => 'status', 'title' => __('Invoice status', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'field_options' => MS_Model_Invoice::get_status_types(true), 'value' => $invoice->status), 'user_id' => array('id' => 'user_id', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->user_id, 'field_options' => $user_list), 'membership_id' => array('id' => 'membership_id', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->membership_id, 'field_options' => $this->data['memberships']), 'amount' => array('id' => 'amount', 'title' => sprintf(__('Amount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->amount), 'config' => array('step' => 'any', 'min' => 0)), 'discount' => array('id' => 'discount', 'title' => sprintf(__('Discount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->discount), 'config' => array('step' => 'any', 'min' => 0)), 'due_date' => array('id' => 'due_date', 'title' => __('Due date', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $invoice->due_date), 'description' => array('id' => 'description', 'title' => __('Description', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'class' => 'widefat', 'value' => $invoice->description), 'notes' => array('id' => 'notes', 'title' => __('Notes', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA, 'class' => 'widefat', 'value' => $invoice->get_notes_desc()), 'invoice_id' => array('id' => 'invoice_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($this->data['action'])), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['action']), 'separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'execute' => array('id' => 'execute', 'title' => __('Execute status change actions on Save (add/remove membership)', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'value' => true), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'title' => __('Cancel', 'membership2'), 'value' => __('Cancel', 'membership2'), 'url' => esc_url_raw(remove_query_arg(array('action', 'invoice_id'))), 'class' => 'wpmui-field-button button'), 'submit' => array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Changes', 'membership2')));
     if ($invoice->id > 0) {
         $fields['user_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
         $fields['membership_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
         $fields['txt_membership']['value'] = $this->data['memberships'][$invoice->membership_id];
         $fields['txt_created']['value'] = MS_Helper_Period::format_date($invoice->invoice_date);
     } else {
         unset($fields['txt_user']);
         unset($fields['txt_membership']);
         unset($fields['txt_created']);
         unset($fields['txt_separator']);
     }
     return apply_filters('ms_view_billing_edit_prepare_fields', $fields, $this);
 }
コード例 #2
0
    public function to_html()
    {
        /**
         * Provide a customized invoice.
         *
         * @since  1.0.0
         */
        $html = apply_filters('ms_shortcode_custom_invoice', '', $this->data);
        if (!empty($html)) {
            return $html;
        } else {
            $html = '';
        }
        $invoice = $this->data['invoice'];
        $member = $this->data['member'];
        $subscription = $this->data['ms_relationship'];
        $membership = $this->data['membership'];
        $gateway = $this->data['gateway'];
        $is_free = false;
        $invoice_number = $invoice->get_invoice_number();
        $inv_title = sprintf('<a href="%s">%s</a>', get_permalink($invoice->id), esc_html(__('Invoice ', MS_TEXT_DOMAIN) . $invoice_number));
        if ($invoice->amount > 0) {
            $inv_amount = sprintf('%1$s %2$s', $invoice->currency, MS_Helper_Billing::format_price($invoice->amount));
        } else {
            $inv_amount = __('Free', MS_TEXT_DOMAIN);
            $is_free = true;
        }
        if ($invoice->tax) {
            $inv_taxes = sprintf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->tax));
        } else {
            $inv_taxes = '';
        }
        if ($invoice->discount) {
            $inv_discount = sprintf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->discount));
        } else {
            $inv_discount = '';
        }
        if ($invoice->pro_rate) {
            $inv_pro_rate = sprintf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->pro_rate));
        } else {
            $inv_pro_rate = '';
        }
        $inv_total = sprintf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->total));
        $inv_title = apply_filters('ms_invoice_title', $inv_title, $invoice);
        $inv_from = apply_filters('ms_invoice_sender', MS_Plugin::instance()->settings->invoice_sender_name, $invoice);
        $inv_to = apply_filters('ms_invoice_recipient', $member->username, $invoice, $member);
        $inv_status = apply_filters('ms_invoice_status', $invoice->status_text(), $invoice);
        $inv_item_name = apply_filters('ms_invoice_item_name', $membership->name, $invoice, $membership);
        $inv_amount = apply_filters('ms_invoice_amount', $inv_amount, $invoice);
        $inv_taxes = apply_filters('ms_invoice_taxes', $inv_taxes, $invoice);
        $inv_discount = apply_filters('ms_invoice_discount', $inv_discount, $invoice);
        $inv_pro_rate = apply_filters('ms_invoice_pro_rate', $inv_pro_rate, $invoice);
        $inv_total = apply_filters('ms_invoice_total', $inv_total, $invoice);
        $inv_details = apply_filters('ms_invoice_description', $invoice->description, $invoice, null);
        $inv_date = apply_filters('ms_invoice_date', MS_Helper_Period::format_date($invoice->invoice_date), $invoice, null);
        $inv_due_date = apply_filters('ms_invoice_due_date', MS_Helper_Period::format_date($invoice->due_date), $invoice, null);
        if ($invoice->uses_trial) {
            $trial_date = apply_filters('ms_invoice_trial_date', MS_Helper_Period::get_period_desc($membership->trial_period, true), $trial_invoice, $invoice);
            $trial_date .= sprintf(' <small>(%s %s)</small>', __('ends on', MS_TEXT_DOMAIN), MS_Helper_Period::format_date($invoice->trial_ends));
        } else {
            $trial_date = '';
        }
        ob_start();
        ?>
		<div class="entry-content ms-invoice" id="invoice">
			<?php 
        /**
         * We hardcode the CSS styles into this file, because the shortcode
         * is also used in Emails, which usually do not load remote CSS
         * files by default...
         */
        ?>
			<style>
			#invoice table, th, td { margin: 0; font-size: 14px; }
			#invoice table { padding: 0; width: 520px; border: 1px solid #DDD; background-color: #FFF; box-shadow: 0 1px 8px #F0F0F0; }
			#invoice th, td { border: 0; padding: 8px; }
			#invoice th { font-weight: bold; text-align: left; text-transform: none; font-size: 13px; }
			#invoice tr.alt { background-color: #F9F9F9; }
			#invoice tr.sep th,
			#invoice tr.sep td { border-top: 1px solid #DDD; padding-top: 16px; }
			#invoice tr.space th,
			#invoice tr.space td { padding-bottom: 16px; }
			#invoice tr.ms-inv-sep th,
			#invoice tr.ms-inv-sep td { line-height: 1px; height: 1px; padding: 0; border-bottom: 1px solid #DDD; background-color: #F9F9F9; }
			#invoice .ms-inv-total .ms-inv-price { font-weight: bold; font-size: 18px; text-align: right; }
			#invoice h2 { text-align: right; padding: 10px 10px 0 0; }
			#invoice h2 a { color: #000; }
			<?php 
        do_action('ms_invoice_css');
        ?>
			</style>

			<div class="ms-invoice-details ms-status-<?php 
        echo esc_attr($invoice->status);
        ?>
">
				<table class="ms-purchase-table">
					<tr class="ms-inv-title">
						<td colspan="2"><h2><?php 
        echo $inv_title;
        ?>
</h2></td>
					</tr>

					<?php 
        if (!empty($inv_from)) {
            ?>
						<tr class="ms-inv-from">
							<th><?php 
            _e('Sender', MS_TEXT_DOMAIN);
            ?>
</th>
							<td class="ms-inv-text"><?php 
            echo $inv_from;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>

					<tr class="ms-inv-to">
						<th><?php 
        _e('Invoice to', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-text"><?php 
        echo $inv_to;
        ?>
</td>
					</tr>
					<tr class="ms-inv-invoice-date">
						<th><?php 
        _e('Invoice date', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-date"><?php 
        echo $inv_date;
        ?>
</td>
					</tr>
					<?php 
        if (!empty($trial_date)) {
            ?>
						<tr class="ms-inv-trial-end-date">
							<th><?php 
            _e('Trial period', MS_TEXT_DOMAIN);
            ?>
</th>
							<td class="ms-inv-date"><?php 
            echo $trial_date;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>
					<tr class="ms-inv-status space">
						<th><?php 
        _e('Status', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-text"><?php 
        echo $inv_status;
        ?>
</td>
					</tr>
					<tr class="ms-inv-item-name alt sep">
						<th><?php 
        _e('Name', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-text"><?php 
        echo $inv_item_name;
        ?>
</td>
					</tr>

					<?php 
        if (!empty($inv_details)) {
            ?>
					<tr class="ms-inv-description alt">
						<th><?php 
            _e('Description', MS_TEXT_DOMAIN);
            ?>
</th>
						<td class="ms-inv-text"><?php 
            echo $inv_details;
            ?>
</td>
					</tr>
					<?php 
        }
        ?>

					<tr class="ms-inv-amount alt space">
						<th><?php 
        _e('Amount', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-price"><?php 
        echo $inv_amount;
        ?>
</td>
					</tr>

					<?php 
        $sep = 'sep';
        ?>

					<?php 
        if (!empty($inv_discount)) {
            ?>
						<tr class="ms-inv-discount <?php 
            echo esc_attr($sep);
            $sep = '';
            ?>
">
							<th><?php 
            _e('Coupon discount', MS_TEXT_DOMAIN);
            ?>
</th>
							<td class="ms-inv-price"><?php 
            echo $inv_discount;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>

					<?php 
        if (!empty($inv_pro_rate)) {
            ?>
						<tr class="ms-inv-pro-rate <?php 
            echo esc_attr($sep);
            $sep = '';
            ?>
">
							<th><?php 
            _e('Pro rate discount', MS_TEXT_DOMAIN);
            ?>
</th>
							<td class="ms-inv-price"><?php 
            echo $inv_pro_rate;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>

					<?php 
        if (!empty($inv_taxes)) {
            ?>
						<tr class="ms-inv-tax <?php 
            echo esc_attr($sep);
            $sep = '';
            ?>
">
							<th><?php 
            printf(__('Taxes %s', MS_TEXT_DOMAIN), '<small>(' . $invoice->tax_name . ')</small>');
            ?>
</th>
							<td class="ms-inv-price"><?php 
            echo $inv_taxes;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>

					<?php 
        if (!$is_free) {
            ?>
						<tr class="ms-inv-due-date <?php 
            echo esc_attr($sep);
            $sep = '';
            ?>
">
							<th><?php 
            _e('Payment due', MS_TEXT_DOMAIN);
            ?>
</th>
							<td class="ms-inv-date"><?php 
            echo $inv_due_date;
            ?>
</td>
						</tr>
					<?php 
        }
        ?>
					<tr class="ms-inv-total <?php 
        echo esc_attr($sep);
        $sep = '';
        ?>
">
						<th><?php 
        _e('Total', MS_TEXT_DOMAIN);
        ?>
</th>
						<td class="ms-inv-price"><?php 
        echo $inv_total;
        ?>
</td>
					</tr>

					<?php 
        $show_button = lib2()->is_true($this->data['pay_button']);
        if ($invoice->is_paid()) {
            // Invoice is already paid. We don't need a payment
            // button...
            $show_button = false;
        }
        if ($show_button) {
            ?>
						<tr class="ms-inv-sep sep"><td colspan="2"></td></tr>
						<?php 
            do_action('ms_view_shortcode_invoice_purchase_button', $subscription, $invoice);
        }
        ?>
				</table>
			</div>
		</div>
		<?php 
        $html = ob_get_clean();
        $html = apply_filters('ms_compact_code', $html);
        return apply_filters('ms_shortcode_invoice', $html, $this->data);
    }
コード例 #3
0
 /**
  * Returns a string that describes the dripped rule.
  *
  * @since  1.0.0
  *
  * @param string $item_id The content id to verify dripped access.
  * @return string Text like "Instantly" or "After 7 days"
  */
 public function get_dripped_description($item_id)
 {
     $desc = '';
     $drip_data = false;
     if (!is_array($this->dripped)) {
         $this->dripped = array();
     }
     if (isset($this->dripped[$item_id])) {
         $drip_data = $this->dripped[$item_id];
     }
     if (is_array($drip_data)) {
         lib3()->array->equip($drip_data, 'type', 'date', 'delay_unit', 'delay_type');
         switch ($drip_data['type']) {
             case MS_Model_Rule::DRIPPED_TYPE_SPEC_DATE:
                 $desc = sprintf(__('On <b>%1$s</b>', 'membership2'), MS_Helper_Period::format_date($drip_data['date']));
                 break;
             case MS_Model_Rule::DRIPPED_TYPE_FROM_REGISTRATION:
                 $periods = MS_Helper_Period::get_period_types();
                 $period_key = $drip_data['delay_type'];
                 if (0 == $drip_data['delay_unit']) {
                     $desc = __('<b>Instantly</b>', 'membership2');
                 } elseif (1 == $drip_data['delay_unit']) {
                     $desc = sprintf(__('After <b>%1$s %2$s</b>', 'membership2'), $periods['1' . $period_key], '');
                 } else {
                     $desc = sprintf(__('After <b>%1$s %2$s</b>', 'membership2'), $drip_data['delay_unit'], $periods[$period_key]);
                 }
                 break;
             case MS_Model_Rule::DRIPPED_TYPE_INSTANTLY:
             default:
                 $desc = __('<b>Instantly</b>', 'membership2');
                 break;
         }
     }
     return apply_filters('ms_rule_get_dripped_description', $desc, $item_id, $this);
 }
コード例 #4
0
 public function column_post_modified($item, $column_name)
 {
     $html = MS_Helper_Period::format_date($item->post_modified);
     return $html;
 }
コード例 #5
0
    public function to_html()
    {
        ob_start();
        ?>
		<div class="ms-account-wrapper">
			<?php 
        if (MS_Model_Member::is_logged_in()) {
            ?>
				<h2>
					<?php 
            _e('Invoice', MS_TEXT_DOMAIN);
            ?>
				</h2>
				<table>
					<thead>
						<tr>
							<th class="ms-col-invoice-no"><?php 
            _e('Invoice #', MS_TEXT_DOMAIN);
            ?>
</th>
							<th class="ms-col-invoice-status"><?php 
            _e('Status', MS_TEXT_DOMAIN);
            ?>
</th>
							<th class="ms-col-invoice-total"><?php 
            printf('%s (%s)', __('Total', MS_TEXT_DOMAIN), MS_Plugin::instance()->settings->currency);
            ?>
</th>
							<th class="ms-col-invoice-title"><?php 
            _e('Membership', MS_TEXT_DOMAIN);
            ?>
</th>
							<th class="ms-col-invoice-due"><?php 
            _e('Due date', MS_TEXT_DOMAIN);
            ?>
</th>
						</tr>
					</thead>
					<tbody>
					<?php 
            foreach ($this->data['invoices'] as $invoice) {
                $inv_membership = MS_Factory::load('MS_Model_Membership', $invoice->membership_id);
                $inv_classes = array('ms-invoice-' . $invoice->id, 'ms-subscription-' . $invoice->ms_relationship_id, 'ms-invoice-' . $invoice->status, 'ms-gateway-' . $invoice->gateway_id, 'ms-membership-' . $invoice->membership_id, 'ms-type-' . $inv_membership->type, 'ms-payment-' . $inv_membership->payment_type);
                ?>
						<tr class="<?php 
                echo esc_attr(implode(' ', $inv_classes));
                ?>
">
							<td class="ms-col-invoice-no"><?php 
                printf('<a href="%s">%s</a>', get_permalink($invoice->id), $invoice->get_invoice_number());
                ?>
</td>
							<td class="ms-col-invoice-status"><?php 
                echo esc_html($invoice->status_text());
                ?>
</td>
							<td class="ms-col-invoice-total"><?php 
                echo esc_html(MS_Helper_Billing::format_price($invoice->total));
                ?>
</td>
							<td class="ms-col-invoice-title"><?php 
                echo esc_html($inv_membership->name);
                ?>
</td>
							<td class="ms-col-invoice-due"><?php 
                echo esc_html(MS_Helper_Period::format_date($invoice->due_date, __('F j', MS_TEXT_DOMAIN)));
                ?>
</td>
						</tr>
					<?php 
            }
            ?>
					</tbody>
				</table>
			<?php 
        } else {
            ?>
				<?php 
            $redirect = esc_url_raw(add_query_arg(array()));
            $title = __('Your account', MS_TEXT_DOMAIN);
            echo do_shortcode("[ms-membership-login redirect='{$redirect}' title='{$title}']");
            ?>
			<?php 
        }
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        $html = apply_filters('ms_compact_code', $html);
        return $html;
    }
コード例 #6
0
 public function column_post_date($item, $column_name)
 {
     return MS_Helper_Period::format_date($item->post_date, __('Y/m/d', MS_TEXT_DOMAIN));
 }
 /**
  * Output column content
  *
  * @since  1.0.0
  * @param  object $item The item that is displayed.
  * @return string The HTML code to output.
  */
 public function column_date($item, $column_name)
 {
     $html = MS_Helper_Period::format_date($item->date, 'Y-m-d H:i');
     return $html;
 }
コード例 #8
0
 public function column_post_date($item, $column_name)
 {
     return MS_Helper_Period::format_date($item->post_date);
 }
コード例 #9
0
 public function column_due_date($item, $column_name)
 {
     $due_now = false;
     $is_paid = $item->is_paid();
     if (!$is_paid) {
         $diff = MS_Helper_Period::subtract_dates($item->due_date, MS_Helper_Period::current_date(), null, true);
         $due_now = $diff < 0;
     }
     $due_date = MS_Helper_Period::format_date($item->due_date);
     if ($due_now) {
         $html = sprintf('<span class="due-now" title="%2$s">%1$s</span>', $due_date, __('Payment is overdue', 'membership2'));
     } elseif ($item->pay_date) {
         $pay_date = MS_Helper_Period::format_date($item->pay_date, 'M j, Y');
         $html = sprintf('<span class="is-paid" title="%2$s">%1$s</span>', $due_date, sprintf(__('Paid: %s', 'membership2'), $pay_date));
     } else {
         $html = sprintf('<span>%1$s</span>', $due_date);
     }
     return $html;
 }
コード例 #10
0
    public function to_html()
    {
        ob_start();
        ?>
		<div class="ms-account-wrapper">
			<?php 
        if (MS_Model_Member::is_logged_in()) {
            ?>
				<h2>
					<?php 
            _e('Activity', MS_TEXT_DOMAIN);
            ?>
				</h2>
				<table>
					<thead>
						<tr>
							<th class="ms-col-activity-date"><?php 
            _e('Date', MS_TEXT_DOMAIN);
            ?>
</th>
							<th class="ms-col-activity-title"><?php 
            _e('Activity', MS_TEXT_DOMAIN);
            ?>
</th>
						</tr>
					</thead>
					<tbody>
					<?php 
            foreach ($this->data['events'] as $event) {
                $ev_classes = array('ms-activity-topic-' . $event->topic, 'ms-activity-type-' . $event->type, 'ms-membership-' . $event->membership_id);
                ?>
						<tr class="<?php 
                echo esc_attr(implode(' ', $ev_classes));
                ?>
">
							<td class="ms-col-activity-date"><?php 
                echo esc_html(MS_Helper_Period::format_date($event->post_modified, __('F j (H:i)', MS_TEXT_DOMAIN)));
                ?>
</td>
							<td class="ms-col-activity-title"><?php 
                echo esc_html($event->description);
                ?>
</td>
						</tr>
					<?php 
            }
            ?>
				</tbody>
			</table>
			<?php 
        } else {
            $redirect = esc_url_raw(add_query_arg(array()));
            $title = __('Your account', MS_TEXT_DOMAIN);
            echo do_shortcode("[ms-membership-login redirect='{$redirect}' title='{$title}']");
        }
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        $html = apply_filters('ms_compact_code', $html);
        return $html;
    }
    /**
     * Echo a member-list. This function can be overwritten by other views
     * to customize the list.
     *
     * @since  1.0.0
     *
     * @param array $members List of members to display.
     */
    protected function members_panel_data($members, $membership_id)
    {
        $item = 0;
        $max_items = 10;
        $class = '';
        $status_types = MS_Model_Relationship::get_status_types();
        ?>
		<table class="ms-list-table widefat">
			<thead>
				<th><?php 
        _e('Member', 'membership2');
        ?>
</th>
				<th><?php 
        _e('Since', 'membership2');
        ?>
</th>
				<th><?php 
        _e('Status', 'membership2');
        ?>
</th>
			</thead>
			<tbody>
			<?php 
        foreach ($this->data['members'] as $member) {
            $item += 1;
            if ($item > $max_items) {
                break;
            }
            $class = $class == 'alternate' ? '' : 'alternate';
            $subscription = $member->get_subscription($membership_id);
            ?>
				<tr class="<?php 
            echo esc_attr($class);
            ?>
">
					<td><?php 
            echo esc_html($member->username);
            ?>
</td>
					<td><?php 
            echo esc_html(MS_Helper_Period::format_date($subscription->start_date));
            ?>
</td>
					<td><?php 
            echo esc_html($status_types[$subscription->status]);
            ?>
</td>
				</tr>
			<?php 
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
コード例 #12
0
 public function column_due_date($item, $column_name)
 {
     $due_now = false;
     if (!$item->is_paid()) {
         $diff = MS_Helper_Period::subtract_dates($item->due_date, MS_Helper_Period::current_date(), null, true);
         $due_now = $diff < 0;
     }
     $date = MS_Helper_Period::format_date($item->due_date);
     if ($due_now) {
         $html = sprintf('<span class="due-now" title="%2$s">%1$s</span>', $date, __('Payment is overdue', MS_TEXT_DOMAIN));
     } else {
         $html = sprintf('<span>%1$s</span>', $date);
     }
     return $html;
 }
コード例 #13
0
 /**
  * Get a detailled status description.
  *
  * @since  1.0.0
  * @api
  *
  * @return string The status description.
  */
 public function get_status_description()
 {
     $desc = '';
     switch ($this->status) {
         case self::STATUS_PENDING:
             $desc = __('Pending payment.', 'membership2');
             break;
         case self::STATUS_TRIAL:
             $desc = sprintf('%s <span class="ms-date">%s</span>', __('Membership Trial expires on ', 'membership2'), MS_Helper_Period::format_date($this->trial_expire_date));
             break;
         case self::STATUS_ACTIVE:
             if (!empty($this->expire_date)) {
                 $desc = sprintf('%s <span class="ms-date">%s</span>', __('Membership expires on ', 'membership2'), MS_Helper_Period::format_date($this->expire_date));
             } else {
                 $desc = __('Permanent access.', 'membership2');
             }
             break;
         case self::STATUS_TRIAL_EXPIRED:
         case self::STATUS_EXPIRED:
             $desc = sprintf('%s <span class="ms-date">%s</span>', __('Membership expired since ', 'membership2'), MS_Helper_Period::format_date($this->expire_date));
             break;
         case self::STATUS_CANCELED:
             $desc = sprintf('%s <span class="ms-date">%s</span>', __('Membership canceled, valid until it expires on ', 'membership2'), MS_Helper_Period::format_date($this->expire_date));
             break;
         case self::STATUS_DEACTIVATED:
             $desc = __('Membership deactivated.', 'membership2');
             break;
     }
     return apply_filters('ms_model_relationship_get_status_description', $desc);
 }
コード例 #14
0
 public function column_post_date($item, $column_name)
 {
     return MS_Helper_Period::format_date($item->post_date, __('Y/m/d', 'membership2'));
 }
コード例 #15
0
    public function to_html()
    {
        global $post;
        /**
         * Provide a customized account page.
         *
         * @since  1.0.0
         */
        $html = apply_filters('ms_shortcode_custom_account', '', $this->data);
        if (!empty($html)) {
            return $html;
        } else {
            $html = '';
        }
        $member = MS_Model_Member::get_current_member();
        $fields = $this->prepare_fields();
        // Extract shortcode options.
        extract($this->data);
        ob_start();
        ?>
		<div class="ms-account-wrapper">
			<?php 
        if (MS_Model_Member::is_logged_in()) {
            ?>

				<?php 
            // ================================================= MEMBERSHIPS
            if ($show_membership) {
                ?>
				<div id="account-membership">
				<h2>
					<?php 
                echo $membership_title;
                if ($show_membership_change) {
                    $signup_url = MS_Model_Pages::get_page_url(MS_Model_Pages::MS_PAGE_REGISTER);
                    printf('<a href="%s" class="ms-edit-profile">%s</a>', $signup_url, $membership_change_label);
                }
                ?>
				</h2>
				<?php 
                /**
                 * Add custom content right before the memberships list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_memberships_top', $member, $this);
                if (MS_Model_Member::is_admin_user()) {
                    _e('You are an admin user and have access to all memberships', 'membership2');
                } else {
                    if (!empty($this->data['subscription'])) {
                        ?>
						<table>
							<tr>
								<th class="ms-col-membership"><?php 
                        _e('Membership name', 'membership2');
                        ?>
</th>
								<th class="ms-col-status"><?php 
                        _e('Status', 'membership2');
                        ?>
</th>
								<th class="ms-col-expire-date"><?php 
                        _e('Expire date', 'membership2');
                        ?>
</th>
							</tr>
							<?php 
                        $empty = true;
                        // These subscriptions have no expire date
                        $no_expire_list = array(MS_Model_Relationship::STATUS_PENDING, MS_Model_Relationship::STATUS_WAITING, MS_Model_Relationship::STATUS_DEACTIVATED);
                        // These subscriptions display the trial-expire date
                        $trial_expire_list = array(MS_Model_Relationship::STATUS_TRIAL, MS_Model_Relationship::STATUS_TRIAL_EXPIRED);
                        foreach ($this->data['subscription'] as $subscription) {
                            $empty = false;
                            $membership = $subscription->get_membership();
                            $subs_classes = array('ms-subscription-' . $subscription->id, 'ms-status-' . $subscription->status, 'ms-type-' . $membership->type, 'ms-payment-' . $membership->payment_type, 'ms-gateway-' . $subscription->gateway_id, 'ms-membership-' . $subscription->membership_id, $subscription->has_trial() ? 'ms-with-trial' : 'ms-no-trial');
                            ?>
								<tr class="<?php 
                            echo esc_attr(implode(' ', $subs_classes));
                            ?>
">
									<td class="ms-col-membership"><?php 
                            echo esc_html($membership->name);
                            ?>
</td>
									<td class="ms-col-status">
									<?php 
                            if (MS_Model_Relationship::STATUS_PENDING == $subscription->status) {
                                // Display a "Purchase" link when status is Pending
                                $code = sprintf('[%s id="%s" label="%s"]', MS_Helper_Shortcode::SCODE_MS_BUY, $membership->id, __('Pending', 'membership2'));
                                echo do_shortcode($code);
                            } else {
                                echo esc_html($subscription->status_text());
                            }
                            ?>
									</td>
									<td class="ms-col-expire-date"><?php 
                            if (in_array($subscription->status, $no_expire_list)) {
                                echo '&nbsp;';
                            } elseif (in_array($subscription->status, $trial_expire_list)) {
                                echo esc_html(MS_Helper_Period::format_date($subscription->trial_expire_date));
                            } elseif ($subscription->expire_date) {
                                echo esc_html(MS_Helper_Period::format_date($subscription->expire_date));
                            } else {
                                _e('Never', 'membership2');
                            }
                            ?>
</td>
								</tr>
							<?php 
                        }
                        if ($empty) {
                            $cols = 3;
                            if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL)) {
                                $cols += 1;
                            }
                            printf('<tr><td colspan="%1$s">%2$s</td></tr>', $cols, __('(No Membership)', 'membership2'));
                        }
                        ?>
						</table>
					<?php 
                    } else {
                        _e('No memberships', 'membership2');
                    }
                }
                /**
                 * Add custom content right after the memberships list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_memberships_bottom', $member, $this);
                ?>
				</div>
				<?php 
            }
            // END: if ( $show_membership )
            // =============================================================
            ?>

				<?php 
            // ===================================================== PROFILE
            if ($show_profile) {
                ?>
				<div id="account-profile">
				<h2>
					<?php 
                echo $profile_title;
                if ($show_profile_change) {
                    $edit_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_EDIT_PROFILE)));
                    printf('<a href="%s" class="ms-edit-profile">%s</a>', $edit_url, $profile_change_label);
                }
                ?>
				</h2>
				<?php 
                /**
                 * Add custom content right before the profile overview.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_profile_top', $member, $this);
                ?>
				<table>
					<?php 
                foreach ($fields['personal_info'] as $field => $title) {
                    ?>
						<tr>
							<th class="ms-label-title"><?php 
                    echo esc_html($title);
                    ?>
: </th>
							<td class="ms-label-field"><?php 
                    echo esc_html($this->data['member']->{$field});
                    ?>
</td>
						</tr>
					<?php 
                }
                ?>
				</table>
				<?php 
                do_action('ms_view_shortcode_account_card_info', $this->data);
                /**
                 * Add custom content right after the profile overview.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_profile_bottom', $member, $this);
                ?>
				</div>
				<?php 
            }
            // END: if ( $show_profile )
            // =============================================================
            ?>

				<?php 
            // ==================================================== INVOICES
            if ($show_invoices) {
                ?>
				<div id="account-invoices">
				<h2>
					<?php 
                echo $invoices_title;
                if ($show_all_invoices) {
                    $detail_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_VIEW_INVOICES)));
                    printf('<a href="%s" class="ms-all-invoices">%s</a>', $detail_url, $invoices_details_label);
                }
                ?>
				</h2>
				<?php 
                /**
                 * Add custom content right before the invoice overview list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_invoices_top', $member, $this);
                ?>
				<table>
					<thead>
						<tr>
							<th class="ms-col-invoice-no"><?php 
                _e('Invoice #', 'membership2');
                ?>
</th>
							<th class="ms-col-invoice-status"><?php 
                _e('Status', 'membership2');
                ?>
</th>
							<th class="ms-col-invoice-total"><?php 
                printf('%s (%s)', __('Total', 'membership2'), MS_Plugin::instance()->settings->currency);
                ?>
</th>
							<th class="ms-col-invoice-title"><?php 
                _e('Membership', 'membership2');
                ?>
</th>
							<th class="ms-col-invoice-due"><?php 
                _e('Due date', 'membership2');
                ?>
</th>
						</tr>
					</thead>
					<tbody>
					<?php 
                foreach ($this->data['invoices'] as $invoice) {
                    $inv_membership = MS_Factory::load('MS_Model_Membership', $invoice->membership_id);
                    $inv_classes = array('ms-invoice-' . $invoice->id, 'ms-subscription-' . $invoice->ms_relationship_id, 'ms-invoice-' . $invoice->status, 'ms-gateway-' . $invoice->gateway_id, 'ms-membership-' . $invoice->membership_id, 'ms-type-' . $inv_membership->type, 'ms-payment-' . $inv_membership->payment_type);
                    ?>
						<tr class="<?php 
                    echo esc_attr(implode(' ', $inv_classes));
                    ?>
">
							<td class="ms-col-invoice-no"><?php 
                    printf('<a href="%s">%s</a>', get_permalink($invoice->id), $invoice->get_invoice_number());
                    ?>
</td>
							<td class="ms-col-invoice-status"><?php 
                    echo esc_html($invoice->status_text());
                    ?>
</td>
							<td class="ms-col-invoice-total"><?php 
                    echo esc_html(MS_Helper_Billing::format_price($invoice->total));
                    ?>
</td>
							<td class="ms-col-invoice-title"><?php 
                    echo esc_html($inv_membership->name);
                    ?>
</td>
							<td class="ms-col-invoice-due"><?php 
                    echo esc_html(MS_Helper_Period::format_date($invoice->due_date, __('F j', 'membership2')));
                    ?>
</td>
						</tr>
					<?php 
                }
                ?>
					</tbody>
				</table>
				<?php 
                /**
                 * Add custom content right after the invoices overview list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_invoices_bottom', $member, $this);
                ?>
				</div>
				<?php 
            }
            // END: if ( $show_invoices )
            // =============================================================
            ?>

				<?php 
            // ==================================================== ACTIVITY
            if ($show_activity) {
                ?>
				<div id="account-activity">
				<h2>
					<?php 
                echo $activity_title;
                if ($show_all_activities) {
                    $detail_url = esc_url_raw(add_query_arg(array('action' => MS_Controller_Frontend::ACTION_VIEW_ACTIVITIES)));
                    printf('<a href="%s" class="ms-all-activities">%s</a>', $detail_url, $activity_details_label);
                }
                ?>
				</h2>
				<?php 
                /**
                 * Add custom content right before the activities overview list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_activity_top', $member, $this);
                ?>
				<table>
					<thead>
						<tr>
							<th class="ms-col-activity-date"><?php 
                _e('Date', 'membership2');
                ?>
</th>
							<th class="ms-col-activity-title"><?php 
                _e('Activity', 'membership2');
                ?>
</th>
						</tr>
					</thead>
					<tbody>
					<?php 
                foreach ($this->data['events'] as $event) {
                    $ev_classes = array('ms-activity-topic-' . $event->topic, 'ms-activity-type-' . $event->type, 'ms-membership-' . $event->membership_id);
                    ?>
						<tr class="<?php 
                    echo esc_attr(implode(' ', $ev_classes));
                    ?>
">
							<td class="ms-col-activity-date"><?php 
                    echo esc_html(MS_Helper_Period::format_date($event->post_modified));
                    ?>
</td>
							<td class="ms-col-activity-title"><?php 
                    echo esc_html($event->description);
                    ?>
</td>
						</tr>
					<?php 
                }
                ?>
					</tbody>
				</table>
				<?php 
                /**
                 * Add custom content right after the activities overview list.
                 *
                 * @since  1.0.0
                 */
                do_action('ms_view_account_activity_bottom', $member, $this);
                ?>
				</div>
				<?php 
            }
            // END: if ( $show_activity )
            // =============================================================
            ?>

			<?php 
        } else {
            $has_login_form = MS_Helper_Shortcode::has_shortcode(MS_Helper_Shortcode::SCODE_LOGIN, $post->post_content);
            if (!$has_login_form) {
                $redirect = esc_url_raw(add_query_arg(array()));
                $title = __('Your account', 'membership2');
                $scode = sprintf('[%1$s redirect="%2$s" title="%3$s"]', MS_Helper_Shortcode::SCODE_LOGIN, esc_url($redirect), esc_attr($title));
                echo do_shortcode($scode);
            }
        }
        ?>
		</div>
		<?php 
        $html = ob_get_clean();
        $html = apply_filters('ms_compact_code', $html);
        return apply_filters('ms_shortcode_account', $html, $this->data);
    }
コード例 #16
0
    /**
     * Returns the HTML code for the Purchase-Membership form.
     *
     * @since  1.0.0
     * @return string
     */
    public function to_html()
    {
        $membership = $this->data['membership'];
        $invoice = $this->data['invoice'];
        $subscription = $this->data['ms_relationship'];
        $class = 'ms-alert-success';
        $msg = __('Please check the details of the membership below and click ' . 'on the relevant button to complete the signup.', 'membership2');
        if (!empty($this->data['error'])) {
            $class = 'ms-alert-error';
            $msg = $this->data['error'];
        }
        /**
         * Log the users IP and current timestamp inside the invoice.
         *
         * @since 1.0.2.0
         */
        $invoice->checkout_ip = lib3()->net->current_ip()->ip;
        $invoice->checkout_date = date('Y-m-d H:i:s');
        $invoice->save();
        $cancel_warning = false;
        if (!MS_Model_Member::is_admin_user()) {
            if (!MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) {
                // Member can only sign up to one membership.
                $valid_status = array(MS_Model_Relationship::STATUS_TRIAL, MS_Model_Relationship::STATUS_ACTIVE, MS_Model_Relationship::STATUS_PENDING);
                foreach ($this->data['member']->subscriptions as $tmp_subscription) {
                    if ($tmp_subscription->is_system()) {
                        continue;
                    }
                    if (in_array($tmp_subscription->status, $valid_status)) {
                        $cancel_warning = __('Your other Memberships will be cancelled when you complete this payment.', 'membership2');
                        break;
                    }
                }
            } elseif ($subscription->move_from_id) {
                $move_from_ids = explode(',', $subscription->move_from_id);
                $names = array();
                foreach ($move_from_ids as $id) {
                    $ms = MS_Factory::load('MS_Model_Membership', $id);
                    if ($ms->is_system()) {
                        continue;
                    }
                    $names[] = $ms->name;
                }
                if (1 == count($names)) {
                    $cancel_warning = sprintf(__('When you complete this payment your Membership "%s" will be cancelled.', 'membership2'), $names[0]);
                } elseif (1 < count($names)) {
                    $cancel_warning = sprintf(__('When you complete this payment the following Memberships will be cancelled: %s.', 'membership2'), implode(', ', $names));
                }
            }
        }
        // Check if the user goes through a trial period before first payment.
        $is_trial = $invoice->uses_trial;
        $skip_form = !MS_Model_Member::is_admin_user() && !$cancel_warning && $membership->is_free();
        /**
         * Filter the flag to allow Add-ons like "Invitation codes" to override
         * the state and force the form to display.
         *
         * @var bool
         */
        $skip_form = apply_filters('ms_view_frontend_payment_skip_form', $skip_form, $invoice, $this);
        if ($skip_form) {
            // No confirmation required. Simply register for this membership!
            $args = array();
            $args['ms_relationship_id'] = $subscription->id;
            $args['gateway'] = MS_Gateway_Free::ID;
            $args['step'] = MS_Controller_Frontend::STEP_PROCESS_PURCHASE;
            $args['_wpnonce'] = wp_create_nonce($args['gateway'] . '_' . $args['ms_relationship_id']);
            $url = esc_url_raw(add_query_arg($args));
            /*
             * Very likely the html output has already began.
             * So we redirect by using javascript.
             */
            ?>
			<script>window.location.href = '<?php 
            echo $url;
            ?>
';</script>
			<?php 
            exit;
        }
        $show_tax = MS_Model_Addon::is_enabled(MS_Addon_Taxamo::ID);
        /**
         * Trigger an action before the payment form is displayed. This hook
         * can be used by Add-ons or plugins to initialize payment settings or
         * add custom code.
         */
        do_action('ms_view_frontend_payment_form_start', $invoice, $this);
        $classes = array('ms-membership-form-wrapper', 'ms-subscription-' . $subscription->id, 'ms-invoice-' . $invoice->id);
        ob_start();
        ?>
		<div class="<?php 
        echo esc_attr(implode(' ', $classes));
        ?>
">
			<legend><?php 
        _e('Join Membership', 'membership2');
        ?>
</legend>
			<p class="ms-alert-box <?php 
        echo esc_attr($class);
        ?>
">
				<?php 
        echo $msg;
        ?>
			</p>
			<table class="ms-purchase-table">
				<tr>
					<td class="ms-title-column">
						<?php 
        _e('Name', 'membership2');
        ?>
					</td>
					<td class="ms-details-column">
						<?php 
        echo esc_html($membership->name);
        ?>
					</td>
				</tr>

				<?php 
        if ($membership->description) {
            ?>
					<tr>
						<td class="ms-title-column">
							<?php 
            _e('Description', 'membership2');
            ?>
						</td>
						<td class="ms-desc-column">
							<span class="ms-membership-description"><?php 
            echo $membership->get_description();
            ?>
</span>
						</td>
					</tr>
				<?php 
        }
        ?>

				<?php 
        if (!$membership->is_free()) {
            ?>
					<?php 
            if ($invoice->discount || $invoice->pro_rate || $invoice->tax_rate) {
                ?>
					<tr>
						<td class="ms-title-column">
							<?php 
                _e('Price', 'membership2');
                ?>
						</td>
						<td class="ms-details-column">
							<?php 
                if ($membership->price > 0) {
                    printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($membership->price));
                } else {
                    _e('Free', 'membership2');
                }
                ?>
						</td>
					</tr>
					<?php 
            }
            ?>

					<?php 
            if ($invoice->discount) {
                ?>
						<tr>
							<td class="ms-title-column">
								<?php 
                _e('Coupon Discount', 'membership2');
                ?>
							</td>
							<td class="ms-price-column">
								<?php 
                printf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->discount));
                ?>
							</td>
						</tr>
					<?php 
            }
            ?>

					<?php 
            if ($invoice->pro_rate) {
                ?>
						<tr>
							<td class="ms-title-column">
								<?php 
                _e('Pro-Rate Discount', 'membership2');
                ?>
							</td>
							<td class="ms-price-column">
								<?php 
                printf('%s -%s', $invoice->currency, MS_Helper_Billing::format_price($invoice->pro_rate));
                ?>
							</td>
						</tr>
					<?php 
            }
            ?>

					<?php 
            if ($show_tax) {
                ?>
						<tr>
							<td class="ms-title-column">
								<?php 
                printf(__('Taxes %s', 'membership2'), '<a href="#" class="ms-tax-editor"><small>(' . $invoice->tax_name . ')</small></a>');
                ?>
							</td>
							<td class="ms-price-column">
								<?php 
                printf('%s %s', $invoice->currency, MS_Helper_Billing::format_price($invoice->tax));
                ?>
							</td>
						</tr>
					<?php 
            }
            ?>

					<tr>
						<td class="ms-title-column">
							<?php 
            _e('Total', 'membership2');
            ?>
						</td>
						<td class="ms-price-column ms-total">
							<?php 
            if ($invoice->total > 0) {
                printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($invoice->total));
            } else {
                _e('Free', 'membership2');
            }
            ?>
						</td>
					</tr>

					<?php 
            if ($is_trial) {
                ?>
						<tr>
							<td class="ms-title-column">
								<?php 
                _e('Payment due', 'membership2');
                ?>
							</td>
							<td class="ms-desc-column"><?php 
                echo MS_Helper_Period::format_date($invoice->due_date);
                ?>
</td>
						</tr>
						<tr>
							<td class="ms-title-column">
								<?php 
                _e('Trial price', 'membership2');
                ?>
							</td>
							<td class="ms-desc-column">
							<?php 
                if ($invoice->trial_price > 0) {
                    printf('<span class="price">%s %s</span>', $invoice->currency, MS_Helper_Billing::format_price($invoice->trial_price));
                } else {
                    _e('Free', 'membership2');
                }
                ?>
							</td>
						</tr>
					<?php 
            }
            ?>

					<?php 
            do_action('ms_view_frontend_payment_after_total_row', $subscription, $invoice, $this);
            ?>

					<tr>
						<td class="ms-desc-column" colspan="2">
							<span class="ms-membership-description"><?php 
            echo $subscription->get_payment_description($invoice);
            ?>
</span>
						</td>
					</tr>
				<?php 
        }
        ?>

				<?php 
        if ($cancel_warning) {
            ?>
					<tr>
						<td class="ms-desc-warning" colspan="2">
							<span class="ms-cancel-other-memberships"><?php 
            echo $cancel_warning;
            ?>
</span>
						</td>
					</tr>
				<?php 
        }
        if (MS_Model_Member::is_admin_user()) {
            ?>
					<tr>
						<td class="ms-desc-adminnote" colspan="2">
							<em><?php 
            _e('As admin user you already have access to this membership', 'membership2');
            ?>
</em>
						</td>
					</tr>
				<?php 
        } else {
            do_action('ms_view_frontend_payment_purchase_button', $subscription, $invoice, $this);
        }
        ?>
			</table>
		</div>
		<?php 
        do_action('ms_view_frontend_payment_after', $this->data, $this);
        do_action('ms_show_prices');
        if ($show_tax) {
            do_action('ms_tax_editor', $invoice);
        }
        ?>
		<div style="clear:both;"></div>
		<?php 
        $html = ob_get_clean();
        $html = apply_filters('ms_compact_code', $html);
        $html = apply_filters('ms_view_frontend_payment_form', $html, $this);
        return $html;
    }