protected function _setup_data()
 {
     //basically ALL we're going to get from this is the transaction object and use it to build the majority of our info.
     $session = $this->_data->get_session_data();
     $this->txn = $session['transaction'];
     if (empty($this->txn) || !$this->txn instanceof EE_Transaction) {
         throw new EE_Error(__('Incoming data for the EE_Session data handler must have a valid EE_Transaction object in order to setup the data'));
     }
     $this->reg_info = array();
     $this->incoming_data = $session;
     $this->taxes = $this->txn->tax_total();
     $this->grand_total_price_object = '';
     //other data from the session (if possible)
     $this->user_id = isset($session['user_id']) ? $session['user_id'] : '';
     $this->ip_address = isset($session['ip_address']) ? $session['ip_address'] : '';
     $this->user_agent = isset($session['user_agent']) ? $session['user_agent'] : '';
     $this->init_access = $this->last_access = '';
     $this->payment = $this->txn->get_first_related('Payment');
     $this->payment = empty($this->payment) ? EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => (int) current_time('timestamp'), 'PAY_gateway' => $this->txn->selected_gateway(), 'PAY_gateway_response' => $this->txn->gateway_response_on_transaction())) : $this->payment;
     //if there is no payments associated with the transaction then we just create a default payment object for potential parsing.
     $this->billing = $this->payment->details();
     EE_Registry::instance()->load_helper('Template');
     $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : '';
     //let's get all the registrations associated with this txn
     $this->reg_objs = $this->txn->registrations();
     $this->_assemble_data();
 }
 /**
  * This will just setup the _events property in the expected format.
  * @return void
  */
 protected function _setup_data()
 {
     //now let's loop and set up the _events property.  At the same time we'll set up attendee properties.
     //a variable for tracking totals
     $running_total = 0;
     //get txn
     $this->txn = $this->reg_obj->transaction();
     $this->taxes = $this->txn->tax_total();
     $this->grand_total_price_object = '';
     //possible session stuff?
     $session = $this->txn->session_data();
     $session_data = $session instanceof EE_Session ? $session->get_session_data() : array();
     //other data from the session (if possible)
     $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
     $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
     $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
     $this->init_access = $this->last_access = '';
     $this->payment = $this->txn->get_first_related('Payment');
     $this->payment = empty($this->payment) ? EE_Payment::new_instance(array('STS_ID' => EEM_Payment::status_id_pending, 'PAY_timestamp' => (int) current_time('timestamp'), 'PAY_gateway' => $this->txn->selected_gateway(), 'PAY_gateway_response' => $this->txn->gateway_response_on_transaction())) : $this->payment;
     //if there is no payments associated with the transaction then we just create a default payment object for potential parsing.
     $this->billing = $this->payment->details();
     EE_Registry::instance()->load_helper('Template');
     $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : '';
     //get reg_objs for txn
     $this->reg_objs = $this->txn->registrations();
     //now we can set things up like we do for other handlers
     $this->_assemble_data();
 }
 protected function _parser($shortcode)
 {
     EE_Registry::instance()->load_helper('Template');
     if (!$this->_data instanceof EE_Ticket) {
         return '';
     }
     //get out cause we can only parse with the ticket object.
     switch ($shortcode) {
         case '[TICKET_ID]':
             return $this->_data->ID();
             break;
         case '[TICKET_NAME]':
             return $this->_data->get('TKT_name');
             break;
         case '[TICKET_DESCRIPTION]':
             return $this->_data->get('TKT_description');
             break;
         case '[TICKET_PRICE]':
             return EEH_Template::format_currency($this->_data->get('TKT_price'));
             break;
         case '[TKT_QTY_PURCHASED]':
             return $this->_extra_data['data']->tickets[$this->_data->ID()]['count'];
             break;
     }
 }
 /**
  * Schemas:
  *	'localized_float': "3,023.00"
  *	'no_currency_code': "$3,023.00"
  *	null: "$3,023.00<span>USD</span>"
  * @param type $value_on_field_to_be_outputted
  * @param type $schema
  * @return string
  */
 function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
 {
     $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
     if ($schema == 'localized_float') {
         return $pretty_float;
     }
     if ($schema == 'no_currency_code') {
         //			echo "schema no currency!";
         $display_code = false;
     } else {
         $display_code = true;
     }
     //we don't use the $pretty_float because format_currency will take care of it.
     return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
 }
 protected function _parser($shortcode)
 {
     EE_Registry::instance()->load_helper('Template');
     $this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null;
     $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
     $aee = !$aee instanceof EE_Messages_Addressee && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $aee;
     //possible EE_Line_Item may be incoming data
     $this->_ticket = empty($this->_ticket) && $this->_data instanceof EE_Line_Item && $aee instanceof EE_Messages_Addressee && !empty($aee->line_items_with_children[$this->_data->ID()]['EE_Ticket']) && $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] instanceof EE_Ticket ? $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] : $this->_ticket;
     //if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
     if (empty($this->_ticket)) {
         $this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->ticket() : NULL;
     }
     //If there is no event object by now then get out.
     if (!$this->_ticket instanceof EE_Ticket) {
         return '';
     }
     switch ($shortcode) {
         case '[TICKET_ID]':
             return $this->_ticket->ID();
             break;
         case '[TICKET_NAME]':
             return $this->_ticket->get('TKT_name');
             break;
         case '[TICKET_DESCRIPTION]':
             return $this->_ticket->get('TKT_description');
             break;
         case '[TICKET_PRICE]':
             return EEH_Template::format_currency($this->_ticket->get('TKT_price'));
             break;
         case '[TICKET_PRICE_WITH_TAXES]':
             return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
             break;
         case '[TKT_QTY_PURCHASED]':
             return $aee instanceof EE_Messages_Addressee ? $aee->tickets[$this->_ticket->ID()]['count'] : '';
             break;
     }
     if (strpos($shortcode, '[TKT_USES_*') !== FALSE) {
         $attrs = $this->_get_shortcode_attrs($shortcode);
         $schema = empty($attrs['schema']) ? null : $attrs['schema'];
         return $this->_ticket->get_pretty('TKT_uses', $schema);
     }
     return '';
 }
 protected function _setup_data()
 {
     $this->reg_info = array();
     $this->txn = $this->_data['txn_obj'];
     $this->payment = $this->_data['pmt_obj'];
     $this->incoming_data = $this->_data;
     $this->taxes = $this->txn->tax_total();
     $this->grand_total_price_object = '';
     //not available and not needed?
     $session_data = $this->txn->session_data();
     //other data from the session (if possible)
     $this->user_id = isset($session_data['user_id']) ? $session_data['user_id'] : '';
     $this->ip_address = isset($session_data['ip_address']) ? $session_data['ip_address'] : '';
     $this->user_agent = isset($session_data['user_agent']) ? $session_data['user_agent'] : '';
     $this->init_access = $this->last_access = '';
     $this->billing = $this->payment->details();
     // check that the gateways didn't blow up
     if (!$this->billing instanceof EE_Error) {
         EE_Registry::instance()->load_helper('Template');
         $this->billing['total_due'] = isset($this->billing['total']) ? EEH_Template::format_currency($this->billing['total']) : '';
     }
     $this->reg_objs = $this->txn->get_many_related('Registration');
     $this->_assemble_data();
 }
			</tbody>
			<tfoot>
				<tr class='total_tr'><td colspan="4"></td>
					<td class="item_r"><?php 
