示例#1
0
 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');
 }