예제 #1
0
 public function indexAction()
 {
     try {
         if (!($pageSlug = $this->params()->fromRoute('apartel-route')) || !ClassicValidator::checkApartmentTitle($pageSlug)) {
             $viewModel = new ViewModel();
             $this->getResponse()->setStatusCode(404);
             return $viewModel->setTemplate('error/404');
         }
         $showReviews = $this->params()->fromQuery('reviews', '');
         /**
          * @var \DDD\Service\Website\Apartel $apartelService
          */
         $apartelService = $this->getServiceLocator()->get('service_website_apartel');
         $apartelData = $apartelService->getApartel($pageSlug);
         if (!$apartelData) {
             $this->getResponse()->setStatusCode(404);
             $viewModel = new ViewModel();
             return $viewModel->setTemplate('error/404');
         }
         return ['data' => $apartelData['data'], 'options' => $apartelData['options'], 'reviews' => $apartelData['reviews']['result'], 'reviewCount' => $apartelData['reviews']['total'], 'roomTypes' => $apartelData['roomTypes'], 'reviewsScore' => $apartelData['reviewsScore'], 'showReviews' => $showReviews];
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Website: Apartel Page Failed');
         return $this->redirect()->toRoute('home');
     }
 }
예제 #2
0
 public function indexAction()
 {
     /**
      * @var Apartment $apartmentService
      */
     try {
         if (!($pageSlug = $this->params()->fromRoute('apartmentTitle')) || !ClassicValidator::checkApartmentTitle($pageSlug)) {
             $viewModel = new ViewModel();
             $this->getResponse()->setStatusCode(404);
             return $viewModel->setTemplate('error/404');
         }
         /* @var $apartmentService \DDD\Service\Website\Apartment */
         $apartmentService = $this->getApartmentService();
         $apartment = $apartmentService->getApartment($pageSlug);
         if (!$apartment) {
             $this->getResponse()->setStatusCode(404);
             $viewModel = new ViewModel();
             return $viewModel->setTemplate('error/404');
         }
         $request = $this->getRequest();
         $data = $request->getQuery();
         $data['slug'] = $pageSlug;
         $filtreData = $apartmentService->filterQueryData($data);
         $reviewCount = false;
         if ($filtreData) {
             $apartment['otherParams']['arrival'] = Helper::dateForSearch($data['arrival']);
             $apartment['otherParams']['departure'] = Helper::dateForSearch($data['departure']);
         }
         if (isset($apartment['general']['aprtment_id'])) {
             $reviewCount = $apartmentService->apartmentReviewCount($apartment['general']['aprtment_id']);
         }
         $show_reviews = false;
         $reviews = [];
         $apartment['otherParams']['guest'] = (int) $data['guest'];
         if (isset($data['show']) && $data['show'] == 'reviews' && isset($apartment['general']['aprtment_id']) && $apartment['general']['aprtment_id'] > 0) {
             $show_reviews = true;
             $reviewsResult = $apartmentService->apartmentReviewList(['apartment_id' => $apartment['general']['aprtment_id']], true);
             if ($reviewsResult && $reviewsResult['result']->count() > 0) {
                 $reviews = $reviewsResult['result'];
             }
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Website: Apartment Page Failed');
         return $this->redirect()->toRoute('home');
     }
     $this->layout()->setVariable('view_currency', 'yes');
     return new ViewModel(['general' => $apartment['general'], 'amenities' => $apartment['amenities'], 'facilities' => $apartment['facilities'], 'otherParams' => $apartment['otherParams'], 'secure_url_booking' => 'https://' . DomainConstants::WS_SECURE_DOMAIN_NAME . '/booking', 'show_reviews' => $show_reviews, 'reviews' => $reviews, 'reviewCount' => $reviewCount, 'sl' => $this->getServiceLocator(), 'apartelId' => (int) $data['apartel_id'] > 0 ? (int) $data['apartel_id'] : 0]);
 }
예제 #3
0
파일: BookingTest.php 프로젝트: arbi/MyCode
 /**
  * Test filter reservation data action
  */
 public function testFilterReservationData()
 {
     // check services and dao`s
     $websiteSearchService = $this->getApplicationServiceLocator()->get('service_website_search');
     $this->assertInstanceOf('\\DDD\\Service\\Website\\Search', $websiteSearchService);
     $cityDao = new City($this->getApplicationServiceLocator(), 'ArrayObject');
     $this->assertInstanceOf('\\DDD\\Dao\\Location\\City', $cityDao);
     $cityName = 'Yerevan';
     $apartmentTitle = 'hollywood-al-pacino';
     $cityResponse = $cityDao->getCityByName($cityName);
     $this->assertTrue(ClassicValidator::checkCityName($cityName), "City Name Validator haven't correct regex");
     $this->assertTrue(ClassicValidator::checkApartmentTitle($apartmentTitle), "Apartment Name Validator haven't correct regex");
     $this->assertArrayHasKey('timezone', $cityResponse);
     // check current date
     $diffHours = 0;
     $boDiffHours = -24;
     $currentDate = Helper::getCurrenctDateByTimezone($cityResponse['timezone'], 'd-m-Y', $diffHours);
     $currentDateForBo = Helper::getCurrenctDateByTimezone($cityResponse['timezone'], 'd-m-Y', $boDiffHours);
     $dateCurrent = new \DateTime("now");
     $dateBoCurrent = new \DateTime("yesterday");
     $this->assertEquals($currentDate, $dateCurrent->format('d-m-Y'), 'Guest timezone logic is not correct');
     $this->assertEquals($currentDateForBo, $dateBoCurrent->format('d-m-Y'), 'Bo User timezone logic is not correct');
 }
예제 #4
0
파일: Booking.php 프로젝트: arbi/MyCode
 /**
  * @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;
 }
예제 #5
0
파일: Search.php 프로젝트: arbi/MyCode
 /**
  *
  * @param array $data
  * @return string
  */
 public function filterSearchData($data)
 {
     $error = '';
     //city
     if (isset($data['city']) && !ClassicValidator::checkCityName($data['city'])) {
         $error .= $this->getTextLineSite(1220);
     }
     if (isset($data['apartel']) && !ClassicValidator::checkApartmentTitle($data['apartel'])) {
         $error .= $this->getTextLineSite(1220);
     }
     return $error;
 }
예제 #6
0
파일: Apartment.php 프로젝트: arbi/MyCode
 /**
  * @param array $data
  * @return string
  */
 private function filterSearchData($data)
 {
     if (!isset($data['city']) || !ClassicValidator::checkCityName($data['city']) || !isset($data['apartment']) || !ClassicValidator::checkApartmentTitle($data['apartment']) || !isset($data['guest']) || !is_numeric($data['guest']) || !$this->filterQueryData($data)) {
         return false;
     }
     return true;
 }
예제 #7
0
파일: Apartel.php 프로젝트: arbi/MyCode
 /**
  * @param $pageSlug
  * @return array|bool
  */
 public function getApartel($pageSlug)
 {
     // explode slug and get apartel name city name
     $pageSlug = explode('--', $pageSlug);
     if (!isset($pageSlug[1]) || !ClassicValidator::checkApartmentTitle($pageSlug[0]) || !ClassicValidator::checkApartmentTitle($pageSlug[1])) {
         return false;
     }
     /**
      * @var $apartelDao \DDD\Dao\Apartel\General
      * @var $serviceLocation \DDD\Service\Website\Location
      * @var $relApartelDao \DDD\Dao\Apartel\RelTypeApartment
      * @var $apartelTypeDao \DDD\Dao\Apartel\Type
      * @var $apartmentService \DDD\Service\Website\Apartment
      */
     $apartelDao = $this->getServiceLocator()->get('dao_apartel_general');
     $serviceLocation = $this->getServiceLocator()->get('service_website_location');
     $apartelTypeDao = $this->getServiceLocator()->get('dao_apartel_type');
     $apartmentService = $this->getServiceLocator()->get('service_website_apartment');
     $router = $this->getServiceLocator()->get('router');
     $apartelSlug = $pageSlug[0];
     $apartelData = $apartelDao->getApartelDataForWebsite($apartelSlug);
     if (!$apartelData) {
         return false;
     }
     $data = [];
     $apartel = $pageSlug[0];
     $city = $pageSlug[1];
     $apartelId = $apartelData['id'];
     $data = $apartelData;
     $data['apartel'] = $apartel;
     $data['city'] = $city;
     $data['img'] = Helper::getImgByWith('/' . DirectoryStructure::FS_IMAGES_APARTEL_BG_IMAGE . $apartelId . '/' . $apartelData['bg_image']);
     $data['apartel_slug'] = $apartelSlug;
     // get options for search
     $dataOption['city_data']['timezone'] = $apartelData['timezone'];
     $options = $serviceLocation->getOptions($dataOption);
     // get review list
     $relApartelDao = $this->getServiceLocator()->get('dao_apartel_rel_type_apartment');
     $reviews = $relApartelDao->getReviewForWebsite($apartelId);
     // review score
     $reviewsScore = $relApartelDao->getReviewAVGScoreForYear($apartelId);
     //change currency
     $userCurrency = $this->getCurrencySite();
     // get room type data
     $roomTypeData = $apartelTypeDao->getRoomTypeForWebsite($apartelId);
     $roomTypes = [];
     foreach ($roomTypeData as $roomtype) {
         if ($userCurrency != $roomtype['code']) {
             $currencyResult = $apartmentService->currencyConvert($roomtype['price'], $userCurrency, $roomtype['code']);
             $roomtype['price'] = $currencyResult[0];
             $roomtype['symbol'] = $currencyResult[1];
         }
         if (strpos(strtolower($roomtype['name']), 'studio') !== false) {
             $roomtype['img'] = 'studio_one_bedroom.png';
             $roomtype['search_name'] = 'studio';
             $roomtype['code'] = $userCurrency;
             $roomtypeName = 'studio';
             $roomTypes[0] = $roomtype;
         } elseif (strpos(strtolower($roomtype['name']), 'one') !== false) {
             $roomtype['img'] = 'studio_one_bedroom.png';
             $roomtype['search_name'] = 'onebedroom';
             $roomtype['code'] = $userCurrency;
             $roomtypeName = 'onebedroom';
             $roomTypes[1] = $roomtype;
         } else {
             $roomtype['img'] = 'two_bedroom.png';
             $roomtype['search_name'] = 'twobedroom';
             $roomtype['code'] = $userCurrency;
             $roomtypeName = 'twobedroom';
             $roomTypes[2] = $roomtype;
         }
         $roomtype['search_url'] = "/search?apartel={$apartel}&guest=2&{$roomtypeName}=1";
     }
     ksort($roomTypes);
     return ['data' => $data, 'options' => $options, 'reviews' => $reviews, 'reviewsScore' => $reviewsScore, 'roomTypes' => $roomTypes];
 }