/** * (non-PHPdoc) * * @see \Zend\InputFilter\InputFilterAwareInterface::getInputFilter() * */ public function getInputFilter() { if (!$this->inputFilter) { $inputFilter = new InputFilter(); $factory = new InputFactory(); // Transaction Date $inputFilter->add($factory->createInput(array('name' => 'transaction_date', 'required' => true, 'validators' => array(array("name" => "regex", 'options' => array('pattern' => ClassicValidator::getDateRegex(), 'messages' => array(Regex::INVALID => "Date format is invalid.", Regex::NOT_MATCH => "Date format is invalid.", Regex::ERROROUS => "Date format is invalid."))))))); // Currency $inputFilter->add($factory->createInput(array('name' => 'currency', 'required' => true, 'validators' => array(array('name' => 'Digits', 'options' => array('min' => 5, 'max' => 1000, 'messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.'))))))); // Category $inputFilter->add($factory->createInput(array('name' => 'category', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000)))))); // Bank Account $inputFilter->add($factory->createInput(array('name' => 'bank_account', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000)))))); // Supplier $inputFilter->add($factory->createInput(array('name' => 'supplier', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000)))))); // Purpose $inputFilter->add($factory->createInput(array('name' => 'purpose', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 1, 'max' => 3500)))))); // Entered For $inputFilter->add($factory->createInput(array('name' => 'entered_for', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000)))))); // Global Cost $inputFilter->add($factory->createInput(array('name' => 'type', 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000)))))); $mainFilter = new InputFilter(); $mainFilter->add($inputFilter, 'fsOne'); $this->inputFilter = $mainFilter; } return $this->inputFilter; }
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'); } }
/** * @param $title * @return array|\ArrayObject|bool|null */ public function getNewsByArticle($title) { if (!ClassicValidator::checkNewsTitle($title)) { return false; } $dao = $this->getNewsDao(); $news = $dao->getNewsByArticle($title); return $news; }
/** * * @param string $article * @return type */ public function getBlogByArticel($article) { if (!ClassicValidator::checkCityName($article)) { return false; } $dao = $this->getBlogDao(); $blog = $dao->getBlogByArticel($article); return $blog; }
private function getBookingData() { if (!$this->reviewHash || !ClassicValidator::validateAlnum($this->reviewHash)) { return FALSE; } /** * @var \DDD\Service\Website\Review $reviewService */ $reviewService = $this->getServiceLocator()->get('service_website_review'); return $reviewService->getBookingData($this->reviewHash); }
public function applyAction() { /** @var Request $request */ $request = $this->getRequest(); $result = ['status' => 'error', 'msg' => 'Unable to save application. Please try again later.']; try { if ($request->isPost() && $request->isXmlHttpRequest()) { /** @var \DDD\Service\Website\Job $jobService */ $jobService = $this->getServiceLocator()->get('service_website_job'); $form = new JobsForm('announcement-form'); $inputs = $request->getPost()->toArray(); $validateTags = ClassicValidator::checkScriptTags($inputs); if (!$validateTags) { return new JsonModel(['status' => 'error', 'msg' => 'Unable to save application. Please try again later.']); } $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $form->setInputFilter(new JobsFilter()); $form->setData($post); if ($form->isValid()) { $data = $form->getData(); $filesObj = new Files($request->getFiles()->toArray()); $acceptedFileTypes = ['pdf', 'doc', 'docx', 'odt', 'rtf']; $filenames = $filesObj->saveFiles('/ginosi/uploads/hr/applicants/' . date('Y/m/'), $acceptedFileTypes, false, true); if ($filenames['cv']) { $data['cv'] = $filenames['cv']; } else { unset($data['cv']); } $data['date_applied'] = date('Y-m-d H:i:s'); $applicantId = $jobService->saveApplicant($data); if ($applicantId) { /** @var \DDD\Dao\Recruitment\Job\Job $jobDao */ $jobDao = $this->getServiceLocator()->get('dao_recruitment_job_job'); /** @var \DDD\Domain\Recruitment\Job\Job $jobInfo */ $jobInfo = $jobDao->fetchOne(['id' => $data['job_id']]); $hiringManager = $jobInfo->getHiringManagerId(); if ($jobInfo && $jobInfo->getNotifyManager() && $hiringManager && !is_null($hiringManager)) { $notificationService = $this->getServiceLocator()->get('service_notifications'); $sender = NotificationService::$applicants; $message = 'You have a new applicant for ' . $jobInfo->getTitle() . ' position - ' . $data['firstname'] . ' ' . $data['lastname'] . '. Applied on ' . date(Constants::GLOBAL_DATE_FORMAT . ' H:i', strtotime($data['date_applied'])); $url = '/recruitment/applicants/edit/' . $applicantId; $notificationData = ['recipient' => $hiringManager, 'sender' => $sender, 'sender_id' => User::SYSTEM_USER_ID, 'message' => $message, 'url' => $url, 'show_date' => date('Y-m-d')]; $notificationService->createNotification($notificationData); } } $result = ['status' => 'success', 'msg' => 'Application saved']; } } } catch (\Exception $ex) { $this->gr2logException($ex, 'Website: Job application saving process failed'); } return new JsonModel($result); }
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]); }
public static function convertDateFromYMD($date, $secondaryDate = null) { if (empty($date)) { return ''; } if (ClassicValidator::checkDateRegexYMD($date)) { list($year, $month, $day) = explode('-', $date); try { $rightDate = self::convertMonth($month) . ' ' . $day . ', ' . $year; } catch (\Exception $ex) { $rightDate = $secondaryDate; } return $rightDate; } else { throw new \Exception('Invalid date format.'); } }
/** * @param $emailAddress * @return \DDD\Domain\Finance\Customer|null */ public function createCustomer($emailAddress) { /** * @var \DDD\Dao\Finance\Customer $customerDao */ $customerDao = $this->getServiceLocator()->get('dao_finance_customer'); // Set unknown email address if email address is empty or invalid if (is_null($emailAddress) || !ClassicValidator::validateEmailAddress($emailAddress)) { $emailAddress = self::UNKNOWN_EMAIL; } $affectedRows = $customerDao->save(['email' => $emailAddress]); if ($affectedRows) { $lastInsertedId = $customerDao->getLastInsertValue(); $customer = $customerDao->getCustomer($lastInsertedId); $this->createCustomerTransactionAccount($lastInsertedId); return $customer; } else { return null; } }
public function __invoke($options = array()) { $render = array_key_exists('render', $options) ? $options['render'] : true; $searchService = $this->getServiceLocator()->get('service_website_search'); $options = $searchService->getOptions(); $request = $this->getServiceLocator()->get('request'); $getParams = $request->getQuery(); $setParams = []; if (isset($getParams['city']) && ClassicValidator::checkCityName($getParams['city'])) { $setParams['city_url'] = $getParams['city']; $city = Helper::urlForSearch($getParams['city']); // $setParams['city'] = ; if (isset($getParams['guest'])) { $setParams['guest'] = $getParams['guest']; } $date = $searchService->getFixedDate($getParams); $setParams['arrival'] = $date['arrival']; $setParams['departure'] = $date['departure']; } $vm = new ViewModel(['options' => $options, 'setParams' => $setParams]); $vm->setTemplate($this->viewTemplate); return $render ? $this->getView()->render($vm) : $vm; }
/** * 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'); }
/** * @param array $data * @return array */ public function bookingDataByCCPassword($data) { /** * @var \DDD\Service\Website\Apartment $apartmentService * @var \DDD\Service\Booking\Charge $chargeService */ $apartmentService = $this->getServiceLocator()->get('service_website_apartment'); $chargeService = $this->getServiceLocator()->get('service_booking_charge'); if (!isset($data['code']) || !ClassicValidator::checkCCPdateCode($data['code'])) { return false; } /** * @var \DDD\Dao\Booking\Booking $bookingDao */ $bookingDao = $this->getServiceLocator()->get('dao_booking_booking'); $bookingDao->setEntity(new \ArrayObject()); $resData = $bookingDao->getResDataByCCUpdateCode($data['code']); if (!$resData) { return false; } $img = Helper::getImgByWith($resData['img1'], WebSite::IMG_WIDTH_SEARCH, true, true); if ($img) { $resData['image'] = $img; } $resData['user_currency'] = $resData['guest_currency_code']; $bookNightCount = Helper::getDaysFromTwoDate($resData['date_from'], $resData['date_to']); $resData['night_count'] = $bookNightCount; $resData['totalNigthCount'] = $bookNightCount; // Cancelation Policy $cancelationDate = $resData; $cancelationDate['penalty_percent'] = $cancelationDate['penalty_fixed_amount'] = $cancelationDate['penalty_nights'] = $resData['penalty_val']; $cancelationDate['night_count'] = $bookNightCount; $cancelationDate['code'] = $resData['apartment_currency_code']; $cancelationPolicy = $apartmentService->cancelationPolicy($cancelationDate); $resData['cancelation_type'] = $cancelationPolicy['type']; $resData['cancelation_policy'] = $cancelationPolicy['description']; $paymentDetails = $chargeService->getCharges($resData['id']); // When showing to customers we don't really want to show base and additional parts of taxes separately // This part of code runs through payment details and combines same type of taxes for same day into a single unit $floatPattern = '/-?(?:\\d+|\\d*\\.\\d+)/'; $smarterPaymentDetails = []; if ($paymentDetails) { foreach ($paymentDetails as $payment) { if ($payment['type'] != 'tax') { array_push($smarterPaymentDetails, $payment); } else { $paymentKey = $payment['type_id'] . '-' . $payment['date']; if (!isset($smarterPaymentDetails[$paymentKey])) { $smarterPaymentDetails[$paymentKey] = $payment; } else { preg_match($floatPattern, $smarterPaymentDetails[$paymentKey]['label'], $match); $currValue = $match[0]; $currPrice = $smarterPaymentDetails[$paymentKey]['price']; preg_match($floatPattern, $payment['label'], $match); $additionalValue = $match[0]; $additionalPrice = $payment['price']; $smarterPaymentDetails[$paymentKey]['label'] = str_replace($currValue, $currValue + $additionalValue, $smarterPaymentDetails[$paymentKey]['label']); $smarterPaymentDetails[$paymentKey]['price'] = str_replace($currPrice, $currPrice + $additionalPrice, $smarterPaymentDetails[$paymentKey]['price']); $smarterPaymentDetails[$paymentKey]['price_view'] = str_replace($currPrice, $currPrice + $additionalPrice, $smarterPaymentDetails[$paymentKey]['price_view']); } } } } $resData['paymentDetails']['payments'] = $smarterPaymentDetails; return $resData; }
public function ajaxcheckusernameAction() { /** * @var Response $response * @var Request $request */ $request = $this->getRequest(); $response = $this->getResponse(); $response->setStatusCode(200); try { if ($request->isXmlHttpRequest()) { $email = $request->getPost('email'); $userId = (int) $request->getPost('id'); $authUserEditorLevel = $this->getUserEditorLevel($userId); if ($authUserEditorLevel != 2) { $response->setContent("no_permissions"); } /** * @var \DDD\Service\User $userService */ $userService = $this->getServiceLocator()->get('service_user'); if (ClassicValidator::validateEmailAddress($email) && !$userService->checkEmail($email, $userId)) { $response->setContent("true"); } else { $response->setContent("false"); } } } catch (\Exception $e) { $response->setContent("false"); } return $response; }
/** * @param $reservationId * @param $dateFrom * @param $dateTo * @param bool $isGetInfo * @return array */ public function changeReservationDate($reservationId, $dateFrom, $dateTo, $isGetInfo = false) { /** * @var ReservationNightly $reservationNightlyDao * @var \DDD\Service\Reservation\Main $reservationService * @var \DDD\Service\Reservation\RateSelector $rateSelector * @var \DDD\Dao\Apartment\Inventory $inventoryDao * @var \DDD\Dao\Booking\Booking $bookingDao */ $inventoryDao = $this->getServiceLocator()->get('dao_apartment_inventory'); $reservationNightlyDao = $this->getServiceLocator()->get('dao_booking_reservation_nightly'); $reservationService = $this->getServiceLocator()->get('service_reservation_main'); $rateSelector = $this->getServiceLocator()->get('service_reservation_rate_selector'); $bookingDao = $this->getServiceLocator()->get('dao_booking_booking'); $reservationData = $bookingDao->getReservationDataForChangeDate($reservationId); $today = Helper::getCurrenctDateByTimezone($reservationData['timezone']); $bookingDao->setEntity(new \ArrayObject()); // Data check if (!$reservationData || !$dateFrom || !ClassicValidator::validateDate($dateFrom, 'Y-m-d') || !$dateTo || !ClassicValidator::validateDate($dateTo, 'Y-m-d') || strtotime($dateFrom) >= strtotime($dateTo)) { return ['status' => 'error', 'msg' => TextConstants::MODIFICATION_BAD_DATA_FOR_CHANGE]; } $error = ''; if ($reservationData['date_from'] != $dateFrom && strtotime($today) > strtotime($dateFrom)) { $error .= TextConstants::MODIFICATION_DATE_NOT_PAST; } if ($reservationData['status'] != BookingService::BOOKING_STATUS_BOOKED) { $error .= TextConstants::MODIFICATION_STATUS_BOOKED; } if ($reservationData['date_from'] == $dateFrom && $reservationData['date_to'] == $dateTo) { $error .= TextConstants::MODIFICATION_NO_INDICATED; } if (strtotime($today) > strtotime($dateTo)) { $error .= TextConstants::MODIFICATION_DATE_SHOULD_FUTURE; } if ($error) { return ['status' => 'error', 'msg' => $error]; } // check is apartel $apartel = $reservationData['apartel_id'] && $reservationData['channel_res_id'] > 0 ? $reservationData['apartel_id'] : false; // New Date generation $resNightlyData = $reservationNightlyDao->fetchAll(['reservation_id' => $reservationId, 'status' => ReservationMainService::STATUS_BOOKED], [], 'date ASC'); $existingNightlyData = $startRateApartment = $lastRateApartment = $existingDate = $newNightlyData = []; $existingNightCount = $resNightlyData->count(); if (!$existingNightCount) { return ['status' => 'error', 'msg' => TextConstants::MODIFICATION_BAD_DATA_FOR_CHANGE]; } foreach ($resNightlyData as $key => $night) { $existingNightlyData[$night['date']] = $night; } // existing date array $existingDate = array_keys($existingNightlyData); $startRateApartment = $existingNightlyData[current($existingDate)]; $lastRateApartment = $existingNightlyData[end($existingDate)]; $dateFromTime = strtotime($dateFrom); $dateToTime = strtotime($dateTo); while ($dateFromTime < $dateToTime) { $date = date('Y-m-d', $dateFromTime); if (in_array($date, $existingDate)) { // existing date $newFromData = $existingNightlyData[$date]; } else { if (strtotime($date) < strtotime($reservationData['date_from'])) { // get rate data from start date $newFromData = $startRateApartment; $rateIdForChangeDate = $startRateApartment['rate_id']; } else { // get rate data from last date $rateIdForChangeDate = $lastRateApartment['rate_id']; $newFromData = $lastRateApartment; } if ($apartel) { /** * @var \DDD\Dao\Apartel\Rate $apartelRateDao * @var \DDD\Dao\Apartel\Inventory $apartelInventoryDao */ $apartelRateDao = $this->getServiceLocator()->get('dao_apartel_rate'); $apartelInventoryDao = $this->getServiceLocator()->get('dao_apartel_inventory'); // rate exist and active if not use fuzzy logic if (!$apartelRateDao->checkRateExistAndActive($rateIdForChangeDate)) { $newFromData = $rateSelector->getSelectorRate($reservationId, $date, $isGetInfo, $apartel); $rateIdForChangeDate = $newFromData['rate_id']; } // check apartment availability if (!$inventoryDao->checkApartmentAvailabilityApartmentDateList($newFromData['apartment_id'], [$date])) { return ['status' => 'error', 'msg' => TextConstants::ERROR_NO_AVAILABILITY]; } // check apartel availability and get price $priceApartel = $apartelInventoryDao->getPriceByRateIdDate($rateIdForChangeDate, $date); $newPrice = $priceApartel['price']; } else { /** @var \DDD\Dao\Apartment\Rate $rateDao */ $rateDao = $this->getServiceLocator()->get('dao_apartment_rate'); // rate exist and active if not use fuzzy logic if (!$rateDao->checkRateExistAndActive($rateIdForChangeDate)) { $newFromData = $rateSelector->getSelectorRate($reservationId, $date, $isGetInfo); $rateIdForChangeDate = $newFromData['rate_id']; } $changeDatePrice = $inventoryDao->fetchOne(['rate_id' => $rateIdForChangeDate, 'date' => $date, 'availability' => 1], ['price']); if (!$changeDatePrice) { return ['status' => 'error', 'msg' => TextConstants::ERROR_NO_AVAILABILITY]; } $newPrice = $changeDatePrice->getPrice(); } $newFromData['price'] = $newPrice; } $newNightlyData[$date] = ['apartment_id' => $newFromData['apartment_id'], 'room_id' => $newFromData['room_id'], 'rate_id' => $newFromData['rate_id'], 'rate_name' => $newFromData['rate_name'], 'price' => $newFromData['price'], 'date' => $date, 'capacity' => $newFromData['capacity']]; $dateFromTime = strtotime('+1 day', $dateFromTime); } if (empty($newNightlyData)) { return ['status' => 'error', 'msg' => 'Bad Data for change Date']; } $changeDateProcess = $reservationService->changeDateForModification($newNightlyData, $reservationId, $isGetInfo, $apartel); // for view if ($isGetInfo && $changeDateProcess['status'] == 'success') { $addonDao = $this->getServiceLocator()->get('dao_booking_addons'); $forViewInfo = []; $type = 'Other'; foreach ($changeDateProcess['data'] as $date => $chargeType) { foreach ($chargeType['data'] as $row) { if (isset($row['view_charge_name'])) { $type = $row['view_charge_name']; } elseif (isset($row['addons_type'])) { $addonName = $addonDao->fetchOne(['id' => $row['addons_type']], ['name']); if ($addonName) { $type = $addonName->getName(); } } $forViewInfo[] = ['date' => $date, 'rate_name' => isset($row['rate_name']) ? $row['rate_name'] : '', 'price' => $chargeType['type'] == 'insert' ? $row['acc_amount'] : -1 * $row['acc_amount'], 'type' => $type]; } } return ['status' => 'success', 'data' => $forViewInfo]; } return $changeDateProcess; }
/** * @return ViewModel */ public function indexAction() { /** * @var \DDD\Service\Textline $textlineService * @var \DDD\Service\Lock\General $lockService */ $textlineService = $this->getServiceLocator()->get('service_textline'); $lockService = $this->getServiceLocator()->get('service_lock_general'); $keyCode = $this->params()->fromQuery('code'); $view = $this->params()->fromQuery('view'); $godMode = $this->params()->fromQuery('bo', false) ?: false; if ($keyCode === null || !ClassicValidator::validateAlnum($keyCode)) { return $this->redirect()->toRoute('home')->setStatusCode('301'); } /** * if have not key code in query... * OR not finded thicket... * OR "arrival date" NOT MORE than "5" * OR "depart date" NOT LESS than "-3" * redirect() -> Home */ $bookingData = $this->getBookingData($keyCode); if (!$bookingData || !Helper::checkDatesByDaysCount(1, $bookingData->getDateTo())) { return $this->redirect()->toRoute('home')->setStatusCode('301'); } $session = new SessionContainer('visitor'); $parkingTextline = ''; if ($bookingData->hasParking()) { $parkingTextline = $textlineService->getUniversalTextline($bookingData->getParkingTextlineId()); } /** * @var \DDD\Service\Website\Textline $textlineService */ $textlineService = $this->getServiceLocator()->get('service_website_textline'); $keyDirectEntryTextline = Helper::evaluateTextline($textlineService->getApartmentDirectKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]); $keyReceptionEntryTextline = Helper::evaluateTextline($textlineService->getApartmentReceptionKeyInstructionTextline($bookingData->getApartmentId()), ['{{PARKING_TEXTLINE}}' => $parkingTextline]); /* @var $customerService \DDD\Service\Customer */ $customerService = $this->getServiceLocator()->get('service_customer'); /** * If NOT HAVE flag from BO (view=0)... * Specify that looked & save the date view */ if ($view !== '0' && $bookingData->isKiViewed() !== '1' && !$customerService->isBot($session)) { /** * @var \DDD\Service\Website\Booking $bookingService */ $bookingService = $this->getServiceLocator()->get('service_website_booking'); $bookingService->updateData($bookingData->getId(), ['ki_viewed' => '1', 'ki_viewed_date' => date('Y-m-d H:i:s')]); } $lockDatas = $lockService->getLockByReservationApartmentId($bookingData->getApartmentIdAssigned(), $bookingData->getPin(), [LockService::USAGE_APARTMENT_TYPE, LockService::USAGE_BUILDING_TYPE, LockService::USAGE_PARKING_TYPE], true); foreach ($lockDatas as $key => $lockData) { switch ($key) { case LockService::USAGE_APARTMENT_TYPE: $bookingData->setPin($lockData['code']); break; case LockService::USAGE_BUILDING_TYPE: $bookingData->setOutsideDoorCode($lockData['code']); break; case LockService::USAGE_PARKING_TYPE: // TODO: to be or not to be, this is the question. break; } } // get Office Address $officeAddress = false; if ($bookingData->getKiPageType() == Building::KI_PAGE_TYPE_RECEPTION) { /** * @var \DDD\Service\Office $officeService */ $officeService = $this->getServiceLocator()->get('service_office'); $officeManagement = $officeService->getData($bookingData->getOfficeId()); /** * @var \DDD\Domain\Office\OfficeManager $officeData */ $officeData = $officeManagement['office']; $officeAddress = $officeData->getAddress(); } if ($view !== '0') { $this->checkCustomerIdentityData($bookingData); } $this->layout()->setTemplate('layout/layout-ki'); $this->layout()->userTrackingInfo = ['res_number' => $bookingData->getResNumber(), 'partner_id' => $bookingData->getPartnerId()]; $this->layout()->godMode = $godMode === substr(md5($keyCode), 12, 5); $this->layout()->keyData = $bookingData; $this->layout()->keyCode = $keyCode; $this->layout()->directEntryTextline = $keyDirectEntryTextline; $this->layout()->receptionEntryTextline = $keyReceptionEntryTextline; return new ViewModel(['keyData' => $bookingData, 'keyCode' => $keyCode, 'directEntryTextline' => $keyDirectEntryTextline, 'receptionEntryTextline' => $keyReceptionEntryTextline, 'godMode' => $godMode === substr(md5($keyCode), 12, 5), 'isGuest' => $view !== '0', 'officeAddress' => $officeAddress]); }
public function ajaxAutocompleteSearchAction() { /** * @var Request $request */ $request = $this->getRequest(); $result = ['status' => 'success', 'result' => []]; try { if ($request->isXmlHttpRequest()) { $txt = $request->getPost('txt'); if (!ClassicValidator::validateAutocomplateSearch($txt)) { return new JsonModel($result); } $searchService = $this->getSearchService(); $searchRespons = $searchService->autocompleteSearch($txt); $result['result'] = $searchRespons; } } catch (\Exception $e) { $result['status'] = 'error'; $result['result'] = []; } return new JsonModel($result); }
/** * @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; }
/** * * @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; }
/** * @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]; }
public function ajaxSaveEmailAction() { /** * @var Request $request * @var \DDD\Service\Frontier $frontierService */ $request = $this->getRequest(); $result = ['status' => 'error', 'msg' => TextConstants::ERROR]; try { if ($request->isXmlHttpRequest()) { $email = $request->getPost('email'); $reservationId = (int) $request->getPost('res_id'); if ($reservationId && ClassicValidator::validateEmailAddress($email)) { $bookingDao = $this->getServiceLocator()->get('dao_booking_booking'); $bookingDao->save(['guest_email' => $email], ['id' => $reservationId]); $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_ADD_EMAIL]; } } } catch (\Exception $e) { } return new JsonModel($result); }
/** * @param int $cityId * @param string $poiSlug * @return boolean */ public function getPoiData($cityId, $poiSlug) { if (!$poiSlug || !ClassicValidator::checkCityName($poiSlug)) { return false; } /* @var $poiDao \DDD\Dao\Geolocation\Poi */ $poiDao = $this->getPoiDao(); $poi = $poiDao->getPoiDataBySlug($cityId, Helper::urlForSearch($poiSlug, TRUE)); if ($poi) { $poi['img'] = Helper::getImgByWith('/locations/' . $poi['detail_id'] . '/' . $poi['cover_image'], WebSite::IMG_WIDTH_LOCATION_BIG); } return $poi; }