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 restoreFromDb($orderId) { Yii::app()->shoppingCart->clear(); $order = Order::model()->findByPk($orderId); if (!$order) { throw new CException("No such order"); } $items = $order->flightItems(); foreach ($items as $item) { $flightTripElement = new FlightTripElement(); $searchParams = @unserialize($item->searchParams); if ($searchParams) { $flightTripElement->fillFromSearchParams($searchParams); } $object = @unserialize($item->object); if ($object) { $flightTripElement->flightVoyage = $object; } Yii::app()->shoppingCart->put($flightTripElement); } $items = $order->hotelItems(); foreach ($items as $item) { $hotelTripElement = new HotelTripElement(); $searchParams = @unserialize($item->searchParams); if ($searchParams) { $hotelTripElement->fillFromSearchParams($searchParams); } /*$city = City::model()->findByPk($item->cityId); $hotelTripElement->city = $city; $hotelTripElement->checkIn = $item->checkIn;*/ $object = @unserialize($item->object); if ($object) { $hotelTripElement->hotel = $object; } if (false && $hotelTripElement->searchParams && $hotelTripElement->searchParams['cityFull']) { //$hotelTripElement->searchParams->cityFull = $hotelTripElement->searchParams->cityFull->getAttributes(); } Yii::app()->shoppingCart->put($hotelTripElement); } }
public function actionAdd($type, $key, $searchId = '', $searchId2 = '', $pCacheId = '') { switch ($type) { case FlightVoyage::TYPE: /** @var $flight FlightVoyage */ $flight = FlightVoyage::getFromCache($key, $searchId); $flightSearchParams = @Yii::app()->pCache->get('flightSearchParams' . $pCacheId); if ($flight) { $id = time(); //todo: add count of flightVoyageFlights Items foreach ($flight->flights as $i => $flightElement) { $item = new FlightTripElement(); $item->fillFromSearchParams($flightSearchParams, $i > 0); $item->flightVoyage = $flight; $item->groupId = $flight->getId(); $item->id = $id++; Yii::app()->shoppingCart->put($item); } } else { throw new CHttpException(404, 'Can\'t found item inside cache'); } break; case Hotel::TYPE: /** @var $hotel Hotel */ $hotel = Hotel::getFromCache($key, $searchId, $searchId2); $hotelSearchParams = @Yii::app()->pCache->get('hotelSearchParams' . $pCacheId); if ($hotel) { $item = new HotelTripElement(); $item->fillFromSearchParams($hotelSearchParams); $item->hotel = $hotel; $item->id = time(); Yii::app()->shoppingCart->put($item); } else { throw new CHttpException(404, 'Can\'t found item inside cache'); } break; } }
public function addHotelTripElement($hotel, $hotelSearchParams) { $hotelTripElement = new HotelTripElement(); $hotelTripElement->fillFromSearchParams($hotelSearchParams); Yii::import('site.common.modules.hotel.models.*'); $hotelClient = new HotelBookClient(); $hotelClient->hotelSearchDetails($hotel); $hotelTripElement->hotel = $hotel; Yii::app()->shoppingCart->put($hotelTripElement); }