_e('Total Paid', 'event_espresso');
?>
</td>
					<td class="item_r"><?php 
echo EEH_Template::format_currency($amount_pd);
?>
 </td>
				</tr>
				<?php 
//echo $discount;
?>
				<tr class="total_tr">
					<td colspan="4"></td>
					<td class="total" id="total_currency"><?php 
_e('Amount Owed', 'event_espresso');
?>
</td>
					<td class="total"><?php 
echo EEH_Template::format_currency($total_cost - $amount_pd);
?>
</td>
				</tr>
			</tfoot>
		</table>

	</div>
 /**
  * update registrations REG_paid field after successful payment and link registrations with payment
  *
  * @param EE_Transaction $transaction
  * @param EE_Payment $payment
  * @param EE_Registration[] $registrations
  * @throws \EE_Error
  */
 public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array())
 {
     // only process if payment was successful
     if ($payment->status() !== EEM_Payment::status_id_approved) {
         return;
     }
     //EEM_Registration::instance()->show_next_x_db_queries();
     if (empty($registrations)) {
         // find registrations with monies owing that can receive a payment
         $registrations = $transaction->registrations(array(array('STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), 'REG_final_price' => array('!=', 0), 'REG_final_price*' => array('!=', 'REG_paid', true))));
     }
     // still nothing ??!??
     if (empty($registrations)) {
         return;
     }
     // todo: break out the following logic into a separate strategy class
     // todo: named something like "Sequential_Reg_Payment_Strategy"
     // todo: which would apply payments using the capitalist "first come first paid" approach
     // todo: then have another strategy class like "Distributed_Reg_Payment_Strategy"
     // todo: which would be the socialist "everybody gets a piece of pie" approach,
     // todo: which would be better for deposits, where you want a bit of the payment applied to each registration
     $refund = $payment->is_a_refund();
     // how much is available to apply to registrations?
     $available_payment_amount = abs($payment->amount());
     foreach ($registrations as $registration) {
         if ($registration instanceof EE_Registration) {
             // nothing left?
             if ($available_payment_amount <= 0) {
                 break;
             }
             if ($refund) {
                 $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
             } else {
                 $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
             }
         }
     }
     if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
         EE_Error::add_attention(sprintf(__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), EEH_Template::format_currency($available_payment_amount), implode(', ', array_keys($registrations)), '<br/>', EEH_Template::format_currency($payment->amount())), __FILE__, __FUNCTION__, __LINE__);
     }
 }
 /**
  * espresso_event_tickets_available
  * returns the ticket types available for purchase for an event
  *
  * @param int  $EVT_ID
  * @param bool $echo
  * @param bool $format
  * @return string
  */
 function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE)
 {
     EE_Registry::instance()->load_helper('Event_View');
     $tickets = EEH_Event_View::event_tickets_available($EVT_ID);
     if (is_array($tickets) && !empty($tickets)) {
         // if formatting then $html will be a string, else it will be an array of ticket objects
         $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
         foreach ($tickets as $ticket) {
             if ($ticket instanceof EE_Ticket) {
                 if ($format) {
                     $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
                     $html .= $ticket->name() . ' ' . EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
                     $html .= '</li>';
                 } else {
                     $html[] = $ticket;
                 }
             }
         }
         if ($format) {
             $html .= '</ul>';
         }
         if ($echo && !$format) {
             echo $html;
             return '';
         }
         return $html;
     }
     return '';
 }
 function column_TKT_price($item)
 {
     return EEH_Template::format_currency($item->get('TKT_price'));
 }
 /**
  * 	_sub_item_row
  *
  * @param EE_Line_Item $line_item
  * @param array        $options
  * @return mixed
  */
 private function _sub_item_row(EE_Line_Item $line_item, $options = array())
 {
     // start of row
     $html = EEH_HTML::tr('', 'item sub-item-row');
     // name && desc
     $name_and_desc = $line_item->name();
     $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
     // name td
     $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
     // discount/surcharge td
     if ($line_item->is_percent()) {
         $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c');
     } else {
         $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
     }
     // total td
     $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
     // end of row
     $html .= EEH_HTML::trx();
     return $html;
 }
 /**
  * 	_total_row
  *
  * @param EE_Line_Item $line_item
  * @param string       $text
  * @return mixed
  */
 private function _sub_total_row(EE_Line_Item $line_item, $text = '')
 {
     $html = '';
     if ($line_item->total()) {
         // start of row
         $html = EEH_HTML::tr('', '', 'total_tr odd');
         $text = $line_item->code() == 'pre-tax-subtotal' ? EED_Multi_Event_Registration::$event_cart_name . ' ' . $text : $text;
         // total td
         $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
         // total td
         $total = $line_item->total();
         $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'total jst-rght');
         // end of row
         $html .= EEH_HTML::trx();
     }
     return $html;
 }
    /**
     * 	get_payment_row_html
     *
     *  @access 	public
     *  @param 	EE_Payment	$payment
     *  @return 	string
     */
    public function get_payment_row_html($payment = NULL)
    {
        $html = '';
        if ($payment instanceof EE_Payment) {
            $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' : '';
            $html .= '
				<tr>
					<td>
						' . $payment->timestamp() . '
					</td>
					<td>
						' . str_replace('_', ' ', $payment->gateway()) . '
					</td>
					<td class="jst-rght">
						' . EEH_Template::format_currency($payment->amount()) . '
					</td>
					<td class="jst-rght" style="line-height:1;">
						' . $payment->pretty_status(TRUE) . $payment_declined_msg . '
					</td>
				</tr>';
            do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
        }
        return $html;
    }
 /**
  * txn_attendees_meta_box
  *    generates HTML for the Attendees Transaction main meta box
  *
  * @access public
  * @param WP_Post $post
  * @param array $metabox
  * @return void
  */
 public function txn_attendees_meta_box($post, $metabox = array('args' => array()))
 {
     extract($metabox['args']);
     $this->_template_args['post'] = $post;
     $this->_template_args['event_attendees'] = array();
     // process items in cart
     $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     if (!empty($line_items)) {
         foreach ($line_items as $item) {
             if ($item instanceof EE_Line_Item) {
                 $ticket = $item->ticket();
                 if (empty($ticket)) {
                     continue;
                     //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
                 }
                 $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
                 $event = $ticket->get_first_related('Registration')->get_first_related('Event');
                 $event_name = $event instanceof EE_Event ? $event->get('EVT_name') . ' - ' . $item->get('LIN_name') : '';
                 $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
                 foreach ($registrations as $registration) {
                     $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count');
                     $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
                     $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
                     // attendee info
                     $attendee = $registration->get_first_related('Attendee');
                     if ($attendee instanceof EE_Attendee) {
                         $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID();
                         $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
                         $this->_template_args['event_attendees'][$registration->ID()]['email'] = $attendee->email();
                         $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array());
                     } else {
                         $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = '';
                         $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = '';
                         $this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
                         $this->_template_args['event_attendees'][$registration->ID()]['address'] = '';
                     }
                 }
             }
         }
         $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
         echo EEH_Template::display_template(TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
     } else {
         echo sprintf(__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'), '<p class="important-notice">', '</p>');
     }
 }
 /**
  * _registration_payment_data_array
  * adds info for 'owing' and 'paid' for each registration to the json response
  *
  * @access protected
  * @param array $REG_IDs
  * @return array
  */
 protected function _registration_payment_data_array($REG_IDs)
 {
     $registration_payment_data = array();
     //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
     if (!empty($REG_IDs)) {
         EE_Registry::instance()->load_helper('Template');
         $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
         foreach ($registrations as $registration) {
             if ($registration instanceof EE_Registration) {
                 $registration_payment_data[$registration->ID()] = array('paid' => $registration->pretty_paid(), 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()));
             }
         }
     }
     return $registration_payment_data;
 }
						<td>
						<?php 
                    echo '<span class="spco-ticket-info-name">' . $registration->ticket()->name() . '</span>';
                    echo $registration->ticket()->description() ? '<br/><span class="spco-ticket-info-description">' . $registration->ticket()->description() . '</span>' : '';
                    ?>
						</td>
						<td class="jst-cntr"><?php 
                    echo $ticket_count[$registration->ticket()->ID()];
                    ?>
