Ejemplo n.º 1
0
 /**
  * @param object $controller
  * @param const|int $action
  */
 public function __construct($controller, $action = CRM_Core_Action::NONE)
 {
     parent::__construct($controller, $action);
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $cart->load_associations();
     if ($cart->is_empty()) {
         CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event'));
     }
     $pages = array();
     $is_monetary = FALSE;
     $is_conference = FALSE;
     foreach ($cart->events_in_carts as $event_in_cart) {
         if ($event_in_cart->event->is_monetary) {
             $is_monetary = TRUE;
         }
     }
     $pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = NULL;
     foreach ($cart->events_in_carts as $event_in_cart) {
         if ($event_in_cart->is_parent_event()) {
             foreach ($event_in_cart->participants as $participant) {
                 $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array('className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}");
             }
         }
     }
     $pages["CRM_Event_Cart_Form_Checkout_Payment"] = NULL;
     $pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = NULL;
     $this->addSequentialPages($pages, $action);
 }
Ejemplo n.º 2
0
 function loadCart()
 {
     if ($this->event_cart_id == NULL) {
         $this->cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     } else {
         $this->cart = CRM_Event_Cart_BAO_Cart::find_by_id($this->event_cart_id);
     }
     $this->cart->load_associations();
     $this->stub_out_and_inherit();
 }
 function run()
 {
     $transaction = new CRM_Core_Transaction();
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $cart->load_associations();
     $this->assign_by_ref('events_in_carts', $cart->get_main_events_in_carts());
     $this->assign('events_count', count($cart->get_main_events_in_carts()));
     $transaction->commit();
     return parent::run();
 }
Ejemplo n.º 4
0
 /**
  * This function takes care of all the things common to all pages.
  *
  * This typically involves assigning the appropriate smarty variables :)
  */
 public function run()
 {
     $transaction = new CRM_Core_Transaction();
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $cart->load_associations();
     $event_in_cart = $cart->get_event_in_cart_by_event_id($this->_id);
     $removed_event = $cart->remove_event_in_cart($event_in_cart->id);
     $removed_event_title = $removed_event->event->title;
     CRM_Core_Session::setStatus(ts("<b>%1</b> has been removed from your cart.", array(1 => $removed_event_title)), '', 'success');
     $transaction->commit();
     return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 5
0
 /**
  * This function takes care of all the things common to all pages.
  *
  * This typically involves assigning the appropriate smarty variables :)
  */
 public function run()
 {
     $transaction = new CRM_Core_Transaction();
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
         CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
     }
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $event_in_cart = $cart->add_event($this->_id);
     $url = CRM_Utils_System::url('civicrm/event/view_cart');
     CRM_Utils_System::setUFMessage(ts("<b>%1</b> has been added to your cart. <a href='%2'>View your cart.</a>", array(1 => $event_in_cart->event->title, 2 => $url)));
     $transaction->commit();
     return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
 }
Ejemplo n.º 6
0
 /**
  * @param int $event_id
  *
  * @return array
  */
 public static function get_registration_link($event_id)
 {
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $cart->load_associations();
     $event_in_cart = $cart->get_event_in_cart_by_event_id($event_id);
     if ($event_in_cart) {
         return array('label' => "Remove from Cart", 'path' => 'civicrm/event/remove_from_cart', 'query' => "reset=1&id={$event_id}");
     } else {
         return array('label' => "Add to Cart", 'path' => 'civicrm/event/add_to_cart', 'query' => "reset=1&id={$event_id}");
     }
 }