Esempio n. 1
0
 public function run()
 {
     /** @var TourBuilderForm $model  */
     $model = Yii::app()->user->getState('tourForm');
     $cities = Yii::app()->user->getState('startCities');
     $citiesIndex = Yii::app()->user->getState('startCitiesIndex', 0);
     if (sizeof($cities) <= $citiesIndex) {
         $url = $this->getController()->createUrl('/admin/events/event/view', array('id' => $model->eventId));
         Yii::app()->user->setState('tourForm', null);
         Yii::app()->user->setState('startCities', null);
         Yii::app()->user->setState('startCitiesIndex', null);
         Yii::app()->user->setState('currentCity', null);
         $this->getController()->redirect($url);
     } else {
         $city = $cities[$citiesIndex];
         $model->startCityId = $city->id;
         Yii::app()->user->setState('startCities', $model->startCities);
         Yii::app()->user->setState('startCitiesIndex', $citiesIndex + 1);
         Yii::app()->user->setState('currentCity', $model->startCityId);
         Yii::app()->user->setState('tourForm', $model);
         ConstructorBuilder::buildAndPutToCart($model);
         $this->init();
         Yii::app()->getClientScript()->registerScriptFile('/js/constructorViewer.js');
         $this->controller->render('showTripForEvent', array('tabs' => $this->tabs));
     }
 }
Esempio n. 2
0
 private function buildTour(TourBuilderForm $tourSearchParams)
 {
     ConstructorBuilder::buildAndPutToCart($tourSearchParams);
 }
Esempio n. 3
0
 public function run($isTab = false)
 {
     /*        if ($res = Yii::app()->user->getState('trip.tour.form'))
                 $model = @unserialize($res);
             else*/
     $model = new TourBuilderForm();
     if (isset($_GET['eventId'])) {
         $model->eventId = $_GET['eventId'];
     }
     if (isset($_POST['TourBuilderForm'])) {
         unset($model);
         $model = new TourBuilderForm();
         $model->attributes = $_POST['TourBuilderForm'];
         $model->trips = array();
         $model->rooms = array();
         if (isset($_POST['TripForm'])) {
             $validTrips = true;
             $validRooms = true;
             $validStartCity = true;
             foreach ($_POST['TripForm'] as $i => $attributes) {
                 $trip = new TripForm();
                 $trip->attributes = $attributes;
                 $validTrips = $validTrips and $trip->validate();
                 if ($validTrips) {
                     $model->trips[] = $trip;
                 }
             }
             foreach ($_POST['HotelRoomForm'] as $i => $attributes) {
                 $room = new HotelRoomForm();
                 $room->attributes = $attributes;
                 $validRooms = $validRooms and $room->validate();
                 if ($validRooms) {
                     $model->rooms[] = $room;
                 }
             }
             $model->startCities = array();
             foreach ($_POST['EventStartCityForm'] as $i => $attributes) {
                 $startCity = new EventStartCityForm();
                 $startCity->attributes = $attributes;
                 $validStartCity = $validStartCity and $startCity->validate();
                 if ($validStartCity) {
                     $model->startCities[] = $startCity;
                 }
             }
             if ($validTrips and $validRooms and $model->validate()) {
                 Yii::app()->user->setState('trip.tour.form', serialize($model));
                 Yii::app()->shoppingCart->clear();
                 if ($model->isLinkedToEvent) {
                     Yii::app()->user->setState('tourForm', $model);
                     Yii::app()->user->setState('startCities', $model->startCities);
                     Yii::app()->user->setState('startCitiesIndex', 0);
                     $this->controller->redirect($this->controller->createUrl('showEventTrip'));
                 } else {
                     ConstructorBuilder::buildAndPutToCart($model);
                     $this->controller->redirect($this->controller->createUrl('showTrip'));
                 }
             }
         }
     }
     if ($isTab) {
         $this->controller->renderPartial('create', array('model' => $model));
     } else {
         $this->controller->render('create', array('model' => $model));
     }
 }