/**
  * 		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);
     }
 }
 /**
  * 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) {
                 switch ($item->OBJ_type()) {
                     case 'Event':
                         break;
                     case 'Ticket':
                         $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'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event->get('EVT_name') . __(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
                                 $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'] = '';
                             }
                         }
                         break;
                 }
             }
         }
         $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>');
     }
 }