Beispiel #1
0
 /**
  *
  * @return array
  */
 public function getOptions()
 {
     //search options
     $searchService = $this->getServiceLocator()->get('service_website_search');
     $options = $searchService->getOptionsForSearch();
     //location options
     $cacheService = $this->getServiceLocator()->get('service_website_cache');
     $keyLocationsCache = 'locations_for_home_en';
     $router = $this->getServiceLocator()->get('router');
     if ($rowsLocations = $cacheService->get($keyLocationsCache)) {
         $options['locations'] = $rowsLocations;
     } else {
         $cityDao = new CityDao($this->getServiceLocator(), 'ArrayObject');
         $citiesList = $cityDao->getCityListForIndex();
         $cities = [];
         foreach ($citiesList as $city) {
             $cityProvince = $city['city_slug'] . '--' . $city['province_slug'];
             $img = Helper::getImgByWith('/locations/' . $city['detail_id'] . '/' . $city['cover_image'], WebSite::IMG_WIDTH_LOCATION_MEDIUM);
             $cities[$city['ordering']] = ['city_id' => $city['city_id'], 'country_id' => $city['country_id'], 'capacity' => $city['capacity'], 'spent_nights' => $city['spent_nights'], 'sold_future_nights' => $city['sold_future_nights'], 'img' => $img, 'url' => $router->assemble(['action' => 'location', 'cityProvince' => $cityProvince], ['name' => 'location/child'])];
         }
         ksort($cities);
         $options['locations'] = $cities;
         $cacheService->set($keyLocationsCache, $cities);
     }
     //country count
     $keyCountryCashe = 'country_count_for_home';
     if ($countryCount = $cacheService->get($keyCountryCashe)) {
         $options['countryCount'] = $countryCount;
     } else {
         $bookingDao = $this->getBookingWebDao();
         $countries = $bookingDao->getBookingCountryEmailCount('guest_country_id');
         $options['countryCount'] = $countries ? $countries['count'] : 0;
         $cacheService->set($keyCountryCashe, $options['countryCount']);
     }
     //people count
     $keyPeopleCache = 'people_count_for_home';
     if ($peopleCount = $cacheService->get($keyPeopleCache)) {
         $options['peopleCount'] = $peopleCount;
     } else {
         $bookingDao = $this->getBookingWebDao();
         $peoples = $bookingDao->getBookingCountryEmailCount('guest_email');
         $options['peopleCount'] = $peoples ? $peoples['count'] : 0;
         $cacheService->set($keyPeopleCache, $options['peopleCount']);
     }
     //blog list
     $blogDao = new Blog($this->getServiceLocator(), 'ArrayObject');
     $bloges = $blogDao->getBlogForWebIndex();
     $options['bloges'] = $bloges;
     $router = $this->getServiceLocator()->get('router');
     $url = $router->assemble([], ['name' => 'search']);
     $options['action'] = $url;
     return $options;
 }
Beispiel #2
0
 /**
  * @param array $data
  * @return string
  */
 private function filterReservationData($data)
 {
     $currentDate = date('Y-m-d');
     $cityDao = new City($this->getServiceLocator(), 'ArrayObject');
     if (isset($data['city']) && ClassicValidator::checkCityName($data['city'])) {
         $cityResp = $cityDao->getCityByName(Helper::urlForSearch($data['city']));
         if ($cityResp) {
             /* @var $websiteSearchService \DDD\Service\Website\Search */
             $websiteSearchService = $this->getServiceLocator()->get('service_website_search');
             $diffHours = $websiteSearchService->getDiffHoursForDate();
             $currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours);
         }
     }
     if (!isset($data['city']) || !ClassicValidator::checkCityName($data['city']) || !isset($data['apartment']) || !ClassicValidator::checkApartmentTitle($data['apartment']) || !isset($data['guest']) || !is_numeric($data['guest']) || !isset($data['apartment_id']) || !is_numeric($data['apartment_id']) || !isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival'], 'd M Y') || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure'], 'd M Y') || strtotime($data['arrival']) >= strtotime($data['departure']) || strtotime($currentDate) - strtotime($data['arrival']) > 129600 || !isset($data['rate-for-booking']) || !is_numeric($data['rate-for-booking']) || isset($data['apartel_id']) && !is_numeric($data['apartel_id'])) {
         return false;
     }
     return true;
 }
Beispiel #3
0
 /**
  *
  */
 public function autocompleteSearch($txt)
 {
     $cityDao = new City($this->getServiceLocator(), 'ArrayObject');
     $cities = $cityDao->getCityForSearch($txt);
     $result = [];
     foreach ($cities as $city) {
         $result[] = ['value' => $city['city_url'], 'slug' => Helper::urlForSite($city['city_url']), 'type' => 'city'];
     }
     $apartmentDao = $this->getApartelGeneralDao();
     $apartments = $apartmentDao->getApartmentSearch($txt);
     foreach ($apartments as $apartment) {
         $result[] = ['value' => $apartment['name'], 'slug' => Helper::urlForSite($apartment['url']) . '--' . Helper::urlForSite($apartment['location_slug']), 'type' => 'apartment'];
     }
     return $result;
 }
Beispiel #4
0
 /**
  * @param array $data
  * @return string
  */
 public function filterQueryData($data)
 {
     $currentDate = date('Y-m-d');
     $cityDao = new City($this->getServiceLocator(), 'ArrayObject');
     if (!isset($data['city'])) {
         $pageSlugExp = explode('--', $data['slug']);
         $citySlug = $pageSlugExp[1];
     } else {
         $citySlug = $data['city'];
     }
     if (isset($citySlug) && ClassicValidator::checkCityName($citySlug)) {
         $cityResp = $cityDao->getCityBySlug(Helper::urlForSearch($citySlug, TRUE));
         if ($cityResp) {
             /* @var $websiteSearchService \DDD\Service\Website\Search */
             $websiteSearchService = $this->getServiceLocator()->get('service_website_search');
             $diffHours = $websiteSearchService->getDiffHoursForDate();
             $currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours);
         }
     }
     if (!isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival']) || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure']) || strtotime($data['arrival']) < strtotime($currentDate) || strtotime($data['arrival']) >= strtotime($data['departure'])) {
         return false;
     }
     return true;
 }