</td>
						<td class="jst-rght"><?php 
                    echo EEH_Template::format_currency($registration->ticket()->price());
                    ?>
</td>
						<td class="jst-rght"><?php 
                    echo EEH_Template::format_currency($registration->ticket()->price() * $ticket_count[$registration->ticket()->ID()]);
                    ?>
</td>
					</tr>
				</table>
			</div>
				<?php 
                }
                ?>
			<?php 
            }
            ?>

			<?php 
            // ATTENDEE QUESTIONS
            $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
													<?php 
                    }
                    ?>
												<?php 
                }
                ?>
													<tr>
														<td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php 
                echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total Ticket Price', 'event_espresso'));
                ?>
</b></td>
														<td data-th="<?php 
                echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total Ticket Price', 'event_espresso'));
                ?>
" class="jst-rght small-text"><b><?php 
                echo EEH_Template::format_currency($running_total);
                ?>
</b></td>
													</tr>
												</tbody>
											</table>
										</div>
									</section>
									<br/>
									<?php 
            }
            ?>

									<section class="tckt-slctr-tkt-sale-dates-sctn">
										<h5><?php 
            echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __('Ticket Sale Dates', 'event_espresso'));
 /**
  * 		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);
 }
    /**
     * 	get_payment_row_html
     *
     *  @access 	public
     *  @param 	EE_Payment	$payment
     *  @return 	string
     */
    public function get_payment_row_html($payment = NULL)
    {
        $html = '';
        if ($payment instanceof EE_Payment) {
            if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->is_off_site() && $payment->status() === EEM_Payment::status_id_failed) {
                // considering the registrant has made it to the Thank You page,
                // any failed payments may actually be pending and the IPN is just slow
                // so let's
                $payment->set_status(EEM_Payment::status_id_pending);
            }
            $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' : '';
            $html .= '
				<tr>
					<td>
						' . $payment->timestamp() . '
					</td>
					<td>
						' . ($payment->payment_method() instanceof EE_Payment_Method ? $payment->payment_method()->name() : __('Unknown', 'event_espresso')) . '
					</td>
					<td class="jst-rght">
						' . EEH_Template::format_currency($payment->amount()) . '
					</td>
					<td class="jst-rght" style="line-height:1;">
						' . $payment->pretty_status(TRUE) . $payment_declined_msg . '
					</td>
				</tr>';
            do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
        }
        return $html;
    }
						<td>
						<?php 
                echo $item['ticket']->name();
                echo $item['ticket']->description() ? '<br/>' . $item['ticket']->description() : '';
                ?>
						</td>
						<td class="jst-cntr"><?php 
                echo $ticket_count[$item['ticket']->ID()];
                ?>
