/** * Display custom text after the view-links are rendered. * * @since 1.0.1.2 */ public function views() { parent::views(); if (!$this->matching_type || !$this->matching_type_id) { if (!MS_Model_Import::can_match()) { $url = MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs')); echo '<p>'; _e('No suitable transaction found.', 'membership2'); echo '</p><p>'; printf('<strong>%s</strong><br />', __('Nothing to do right now:', 'membership2')); _e('Transactions that can be automatically matched will appear here when they are processed by a payment gateway.<br>So simply check again later after new payments were made.', 'membership2'); echo '</p><p>'; printf(__('If you are impatient then "Retry" some error-state transactions in the %sTransaction Logs%s section and then see if they appear on this page.', 'membership2'), '<a href="' . $url . '">', '</a>'); echo '</p>'; } // Don't display anything if no matching source was selected. return; } if (!MS_Model_Import::can_match($this->matching_type_id, $this->matching_type)) { // For this transaction details is no matching possible right now. return; } $settings = MS_Factory::load('MS_Model_Settings'); $label = $this->get_source_label($this->matching_type, $this->matching_type_id); $memberships = MS_Model_Membership::get_memberships(); $options = array('0' => '-----'); foreach ($memberships as $item) { if ($item->is_system()) { continue; } if ($item->is_free()) { $options[$item->id] = sprintf('%s • %s', $item->name, __('Free', 'membership2')); } else { $options[$item->id] = sprintf('%s • %s • %s', $item->name, $settings->currency . ' ' . MS_Helper_Billing::format_price($item->price), $item->get_payment_type_desc()); } } asort($options); $field_memberships = array('id' => 'match_with', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'before' => sprintf(__('2. Link %s with', 'membership2'), '<b>' . $label . '</b>'), 'field_options' => $options); $field_action = array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Controller_Import::AJAX_ACTION_MATCH); $field_source = array('id' => 'source', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->matching_type); $field_source_id = array('id' => 'source_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->matching_type_id); $field_save = array('class' => 'action-match', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save', 'membership2')); $field_retry_action = array('class' => 'retry_action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => MS_Controller_Import::AJAX_ACTION_RETRY); $field_retry_nonce = array('class' => 'retry_nonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce(MS_Controller_Import::AJAX_ACTION_RETRY)); ?> <div class="cf"></div> <form class="transaction-matching"> <?php wp_nonce_field(MS_Controller_Import::AJAX_ACTION_MATCH); MS_Helper_Html::html_element($field_retry_action); MS_Helper_Html::html_element($field_retry_nonce); MS_Helper_Html::html_element($field_action); MS_Helper_Html::html_element($field_source); MS_Helper_Html::html_element($field_source_id); ?> <div class="content"> <p><?php printf(__('1. Below is a list of possible "%s" transactions. Examine these transactions to find out which Membership they refer to.', 'membership2'), '<b>' . $label . '</b>'); ?> </p> <hr /> <p><?php MS_Helper_Html::html_element($field_memberships); ?> </p> <div style="margin-left:14px"> <?php _e('Notes:', 'membership2'); ?> <br /> <?php _e('This choice is saved so new transactions are processed automatically from now on.', 'membership2'); ?> <br /> <?php _e('Upon saving all transactions below will be processed, this might take a while.', 'membership2'); ?> </div> </div> <div class="buttons"> <?php MS_Helper_Html::html_element($field_save); ?> </div> </form> <?php }