Updated the variable names and function names for the max booking offeset and min booking offset
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
) {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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'])) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
@@ -437,7 +437,7 @@
|
||||
<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 maximum booking offset:' mod='hotelreservationsystem'} {$GLOBAL_MAX_BOOKING_OFFSET}</div>
|
||||
<div class="help-block">{l s='Global maximum booking offset:' mod='hotelreservationsystem'} {$PS_MAX_BOOKING_OFFSET}</div>
|
||||
</div>
|
||||
</div>
|
||||
<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}>
|
||||
@@ -458,7 +458,7 @@
|
||||
<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_MIN_BOOKING_OFFSET}</div>
|
||||
<div class="help-block">{l s='Global minimum booking offset :' mod='hotelreservationsystem'} {$PS_MIN_BOOKING_OFFSET}</div>
|
||||
</div>
|
||||
</div>
|
||||
<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}>
|
||||
|
||||
@@ -144,7 +144,7 @@ class WkRoomSearchHelper
|
||||
$idHotel = HotelBranchInformation::getHotelIdByIdCategory($idHotelCategory);
|
||||
$htlCategoryInfo = $objHotelInfo->getCategoryDataByIdCategory((int) $objCategory->id_parent);
|
||||
$searchedData['htl_dtl'] = $objHotelInfo->hotelBranchesInfo(0, 1, 1, $idHotel);
|
||||
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel);
|
||||
$minBookingOffset = (int) HotelOrderRestrictDate::getMinimumBookingOffset($idHotel);
|
||||
if ($minBookingOffset
|
||||
&& strtotime(date('Y-m-d', strtotime('+'. ($minBookingOffset) .' days'))) > strtotime($dateFrom)
|
||||
) {
|
||||
@@ -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]['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinBookingOffset($hotel_info['id']);
|
||||
$hotelsInfo[$key]['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinimumBookingOffset($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['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinBookingOffset($idHotel);
|
||||
$smartyVars['min_booking_offset'] = (int) HotelOrderRestrictDate::getMinimumBookingOffset($idHotel);
|
||||
|
||||
if (!$locationEnabled
|
||||
&& !$smartyVars['show_hotel_name']
|
||||
|
||||
@@ -47,7 +47,7 @@ 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));
|
||||
$minBookingOffset = (int) HotelOrderRestrictDate::getMinBookingOffset($hotelInfo['id']);
|
||||
$minBookingOffset = (int) HotelOrderRestrictDate::getMinimumBookingOffset($hotelInfo['id']);
|
||||
$hotelsInfo[] = array(
|
||||
'id_hotel' => $hotelInfo['id'],
|
||||
'id_category' => $hotelInfo['id_category'],
|
||||
|
||||
Reference in New Issue
Block a user