diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 392b83542..f2e2a698c 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1414,7 +1414,7 @@ class AdminImportControllerCore extends AdminController $objHotelOrderRestrictDate->use_global_min_booking_offset = true; if (isset($info['max_booking_offset']) - && (Configuration::get('GLOBAL_MIN_BOOKING_OFFSET') < $info['max_booking_offset'] + && (Configuration::get('PS_MIN_BOOKING_OFFSET') < $info['max_booking_offset'] || isset($info['min_booking_offset']) && $info['min_booking_offset'] < $info['max_booking_offset']) ) { $objHotelOrderRestrictDate->use_global_max_booking_offset = false; @@ -1422,7 +1422,7 @@ class AdminImportControllerCore extends AdminController } if (isset($info['min_booking_offset']) - && (Configuration::get('GLOBAL_MAX_BOOKING_OFFSET') > $info['min_booking_offset'] + && (Configuration::get('PS_MAX_BOOKING_OFFSET') > $info['min_booking_offset'] || isset($info['max_booking_offset']) && $info['max_booking_offset'] > $info['min_booking_offset']) ) { $objHotelOrderRestrictDate->use_global_min_booking_offset = false; diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index 23c9e2996..4fcf356da 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -87,14 +87,14 @@ class AdminOrderPreferencesControllerCore extends AdminController 'title' => $this->l('Order Restrict'), 'icon' => 'icon-cogs', 'fields' => array( - 'GLOBAL_MAX_BOOKING_OFFSET' => array( + 'PS_MAX_BOOKING_OFFSET' => array( 'title' => $this->l('Maximum booking offset'), 'hint' => $this->l('The maximum booking offset defines the number of days from today till which bookings can be made. It is used to limiting how far in advance reservations are allowed to the guest.'), 'type' => 'text', 'class' => 'fixed-width-xl', 'suffix' => $this->l('day(s)'), ), - 'GLOBAL_MIN_BOOKING_OFFSET' => array( + 'PS_MIN_BOOKING_OFFSET' => array( 'title' => $this->l('Minimum booking offset'), 'hint' => $this->l('The minimum booking offset is the minimum number of days before the check-in date that a guest must book a room. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'), 'desc' => $this->l('Set to 0 to disable this feature.'), @@ -329,8 +329,8 @@ class AdminOrderPreferencesControllerCore extends AdminController $this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.'); } - $maxBookingOffset = Tools::getValue('GLOBAL_MAX_BOOKING_OFFSET'); - $minBookingOffset = Tools::getValue('GLOBAL_MIN_BOOKING_OFFSET'); + $maxBookingOffset = Tools::getValue('PS_MAX_BOOKING_OFFSET'); + $minBookingOffset = Tools::getValue('PS_MIN_BOOKING_OFFSET'); if ($maxBookingOffset === '') { $this->errors[] = Tools::displayError('Field \'Maximum booking offset\' can not be empty.'); } elseif (!$maxBookingOffset || !Validate::isUnsignedInt($maxBookingOffset)) { diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index e35124b33..2d72cf848 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -156,7 +156,7 @@ class CategoryControllerCore extends FrontController $currency = new Currency($this->context->currency->id); if ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($id_category)) { - $minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($id_hotel); + $minBookingOffset = (int) HotelOrderRestrictDate::getMinimumBookingOffset($id_hotel); if ($minBookingOffset && strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($date_from) ) { diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a5ca5fe85..09f95daa5 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -334,7 +334,7 @@ class ProductControllerCore extends FrontController $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); - $minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($hotel_id); + $minBookingOffset = (int) HotelOrderRestrictDate::getMinimumBookingOffset($hotel_id); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); } diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index d8e24647e..35ac2b563 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -1131,12 +1131,12 @@ class HotelBranchInformation extends ObjectModel $message = Tools::displayError('Maximum booking cannot be less than or equal to Minimum booking offset.'); } else if (!$this->use_global_max_booking_offset && $this->use_global_min_booking_offset - && $this->max_booking_offset <= Configuration::get('GLOBAL_MIN_BOOKING_OFFSET') + && $this->max_booking_offset <= Configuration::get('PS_MIN_BOOKING_OFFSET') ) { $message = Tools::displayError('Maximum booking cannot be less than or equal to Global Minimum booking offset.'); } else if ($this->use_global_max_booking_offset && !$this->use_global_min_booking_offset - && $this->min_booking_offset >= Configuration::get('GLOBAL_MAX_BOOKING_OFFSET') + && $this->min_booking_offset >= Configuration::get('PS_MAX_BOOKING_OFFSET') ) { $message = Tools::displayError('Minimum booking offset cannot be be greater than or equal to Global Maximum booking offset.'); } elseif (!Validate::isLoadedObject($objCountry = new Country($this->id_country))) { diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 888775d1f..5641363bd 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1029,7 +1029,7 @@ class HotelCartBookingData extends ObjectModel } } - $minBookingOffset = HotelOrderRestrictDate::getMinBookingOffset($roomData['id_hotel']); + $minBookingOffset = HotelOrderRestrictDate::getMinimumBookingOffset($roomData['id_hotel']); if ($minBookingOffset !== false) { $minOrderDate = date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days')); if (strtotime($minOrderDate) > strtotime($roomData['date_from'])) { diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index d2bb1dc02..1dd4a74ed 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1063,8 +1063,8 @@ class HotelHelper Configuration::updateValue('WK_GLOBAL_CHILD_MAX_AGE', 15); Configuration::updateValue('WK_GLOBAL_MAX_CHILD_IN_ROOM', 0); - Configuration::updateValue('GLOBAL_MAX_BOOKING_OFFSET', 1000); - Configuration::updateValue('GLOBAL_MIN_BOOKING_OFFSET', 0); + Configuration::updateValue('PS_MAX_BOOKING_OFFSET', 365); + Configuration::updateValue('PS_MIN_BOOKING_OFFSET', 0); Configuration::updateValue('HTL_FEATURE_PRICING_PRIORITY', 'specific_date;special_day;date_range'); Configuration::updateValue('WK_GOOGLE_ACTIVE_MAP', 0); @@ -2510,7 +2510,7 @@ class HotelHelper public static function validateDateRangeForHotel($dateFrom, $dateTo, $idHotel) { $validStartDateTimeStamp = strtotime(date('Y-m-d')); - if ($minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel)) { + if ($minBookingOffset = (int) HotelOrderRestrictDate::getMinimumBookingOffset($idHotel)) { $validStartDateTimeStamp = strtotime('+ '.$minBookingOffset.' day', $validStartDateTimeStamp); } diff --git a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php index cc1d8b0d7..0aed9c994 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRestrictDate.php @@ -43,6 +43,10 @@ class HotelOrderRestrictDate extends ObjectModel ), ); + /** + * @param int $id_hotel + * @return array hote wise restriction. + */ public static function getDataByHotelId($idHotel) { return Db::getInstance()->getRow( @@ -50,57 +54,49 @@ class HotelOrderRestrictDate extends ObjectModel ); } - /*Max date of ordering for order restrict*/ + /** + * @param int $id_hotel + * @return string Max date of ordering for order restrict + */ public static function getMaxOrderDate($idHotel) { $result = self::getDataByHotelId($idHotel); if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) { - return date('Y-m-d H:i:s', strtotime('+ '.$result['max_booking_offset'].' days')); + return date('Y-m-d H:i:s', strtotime('+ '.($result['max_booking_offset'] + 1).' days')); } - if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { - return date('Y-m-d H:i:s', strtotime('+ '.$globalBookingDate.' days')); - } + // since this cannot be zero, this function will always return a date. + $globalBookingDate = (int) Configuration::get('PS_MAX_BOOKING_OFFSET'); - return 0; + return date('Y-m-d H:i:s', strtotime('+ '.($globalBookingDate + 1).' days')); } /** * @param int $id_hotel - * @return int|false + * @return int Maximum allowable number of days between booking date and check-in date. */ - public static function getMaxBookingOffset($idHotel) + public static function getMaximumBookingOffset($idHotel) { $result = self::getDataByHotelId($idHotel); if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) { return $result['max_booking_offset']; } - if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { - return $globalBookingDate; - } - - return 0; + return (int) Configuration::get('PS_MAX_BOOKING_OFFSET'); } - /** * @param int $id_hotel - * @return int|false + * @return int Minimum number of days required between booking and check-in. */ - public static function getMinBookingOffset($idHotel) + public static function getMinimumBookingOffset($idHotel) { $result = self::getDataByHotelId($idHotel); if (is_array($result) && count($result) && !$result['use_global_min_booking_offset']) { return (int) $result['min_booking_offset']; } - $globalPreparationTime = Configuration::get('GLOBAL_MIN_BOOKING_OFFSET'); - if ($globalPreparationTime != '0') { - return (int) $globalPreparationTime; - } - - return false; + return (int) Configuration::get('PS_MIN_BOOKING_OFFSET'); } public static function validateOrderRestrictDateOnPayment(&$controller) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index e153443eb..381464a65 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -212,8 +212,8 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['state_var'] = $stateOptions; $smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP'); $smartyVars['ps_img_dir'] = _PS_IMG_.'l/'; - $smartyVars['GLOBAL_MAX_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET'); - $smartyVars['GLOBAL_MIN_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MIN_BOOKING_OFFSET'); + $smartyVars['PS_MAX_BOOKING_OFFSET'] = (int) Configuration::get('PS_MAX_BOOKING_OFFSET'); + $smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET'); $smartyVars['WK_ORDER_REFUND_ALLOWED'] = Configuration::get('WK_ORDER_REFUND_ALLOWED'); $this->context->smarty->assign($smartyVars); @@ -450,9 +450,9 @@ class AdminAddHotelController extends ModuleAdminController $this->errors[] = $this->l('Field Maximum booking offset cannot be be less than or equal to Minimum booking offset.'); } } else { - if (!$enableUseGlobalMaxBookingOffset && $maxBookingOffset <= Configuration::get('GLOBAL_MIN_BOOKING_OFFSET')) { + if (!$enableUseGlobalMaxBookingOffset && $maxBookingOffset <= Configuration::get('PS_MIN_BOOKING_OFFSET')) { $this->errors[] = $this->l('Field Maximum booking offset cannot be be less than or equal to global Minimum booking offset.'); - } else if (!$enableUseGlobalMinBookingOffset && $minBookingOffset >= Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) { + } else if (!$enableUseGlobalMinBookingOffset && $minBookingOffset >= Configuration::get('PS_MAX_BOOKING_OFFSET')) { $this->errors[] = $this->l('Field Minimum booking offset cannot be be greater than or equal to Global Maximum booking offset.'); } } @@ -771,7 +771,7 @@ class AdminAddHotelController extends ModuleAdminController $conf = 3; if ($idHotel) { - $con = 4; + $conf = 4; } if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) { diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index e0b37ff23..937cada04 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -437,7 +437,7 @@ -