/**
  * 	init
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     $this->_get_reg_url_link();
     if (!$this->get_txn()) {
         EE_Registry::instance()->load_helper('HTML');
         echo EEH_HTML::div(EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . sprintf(__('This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', 'event_espresso'), '<br/>'), '', 'ee-attention');
         return NULL;
     }
     // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
     if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) {
         $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
         $this->_current_txn->save();
     }
     $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL;
     $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE;
     $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE);
     // txn status ?
     if ($this->_current_txn->is_completed()) {
         $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
     } else {
         if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) {
             $this->_show_try_pay_again_link = TRUE;
         } else {
             if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
                 // its pending
                 $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default;
             } else {
                 $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
             }
         }
     }
     $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE;
     if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) {
         $this->_is_offline_payment_method = true;
     } else {
         $this->_is_offline_payment_method = false;
     }
     // link to SPCO
     $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url());
     // link to SPCO payment_options
     $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url);
     // link to SPCO attendee_information
     $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE;
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_helper('Template_Validator');
     do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
     // set no cache headers and constants
     EE_System::do_not_cache();
 }
 /**
  * 	init
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     $this->_get_reg_url_link();
     if (!$this->get_txn()) {
         return NULL;
     }
     // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
     if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) {
         $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
         $this->_current_txn->save();
     }
     $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL;
     $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE;
     $show_try_pay_again_link_default = apply_filters('AFEE__EES_Espresso_Thank_You__init__show_try_pay_again_link_default', TRUE);
     // txn status ?
     if ($this->_current_txn->is_completed()) {
         $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
     } else {
         if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) {
             $this->_show_try_pay_again_link = TRUE;
         } else {
             if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
                 // its pending
                 $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : $show_try_pay_again_link_default;
             } else {
                 $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
             }
         }
     }
     $this->_payments_closed = !$this->_current_txn->payment_method() instanceof EE_Payment_Method ? TRUE : FALSE;
     if (!$this->_current_txn->payment_method() instanceof EE_Payment_Method || $this->_current_txn->payment_method() instanceof EE_Payment_Method && $this->_current_txn->payment_method()->is_off_line()) {
         $this->_is_offline_payment_method = true;
     } else {
         $this->_is_offline_payment_method = false;
     }
     // link to SPCO
     $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url());
     // link to SPCO payment_options
     $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url);
     // link to SPCO attendee_information
     $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE;
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_helper('Template_Validator');
     do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
     // set no cache headers and constants
     EE_System::do_not_cache();
 }
 /**
  * 	init
  *
  *  @access 	public
  *  @return 	void
  */
 public function init()
 {
     //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
     $this->_current_txn = EE_Registry::instance()->load_model('Transaction')->get_transaction_from_reg_url_link($this->_reg_url_link);
     // verify TXN
     if (!$this->_current_txn instanceof EE_Transaction) {
         EE_Error::add_error(__('No transaction information could be retrieved or the transaction data is not of the correct type.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         return;
     }
     // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
     if ($this->_current_txn->status_ID() == EEM_Transaction::failed_status_code) {
         $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
         $this->_current_txn->save();
     }
     $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration ? $this->_current_txn->primary_registration() : NULL;
     $this->_is_primary = $this->_primary_registrant->reg_url_link() == $this->_reg_url_link ? TRUE : FALSE;
     // txn status ?
     if ($this->_current_txn->is_completed()) {
         $this->_show_try_pay_again_link = FALSE;
     } else {
         if ($this->_current_txn->is_incomplete() && ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment())) {
             $this->_show_try_pay_again_link = TRUE;
         } else {
             if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
                 // its pending
                 $this->_show_try_pay_again_link = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) && EE_Registry::instance()->CFG->registration->show_pending_payment_options ? TRUE : FALSE;
             } else {
                 $this->_show_try_pay_again_link = FALSE;
             }
         }
     }
     $this->_is_offline_payment_method = in_array($this->_current_txn->selected_gateway(TRUE), array('Bank', 'Check', 'Invoice'));
     if ($this->_current_txn->last_payment() instanceof EE_Payment && $this->_current_txn->last_payment()->gateway() != NULL) {
         $this->_is_offline_payment_method = in_array($this->_current_txn->last_payment()->gateway(), array('Bank', 'Check', 'Invoice'));
     }
     // link to SPCO
     $revisit_spco_url = add_query_arg(array('ee' => '_register', 'revisit' => TRUE, 'e_reg_url_link' => $this->_reg_url_link), EE_Registry::instance()->CFG->core->reg_page_url());
     // link to SPCO payment_options
     $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->payment_overview_url() : add_query_arg(array('step' => 'payment_options'), $revisit_spco_url);
     // link to SPCO attendee_information
     $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration ? $this->_primary_registrant->edit_attendee_information_url() : FALSE;
     EE_Registry::instance()->load_helper('Template');
     EE_Registry::instance()->load_helper('Template_Validator');
     do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
 }
 /**
  * additional_primary_registrant_inputs
  *
  * @access public
  * @param EE_Registration $registration
  * @return    EE_Form_Input_Base
  */
 public function additional_primary_registrant_inputs(EE_Registration $registration)
 {
     // generate hidden input
     return new EE_Hidden_Input(array('html_id' => 'primary_registrant', 'default' => $registration->reg_url_link()));
 }
 /**
  * 	visit_allows_processing_of_this_registration
  *
  * 	determines if the current SPCO visit should allow the passed EE_Registration to be used in processing.
  * 	one of the following conditions must be met:
  * 		EITHER: 	A) first time thru SPCO -> process ALL registrations ( NOT a revisit )
  * 		OR : 		B) primary registrant is editing info -> process ALL registrations ( primary_revisit )
  * 		OR : 		C) another registrant is editing info -> ONLY process their registration ( revisit AND their reg_url_link matches )
  *
  * 	@access public
  * @param 	EE_Registration 	$registration
  * 	@return 	bool
  */
 public function visit_allows_processing_of_this_registration(EE_Registration $registration)
 {
     return !$this->revisit || $this->primary_revisit || $this->revisit && $this->reg_url_link == $registration->reg_url_link() ? TRUE : FALSE;
 }
 /**
  * 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);
 }
 /**
  * This generates a url trigger for the msg_url_trigger route using the given arguments
  *
  * @param string          $sending_messenger    The sending messenger slug.
  * @param string          $generating_messenger The generating messenger slug.
  * @param string          $context              The context for the template.
  * @param string          $message_type         The message type slug
  * @param EE_Registration $registration
  * @param integer          $message_template_group id              The EE_Message_Template_Group ID for the template.
  * @param integer          $data_id              The id to the EE_Base_Class for getting the data used by the trigger.
  *
  * @return string          The generated url.
  */
 public static function generate_url_trigger($sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id)
 {
     $query_args = array('ee' => 'msg_url_trigger', 'snd_msgr' => $sending_messenger, 'gen_msgr' => $generating_messenger, 'message_type' => $message_type, 'context' => $context, 'token' => $registration->reg_url_link(), 'GRP_ID' => $message_template_group, 'id' => $data_id);
     $url = add_query_arg($query_args, get_site_url());
     //made it here so now we can just get the url and filter it.  Filtered globally and by message type.
     $url = apply_filters('FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id);
     return $url;
 }