/**
  * Set up page for people list table
  *
  * @return string
  */
 protected function _people_list_table()
 {
     $this->_search_btn_label = __('People', 'event_espresso');
     $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add-person', array(), 'add-new-h2');
     if (!empty($this->_req_data['EVT_ID'])) {
         $event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
         if ($event instanceof EE_Event) {
             $this->_template_args['before_list_table'] = '<h2>' . sprintf(__('Showing people assigned to the event: %s', 'event_espresso'), $event->name()) . '</h2>';
         }
     }
     $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_people'), __("View People Archive Page", "event_espresso"), 'button');
     $this->display_admin_list_table_page_with_no_sidebar();
 }
 protected function _overview_list_table()
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button');
     $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
     $this->_search_btn_label = __('Venues', 'event_espresso');
     $this->display_admin_list_table_page_with_sidebar();
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_details_meta_box()
 {
     EEH_Autoloader::register_line_item_display_autoloaders();
     EEH_Autoloader::register_line_item_filter_autoloaders();
     EE_Registry::instance()->load_Helper('Line_Item');
     $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
     $this->_session = $transaction->session_data();
     $filters = new EE_Line_Item_Filter_Collection();
     $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
     $filters->add(new EE_Non_Zero_Line_Item_Filter());
     $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
     $filtered_line_item_tree = $line_item_filter_processor->process();
     $this->_template_args['REG_ID'] = $this->_registration->ID();
     $line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
     $this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
     $attendee = $this->_registration->attendee();
     $this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
     $this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     $payment = $transaction->get_first_related('Payment');
     $payment = !$payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
     $payment_method = $payment->get_first_related('Payment_Method');
     $payment_method = !$payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
     $reg_status_class = 'status-' . $this->_registration->status_ID();
     $reg_details = array('payment_method' => $payment_method->name(), 'response_msg' => $payment->gateway_response(), 'registration_id' => $this->_registration->get('REG_code'), 'registration_session' => $this->_registration->session_ID(), 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '');
     if (isset($reg_details['registration_id'])) {
         $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
         $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
         $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
     }
     if (isset($reg_details['payment_method'])) {
         $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
         $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
         $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
         $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
         $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
         $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
     }
     $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
     $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
     $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
     $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
     $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
     $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * _events_overview_list_table
  * This contains the logic for showing the events_overview list
  *
  * @access protected
  * @return string html for generated table
  */
 protected function _events_overview_list_table()
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button') . $this->_display_legend($this->_event_legend_items());
     $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
     $this->display_admin_list_table_page_with_no_sidebar();
 }
 /**
  * 	_transaction_details
  * generates HTML for the View Transaction Details Admin page
  *
  * @access protected
  *	@return void
  */
 protected function _transaction_details()
 {
     do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
     EE_Registry::instance()->load_helper('MSG_Template');
     $this->_set_transaction_status_array();
     $this->_template_args = array();
     $this->_template_args['transactions_page'] = $this->_wp_page_slug;
     $this->_set_transaction_object();
     $primary_registration = $this->_transaction->primary_registration();
     $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
     $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
     $this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
     $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a');
     $this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
     $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
     $this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
     $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
     $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
     if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
         EE_Registry::instance()->load_helper('MSG_Template');
         $this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active('payment_reminder') && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'send_payment_reminder', 'TXN_ID' => $this->_transaction->ID(), 'redirect_to' => 'view_transaction'), TXN_ADMIN_URL), __(' Send Payment Reminder'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     } else {
         $this->_template_args['send_payment_reminder_button'] = '';
     }
     $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
     $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
     if (EE_Registry::instance()->CFG->currency->sign_b4) {
         $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
     } else {
         $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
     }
     $this->_template_args['amount_due_class'] = '';
     if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
         // paid in full
         $this->_template_args['amount_due'] = FALSE;
     } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
         // overpaid
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') > 0) {
         // monies owing
         $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') == 0) {
         // no payments made yet
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') == 0) {
         // free event
         $this->_template_args['amount_due'] = FALSE;
     }
     $payment_method = $this->_transaction->payment_method();
     $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso');
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     // link back to overview
     $this->_template_args['txn_overview_url'] = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
     //next and previous links
     $next_txn = $this->_transaction->next(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
     $this->_template_args['next_transaction'] = $next_txn ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
     $previous_txn = $this->_transaction->previous(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
     $this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
     // grab messages at the last second
     $this->_template_args['notices'] = EE_Error::get_notices();
     // path to template
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
     $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
     // the details template wrapper
     $this->display_admin_page_with_sidebar();
 }
 /**
  * get_action_link_or_button
  * returns the button html for adding, editing, or deleting an item (depending on given type)
  *
  * @access  public
  *
  * @param string $action use this to indicate which action the url is generated with.
  * @param string $type accepted strings must be defined in the $_labels['button'] array(as the key) property.
  * @param array $extra_request if the button requires extra params you can include them in $key=>$value pairs.
  * @param string $class Use this to give the class for the button. Defaults to 'button-primary'
  * @param string $base_url If this is not provided the _admin_base_url will be used as the default for the button base_url.  Otherwise this value will be used.
  * @return string html for button
  */
 public function get_action_link_or_button($action, $type = 'add', $extra_request = array(), $class = 'button-primary', $base_url = FALSE)
 {
     //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
     if (!isset($this->_page_routes[$action]) && !$base_url) {
         throw new EE_Error(sprintf(__('There is no page route for given action for the button.  This action was given: %s', 'event_espresso'), $action));
     }
     if (!isset($this->_labels['buttons'][$type])) {
         throw new EE_Error(sprintf(__('There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', 'event_espresso'), $type));
     }
     //finally check user access for this button.
     $has_access = $this->check_user_access($action, TRUE);
     if (!$has_access) {
         return '';
     }
     $_base_url = !$base_url ? $this->_admin_base_url : $base_url;
     $query_args = array('action' => $action);
     //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
     if (!empty($extra_request)) {
         $query_args = array_merge($extra_request, $query_args);
     }
     $url = self::add_query_args_and_nonce($query_args, $_base_url);
     $button = EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
     return $button;
 }
 /**
  * 		generates HTML for the View Transaction Details Admin page
  *		@access protected
  *		@return void
  */
 protected function _transaction_details()
 {
     $this->_get_transaction_status_array();
     $this->_template_args = array();
     $this->_template_args['transactions_page'] = $this->wp_page_slug;
     $this->_set_transaction_object();
     $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
     $this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
     $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a');
     $this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
     $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
     $this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
     $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
     $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
     EE_Registry::instance()->load_helper('MSG_Template');
     $this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active('payment_reminder') && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'send_payment_reminder', 'TXN_ID' => $this->_transaction->ID(), 'redirect_to' => 'view_transaction'), TXN_ADMIN_URL), __(' Send Payment Reminder'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
     $this->_template_args['amount_due'] = ' <span id="txn-admin-total-amount-due">' . EEH_Template::format_currency($amount_due, TRUE) . '</span>';
     if (EE_Registry::instance()->CFG->currency->sign_b4) {
         $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
     } else {
         $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
     }
     $this->_template_args['amount_due_class'] = '';
     if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
         // paid in full
         $this->_template_args['amount_due'] = FALSE;
     } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
         // overpaid
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') > 0) {
         // monies owing
         $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') == 0) {
         // no payments made yet
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') == 0) {
         // free event
         $this->_template_args['amount_due'] = FALSE;
     }
     $gateway = $this->_transaction->get_extra_meta('gateway', true, FALSE);
     $this->_template_args['method_of_payment'] = $gateway;
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     // link back to overview
     $this->_template_args['txn_overview_url'] = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
     // grab messages at the last second
     $this->_template_args['notices'] = EE_Error::get_notices();
     // path to template
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
     $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
     // the details template wrapper
     $this->display_admin_page_with_sidebar();
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_details_meta_box()
 {
     $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
     $this->_template_args['line_items'] = $transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     // process taxes
     if ($transaction) {
         //get all "tax" line items for this transaction and we'll use them for the tax display.
         $taxes = $transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
         $this->_template_args['taxes'] = !empty($taxes) ? $taxes : array();
     } else {
         $this->_template_args['taxes'] = array();
     }
     $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart');
     $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt');
     $this->_template_args['grand_total'] = EEH_Template::format_currency($transaction->total());
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     $reg_status_class = 'status-' . $this->_registration->status_ID();
     $payment = $transaction->get_first_related('Payment');
     $reg_details = !empty($payment) ? maybe_unserialize($payment->details()) : NULL;
     //REG_ID will NOT be retrieved from $payment!
     $reg_details['registration_id'] = $this->_registration->get('REG_code');
     if (!is_array($reg_details) || is_array($reg_details) && isset($reg_details['REDO_TXN']) && $reg_details['REDO_TXN']) {
         $reg_details = array();
         $reg_details['method'] = '';
         $reg_details['response_msg'] = '';
         $reg_details['invoice_number'] = '';
     }
     $card_type = isset($reg_details['card_type']) ? ' : ' . $reg_details['card_type'] : '';
     if (isset($reg_details['registration_id'])) {
         $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
         $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
         $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
     }
     if (isset($reg_details['invoice_number'])) {
         $this->_template_args['reg_details']['invoice_number']['value'] = isset($reg_details['invoice_number']) ? $reg_details['invoice_number'] : '';
         $this->_template_args['reg_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
         $this->_template_args['reg_details']['invoice_number']['class'] = 'regular-text';
     }
     $this->_template_args['reg_details']['registration_session']['value'] = $this->_registration->session_ID();
     $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['reg_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
     $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
     $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['reg_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
     $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
     $this->_template_args['full_session'] = $this->_session;
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_details_meta_box()
 {
     $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
     $this->_session = $transaction->session_data();
     $this->_template_args['REG_ID'] = $this->_registration->ID();
     $this->_template_args['line_items'] = $transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     $attendee = $this->_registration->attendee();
     // process taxes
     if ($transaction) {
         //get all "tax" line items for this transaction and we'll use them for the tax display.
         $taxes = $transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
         $this->_template_args['taxes'] = !empty($taxes) ? $taxes : array();
     } else {
         $this->_template_args['taxes'] = array();
     }
     $this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
     $this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     $this->_template_args['grand_total'] = EEH_Template::format_currency($transaction->total());
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     $payment = $transaction->get_first_related('Payment');
     $payment = !$payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
     $payment_method = $payment->get_first_related('Payment_Method');
     $payment_method = !$payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
     $reg_status_class = 'status-' . $this->_registration->status_ID();
     $reg_details = array('payment_method' => $payment_method->name(), 'response_msg' => $payment->gateway_response(), 'registration_id' => $this->_registration->get('REG_code'), 'registration_session' => $this->_registration->session_ID(), 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '');
     if (isset($reg_details['registration_id'])) {
         $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
         $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
         $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
     }
     if (isset($reg_details['payment_method'])) {
         $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
         $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
         $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
         $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
         $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
         $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
     }
     $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
     $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
     $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
     $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
     $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
     $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * 	_transaction_details
  * generates HTML for the View Transaction Details Admin page
  *
  * @access protected
  *	@return void
  */
 protected function _transaction_details()
 {
     do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
     $this->_set_transaction_status_array();
     $this->_template_args = array();
     $this->_template_args['transactions_page'] = $this->_wp_page_slug;
     $this->_set_transaction_object();
     $primary_registration = $this->_transaction->primary_registration();
     $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
     $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
     $this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
     $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp');
     $this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
     $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
     $this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
     $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
     $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
     if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
         $this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active('payment_reminder') && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'send_payment_reminder', 'TXN_ID' => $this->_transaction->ID(), 'redirect_to' => 'view_transaction'), TXN_ADMIN_URL), __(' Send Payment Reminder', 'event_espresso'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
     } else {
         $this->_template_args['send_payment_reminder_button'] = '';
     }
     $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
     $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
     if (EE_Registry::instance()->CFG->currency->sign_b4) {
         $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
     } else {
         $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
     }
     $this->_template_args['amount_due_class'] = '';
     if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
         // paid in full
         $this->_template_args['amount_due'] = FALSE;
     } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
         // overpaid
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') > 0) {
         // monies owing
         $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') > 0 && $this->_transaction->get('TXN_paid') == 0) {
         // no payments made yet
         $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
     } elseif ($this->_transaction->get('TXN_total') == 0) {
         // free event
         $this->_template_args['amount_due'] = FALSE;
     }
     $payment_method = $this->_transaction->payment_method();
     $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso');
     $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
     // link back to overview
     $this->_template_args['txn_overview_url'] = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
     // next link
     $next_txn = $this->_transaction->next(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
     $this->_template_args['next_transaction'] = $next_txn ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
     // previous link
     $previous_txn = $this->_transaction->previous(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
     $this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
     // were we just redirected here after adding a new registration ???
     if (isset($this->_req_data['redirect_from'], $this->_req_data['EVT_ID'], $this->_req_data['event_name'])) {
         if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', 'espresso_registrations_new_registration', $this->_req_data['EVT_ID'])) {
             $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
             $this->_admin_page_title .= EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'new_registration', 'return' => 'default', 'TXN_ID' => $this->_transaction->ID(), 'event_id' => $this->_req_data['EVT_ID']), REG_ADMIN_URL);
             $this->_admin_page_title .= '">';
             $this->_admin_page_title .= sprintf(__('Add Another New Registration to Event: "%1$s" ?'), htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8'));
             $this->_admin_page_title .= '</a>';
         }
         EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
     }
     // grab messages at the last second
     $this->_template_args['notices'] = EE_Error::get_notices();
     // path to template
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
     $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
     // the details template wrapper
     $this->display_admin_page_with_sidebar();
 }