/**
  * 		generates HTML for the Registration main meta box
  *		@access public
  *		@return void
  */
 public function _reg_attendees_meta_box()
 {
     global $wpdb;
     $REG = EEM_Registration::instance();
     //get all other registrations on this transaction, and cache
     //the attendees for them so we don't have to run another query using force_join
     $registrations = $REG->get_all(array(array('TXN_ID' => $this->_registration->transaction_ID(), 'REG_ID' => array('!=', $this->_registration->ID())), 'force_join' => array('Attendee')));
     $this->_template_args['attendees'] = array();
     $this->_template_args['attendee_notice'] = '';
     EE_Registry::instance()->load_helper('Array');
     if (empty($registrations) || is_array($registrations) && !EEH_Array::get_one_item_from_array($registrations)) {
         EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         $this->_template_args['attendee_notice'] = EE_Error::get_notices();
     } else {
         $att_nmbr = 1;
         foreach ($registrations as $registration) {
             /* @var $registration EE_Registration */
             $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
             $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname();
             //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
             $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname();
             //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
             $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email();
             //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
             $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->price_paid();
             //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
             $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
             $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $attendee->ID()), REG_ADMIN_URL);
             $att_nmbr++;
         }
         //printr( $attendees, '$attendees  <br /><span style="font-size:10px;font-weight:normal;">( file: '. __FILE__ . ' - line no: ' . __LINE__ . ' )</span>', 'auto' );
         $this->_template_args['event_name'] = $this->_registration->event_obj()->name();
         $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
         //			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
     }
     $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
     echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
 }
 /**
  * Gets the query params used to retrieve a specific line item for the given registration
  * @param EE_Registration $registration
  * @param array $original_query_params any extra query params you'd like to be merged with
  * @return array like EEM_Base::get_all()'s $query_params
  */
 public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array())
 {
     return array_replace_recursive($original_query_params, array(array('OBJ_ID' => $registration->ticket_ID(), 'OBJ_type' => 'Ticket', 'TXN_ID' => $registration->transaction_ID())));
 }
    /**
     * 		column_TXN_paid
     */
    function column_TXN_paid(EE_Registration $item)
    {
        if ($item->count() == 1) {
            if ($item->transaction()->paid() >= $item->transaction()->total()) {
                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
            } else {
                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), TXN_ADMIN_URL);
                return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '
				<span class="reg-pad-rght">
					<a class="status-' . $item->transaction()->status_ID() . '" href="' . $view_txn_lnk_url . '"  title="' . esc_attr__('View Transaction', 'event_espresso') . '">
						' . $item->transaction()->pretty_paid() . '
					</a>
				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
            }
        } else {
            return '<span class="reg-pad-rght"></span>';
        }
    }
 /**
  * generates reg code
  *
  * @param \EE_Registration $registration
  * @return string
  */
 public function generate_reg_code(EE_Registration $registration)
 {
     // figure out where to start parsing the reg code
     $chars = strpos($registration->reg_url_link(), '-') + 5;
     // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
     $new_reg_code = array($registration->transaction_ID(), $registration->ticket_ID(), substr($registration->reg_url_link(), 0, $chars));
     // now put it all together
     $new_reg_code = implode('-', $new_reg_code);
     return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration);
 }
    /**
     * 		column_actions
     */
    function column_actions(EE_Registration $item)
    {
        //Build row actions
        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $item->ID()), REG_ADMIN_URL);
        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $item->attendee_ID()), REG_ADMIN_URL);
        // page=attendees&event_admin_reports=resend_email&registration_id=43653465634&event_id=2&form_action=resend_email
        //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID );
        $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'resend_registration', '_REG_ID' => $item->ID()), REG_ADMIN_URL);
        //Build row actions
        $view_lnk = '
		<li>
			<a href="' . $view_lnk_url . '" title="' . __('View Registration Details', 'event_espresso') . '" class="tiny-text">
				<div class="dashicons dashicons-clipboard"></div>
			</a>
		</li>';
        $edit_lnk = '
		<li>
			<a href="' . $edit_lnk_url . '" title="' . __('Edit Contact Details', 'event_espresso') . '" class="tiny-text">
				<div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
			</a>
		</li>';
        $resend_reg_lnk = '
		<li>
			<a href="' . $resend_reg_lnk_url . '" title="' . __('Resend Registration Details', 'event_espresso') . '" class="tiny-text">
				<div class="dashicons dashicons-email-alt"></div>
			</a>
		</li>';
        // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb
        $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), TXN_ADMIN_URL);
        $view_txn_lnk = '
		<li>
			<a href="' . $view_txn_lnk_url . '"  title="' . __('View Transaction', 'event_espresso') . '" class="tiny-text">
				<div class="dashicons dashicons-cart"></div>
			</a>
		</li>';
        $actions = '
	<ul class="reg-overview-actions-ul">' . $view_lnk . $edit_lnk . $resend_reg_lnk . $view_txn_lnk . '
	</ul>';
        return $actions;
    }