public static function addGroupedInfoToTab($preparedFlight, $flight) { $from = City::getCityByPk($flight->departureCity); $to = City::getCityByPk($flight->arrivalCity); $preparedFlight['info']['flights'][] = array('label' => '<br>' . $flight->departureDate . "<br>" . $from->localRu . " — " . $to->localRu, 'departureDate' => $flight->departureDate, 'cityFromId' => $flight->departureCity, 'cityToId' => $flight->arrivalCity, 'adultCount' => $flight->adultCount, 'childCount' => $flight->childCount, 'infantCount' => $flight->infantCount); return $preparedFlight; }
public static function prepareInfoForTab(HotelTripElement $hotel) { /** @var $hotel HotelTripElement */ $from = City::getCityByPk($hotel->city); $tab = array(); $tab['label'] = '<b>Отель в городе ' . $from->localRu . '</b><br>' . $hotel->checkIn . " — " . $hotel->checkOut; $tab['id'] = $hotel->id . '_tab'; $tab['info'] = array('type' => 'hotel', 'cityId' => $hotel->city, 'checkIn' => $hotel->checkIn, 'checkOut' => $hotel->checkOut, 'duration' => $hotel->getDuration()); foreach ($hotel->rooms as $i => $room) { $tab['info']['room'][$i]['adultCount'] = $room->adultCount; $tab['info']['room'][$i]['childCount'] = $room->childCount; $tab['info']['room'][$i]['cots'] = $room->cots; $tab['info']['room'][$i]['childAge'] = $room->childAge; } if ($hotel->hotel) { $controller = Yii::app()->getController(); $tab['content'] = $controller->renderPartial('//tour/constructor/_chosen_hotel_precompiled', array('hotel' => $hotel->hotel), true); $tab['itemOptions']['class'] = 'hotel fill'; $tab['fill'] = true; } else { $tab['content'] = 'loading...'; $tab['itemOptions']['class'] = 'hotel unfill'; $tab['fill'] = false; } return $tab; }
public function getArrivalCity() { if ($this->arrivalCity == null) { $this->arrivalCity = City::getCityByPk($this->_id['arrivalCityId']); } return $this->arrivalCity; }
public function actionSearch($from, $to, $date) { $flightForm = new FlightForm(); $flightForm->departureCityId = $from; $flightForm->arrivalCityId = $to; $flightForm->departureDate = $date; $fromCityName = City::getCityByPk($from)->localRu; $toCityName = City::getCityByPk($to)->localRu; $this->render('index', array('items' => $this->generateItems(), 'flightForm' => $flightForm, 'autosearch' => true, 'fromCityName' => $fromCityName, 'toCityName' => $toCityName)); }
public function getArrivalCity() { if (!$this->arrivalCity) { $this->arrivalCity = City::getCityByPk($this->arrivalCityId); if (!$this->arrivalCity) { throw new CException(Yii::t('application', 'Arrival city not found. City with id {city_id} not set in db.', array('{city_id}' => $this->arrivalCityId))); } } return $this->arrivalCity; }
public function run() { Yii::import('site.common.modules.hotel.models.*'); $hotelForm = new HotelForm(); if (isset($_REQUEST['HotelForm'])) { $hotelForm->attributes = $_REQUEST['HotelForm']; $rooms = array(); if (isset($_REQUEST['HotelRoomForm'])) { foreach ($_REQUEST['HotelRoomForm'] as $i => $info) { $room = new HotelRoomForm(); $room->attributes = $info; if ($room->validate()) { $rooms[] = $room; } } } $hotelForm->rooms = $rooms; if ($hotelForm->validate()) { $hotelSearchParams = new HotelSearchParams(); $hotelSearchParams->checkIn = date('Y-m-d', strtotime($hotelForm->fromDate)); $hotelSearchParams->city = City::getCityByPk($hotelForm->cityId); $hotelSearchParams->duration = $hotelForm->duration; foreach ($hotelForm->rooms as $room) { if ($room->childCount == 1) { $hotelSearchParams->addRoom($room->adultCount, $room->cots, $room->childAge); } else { $hotelSearchParams->addRoom($room->adultCount, $room->cots, false); } } $HotelClient = new HotelBookClient(); $pCacheId = md5(serialize($hotelSearchParams)); Yii::app()->pCache->set('hotelSearchParams' . $pCacheId, $hotelSearchParams, appParams('hotel_search_cache_time')); $resultSearch = $HotelClient->fullHotelSearch($hotelSearchParams); Yii::app()->hotelsRating->injectRating($resultSearch->hotels, $hotelSearchParams->city); $cacheId = substr(md5(uniqid('', true)), 0, 10); Yii::app()->cache->set('hotelResult' . $cacheId, $resultSearch, appParams('hotel_search_cache_time')); Yii::app()->cache->set('hotelSearchParams' . $cacheId, $hotelSearchParams, appParams('hotel_search_cache_time')); Yii::app()->cache->set('hotelForm' . $cacheId, $hotelForm, appParams('hotel_search_cache_time')); if ($resultSearch['hotels']) { $hotelStack = new HotelStack($resultSearch); $results = $hotelStack->groupBy('hotelId')->groupBy('roomSizeId')->groupBy('rubPrice')->sortBy('rubPrice', 2)->getJsonObject(); echo json_encode(array('pCacheId' => $pCacheId, 'cacheId' => $cacheId, 'hotels' => $results)); } else { echo json_encode(array('cacheId' => $cacheId, 'hotels' => array())); } } else { //invalid form throw new CHttpException(500, CHtml::errorSummary($hotelForm)); } Yii::app()->end(); } else { throw new CHttpException(404); } }
public function actionIndex($isTab = false) { Yii::import('site.common.modules.hotel.models.*'); $hotelForm = new HotelForm(); if (isset($_POST['ajax']) && $_POST['ajax'] === 'hotel-form') { echo CActiveForm::validate($hotelForm); Yii::app()->end(); } if (isset($_POST['HotelForm'])) { $hotelForm->attributes = $_POST['HotelForm']; $rooms = array(); if (isset($_POST['HotelRoomForm'])) { foreach ($_POST['HotelRoomForm'] as $i => $info) { $room = new HotelRoomForm(); $room->attributes = $info; if ($room->validate()) { $rooms[] = $room; } } } $hotelForm->rooms = $rooms; if ($hotelForm->validate()) { $hotelSearchParams = new HotelSearchParams(); $hotelSearchParams->checkIn = date('Y-m-d', strtotime($hotelForm->fromDate)); $hotelSearchParams->city = City::getCityByPk($hotelForm->cityId); $hotelSearchParams->duration = $hotelForm->duration; foreach ($hotelForm->rooms as $room) { if ($room->childCount == 1) { $hotelSearchParams->addRoom($room->adultCount, $room->cots, $room->childAge); } else { $hotelSearchParams->addRoom($room->adultCount, $room->cots, false); } } $HotelClient = new HotelBookClient(); $resultSearch = $HotelClient->fullHotelSearch($hotelSearchParams); Yii::app()->hotelsRating->injectRating($resultSearch->hotels, $hotelSearchParams->city); $cacheId = substr(md5(uniqid('', true)), 0, 10); Yii::app()->cache->set('hotelResult' . $cacheId, $resultSearch, appParams('hotel_search_cache_time')); Yii::app()->cache->set('hotelSearchParams' . $cacheId, $hotelSearchParams, appParams('hotel_search_cache_time')); Yii::app()->cache->set('hotelForm' . $cacheId, $hotelForm, appParams('hotel_search_cache_time')); Yii::app()->user->setState('hotel.cacheId', $cacheId); //die(); $this->redirect('/booking/hotel/result/cacheId/' . $cacheId); } else { $this->render('index', array('items' => $this->generateItems(), 'hotelForm' => $hotelForm, 'autosearch' => false, 'cityName' => '', 'duration' => 1)); } } else { if ($isTab) { $this->renderPartial('index', array('items' => $this->generateItems(), 'hotelForm' => $hotelForm, 'autosearch' => false, 'cityName' => '', 'duration' => 1)); } else { $this->render('index', array('items' => $this->generateItems(), 'hotelForm' => $hotelForm, 'autosearch' => false, 'cityName' => '', 'duration' => 1)); } } }
private function addMoreInfo($cities) { foreach ($cities as $i => $one) { $city = City::getCityByPk($one['id']); $cities[$i]['code'] = $city->code; $cities[$i]['name'] = $city->localRu; $cities[$i]['nameGen'] = $city->caseGen; $cities[$i]['nameAcc'] = $city->caseAcc; $cities[$i]['country'] = $city->country->localRu; $cities[$i]['label'] = CityManager::parseTemplate(CityManager::templateForLabelAutocomplete(), $city); } return $cities; }
public function actionInfo($eventId) { $event = Event::model()->findByPk($eventId); $defaultCityId = 4466; $pricesData = array(); $this->layout = 'static'; foreach ($event->prices as $price) { $pricesData[$price->city->id] = array('price' => floor($price->bestPrice), 'cityName' => $price->city->localRu, 'cityId' => $price->city->id, 'updateTime' => str_replace(' ', 'T', $price->updated)); } $tours = array(); $dataProvider = new TripDataProvider(); $cities = array(); foreach ($event->tours as $tour) { $tours[$tour->startCityId] = array(); $dataProvider->restoreFromDb($tour->orderId); //echo $tour->orderId.'dsf'; //print_r($dataProvider->getSortedCartItemsOnePerGroup(false));//die(); $items = $dataProvider->getWithAdditionalInfo($dataProvider->getSortedCartItemsOnePerGroup(false)); //print_r($items);die(); $tours[$tour->startCityId] = $items; $tours[$tour->startCityId]['city'] = City::getCityByPk($tour->startCityId)->getAttributes(); $eventPrice = EventPrice::model()->findByAttributes(array('eventId' => $eventId, 'cityId' => $tour->startCityId)); if ($eventPrice) { $tours[$tour->startCityId]['price'] = ceil($eventPrice->bestPrice); } $cities[$tour->startCityId] = City::getCityByPk($tour->startCityId)->getAttributes(); } //die(); if (!isset($cities[$defaultCityId])) { foreach ($cities as $defaultCityId => $city) { break; } } //need search params $twoCities = array(); $twoCities[$defaultCityId] = $cities[$defaultCityId]; foreach ($cities as $cityId => $city) { if (!isset($twoCities[$cityId])) { $twoCities[$cityId] = $city; break; } } $pictures = array(); foreach ($event->pictures as $picture) { $pictures[] = array('url' => $picture->getUrl()); } $this->render('info', array('event' => $event, 'priceData' => $pricesData, 'defaultCity' => $defaultCityId, 'tours' => $tours, 'cities' => $cities, 'twoCities' => $twoCities, 'pictures' => $pictures)); }
?> </div> </td> <td class="tdTo"> <?php echo date('d.m', strtotime($fc->dateFrom)); ?> </td> <td class="tdFrom"> <?php echo $fc->dateBack == '0000-00-00' ? '' : date('d.m', strtotime($fc->dateBack)); ?> </td> <td class="tdPrice"> <a href="<?php echo '/land/' . City::getCityByPk($fc->to)->country->code . '/' . City::getCityByPk($fc->from)->code . '/' . City::getCityByPk($fc->to)->code . ($fc->dateBack == '0000-00-00' ? '/trip/OW' : ''); ?> "><span class="price"><?php echo UtilsHelper::formatPrice($fc->priceBestPrice); ?> </span> <span class="rur">o</span></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="clear"></div>
</td> <td class="tdTime"><?php echo date('H:i', $flightPart->timestampEnd); ?> </td> <td class="tdIco"> <?php if ($keyPart == $lastKey) { ?> <img src="images/ico-fly.png"> <?php } ?> </td> <td class="tdCity"><?php echo City::getCityByPk($flightPart->arrivalCityId)->localRu; ?> , <span class="airport"><?php echo $flightPart->arrivalAirport->localRu; echo $flightPart->arrivalTerminalCode ? " ({$flightPart->arrivalTerminalCode})" : ''; ?> </span></td> </tr> </table> <?php $firstPart = false; ?> <?php } ?> </div>
if ($i > $firstHalf) { $back = $fc->dateBack == '0000-00-00' ? false : true; ?> <tr<?php echo $i % 2 == 0 ? ' class="select"' : ''; ?> > <td class="tdFlight"> <div><?php echo City::getCityByPk($fc->from)->localRu; ?> <span class="<?php echo $back ? 'toFrom' : 'to'; ?> "></span> <?php echo City::getCityByPk($fc->to)->localRu; ?> </div> </td> <td class="tdTo"> <?php echo date('d.m', strtotime($fc->dateFrom)); ?> </td> <td class="tdFrom"> <?php echo $fc->dateBack == '0000-00-00' ? '' : date('d.m', strtotime($fc->dateBack)); ?> </td> <td class="tdPrice"> <a href="#"><span class="price"><?php
public function getCity() { if (isset($this->city)) { return $this->city; } else { $this->city = City::getCityByPk($this->cityId); return $this->city; } }
public function getJsonObject() { $airline = Airline::getAirlineByCode($this->transportAirlineCode); //echo 1; //die(); if (!$this->markAirline) { //$this->markAirline = $airline; $ret = array('transportAirline' => $this->transportAirlineCode, 'transportAirlineName' => $airline->localRu, 'transportAirlineNameEn' => $airline->localEn, 'departureCity' => City::getCityByPk($this->departureCityId)->localRu, 'departureCityPre' => City::getCityByPk($this->departureCityId)->casePre, 'departureCityId' => $this->departureCityId, 'arrivalCity' => City::getCityByPk($this->arrivalCityId)->localRu, 'arrivalCityPre' => City::getCityByPk($this->arrivalCityId)->casePre, 'arrivalCityId' => $this->arrivalCityId, 'datetimeBegin' => DateTimeHelper::formatForJs($this->timestampBegin), 'datetimeEnd' => DateTimeHelper::formatForJs($this->timestampEnd), 'flightCode' => $this->code, 'duration' => $this->duration, 'departureAirport' => $this->departureAirport->localRu, 'arrivalAirport' => $this->arrivalAirport->localRu, 'departureAirportId' => $this->departureAirport->id, 'arrivalAirportId' => $this->arrivalAirport->id, 'aircraftCode' => $this->aircraftCode, 'aircraftName' => $this->getAircraftName(), 'stopNum' => $this->stopNum, 'bookingCode' => $this->bookingCodes[0]); } else { $ret = array('transportAirline' => $this->transportAirlineCode, 'transportAirlineName' => $airline->localRu, 'transportAirlineNameEn' => $airline->localEn, 'markAirline' => $this->markAirline->code, 'markAirlineName' => $this->markAirline->localRu, 'markAirlineNameEn' => $this->markAirline->localEn, 'departureCity' => City::getCityByPk($this->departureCityId)->localRu, 'departureCityPre' => City::getCityByPk($this->departureCityId)->casePre, 'departureCityId' => $this->departureCityId, 'arrivalCity' => City::getCityByPk($this->arrivalCityId)->localRu, 'arrivalCityPre' => City::getCityByPk($this->arrivalCityId)->casePre, 'arrivalCityId' => $this->arrivalCityId, 'datetimeBegin' => DateTimeHelper::formatForJs($this->timestampBegin), 'datetimeEnd' => DateTimeHelper::formatForJs($this->timestampEnd), 'flightCode' => $this->code, 'duration' => $this->duration, 'departureAirport' => $this->departureAirport->localRu, 'arrivalAirport' => $this->arrivalAirport->localRu, 'departureAirportId' => $this->departureAirport->id, 'arrivalAirportId' => $this->arrivalAirport->id, 'aircraftCode' => $this->aircraftCode, 'aircraftName' => $this->getAircraftName(), 'stopNum' => $this->stopNum, 'bookingCode' => $this->bookingCodes[0]); } //print_r($ret); //die(); return $ret; }
public function saveHotelDb() { $hotels = $this->getJsonObject(0); if ($hotels) { $city = City::getCityByPk($hotels['hotels'][0]['cityId']); $hotelNames = array(); foreach ($hotels['hotels'] as $hotelInfo) { $hotelNames[$hotelInfo['hotelName']] = $hotelInfo['hotelName']; } $ratingNames = HotelRating::model()->findByNames($hotelNames, $city); foreach ($hotels['hotels'] as $hotelInfo) { $hotelDb = HotelDb::lazySaveHotelDb(array('id' => $hotelInfo['hotelId'], 'name' => $hotelInfo['hotelName'], 'stars' => $hotelInfo['categoryId'], 'cityId' => $city->id, 'countryId' => $city->countryId, 'rating' => isset($ratingNames[$hotelInfo['hotelName']]) ? $ratingNames[$hotelInfo['hotelName']] : null, 'minPrice' => $hotelInfo['rubPrice'])); } HotelDb::lazySave(); } }
private function addCityFrom(&$cityFromArray, $cityFromId) { if (!isset($cityFromArray[$cityFromId])) { $city = City::getCityByPk($cityFromId); $cityFromArray[$cityFromId] = array('cityId' => $cityFromId, 'cityName' => $city->localRu, 'cityAcc' => $city->caseAcc); } }