</td>
						<td class="jst-rght"><?php 
                echo EEH_Template::format_currency($item['ticket']->price());
                ?>
</td>
						<td class="jst-rght"><?php 
                echo EEH_Template::format_currency($item['ticket']->price() * $ticket_count[$item['ticket']->ID()]);
                ?>
</td>
					</tr>
				</table>
			</div>
				<?php 
            }
            ?>
			<?php 
        }
        ?>

			<fieldset id="spco-attendee-wrap-<?php 
        echo $line_item;
        ?>
 /**
  * delete_payment
  * 	delete a payment or refund made towards a transaction
  *
  * @access public
  *	@return void
  */
 public function delete_payment()
 {
     $json_response_data = array('return_data' => FALSE);
     $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
     if ($PAY_ID) {
         $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
         $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
         if ($payment instanceof EE_Payment) {
             $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
             /** @type EE_Transaction_Payments $transaction_payments */
             $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
             if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
                 EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
                 $json_response_data['return_data'] = array('PAY_ID' => $PAY_ID, 'amount' => $payment->amount(), 'total_paid' => $payment->transaction()->paid(), 'txn_status' => $payment->transaction()->status_ID(), 'pay_status' => $payment->STS_ID(), 'delete_txn_reg_status_change' => $delete_txn_reg_status_change);
                 //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
                 if (!empty($REG_IDs)) {
                     EE_Registry::instance()->load_helper('Template');
                     $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
                     foreach ($registrations as $registration) {
                         $json_response_data['return_data']['registrations'][$registration->ID()] = array('owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), 'paid' => $registration->pretty_paid());
                     }
                 }
                 if ($delete_txn_reg_status_change) {
                     $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     //MAKE sure we also add the delete_txn_req_status_change to the
                     //$_REQUEST global because that's how messages will be looking
                     //for it.
                     $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
                     $this->_process_registration_status_change($payment->transaction());
                 }
             }
         } else {
             EE_Error::add_error(__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         }
     } else {
         $msg = __('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso');
         EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
     }
     $notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
     echo json_encode(array_merge($json_response_data, $notices));
     die;
 }
 /**
  * 		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);
 }
 protected function _parser($shortcode)
 {
     EE_Registry::instance()->load_helper('Template');
     if (!$this->_data->txn instanceof EE_Transaction) {
         return '';
     }
     switch ($shortcode) {
         case '[TXN_ID]':
             return $this->_data->txn->ID();
             break;
         case '[PAYMENT_URL]':
             $payment_url = $this->_data->txn->payment_overview_url();
             return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
             break;
         case '[INVOICE_LINK]':
             $invoice_url = $this->_data->txn->invoice_url();
             $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
             return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>');
             break;
             /**/
         /**/
         case '[INVOICE_URL]':
             $invoice_url = $this->_data->txn->invoice_url();
             return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
             break;
         case "[TOTAL_COST]":
             $total = $this->_data->txn->total();
             return !empty($total) ? EEH_Template::format_currency($total) : '';
             break;
         case "[PAYMENT_STATUS]":
             $status = $this->_data->txn->pretty_status();
             return !empty($status) ? $status : __('Unknown', 'event_espresso');
             break;
             /**/
         /**/
         case "[PAYMENT_GATEWAY]":
             return $this->_get_payment_gateway();
             break;
         case "[AMOUNT_PAID]":
             $amount = isset($this->_data->payment) && is_object($this->_data->payment) ? $this->_data->payment->amount() : 0;
             return EEH_Template::format_currency($amount);
             break;
         case "[TOTAL_OWING]":
             $total_owing = isset($this->_data->txn) && is_object($this->_data->txn) ? $this->_data->txn->remaining() : $this->_data->txn->total();
             return EEH_Template::format_currency($total_owing);
             break;
         case "[TKT_QTY_PURCHASED]":
             return $this->_data->total_ticket_count;
             break;
         case "[TRANSACTION_ADMIN_URL]":
             require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
             $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $this->_data->txn->ID());
             $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
             return $url;
             break;
     }
     return '';
 }
						<span class="red-text smaller-text"><?php 
        _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso');
        ?>
