Commit | Line | Data |
---|---|---|
7f254ad8 AE |
1 | <?php |
2 | ||
3 | /** | |
4 | * Class CRM_Event_Cart_StateMachine_Checkout | |
5 | */ | |
6 | class CRM_Event_Cart_StateMachine_Checkout extends CRM_Core_StateMachine { | |
7 | /** | |
8 | * @param object $controller | |
9 | * @param const|int $action | |
10 | */ | |
11 | public function __construct($controller, $action = CRM_Core_Action::NONE) { | |
12 | parent::__construct($controller, $action); | |
13 | ||
14 | $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session(); | |
15 | $cart->load_associations(); | |
16 | if ($cart->is_empty()) { | |
17 | CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event')); | |
18 | } | |
19 | ||
20 | $pages = array(); | |
21 | $is_monetary = FALSE; | |
22 | $is_conference = FALSE; | |
23 | foreach ($cart->events_in_carts as $event_in_cart) { | |
24 | if ($event_in_cart->event->is_monetary) { | |
25 | $is_monetary = TRUE; | |
26 | } | |
27 | } | |
28 | $pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = NULL; | |
29 | foreach ($cart->events_in_carts as $event_in_cart) { | |
30 | if ($event_in_cart->is_parent_event()) { | |
31 | foreach ($event_in_cart->participants as $participant) { | |
32 | $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array( | |
33 | 'className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', | |
34 | 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}", | |
35 | ); | |
36 | } | |
37 | } | |
38 | } | |
39 | $pages["CRM_Event_Cart_Form_Checkout_Payment"] = NULL; | |
40 | $pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = NULL; | |
41 | $this->addSequentialPages($pages, $action); | |
42 | } | |
43 | ||
44 | } |