Updated: Changed the max order date with maximum booking offset

This commit is contained in:
vishalsingh.qlo325
2025-01-23 11:17:07 +05:30
parent 950b37ed1c
commit b2f13339ac
22 changed files with 231 additions and 246 deletions

View File

@@ -148,8 +148,8 @@ class AdminImportControllerCore extends AdminController
'policies' => array('label' => $this->l('Hotel Policies')),
'active_refund' => array('label' => $this->l('Allow Refund (0 = No, 1 = Yes)')),
'refund_ids' => array('label' => $this->l('Refund IDs (x,y,z...)')),
'max_order_date' => array('label' => $this->l('Max Order Date')),
'preparation_time' => array('label' => $this->l('Prepration Time')),
'max_booking_offset' => array('label' => $this->l('Max booking offset')),
'min_booking_offset' => array('label' => $this->l('Min booking offset')),
'image' => array('label' => $this->l('Image URLs (x,y,z...)')),
'delete_existing_images' => array(
'label' => $this->l('Delete existing images (0 = No, 1 = Yes)')
@@ -1410,19 +1410,19 @@ class AdminImportControllerCore extends AdminController
}
$objHotelOrderRestrictDate->id_hotel = $objHotelBranch->id;
$objHotelOrderRestrictDate->use_global_max_order_date = true;
if (isset($info['max_order_date'])
&& strtotime('now') < strtotime($info['max_order_date'])
$objHotelOrderRestrictDate->use_global_max_booking_offset = true;
if (isset($info['max_booking_offset'])
&& strtotime('now') < strtotime($info['max_booking_offset'])
) {
$objHotelOrderRestrictDate->use_global_max_order_date = false;
$date = date('Y-m-d', strtotime($info['max_order_date']));
$objHotelOrderRestrictDate->max_order_date = $date;
$objHotelOrderRestrictDate->use_global_max_booking_offset = false;
$date = date('Y-m-d', strtotime($info['max_booking_offset']));
$objHotelOrderRestrictDate->max_booking_offset = $date;
}
$objHotelOrderRestrictDate->use_global_preparation_time = true;
if (isset($info['preparation_time']) && $info['preparation_time']) {
$objHotelOrderRestrictDate->use_global_preparation_time = false;
$objHotelOrderRestrictDate->preparation_time = $info['preparation_time'];
$objHotelOrderRestrictDate->use_global_min_booking_offset = true;
if (isset($info['min_booking_offset']) && $info['min_booking_offset']) {
$objHotelOrderRestrictDate->use_global_min_booking_offset = false;
$objHotelOrderRestrictDate->min_booking_offset = $info['min_booking_offset'];
}
$objHotelOrderRestrictDate->save();

View File

@@ -82,22 +82,19 @@ class AdminOrderPreferencesControllerCore extends AdminController
)
);
$maxOrderDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE', Configuration::get('MAX_GLOBAL_BOOKING_DATE'));
$this->fields_options = array(
'order_restrict' => array(
'title' => $this->l('Order Restrict'),
'icon' => 'icon-cogs',
'fields' => array(
'MAX_GLOBAL_BOOKING_DATE' => array(
'title' => $this->l('Maximum Global Check-out Date to book a room'),
'hint' => $this->l('Maximum date of check-out for which rooms of your hotels can be booked.'),
'GLOBAL_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',
'id' => 'max_global_book_date',
'auto_value' => false,
'value' => date('d-m-Y', strtotime($maxOrderDate)),
'class' => 'fixed-width-xxl readonly',
'class' => 'fixed-width-xl',
'suffix' => $this->l('day(s)'),
),
'GLOBAL_PREPARATION_TIME' => array(
'GLOBAL_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.'),
@@ -332,24 +329,23 @@ class AdminOrderPreferencesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.');
}
$_POST['MAX_GLOBAL_BOOKING_DATE'] = date('Y-m-d', strtotime(Tools::getValue('MAX_GLOBAL_BOOKING_DATE')));
$maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE');
$globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME');
$maxGlobalBookingDateFormatted = date('Y-m-d', strtotime($maxGlobalBookingDate));
if ($maxGlobalBookingDate == '') {
$this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' can not be empty.');
} elseif (!Validate::isDate($maxGlobalBookingDateFormatted)) {
$this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' is invalid.');
} elseif (strtotime($maxGlobalBookingDateFormatted) < strtotime(date('Y-m-d'))) {
$this->errors[] = Tools::displayError('Field \'Maximum Global Check-out Date to book a room\' can not be a past date. Please use a future date.');
$maxBookingOffset = Tools::getValue('GLOBAL_MAX_BOOKING_OFFSET');
$minBookingOffset = Tools::getValue('GLOBAL_MIN_BOOKING_OFFSET');
if ($maxBookingOffset === '') {
$this->errors[] = Tools::displayError('Field \'Maximum booking offset\' can not be empty.');
} elseif (!$maxBookingOffset || !Validate::isUnsignedInt($maxBookingOffset)) {
$this->errors[] = Tools::displayError('Field \'Maximum booking offset\' is invalid.');
}
if ($globalPreparationTime === '') {
if ($minBookingOffset === '') {
$this->errors[] = Tools::displayError('Field \'Minimum booking offset\' can not be empty.');
} elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) {
} elseif ($minBookingOffset != 0 && !Validate::isUnsignedInt($minBookingOffset)) {
$this->errors[] = Tools::displayError('Field \'Minimum booking offset\' is invalid.');
}
if ($maxBookingOffset && $maxBookingOffset <= $minBookingOffset) {
$this->errors[] = Tools::displayError('Field \'Maximum booking offset\' cannot be be less than or equal to \'Minimum booking offset\'.');
}
}
public function setMedia()

View File

@@ -156,11 +156,11 @@ class CategoryControllerCore extends FrontController
$currency = new Currency($this->context->currency->id);
if ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($id_category)) {
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($id_hotel);
if ($preparationTime
&& strtotime(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))) > strtotime($date_from)
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($id_hotel);
if ($minBookingOffset
&& strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($date_from)
) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
$date_from = date('Y-m-d', strtotime('+ '.$minBookingOffset.' day'));
if (strtotime($date_from) >= strtotime($date_to)) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
}