</span>
					</td>
				</tr>
				<tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php 
        echo $pay_totals_class;
        ?>
">
					<th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php 
        echo $overpaid . sprintf(__('Payments Total %s', 'event_espresso'), '(' . EE_Registry::instance()->CFG->currency->code . ')');
        ?>
</span></th>
					<th class=" jst-rght"><span id="txn-admin-payment-total"><?php 
        echo EEH_Template::format_currency($payment_total, FALSE, FALSE);
        ?>
</span></th>
				</tr>
		<?php 
    } else {
        ?>
				<tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
					<td class=" jst-rght" colspan="11">
						<span class="red-text smaller-text"><?php 
        _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso');
        ?>
</span>
					</td>
				</tr>
				<tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
 protected function _get_tax_rows($tktrow, $ticket)
 {
     $tax_rows = '';
     $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
     $template_args = array();
     $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
     foreach ($taxes as $tax) {
         $tax_added = $this->_get_tax_added($tax, $ticket);
         $template_args = array('display_tax' => !empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', 'tax_id' => $tax->ID(), 'tkt_row' => $tktrow, 'tax_label' => $tax->get('PRC_name'), 'tax_added' => $tax_added, 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), 'tax_amount' => $tax->get('PRC_amount'));
         $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
         $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
     }
     return $tax_rows;
 }
 /**
  * 		generates HTML for the Attendees Transaction main meta box
  *		@access private
  *		@return void
  */
 function _txn_attendees_meta_box($post, $metabox = array('args' => array()))
 {
     global $wpdb;
     extract($metabox['args']);
     // process items in cart
     $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
     $this->_template_args['event_attendees'] = array();
     if (!empty($line_items)) {
         foreach ($line_items as $item) {
             $ticket = $item->ticket();
             if (empty($ticket)) {
                 continue;
             }
             //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
             $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
             $event = $ticket->get_first_related('Registration')->get_first_related('Event');
             foreach ($registrations as $registration) {
                 $attendee = $registration->get_first_related('Attendee');
                 $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count');
                 $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event->get('EVT_name') . ' - ' . $item->get('LIN_name');
                 $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name();
                 $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = EEH_Template::format_currency($item->get('LIN_unit_price'));
                 $this->_template_args['event_attendees'][$registration->ID()]['email'] = $attendee->email();
                 $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array());
                 $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID();
             }
         }
         $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
         $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php';
         echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
     }
 }
 function column_amount($item)
 {
     if ($this->_price_types[$item->type()]->is_percent()) {
         return '<div class="pad-amnt-rght">' . number_format($item->amount(), 1) . '%</div>';
     } else {
         return '<div class="pad-amnt-rght">' . EEH_Template::format_currency($item->amount()) . '</div>';
     }
 }
 /**
  *    _payments_and_amount_owing_rows
  *
  * @param EE_Line_Item $line_item
  * @param array        $options
  * @return mixed
  */
 private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array())
 {
     $html = '';
     $owing = $line_item->total();
     $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
     if ($transaction instanceof EE_Transaction) {
         $registration_payments = array();
         $registrations = !empty($options['registrations']) ? $options['registrations'] : $transaction->registrations();
         foreach ($registrations as $registration) {
             if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
                 $registration_payments = $registration_payments + $registration->registration_payments();
             }
         }
         if (!empty($registration_payments)) {
             foreach ($registration_payments as $registration_payment) {
                 if ($registration_payment instanceof EE_Registration_Payment) {
                     $owing = $owing - $registration_payment->amount();
                     $payment = $registration_payment->payment();
                     if ($payment instanceof EE_Payment) {
                         $payment_desc = sprintf(__('Payment%1$s Received: %2$s', 'event_espresso'), $payment->txn_id_chq_nmbr() != '' ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' : '', $payment->timestamp());
                     } else {
                         $payment_desc = '';
                     }
                     // start of row
                     $html .= EEH_HTML::tr('', '', 'total_tr odd');
                     // payment desc
                     $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
                     // total td
                     $html .= EEH_HTML::td(EEH_Template::format_currency($registration_payment->amount(), false, false), '', 'total jst-rght');
                     // end of row
                     $html .= EEH_HTML::trx();
                 }
             }
             if ($line_item->total()) {
                 // start of row
                 $html .= EEH_HTML::tr('', '', 'total_tr odd');
                 // total td
                 $html .= EEH_HTML::td(__('Amount Owing', 'event_espresso'), '', 'total_currency total jst-rght', '', ' colspan="3"');
                 // total td
                 $html .= EEH_HTML::td(EEH_Template::format_currency($owing, false, false), '', 'total jst-rght');
                 // end of row
                 $html .= EEH_HTML::trx();
             }
         }
     }
     $this->_grand_total = $owing;
     return $html;
 }
    echo EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $registration->ID()) ? '
							<a href="' . $reg_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' . sprintf(__('
								View Registration ', 'event_espresso'), $registration->ID()) . '</a>' : '';
    ?>
					</td>
					<td class="jst-left">
					<?php 
    $txn_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $registration->transaction_ID()), TXN_ADMIN_URL);
    echo EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '
						<a href="' . $txn_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '">
							View Transaction ' . $registration->transaction_ID() . '
						</a>' : '';
    ?>
					</td>
					<td class="jst-left"><?php 
    echo $registration->reg_code();
    ?>
</td>
					<td class="jst-rght"><?php 
    echo EEH_Template::format_currency($registration->final_price());
    ?>
</td>
				</tr>
			<?php 
}
?>
			</tbody>
		</table>
	</div>
</div>
						<td class="item_r"><?php 
echo EEH_Template::format_currency($amount_pd, false, false);
?>
 </td>
					</tr>
					<?php 
//echo $discount;
?>
					<tr class="total_tr odd">
						<td colspan="4">&nbsp;</td>
						<td class="total" id="total_currency"><?php 
_e('Amount Owed:', 'event_espresso');
?>
</td>
						<td class="total"><?php 
echo EEH_Template::format_currency($amount_owed);
?>
</td>
					</tr>
				</tfoot>
			</table>
		</div>
		<div class="additional-info-dv">
			<h3 class="section-title"><?php 
_e("Additional Information:", "event_espresso");
?>
</h3>
			<div class="additional-info">
				<?php 
if ($venues_for_events) {
    ?>