Exemplo n.º 1
0
 public function getFullDescription()
 {
     $description = array();
     if ($this->_hotel == null) {
         if ($this->isNewRecord) {
             return null;
         } else {
             $element = unserialize($this->hotelInfo);
             $this->_hotel = $element;
         }
     }
     if ($this->_hotel) {
         $city = City::getCityByHotelbookId($this->_hotel->cityId);
         $description[] = $city->localRu . ': ' . $this->_hotel->hotelName;
         if ($this->hotelBookingPassports) {
             foreach ($this->hotelBookingPassports as $passport) {
                 $description[] = $passport->firstName . ' ' . $passport->lastName;
             }
         }
     }
     return $description;
 }
Exemplo n.º 2
0
 /**
  * @param $params
  * @param bool $async
  * @return array|int|mixed
  */
 public function hotelSearch($params, $async = false)
 {
     $this->synchronize();
     $time = time() + $this->differenceTimestamp;
     $getData = array('login' => Yii::app()->params['HotelBook']['login'], 'time' => $time, 'checksum' => $this->getChecksum($time));
     self::$lastRequestMethod = 'HotelSearch';
     self::$lastRequestDescription = '';
     self::$lastRequestCity = City::getCityByHotelbookId($params['cityId']);
     self::$lastRequestDescription = self::$lastRequestCity->code . ' ';
     self::$lastRequestCityHaveCoordinates = self::$lastRequestCity->latitude !== null && self::$lastRequestCity->longitude !== null;
     foreach ($params['rooms'] as $room) {
         self::$lastRequestDescription .= (self::$lastRequestDescription ? ' & ' : '') . self::$roomSizeIdNamesMap[$room['roomSizeId']] . ($room['cots'] ? $room['cots'] . 'COTS' : '') . ($room['child'] ? 'CHLD' . $room['ChildAge'] . 'AGE' : '') . (isset($room['roomNumber']) ? $room['roomNumber'] > 1 ? 'x' . $room['roomNumber'] : '' : '');
     }
     if ($async) {
         $asyncParams = array('function' => array($this, 'processHotelSearchResponse'), 'params' => array($params['checkIn'], $params['duration']));
         //$asyncParams = array();
         return $this->request(Yii::app()->params['HotelBook']['uri'] . 'hotel_search', $getData, array('request' => $this->prepareHotelSearchRequest($params)), $asyncParams);
     } else {
         $path = Yii::getPathOfAlias('application.runtime');
         file_put_contents($path . '/request_' . date('Y-m-d_H_i_s') . '.txt', $this->prepareHotelSearchRequest($params));
         $hotelsXml = $this->request(Yii::app()->params['HotelBook']['uri'] . 'hotel_search', $getData, array('request' => $this->prepareHotelSearchRequest($params)));
         //CTextHighlighter::registerCssFile();
         file_put_contents($path . '/response_' . date('Y-m-d_H_i_s') . '.txt', $hotelsXml);
         //echo $hotelsXml;
         //die();
         //VarDumper::xmlDump($hotelsXml);
         //die();
         return (array) $this->processHotelSearchResponse($hotelsXml, $params['checkIn'], $params['duration']);
     }
 }
Exemplo n.º 3
0
 /**
   Returns City object for given hotel
   @return City
 */
 public function getCity()
 {
     if (!$this->_city) {
         $this->_city = City::getCityByHotelbookId($this->cityId);
         if (!$this->_city) {
             throw new CException(Yii::t('application', 'Hotel city not found. City with hotelbookId {city_id} not set in db.', array('{city_id}' => $this->cityId)));
         }
     }
     return $this->_city;
 }