View File

@@ -334,15 +334,15 @@ class ProductControllerCore extends FrontController
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id);
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($hotel_id);
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
}
if ($preparationTime
&& strtotime(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))) > strtotime($date_from)
if ($minBookingOffset
&& strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($date_from)
) {
$date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day'));
$date_from = date('Y-m-d', strtotime('+ '.$minBookingOffset.' day'));
}
if (!($date_to = Tools::getValue('date_to'))) {
@@ -392,7 +392,7 @@ class ProductControllerCore extends FrontController
'room_type_info' => $room_info_by_product_id,
'isHotelRefundable' => $hotel_branch_obj->isRefundable(),
'max_order_date' => $max_order_date,
'preparation_time' => $preparationTime,
'min_booking_offset' => $minBookingOffset,
'warning_num' => Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'),
'ratting_img_path' => _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png',
'product_controller_url' => $this->context->link->getPageLink('product'),

View File

@@ -1,3 +1,3 @@
Hotel ID;Active(0/1);Hotel Name;Short Description;Description;Mobile Phone;Email;Address;Rating;Check-In;Check-Out;Country ID;State ID;City;Zip Code;Hotel Policies;Allow Refund(0/1);Refund IDs (x,y,z...);Max Order Date;Prepration Time;Image URLs (x,y,z...);Delete Existing Images (0 = No, 1 = Yes)
Hotel ID;Active(0/1);Hotel Name;Short Description;Description;Mobile Phone;Email;Address;Rating;Check-In;Check-Out;Country ID;State ID;City;Zip Code;Hotel Policies;Allow Refund(0/1);Refund IDs (x,y,z...);Max booking offset;Min booking offset;Image URLs (x,y,z...);Delete Existing Images (0 = No, 1 = Yes)
2;1;The Kings Hotel;The Kings Hotel with king size rooms. visit for a wonderful experience.;The Kings Hotel with king-size rooms. visit for a wonderful experience.;0900000009;kingshotel@demo.com;Greene St, New York, NY 10003, USA;3;12:00;11:00;21;32;New York;10003;1. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.2. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.;1;1;2024-01-01;0;http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/1.jpg;0
3;1;The Sunshine Palace Inn;The Sunshine Palace Inn is a beautiful hotel in japan.;The Sunshine Palace Inn is a beautiful hotel in japan.;0900000009;sunshine@demo.com;Shingashi, Itabashi, Tokyo;4;09:00;08:00;11;306;Tokyo;611-0043;1.loremipsertmkjbg ag mixtape meggings tousled ramps VHS cred.;0;0;;3;http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/2.jpg,http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/3.jpg;0
1 Hotel ID Active(0/1) Hotel Name Short Description Description Mobile Phone Email Address Rating Check-In Check-Out Country ID State ID City Zip Code Hotel Policies Allow Refund(0/1) Refund IDs (x,y,z...) Max Order Date Max booking offset Prepration Time Min booking offset Image URLs (x,y,z...) Delete Existing Images (0 = No, 1 = Yes)
2 2 1 The Kings Hotel The Kings Hotel with king size rooms. visit for a wonderful experience. The Kings Hotel with king-size rooms. visit for a wonderful experience. 0900000009 kingshotel@demo.com Greene St, New York, NY 10003, USA 3 12:00 11:00 21 32 New York 10003 1. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.2. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 1 1 2024-01-01 2024-01-01 0 0 http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/1.jpg 0
3 3 1 The Sunshine Palace Inn The Sunshine Palace Inn is a beautiful hotel in japan. The Sunshine Palace Inn is a beautiful hotel in japan. 0900000009 sunshine@demo.com Shingashi, Itabashi, Tokyo 4 09:00 08:00 11 306 Tokyo 611-0043 1.loremipsertmkjbg ag mixtape meggings tousled ramps VHS cred. 0 0 3 3 http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/2.jpg,http://localhost/hotelcommerce/modules/hotelreservationsystem/views/img/hotel_img/1/3.jpg 0

View File

@@ -71,10 +71,10 @@ class HotelBranchInformation extends ObjectModel
public $zipcode;
public $address;
public $phone;
public $use_global_max_order_date = 1;
public $max_order_date = '0000-00-00';
public $use_global_preparation_time = 1;
public $preparation_time = '0000-00-00';
public $use_global_max_booking_offset = 1;
public $max_booking_offset = '1000';
public $use_global_min_booking_offset = 1;
public $min_booking_offset = '0';
protected $webserviceParameters = array(
'objectsNodeName' => 'hotels',
@@ -106,10 +106,10 @@ class HotelBranchInformation extends ObjectModel
'subResourceName' => 'hotels'
)
),
'use_global_max_order_date' => array(),
'max_order_date' => array(),
'use_global_preparation_time' => array(),
'preparation_time' => array(),
'use_global_max_booking_offset' => array(),
'max_booking_offset' => array(),
'use_global_min_booking_offset' => array(),
'min_booking_offset' => array(),
),
'associations' => array(
'room_types' => array(
@@ -149,10 +149,10 @@ class HotelBranchInformation extends ObjectModel
}
if ($hotelRestrictions = HotelOrderRestrictDate::getDataByHotelId($id)) {
$this->use_global_max_order_date = $hotelRestrictions['use_global_max_order_date'];
$this->max_order_date = $hotelRestrictions['max_order_date'];
$this->use_global_preparation_time = $hotelRestrictions['use_global_preparation_time'];
$this->preparation_time = $hotelRestrictions['preparation_time'];
$this->use_global_max_booking_offset = $hotelRestrictions['use_global_max_booking_offset'];
$this->max_booking_offset = $hotelRestrictions['max_booking_offset'];
$this->use_global_min_booking_offset = $hotelRestrictions['use_global_min_booking_offset'];
$this->min_booking_offset = $hotelRestrictions['min_booking_offset'];
}
}
}
@@ -1072,13 +1072,13 @@ class HotelBranchInformation extends ObjectModel
}
$objHotelRestrictDate->id_hotel = $this->id;
$objHotelRestrictDate->use_global_max_order_date = $this->use_global_max_order_date;
if (!$this->use_global_max_order_date) {
$objHotelRestrictDate->max_order_date = $this->max_order_date;
$objHotelRestrictDate->use_global_max_booking_offset = $this->use_global_max_booking_offset;
if (!$this->use_global_max_booking_offset) {
$objHotelRestrictDate->max_booking_offset = $this->max_booking_offset;
}
$objHotelRestrictDate->use_global_preparation_time = $this->use_global_preparation_time;
if (!$this->use_global_preparation_time) {
$objHotelRestrictDate->preparation_time = $this->preparation_time;
$objHotelRestrictDate->use_global_min_booking_offset = $this->use_global_min_booking_offset;
if (!$this->use_global_min_booking_offset) {
$objHotelRestrictDate->min_booking_offset = $this->min_booking_offset;
}
return $objHotelRestrictDate->save();
@@ -1111,23 +1111,34 @@ class HotelBranchInformation extends ObjectModel
$message = Tools::displayError('City is required field.');
} elseif (!Validate::isCityName($this->city)) {
$message = Tools::displayError('Enter a Valid City Name.');
} elseif (!Validate::isBool($this->use_global_max_order_date)) {
$message = Tools::displayError('invalid value for use_global_max_order_date.');
} elseif (!Validate::isBool($this->use_global_preparation_time)) {
$message = Tools::displayError('invalid value for use_global_preparation_time.');
} elseif (!$this->use_global_max_order_date && $this->max_order_date == '') {
$message = Tools::displayError('Maximum date to book a room is required.');
} elseif (!$this->use_global_max_order_date && !Validate::isDate($this->max_order_date)) {
$message = Tools::displayError('Maximum date to book a room is invalid.');
} elseif (!$this->use_global_max_order_date
&& ($maxOrderDateFormatted = date('Y-m-d', strtotime($this->max_order_date)))
&& strtotime($maxOrderDateFormatted) < strtotime(date('Y-m-d'))
) {
$message = Tools::displayError('Maximum Global Date to book a room can not be a past date. Please use a future date.');
} elseif (!$this->use_global_preparation_time && $this->preparation_time === '') {
} elseif (!Validate::isBool($this->use_global_max_booking_offset)) {
$message = Tools::displayError('invalid value for use_global_max_booking_offset.');
} elseif (!Validate::isBool($this->use_global_min_booking_offset)) {
$message = Tools::displayError('invalid value for use_global_min_booking_offset.');
} elseif (!$this->use_global_max_booking_offset && $this->max_booking_offset == '') {
$message = Tools::displayError('Maximum booking offset is required.');
} elseif (!$this->use_global_max_booking_offset && (!$this->max_booking_offset || !Validate::isUnsignedInt($this->max_booking_offset))) {
$message = Tools::displayError('Maximum booking offset is invalid.');
} elseif (!$this->use_global_min_booking_offset && $this->min_booking_offset === '') {
$message = Tools::displayError('Minimum booking offset is a required.');
} elseif (!$this->use_global_preparation_time && $this->preparation_time !== '0' && !Validate::isUnsignedInt($this->preparation_time)) {
} elseif (!$this->use_global_min_booking_offset && !Validate::isUnsignedInt($this->min_booking_offset)) {
$message = Tools::displayError('Minimum booking offset is invalid.');
} else if (!$this->use_global_min_booking_offset
&& !$this->use_global_max_booking_offset
&& $this->max_booking_offset
&& $this->max_booking_offset <= $this->min_booking_offset
) {
$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')
) {
$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')
) {
$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))) {
$message = Tools::displayError('country is invalid.');
} elseif ($this->id_state

View File

@@ -1029,9 +1029,9 @@ class HotelCartBookingData extends ObjectModel
}
}
$preparationTime = HotelOrderRestrictDate::getPreparationTime($roomData['id_hotel']);
if ($preparationTime !== false) {
$minOrderDate = date('Y-m-d', strtotime('+'. ($preparationTime) .' days'));
$minBookingOffset = HotelOrderRestrictDate::getMinBookingOffset($roomData['id_hotel']);
if ($minBookingOffset !== false) {
$minOrderDate = date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'));
if (strtotime($minOrderDate) > strtotime($roomData['date_from'])
|| strtotime($minOrderDate . ' +1 day')> strtotime($roomData['date_to'])
) {

View File

@@ -1063,12 +1063,8 @@ class HotelHelper
Configuration::updateValue('WK_GLOBAL_CHILD_MAX_AGE', 15);
Configuration::updateValue('WK_GLOBAL_MAX_CHILD_IN_ROOM', 0);
Configuration::updateValue(
'MAX_GLOBAL_BOOKING_DATE',
date('Y-m-d', strtotime(date('Y-m-d', time()).' + 1 year'))
);
Configuration::updateValue('GLOBAL_PREPARATION_TIME', 0);
Configuration::updateValue('GLOBAL_MAX_BOOKING_OFFSET', 1000);
Configuration::updateValue('GLOBAL_MIN_BOOKING_OFFSET', 0);
Configuration::updateValue('HTL_FEATURE_PRICING_PRIORITY', 'specific_date;special_day;date_range');
Configuration::updateValue('WK_GOOGLE_ACTIVE_MAP', 0);
@@ -2502,8 +2498,8 @@ class HotelHelper
public static function validateDateRangeForHotel($dateFrom, $dateTo, $idHotel)
{
$validStartDateTimeStamp = strtotime(date('Y-m-d'));
if ($preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($idHotel)) {
$validStartDateTimeStamp = strtotime(date('Y-m-d', strtotime('+ '.$preparationTime.' day')));
if ($minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel)) {
$validStartDateTimeStamp = strtotime(date('Y-m-d', strtotime('+ '.$minBookingOffset.' day')));
}
$dateFromTimestamp = strtotime($dateFrom);

View File

@@ -22,10 +22,10 @@ class HotelOrderRestrictDate extends ObjectModel
{
public $id;
public $id_hotel;
public $use_global_max_order_date;
public $max_order_date;
public $use_global_preparation_time;
public $preparation_time;
public $use_global_max_booking_offset;
public $max_booking_offset;
public $use_global_min_booking_offset;
public $min_booking_offset;
public $date_add;
public $date_upd;
@@ -34,10 +34,10 @@ class HotelOrderRestrictDate extends ObjectModel
'primary' => 'id',
'fields' => array(
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'use_global_max_order_date' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'max_order_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
'use_global_preparation_time' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'preparation_time' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'use_global_max_booking_offset' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'max_booking_offset' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'use_global_min_booking_offset' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'min_booking_offset' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
),
@@ -54,12 +54,12 @@ class HotelOrderRestrictDate extends ObjectModel
public static function getMaxOrderDate($idHotel)
{
$result = self::getDataByHotelId($idHotel);
if (is_array($result) && count($result) && !$result['use_global_max_order_date']) {
return $result['max_order_date'];
if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) {
return date('Y-m-d', strtotime('+ '.$result['max_booking_offset'].' days'));
}
if ($globalBookingDate = Configuration::get('MAX_GLOBAL_BOOKING_DATE')) {
return $globalBookingDate;
if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) {
return date('Y-m-d', strtotime('+ '.$globalBookingDate.' days'));
}
return 0;
@@ -69,14 +69,33 @@ class HotelOrderRestrictDate extends ObjectModel
* @param int $id_hotel
* @return int|false
*/
public static function getPreparationTime($idHotel)
public static function getMaxBookingOffset($idHotel)
{
$result = self::getDataByHotelId($idHotel);
if (is_array($result) && count($result) && !$result['use_global_preparation_time']) {
return (int) $result['preparation_time'];
if (is_array($result) && count($result) && !$result['use_global_max_booking_offset']) {
return $result['max_booking_offset'];
}
$globalPreparationTime = Configuration::get('GLOBAL_PREPARATION_TIME');
if ($globalBookingDate = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET')) {
return $globalBookingDate;
}
return 0;
}
/**
* @param int $id_hotel
* @return int|false
*/
public static function getMinBookingOffset($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;
}

View File

@@ -267,10 +267,10 @@ class HotelReservationSystemDb
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_order_restrict_date` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_hotel` int(11) NOT NULL,
`use_global_max_order_date` tinyint(1) NOT NULL,
`max_order_date` date NOT NULL,
`use_global_preparation_time` tinyint(1) NOT NULL,
`preparation_time` int(11) NOT NULL,
`use_global_max_booking_offset` tinyint(1) NOT NULL,
`max_booking_offset` int(11) NOT NULL,
`use_global_min_booking_offset` tinyint(1) NOT NULL,
`min_booking_offset` int(11) NOT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id`)

View File

@@ -168,15 +168,7 @@ class AdminAddHotelController extends ModuleAdminController
}
}
$restrictDateInfo = HotelOrderRestrictDate::getDataByHotelId($idHotel);
if ($restrictDateInfo) {
if ($restrictDateInfo['max_order_date'] == '0000-00-00') {
$restrictDateInfo['max_order_date'] = date('d-m-Y', strtotime('1 year'));
} else {
$restrictDateInfo['max_order_date'] = date('d-m-Y', strtotime($restrictDateInfo['max_order_date']));
}
}
$smartyVars['order_restrict_date_info'] = $restrictDateInfo;
$smartyVars['order_restrict_date_info'] = HotelOrderRestrictDate::getDataByHotelId($idHotel);
$objHotelFeatures = new HotelFeatures();
$hotelFeatures = $this->object->getFeaturesOfHotelByHotelId($this->object->id);
if ($features = $objHotelFeatures->HotelBranchSelectedFeaturesArray($hotelFeatures)) {
@@ -220,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['MAX_GLOBAL_BOOKING_DATE'] = (Configuration::get('MAX_GLOBAL_BOOKING_DATE'));
$smartyVars['GLOBAL_PREPARATION_TIME'] = Configuration::get('GLOBAL_PREPARATION_TIME');
$smartyVars['GLOBAL_MAX_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MAX_BOOKING_OFFSET');
$smartyVars['GLOBAL_MIN_BOOKING_OFFSET'] = Configuration::get('GLOBAL_MIN_BOOKING_OFFSET');
$this->context->smarty->assign($smartyVars);
@@ -241,6 +233,10 @@ class AdminAddHotelController extends ModuleAdminController
public function processSave()
{
if (!$this->loadObject(true)) {
return false;
}
$idHotel = Tools::getValue('id');
$phone = Tools::getValue('phone');
$email = Tools::getValue('email');
@@ -254,10 +250,10 @@ class AdminAddHotelController extends ModuleAdminController
$address = Tools::getValue('address');
$active = Tools::getValue('ENABLE_HOTEL');
$activeRefund = Tools::getValue('active_refund');
$enableUseGlobalMaxOrderDate = Tools::getValue('enable_use_global_max_order_date');
$maximumBookingDate = Tools::getValue('maximum_booking_date');
$enableUseGlobalPreparationTime = Tools::getValue('enable_use_global_preparation_time');
$preparationTime = Tools::getValue('preparation_time');
$enableUseGlobalMaxBookingOffset = Tools::getValue('enable_use_global_max_booking_offset');
$maxBookingOffset = trim(Tools::getValue('max_booking_offset'));
$enableUseGlobalMinBookingOffset = Tools::getValue('enable_use_global_min_booking_offset');
$minBookingOffset = trim(Tools::getValue('min_booking_offset'));
$latitude = Tools::getValue('loclatitude');
$longitude = Tools::getValue('loclongitude');
$map_formated_address = Tools::getValue('locformatedAddr');
@@ -427,24 +423,35 @@ class AdminAddHotelController extends ModuleAdminController
}
if ($idHotel) {
if (!$enableUseGlobalMaxOrderDate) {
$maximumBookingDateFormatted = date('Y-m-d', strtotime($maximumBookingDate));
if ($maximumBookingDate == '') {
$this->errors[] = $this->l('Maximum Check-out Date to book a room is a required field.');
} elseif (!Validate::isDate($maximumBookingDateFormatted)) {
$this->errors[] = $this->l('Maximum Check-out Date to book a room is invalid.');
} elseif (strtotime($maximumBookingDateFormatted) < strtotime(date('Y-m-d'))) {
$this->errors[] = $this->l('Maximum Check-out Date to book a room can not be a past date. Please use a future date.');
if (!$enableUseGlobalMaxBookingOffset) {
if ($maxBookingOffset === '') {
$this->errors[] = $this->l('Maximum booking offset is a required field.');
} elseif (!$maxBookingOffset || !Validate::isUnsignedInt($maxBookingOffset)) {
$this->errors[] = $this->l('Maximum booking offset is invalid.');
}
}
if (!$enableUseGlobalPreparationTime) {
if ($preparationTime === '') {
if (!$enableUseGlobalMinBookingOffset) {
if ($minBookingOffset === '') {
$this->errors[] = $this->l('Minimum booking offset is a required field.');
} elseif ($preparationTime !== '0' && !Validate::isUnsignedInt($preparationTime)) {
} elseif (!Validate::isUnsignedInt($minBookingOffset)) {
$this->errors[] = $this->l('Minimum booking offset is invalid.');
}
}
if (empty($this->errors)) {
if (!$enableUseGlobalMaxBookingOffset && !$enableUseGlobalMinBookingOffset) {
if ($maxBookingOffset && $maxBookingOffset <= $minBookingOffset) {
$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')) {
$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')) {
$this->errors[] = $this->l('Field Minimum booking offset cannot be be greater than or equal to Global Maximum booking offset.');
}
}
}
}
if (!count($this->errors)) {
@@ -734,19 +741,20 @@ class AdminAddHotelController extends ModuleAdminController
$restrictDateInfo = HotelOrderRestrictDate::getDataByHotelId($newIdHotel);
if ($restrictDateInfo) {
$objHotelOrderRestrictDate = new HotelOrderRestrictDate($restrictDateInfo['id']);
} else {
$objHotelOrderRestrictDate = new HotelOrderRestrictDate();
}
$objHotelOrderRestrictDate->id_hotel = $newIdHotel;
$objHotelOrderRestrictDate->use_global_max_order_date = $enableUseGlobalMaxOrderDate;
if (!$enableUseGlobalMaxOrderDate) {
$objHotelOrderRestrictDate->max_order_date = $maximumBookingDateFormatted;
$objHotelOrderRestrictDate->use_global_max_booking_offset = $enableUseGlobalMaxBookingOffset;
$objHotelOrderRestrictDate->use_global_min_booking_offset = $enableUseGlobalMinBookingOffset;
if (!$enableUseGlobalMaxBookingOffset) {
$objHotelOrderRestrictDate->max_booking_offset = $maxBookingOffset;
}
$objHotelOrderRestrictDate->use_global_preparation_time = $enableUseGlobalPreparationTime;
if (!$enableUseGlobalPreparationTime) {
$objHotelOrderRestrictDate->preparation_time = $preparationTime;
if (!$enableUseGlobalMinBookingOffset) {
$objHotelOrderRestrictDate->min_booking_offset = $minBookingOffset;
}
$objHotelOrderRestrictDate->save();
$objHotelFeatures = new HotelBranchFeatures();
@@ -756,32 +764,25 @@ class AdminAddHotelController extends ModuleAdminController
}
}
$conf = 3;
if ($idHotel) {
$con = 4;
}
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
if ($idHotel) {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf=4&token='.
$this->token
);
} else {
Tools::redirectAdmin(
self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf=3&token='.
$this->token
);
}
Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token );
} else {
if ($idHotel) {
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
} else {
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
}
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
}
}
if ($idHotel) {
$this->display = 'edit';
} else {
$this->display = 'add';
}
}
public function processStatus()
{
parent::processStatus();

View File

@@ -65,15 +65,6 @@ class HotelReservationSystem extends Module
public function hookDisplayHeader()
{
// check max global order_restriction date is set
if (!Configuration::get('MAX_GLOBAL_BOOKING_DATE')
|| (strtotime(date('Y-m-d')) > strtotime(Configuration::get('MAX_GLOBAL_BOOKING_DATE')))
) {
Configuration::updateValue(
'MAX_GLOBAL_BOOKING_DATE',
date('Y-m-d', strtotime(date('Y-m-d', time()).' + 1 year'))
);
}
if (!Configuration::get('PS_CATALOG_MODE')) {
/*To remove room from cart before todays date*/
if (isset($this->context->cart->id) && $this->context->cart->id) {

View File

@@ -426,12 +426,6 @@ p.room_cat_data
}
/*AdminHotelConfigurationSetting controller*/
#max_global_book_date
{
width: 30%;
}
.htl_all_setting .btn.btn-default {
margin: 20px!important;
}

View File

@@ -551,22 +551,6 @@ $(document).ready(function() {
$("#conf_id_WK_BO_MESSAGE").hide();
});
/*For OrderRestrict Functionality*/
$("#max_htl_book_date").datepicker({
defaultDate: new Date(),
dateFormat: 'dd-mm-yy',
minDate: 0,
});
$("#max_global_book_date").datepicker({
defaultDate: new Date(),
dateFormat: 'dd-mm-yy',
minDate: 0,
});
//$( "#max_global_book_date" ).datepicker( "option", "maxDate", '20 Mar 2020');
/*END*/
/* ---- AdminHotelFeaturePricesSettingsController Admin ---- */
$('#date_selection_type').on('change', function() {
@@ -805,26 +789,19 @@ $(document).ready(function() {
});
}
// manage hotel page
$('#maximum_booking_date').datepicker({
defaultDate: new Date(),
dateFormat: 'dd-mm-yy',
minDate: 0,
});
$('input[name="enable_use_global_max_order_date"]').on('change', function () {
$('input[name="enable_use_global_max_booking_offset"]').on('change', function () {
if (parseInt($(this).val())) {
$('input[name="maximum_booking_date"]').closest('.form-group').hide(200);
$('input[name="max_booking_offset"]').closest('.form-group').hide(200);
} else {
$('input[name="maximum_booking_date"]').closest('.form-group').show(200);
$('input[name="max_booking_offset"]').closest('.form-group').show(200);
}
});
$('input[name="enable_use_global_preparation_time"]').on('change', function () {
$('input[name="enable_use_global_min_booking_offset"]').on('change', function () {
if (parseInt($(this).val())) {
$('input[name="preparation_time"]').closest('.form-group').hide(200);
$('input[name="min_booking_offset"]').closest('.form-group').hide(200);
} else {
$('input[name="preparation_time"]').closest('.form-group').show(200);
$('input[name="min_booking_offset"]').closest('.form-group').show(200);
}
});

View File

@@ -427,23 +427,23 @@
{if isset($hotel_info.id) && $hotel_info.id}
<div class="form-group">
<label class="control-label col-lg-3">
<span>{l s='Use Global Maximum Order date :' mod='hotelreservationsystem'}</span>
<span>{l s='Use Global maximum booking offset:' mod='hotelreservationsystem'}</span>
</label>
<div class="col-lg-6">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" {if isset($edit) && isset($order_restrict_date_info.use_global_max_order_date) && $order_restrict_date_info.use_global_max_order_date} checked="checked" {else} checked="checked" {/if} value="1" id="enable_use_global_max_order_date_on" name="enable_use_global_max_order_date">
<label for="enable_use_global_max_order_date_on">{l s='Yes' mod='hotelreservationsystem'}</label>
<input {if isset($edit) && isset($order_restrict_date_info.use_global_max_order_date) && !$order_restrict_date_info.use_global_max_order_date} checked="checked" {/if} type="radio" value="0" id="enable_use_global_max_order_date_off" name="enable_use_global_max_order_date">
<label for="enable_use_global_max_order_date_off">{l s='No' mod='hotelreservationsystem'}</label>
<input type="radio" {if isset($smarty.post.enable_use_global_max_booking_offset)} {if $smarty.post.enable_use_global_max_booking_offset} checked="checked"{/if} {elseif isset($edit) && isset($order_restrict_date_info.use_global_max_booking_offset) && $order_restrict_date_info.use_global_max_booking_offset} checked="checked" {else if isset($order_restrict_date_info) && !$order_restrict_date_info} checked="checked" {/if} value="1" id="enable_use_global_max_booking_offset_on" name="enable_use_global_max_booking_offset">
<label for="enable_use_global_max_booking_offset_on">{l s='Yes' mod='hotelreservationsystem'}</label>
<input type="radio" {if isset($smarty.post.enable_use_global_max_booking_offset)} {if !$smarty.post.enable_use_global_max_booking_offset} checked="checked"{/if} {elseif isset($edit) && isset($order_restrict_date_info.use_global_max_booking_offset) && !$order_restrict_date_info.use_global_max_booking_offset} checked="checked" {/if} value="0" id="enable_use_global_max_booking_offset_off" name="enable_use_global_max_booking_offset">
<label for="enable_use_global_max_booking_offset_off">{l s='No' mod='hotelreservationsystem'}</label>
<a class="slide-button btn"></a>
</span>
<div class="help-block">{l s='Global max order date:' mod='hotelreservationsystem'} {dateFormat date=$MAX_GLOBAL_BOOKING_DATE}</div>
<div class="help-block">{l s='Global maximum booking offset:' mod='hotelreservationsystem'} {$GLOBAL_MAX_BOOKING_OFFSET}</div>
</div>
</div>
<div class="form-group" {if isset($smarty.post.enable_use_global_max_order_date)}{if !$smarty.post.enable_use_global_max_order_date}style="display:block;"{else}style="display:none;"{/if}{elseif isset($order_restrict_date_info.use_global_max_order_date) && !$order_restrict_date_info.use_global_max_order_date}style="display:block;" {else} style="display:none;" {/if}>
<label class="control-label col-sm-3 required" for="maximum_booking_date">{l s='Maximum Check-out Date to book a room :' mod='hotelreservationsystem'}</label>
<div class="form-group" {if isset($smarty.post.enable_use_global_max_booking_offset)} {if !$smarty.post.enable_use_global_max_booking_offset} style="display:block;" {else} style="display:none;" {/if} {elseif isset($order_restrict_date_info.use_global_max_booking_offset) && !$order_restrict_date_info.use_global_max_booking_offset} style="display:block;" {else} style="display:none;" {/if}>
<label class="control-label col-sm-3 required" for="max_booking_offset">{l s='Maximum Check-out Date to book a room :' mod='hotelreservationsystem'}</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="maximum_booking_date" name="maximum_booking_date" value="{if isset($order_restrict_date_info.max_order_date)}{$order_restrict_date_info.max_order_date|escape:'htmlall':'UTF-8'}{/if}" />
<input type="text" class="form-control" id="max_booking_offset" name="max_booking_offset" value="{if isset($smarty.post.max_booking_offset)}{$smarty.post.max_booking_offset}{elseif isset($order_restrict_date_info.max_booking_offset)}{$order_restrict_date_info.max_booking_offset|escape:'htmlall':'UTF-8'}{/if}" />
</div>
</div>
<div class="form-group">
@@ -452,19 +452,19 @@
</label>
<div class="col-lg-6">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" {if isset($edit) && isset($order_restrict_date_info.use_global_preparation_time) && $order_restrict_date_info.use_global_preparation_time} checked="checked" {else} checked="checked" {/if} value="1" id="enable_use_global_preparation_time_on" name="enable_use_global_preparation_time">
<label for="enable_use_global_preparation_time_on">{l s='Yes' mod='hotelreservationsystem'}</label>
<input {if isset($edit) && isset($order_restrict_date_info.use_global_preparation_time) && !$order_restrict_date_info.use_global_preparation_time} checked="checked" {/if} type="radio" value="0" id="enable_use_global_preparation_time_off" name="enable_use_global_preparation_time">
<label for="enable_use_global_preparation_time_off">{l s='No' mod='hotelreservationsystem'}</label>
<input type="radio" {if isset($smarty.post.enable_use_global_min_booking_offset)} {if $smarty.post.enable_use_global_min_booking_offset} checked="checked" {/if} {elseif isset($edit) && isset($order_restrict_date_info.use_global_min_booking_offset) && $order_restrict_date_info.use_global_min_booking_offset} checked="checked" {else if isset($order_restrict_date_info) && !$order_restrict_date_info} checked="checked" {/if} value="1" id="enable_use_global_min_booking_offset_on" name="enable_use_global_min_booking_offset">
<label for="enable_use_global_min_booking_offset_on">{l s='Yes' mod='hotelreservationsystem'}</label>
<input type="radio" {if isset($smarty.post.enable_use_global_min_booking_offset)} {if !$smarty.post.enable_use_global_min_booking_offset} checked="checked" {/if} {elseif isset($edit) && isset($order_restrict_date_info.use_global_min_booking_offset) && !$order_restrict_date_info.use_global_min_booking_offset} checked="checked" {/if} value="0" id="enable_use_global_min_booking_offset_off" name="enable_use_global_min_booking_offset">
<label for="enable_use_global_min_booking_offset_off">{l s='No' mod='hotelreservationsystem'}</label>
<a class="slide-button btn"></a>
</span>
<div class="help-block">{l s='Global minimum booking offset :' mod='hotelreservationsystem'} {$GLOBAL_PREPARATION_TIME}</div>
<div class="help-block">{l s='Global minimum booking offset :' mod='hotelreservationsystem'} {$GLOBAL_MIN_BOOKING_OFFSET}</div>
</div>
</div>
<div class="form-group" {if isset($smarty.post.enable_use_global_preparation_time)}{if !$smarty.post.enable_use_global_preparation_time}style="display:block;"{else}style="display:none;"{/if}{elseif isset($order_restrict_date_info.use_global_preparation_time) && !$order_restrict_date_info.use_global_preparation_time}style="display:block;" {else} style="display:none;" {/if}>
<label class="control-label col-sm-3 required" for="preparation_time">{l s='Minimum booking offset :' mod='hotelreservationsystem'}</label>
<div class="form-group" {if isset($smarty.post.enable_use_global_min_booking_offset)} {if !$smarty.post.enable_use_global_min_booking_offset} style="display:block;" {else} style="display:none;" {/if} {else if isset($edit) && isset($order_restrict_date_info.use_global_min_booking_offset) && !$order_restrict_date_info.use_global_min_booking_offset} style="display:block;" {else} style="display:none;" {/if}>
<label class="control-label col-sm-3 required" for="min_booking_offset">{l s='Minimum booking offset :' mod='hotelreservationsystem'}</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="preparation_time" name="preparation_time" value="{if isset($smarty.post.preparation_time)}{$smarty.post.preparation_time|escape:'html':'UTF-8'}{elseif isset($edit) && isset($order_restrict_date_info.preparation_time)}{$order_restrict_date_info.preparation_time|escape:'htmlall':'UTF-8'}{/if}" />
<input type="text" class="form-control" id="min_booking_offset" name="min_booking_offset" value="{if isset($smarty.post.min_booking_offset)}{$smarty.post.min_booking_offset|escape:'html':'UTF-8'}{elseif isset($edit) && isset($order_restrict_date_info.min_booking_offset)}{$order_restrict_date_info.min_booking_offset|escape:'htmlall':'UTF-8'}{/if}" />
</div>
<div class="col-lg-9 col-lg-offset-3">
<div class="help-block">{l s='Set to 0 to disable this feature.' mod='hotelreservationsystem'}</div>

View File

@@ -144,11 +144,11 @@ class WkRoomSearchHelper
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idHotelCategory);
$htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent);
$searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel);
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($idHotel);
if ($preparationTime
&& strtotime(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))) > strtotime($dateFrom)
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel);
if ($minBookingOffset
&& strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($dateFrom)
) {
$dateFrom = date('Y-m-d', strtotime(date('Y-m-d', strtotime('+'. ($preparationTime) .' days'))));
$dateFrom = date('Y-m-d', strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))));
if (strtotime($dateFrom) >= strtotime($dateTo)) {
$controller = Tools::getValue('controller');
if ($controller == 'product'
@@ -237,7 +237,7 @@ class WkRoomSearchHelper
$hotelsInfo[$key]['id'] = $hotel_info['id'];
$hotelsInfo[$key]['hotel_name'] = $hotel_info['hotel_name'];
$hotelsInfo[$key]['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
$hotelsInfo[$key]['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel_info['id']);
$hotelsInfo[$key]['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinBookingOffset($hotel_info['id']);
} else {
unset($hotelsInfo[$key]);
}
@@ -251,7 +251,7 @@ class WkRoomSearchHelper
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
$smartyVars['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
$smartyVars['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($idHotel);
$smartyVars['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel);
if (!$locationEnabled
&& !$smartyVars['show_hotel_name']

View File

@@ -47,13 +47,13 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro
if ($hotelInfo = $obj_htl_info->hotelBranchInfoByCategoryId($category['id_category'])) {
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotelInfo['id']);
$maxOrderDate = date('Y-m-d', strtotime($maxOrderDate));
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotelInfo['id']);
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($hotelInfo['id']);
$hotelsInfo[] = array(
'id_hotel' => $hotelInfo['id'],
'id_category' => $hotelInfo['id_category'],
'hotel_name' => $hotelInfo['hotel_name'],
'max_order_date' => $maxOrderDate,
'preparation_time' => $preparationTime
'min_booking_offset' => $minBookingOffset
);
}
}

View File

@@ -139,10 +139,10 @@ const BookingSearchManager = {
$('#id_hotel_button').html(result.html_hotel_options);
$('#id_hotel_button').trigger('chosen:updated');
// Resetting the data from previously selected hotel
$('#preparation_time').val(0);
$('#min_booking_offset').val(0);
var max_order_date = $('#max_order_date').val();
var preparation_time = 0;
createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val());
var min_booking_offset = 0;
createDateRangePicker(max_order_date, min_booking_offset, $('#check_in_time').val(), $('#check_out_time').val());
if (search_auto_focus_next_field) {
BookingSearchManager.activateStep('hotel');
}
@@ -223,12 +223,12 @@ const BookingSearchManager = {
if ($(selectedHotel).val().trim() != '') {
const maxOrderDate = $(selectedHotel).attr('data-max_order_date');
const preparationTime = $(selectedHotel).attr('data-preparation_time')
const preparationTime = $(selectedHotel).attr('data-min_booking_offset')
createDateRangePicker(maxOrderDate, preparationTime, $('#check_in_time').val(), $('#check_out_time').val());
$('#max_order_date').val(maxOrderDate);
$('#preparation_time').val(preparationTime);
$('#min_booking_offset').val(preparationTime);
$('#id_hotel').val($(selectedHotel).attr('data-id-hotel'));
$('#hotel_cat_id').val($(selectedHotel).attr('data-hotel-cat-id'));
@@ -396,10 +396,10 @@ $(document).ready(function() {
/*END*/
var ajax_check_var = '';
createDateRangePicker = function (max_order_date, preparation_time, dateFrom, dateTo) {
createDateRangePicker = function (max_order_date, min_booking_offset, dateFrom, dateTo) {
let start_date = new Date();
if (preparation_time) {
start_date.setDate(start_date.getDate() + parseInt(preparation_time));
if (min_booking_offset) {
start_date.setDate(start_date.getDate() + parseInt(min_booking_offset));
start_date.setHours(0, 0, 0, 0);
let selectedDateFrom = new Date(Date.parse(dateFrom));
let selectedDateTo = new Date(Date.parse(dateTo));
@@ -549,8 +549,8 @@ $(document).ready(function() {
// If only one hotel then set max order date on date pickers
var max_order_date = $('#max_order_date').val();
var preparation_time = $('#preparation_time').val();
createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val());
var min_booking_offset = $('#min_booking_offset').val();
createDateRangePicker(max_order_date, min_booking_offset, $('#check_in_time').val(), $('#check_out_time').val());
// validations on the submit of the search fields
$(document).on('click', '#search_room_submit', function() {

View File

@@ -20,7 +20,7 @@
<option value=""></option>
{if isset($hotels_info) && is_array($hotels_info)}
{foreach from=$hotels_info item=hotel_info}
<option class="search_result_li" data-id-hotel="{$hotel_info.id_hotel}" data-hotel-cat-id="{$hotel_info.id_category}" data-max_order_date="{$hotel_info.max_order_date}" data-preparation_time="{$hotel_info.preparation_time}" tabindex="-1">
<option class="search_result_li" data-id-hotel="{$hotel_info.id_hotel}" data-hotel-cat-id="{$hotel_info.id_category}" data-max_order_date="{$hotel_info.max_order_date}" data-min_booking_offset="{$hotel_info.min_booking_offset}" tabindex="-1">
{$hotel_info.hotel_name}
</option>
{/foreach}

View File

@@ -35,7 +35,7 @@
{block name='search_form_hotel'}
{if count($hotels_info) <= 1 && !$show_hotel_name}
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($hotels_info[0]['max_order_date'])}{$hotels_info[0]['max_order_date']|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($hotels_info[0]['preparation_time'])}{$hotels_info[0]['preparation_time']|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="min_booking_offset" name="min_booking_offset" value="{if isset($hotels_info[0]['min_booking_offset'])}{$hotels_info[0]['min_booking_offset']|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" value="{$hotels_info[0]['id_category']}">
<input type="hidden" id="id_hotel" name="id_hotel" value="{$hotels_info[0]['id']|escape:'htmlall':'UTF-8'}">
<input type="hidden" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
@@ -44,13 +44,13 @@
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id" {if isset($search_data)}value="{$search_data['htl_dtl']['id_category']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="id_hotel" name="id_hotel" {if isset($search_data)}value="{$search_data['htl_dtl']['id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="hidden" id="max_order_date" name="max_order_date" value="{if isset($max_order_date)}{$max_order_date|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|escape:'htmlall':'UTF-8'}{/if}">
<input type="hidden" id="min_booking_offset" name="min_booking_offset" value="{if isset($min_booking_offset)}{$min_booking_offset|escape:'htmlall':'UTF-8'}{/if}">
<div class="hotel-selector-wrap {if isset($language_is_rtl) && $language_is_rtl}rtl{/if}">
<select name="id_hotel" class="chosen header-rmsearch-input" data-placeholder="{l s='Select Hotel' mod='wkroomsearchblock'}" id="id_hotel_button">
<option value=""></option>
{foreach $hotels_info as $name_val}
<option class="search_result_li" value="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}" {if isset($search_data) && $name_val['id'] == $search_data['htl_dtl']['id']}selected{/if}>{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</option>
<option class="search_result_li" value="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-id-hotel="{$name_val['id']|escape:'htmlall':'UTF-8'}" data-hotel-cat-id="{$name_val['id_category']|escape:'htmlall':'UTF-8'}" data-max_order_date="{$name_val['max_order_date']}" data-min_booking_offset="{$name_val['min_booking_offset']|escape:'htmlall':'UTF-8'}" {if isset($search_data) && $name_val['id'] == $search_data['htl_dtl']['id']}selected{/if}>{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
</div>

View File

@@ -1286,7 +1286,7 @@ var BookingForm = {
currentRequest: null,
init: function() {
this.currentRequest = null;
BookingForm.initDatepicker(max_order_date, preparation_time, $('#room_check_in').val(), $('#room_check_out').val());
BookingForm.initDatepicker(max_order_date, min_booking_offset, $('#room_check_in').val(), $('#room_check_out').val());
// initialize tootltip for extra service
if ($('.price_desc_block .services-info').length) {
$('.price_desc_block .services-info img').tooltip({
@@ -1337,10 +1337,10 @@ var BookingForm = {
}
$(document).trigger("QloApps:afterBookingFormInit");
},
initDatepicker: function(max_order_date, preparation_time, dateFrom, dateTo) {
initDatepicker: function(max_order_date, min_booking_offset, dateFrom, dateTo) {
let start_date = new Date();
if (preparation_time) {
start_date.setDate(start_date.getDate() + parseInt(preparation_time));
if (min_booking_offset) {
start_date.setDate(start_date.getDate() + parseInt(min_booking_offset));
start_date.setHours(0, 0, 0, 0);
if (dateFrom && new Date(dateFrom + ' 00:00:00') < start_date) {
dateFrom = $.datepicker.formatDate('yy-mm-dd', start_date);

View File

@@ -743,7 +743,7 @@
{if isset($id_hotel) && $id_hotel}
{addJsDef id_hotels = $id_hotel}
{addJsDef max_order_date = $max_order_date}
{addJsDef preparation_time = $preparation_time}
{addJsDef min_booking_offset = $min_booking_offset}
{addJsDef booking_date_to = $date_to}
{addJsDef booking_date_from = $date_from}
{/if}