Example #1
0
 public function run()
 {
     $this->getController()->layout = 'static';
     $dataProvider = new TripDataProvider();
     $this->tripItems = $dataProvider->getSortedCartItems();
     if ($this->areNotAllItemsLinked()) {
         throw new CHttpException(500, 'There are exists element inside trip that are not linked. You cannot continue booking');
     }
     $passportManager = new PassportManager();
     $passportManager->tripItems = $this->tripItems;
     $orderBookingId = $this->createNewOrderBooking();
     $ambigousPassports = $passportManager->generatePassportForms();
     $this->passportForms = $passportManager->passportForms;
     if ($this->weGotPassportsAndBooking()) {
         $flag1 = $this->fillOutBookingForm();
         $flag2 = $this->fillOutPassports($ambigousPassports);
         if ($flag1 && $flag2) {
             Yii::app()->user->setState('passportForms', $this->passportForms);
             Yii::app()->user->setState('bookingForm', $this->bookingForm);
             //$tripElementsWorkflow = Yii::app()->order->bookAndReturnTripElementWorkflowItems();
             // FIXME return status here
             header("Content-type: application/json");
             echo '{"status":"success"}';
             Yii::app()->end();
         } else {
             header("Content-type: application/json");
             echo json_encode(array('status' => 'error', 'message' => $this->validationErrors));
             Yii::app()->end();
         }
     }
     $this->bookingForm = new BookingForm();
     $tripStorage = new TripDataProvider();
     $trip = $tripStorage->getSortedCartItemsOnePerGroupAsJson();
     list($icon, $header) = $tripStorage->getIconAndTextForPassports();
     $viewData = array('passportForms' => $this->passportForms, 'ambigousPassports' => $ambigousPassports, 'bookingForm' => $this->bookingForm, 'trip' => $trip, 'orderId' => $orderBookingId, 'icon' => $icon, 'header' => $header, 'headersForAmbigous' => $tripStorage->getHeadersForPassportDataPage(), 'roomCounters' => sizeof($passportManager->roomCounters) > 0 ? $passportManager->roomCounters : false);
     $this->controller->render('makeBooking', $viewData);
 }
Example #2
0
 private function getPassports($tripStorage)
 {
     $items = $tripStorage->getSortedCartItems();
     $passportManager = new PassportManager();
     $passportManager->tripItems = $items;
     $ambigousPassports = $passportManager->generatePassportForms();
     $passports = $this->restorePassportsFromDb($items, $ambigousPassports);
     $passportManager->fillFromArray($passports);
     $roomCounters = sizeof($passportManager->roomCounters) > 0 ? $passportManager->roomCounters : false;
     return array($passportManager->passportForms, $ambigousPassports, $roomCounters);
 }
Example #3
0
 public function actionLogout()
 {
     PassportManager::logOut();
 }