/**
  * 		generates HTML for the Transaction main meta box
  *		@access private
  *		@return void
  */
 function _txn_details_meta_box()
 {
     global $wpdb;
     $this->_set_transaction_object();
     //get line items from transaction
     $this->_template_args['line_items'] = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
     // process taxes
     if ($taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)))) {
         $this->_template_args['taxes'] = $taxes;
     } else {
         $this->_template_args['taxes'] = FALSE;
     }
     $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
     $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
     $txn_status_class = 'status-' . $this->_transaction->get('STS_ID');
     // process payment details
     if (!($this->_template_args['payments'] = $this->_transaction->get_many_related('Payment'))) {
         $this->_template_args['payments'] = FALSE;
     }
     $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
     $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
     if (isset($txn_details['invoice_number'])) {
         $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
         $this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
         $this->_template_args['txn_details']['invoice_number']['class'] = 'regular-text';
     }
     $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
     $this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['txn_details']['registration_session']['class'] = 'regular-text';
     $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
     $this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
     $this->_template_args['txn_details']['ip_address']['class'] = 'regular-text';
     $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
     $this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $this->_template_args['txn_details']['user_agent']['class'] = 'large-text';
     $this->_get_payment_methods();
     $this->_get_active_gateways();
     $this->_get_payment_status_array();
     $this->_get_reg_status_selection();
     //setsup the template args for the reg status array for the transaction.
     $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
     $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
     $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
     // 'espresso_delete_payment_nonce'
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * txn_details_meta_box
  * generates HTML for the Transaction main meta box
  *
  * @access public
  *	@return void
  */
 public function txn_details_meta_box()
 {
     $this->_set_transaction_object();
     $this->_template_args['TXN_ID'] = $this->_transaction->ID();
     $this->_template_args['attendee'] = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->attendee() : null;
     //get line items from transaction
     $this->_template_args['line_items'] = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
     // process taxes
     $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
     $this->_template_args['taxes'] = !empty($taxes) ? $taxes : FALSE;
     $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
     $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
     $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
     //		$txn_status_class = 'status-' . $this->_transaction->get('STS_ID');
     // process payment details
     $payments = $this->_transaction->get_many_related('Payment');
     if (!empty($payments)) {
         $this->_template_args['payments'] = $payments;
         $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
     } else {
         $this->_template_args['payments'] = false;
         $this->_template_args['existing_reg_payments'] = array();
     }
     $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
     $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
     if (isset($txn_details['invoice_number'])) {
         $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
         $this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
     }
     $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
     $this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
     $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
     $this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
     $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
     $this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
     $reg_steps = '<ul>';
     foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
         if ($reg_step_status === true) {
             $reg_steps .= '<li style="color:#70cc50">' . sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
         } else {
             if (is_numeric($reg_step_status) && $reg_step_status !== false) {
                 $reg_steps .= '<li style="color:#2EA2CC">' . sprintf(__('%1$s : Initiated %2$s', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step)), gmdate(get_option('date_format') . ' ' . get_option('time_format'), $reg_step_status + get_option('gmt_offset') * HOUR_IN_SECONDS)) . '</li>';
             } else {
                 $reg_steps .= '<li style="color:#E76700">' . sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))) . '</li>';
             }
         }
     }
     $reg_steps .= '</ul>';
     $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
     $this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
     $this->_get_registrations_to_apply_payment_to();
     $this->_get_payment_methods($payments);
     $this->_get_payment_status_array();
     $this->_get_reg_status_selection();
     //sets up the template args for the reg status array for the transaction.
     $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
     $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
     $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
     // 'espresso_delete_payment_nonce'
     $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
    /**
     * 	column_actions
     * @param \EE_Transaction $item
     * @return string
     */
    function column_actions(EE_Transaction $item)
    {
        $registration = $item->primary_registration();
        $attendee = $registration->attendee();
        EE_Registry::instance()->load_helper('MSG_Template');
        //Build row actions
        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $item->ID()), TXN_ADMIN_URL);
        $dl_invoice_lnk_url = $registration->invoice_url();
        $dl_receipt_lnk_url = $registration->receipt_url();
        $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $registration->ID()), REG_ADMIN_URL);
        $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'send_payment_reminder', 'TXN_ID' => $item->ID()), TXN_ADMIN_URL);
        //Build row actions
        $view_lnk = '
			<li>
				<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
					<span class="dashicons dashicons-cart"></span>
				</a>
			</li>';
        //only show invoice link if message type is active.
        if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) {
            $dl_invoice_lnk = '
		<li>
			<a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text">
				<span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
			</a>
		</li>';
        } else {
            $dl_invoice_lnk = '';
        }
        //only show receipt link if message type is active.
        if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) {
            $dl_receipt_lnk = '
		<li>
			<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text">
				<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
			</a>
		</li>';
        } else {
            $dl_receipt_lnk = '';
        }
        //only show payment reminder link if the message type is active.
        if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
            $send_pay_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder') ? '
			<li>
				<a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
					<span class="dashicons dashicons-email-alt"></span>
				</a>
			</li>' : '';
            $send_pay_lnk = $item->get('STS_ID') != EEM_Transaction::complete_status_code && $item->get('STS_ID') != EEM_Transaction::overpaid_status_code ? $send_pay_lnk : '';
        } else {
            $send_pay_lnk = '';
        }
        $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? '
			<li>
				<a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
					<span class="dashicons dashicons-clipboard"></span>
				</a>
			</li>' : '';
        return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk, $item, 'ul', 'txn-overview-actions-ul');
    }