public function createAction() { TBB_Utility_Redirector::redirectIfSessionExpired(); // get params from session $customerID = $this->_getCustomerNS()->customerID; $tripID = $this->_getCustomerNS()->tripID; $seatCountYouWant = $this->_getCustomerNS()->seatCountYouWant; $seats = $this->_getCustomerNS()->seats; $tempSeats = $this->_getCustomerNS()->tempSeats; $bookingModel = new Customer_Model_Booking(); if (($identity = TBB_Utility_Checker::isLoggedInUser()) && ($customerID = TBB_Utility_Checker::isCustomer($identity))) { try { // do the booking for the user has customer role $code = $bookingModel->bookingForExistCustomer($customerID, $tripID, $seatCountYouWant, $seats, $tempSeats); } catch (Exception $e) { return $this->_redirect('/error/expire'); } } else { try { $data = $this->_getCustomerNS()->customerData; $code = $bookingModel->booking($data['name'], $data['email'], $data['ssn'], $data['mobile'], $tripID, $seatCountYouWant, $seats, $tempSeats); } catch (Exception $e) { return $this->_redirect('/error/expire'); } } // store order code $this->_getCustomerNS()->code = $code; // mark this session as expired TBB_Utility_Redirector::setExpiredForSession(true); // receive the order, end the booking process. return $this->_redirect('/payment/receive-code'); }
public function enterInfoAction() { $customerForm = new Customer_Form_Customer(); $customerForm->setAction('/customers/enter-info')->setMethod('post'); $fromTicketList = $this->_request->getParam('fromTicketList'); // get params from ticket/list $tripID = $this->_request->getParam('trip'); $seatCountYouWant = $this->_request->getParam('seatCountYouWant'); $seats = $this->_request->getParam('seats'); $tempSeats = $this->_request->getParam('tempSeats'); // get selected seat number for later use if ($seats) { $selectedSeatNumbers = $this->_getSelectedSeatNumbers($seats); } // check if the request is from ticket/list if ($fromTicketList) { // store them in session for reviewing later $this->_getCustomerNS()->tripID = $tripID; $this->_getCustomerNS()->seats = $seats; $this->_getCustomerNS()->tempSeats = $tempSeats; $this->_getCustomerNS()->seatCountYouWant = $seatCountYouWant; $this->_getCustomerNS()->selectedSeatNumbers = $selectedSeatNumbers; // check if the user logged has customer role, if yes, he will be route to other page if (($identity = TBB_Utility_Checker::isLoggedInUser()) && ($customerID = TBB_Utility_Checker::isCustomer($identity))) { $this->_getCustomerNS()->customerID = $customerID; // forward to orders/review $this->_request->setParam('fromCustomerEnterInfo', true); return $this->_forward('review', 'orders', 'customer'); } } else { if ($this->_request->isPost()) { // check if POST array is valid if ($customerForm->isValid($_POST)) { $this->_getCustomerNS()->customerData = $customerForm->getValues(); // forward to orders/review $this->_request->setParam('fromCustomerEnterInfo', true); return $this->_forward('review', 'orders', 'customer'); } } } // populate form $customerForm->getElement('trip')->setValue($tripID); $customerForm->getElement('seatCountYouWant')->setValue($seatCountYouWant); // store seats for later sending if ($seats) { $customerForm->addSeats($seats); } // store temp seats for later sending if ($tempSeats) { $customerForm->addTempSeats($tempSeats); } $this->view->form = $customerForm; }