예제 #1
0
 public function actionOrder($id)
 {
     $secretKey = $id;
     $this->layout = 'static';
     $orderBooking = OrderBooking::model()->findByAttributes(array('secretKey' => $secretKey));
     if (!$orderBooking) {
         throw new CHttpException(404, 'Page not found');
     }
     if ($orderBooking->userId != Yii::app()->user->id) {
         throw new CHttpException(403, 'Доступ запрещён');
     }
     $tripStorage = new TripDataProvider($orderBooking->id);
     $trip = $tripStorage->getSortedCartItemsOnePerGroupAsJson();
     $orderId = $orderBooking->id;
     $readableOrderId = $orderBooking->readableId;
     list($passports, $ambigous, $roomCounters) = $this->getPassports($tripStorage);
     list($icon, $header) = $tripStorage->getIconAndTextForPassports();
     $this->render('complete', array('trip' => $trip, 'readableOrderId' => $readableOrderId, 'orderId' => $orderId, 'secretKey' => $secretKey, 'ambigousPassports' => $ambigous, 'passportForms' => $passports, 'bookingForm' => $this->getBookingForm($orderBooking), 'icon' => $icon, 'header' => $header, 'headersForAmbigous' => $tripStorage->getHeadersForPassportDataPage(), 'roomCounters' => $roomCounters));
 }
예제 #2
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);
 }
예제 #3
0
 public function actionShow($orderId = false)
 {
     $this->orderId = $orderId;
     $this->prepareData();
     $dataProvider = new TripDataProvider();
     echo $dataProvider->getSortedCartItemsOnePerGroupAsJson();
 }