Merge pull request #479 from abhishek-webkul/gli-1045
New Feature: Preparation time for bookings
This commit is contained in:
@@ -59,6 +59,30 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$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 Date to book a room'),
|
||||
'hint' => $this->l('Maximum date by which rooms of your hotels can be booked.'),
|
||||
'type' => 'text',
|
||||
'id' => 'max_global_book_date',
|
||||
'class' => 'fixed-width-xxl readonly',
|
||||
),
|
||||
'GLOBAL_PREPARATION_TIME' => array(
|
||||
'title' => $this->l('Preparation time'),
|
||||
'hint' => $this->l('Number of days required to prepare a room for stay.'),
|
||||
'desc' => $this->l('Set to 0 to disable this feature.'),
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xl',
|
||||
'suffix' => $this->l('day(s)'),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
),
|
||||
'general' => array(
|
||||
'title' => $this->l('General'),
|
||||
'icon' => 'icon-cogs',
|
||||
@@ -183,9 +207,34 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
$sql = 'SELECT `id_cms` FROM `'._DB_PREFIX_.'cms`
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
WHERE id_cms = '.(int)Tools::getValue('PS_CONDITIONS_CMS_ID');
|
||||
if (Tools::getValue('PS_CONDITIONS') && (Tools::getValue('PS_CONDITIONS_CMS_ID') == 0 || !Db::getInstance()->getValue($sql))) {
|
||||
$this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.');
|
||||
}
|
||||
|
||||
$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 Date to book a room\' can not be empty.');
|
||||
} elseif (!Validate::isDate($maxGlobalBookingDateFormatted)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' is invalid.');
|
||||
} elseif (strtotime($maxGlobalBookingDateFormatted) < strtotime(date('Y-m-d'))) {
|
||||
$this->errors[] = Tools::displayError('Field \'Maximum Global Date to book a room\' can not be a past date. Please use a future date.');
|
||||
}
|
||||
|
||||
if ($globalPreparationTime === '') {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' can not be empty.');
|
||||
} elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) {
|
||||
$this->errors[] = Tools::displayError('Field \'Preparation time\' is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
$this->addJS(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +323,8 @@ class ProductControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
/*End*/
|
||||
// booking preparation time
|
||||
$preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id);
|
||||
|
||||
$hotelImageLink = null;
|
||||
if ($coverImage = HotelImage::getCover($hotel_id)) {
|
||||
@@ -347,6 +349,7 @@ class ProductControllerCore extends FrontController
|
||||
array(
|
||||
'isHotelRefundable' => $hotel_branch_obj->isRefundable(),
|
||||
'max_order_date' => $max_order_date,
|
||||
'preparation_time' => $preparationTime,
|
||||
'warning_num' => Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER'),
|
||||
'product_controller_url' => $this->context->link->getPageLink('product'),
|
||||
'date_from' => $date_from,
|
||||
|
||||
@@ -222,6 +222,8 @@ class HotelHelper
|
||||
date('d-m-Y', strtotime(date('Y-m-d', time()).' + 1 year'))
|
||||
);
|
||||
|
||||
Configuration::updateValue('GLOBAL_PREPARATION_TIME', 0);
|
||||
|
||||
Configuration::updateValue('HTL_FEATURE_PRICING_PRIORITY', 'specific_date;special_day;date_range');
|
||||
Configuration::updateValue('WK_GOOGLE_ACTIVE_MAP', 0);
|
||||
Configuration::updateValue('WK_MAP_HOTEL_ACTIVE_ONLY', 1);
|
||||
|
||||
@@ -22,7 +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 $date_add;
|
||||
public $date_upd;
|
||||
|
||||
@@ -31,49 +34,54 @@ class HotelOrderRestrictDate extends ObjectModel
|
||||
'primary' => 'id',
|
||||
'fields' => array(
|
||||
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'max_order_date' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'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'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||
),
|
||||
);
|
||||
|
||||
public function getDataByHotelId($id_hotel)
|
||||
public static function getDataByHotelId($idHotel)
|
||||
{
|
||||
$result = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'htl_order_restrict_date` WHERE `id_hotel`='.$id_hotel);
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_order_restrict_date` ord WHERE ord.`id_hotel` = '.(int) $idHotel
|
||||
);
|
||||
}
|
||||
|
||||
/*Max date of ordering for order restrict*/
|
||||
public static function getMaxOrderDate($id_hotel)
|
||||
public static function getMaxOrderDate($idHotel)
|
||||
{
|
||||
$global_max_order_date = Configuration::get('MAX_GLOBAL_BOOKING_DATE');
|
||||
$obj_ord_rest = new self();
|
||||
$order_restrict_data = $obj_ord_rest->getDataByHotelId($id_hotel);
|
||||
|
||||
if (isset($order_restrict_data['max_order_date']) && $order_restrict_data['max_order_date']) {
|
||||
$max_order_date = $order_restrict_data['max_order_date'];
|
||||
} elseif (isset($global_max_order_date) && $global_max_order_date) {
|
||||
$max_order_date = $global_max_order_date;
|
||||
} else {
|
||||
$max_order_date = 0;
|
||||
$result = self::getDataByHotelId($idHotel);
|
||||
if (is_array($result) && count($result) && !$result['use_global_max_order_date']) {
|
||||
return $result['max_order_date'];
|
||||
}
|
||||
|
||||
return $max_order_date;
|
||||
if ($globalBookingDate = Configuration::get('MAX_GLOBAL_BOOKING_DATE')) {
|
||||
return $globalBookingDate;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getUnsavedHotelsForOrderRestrict()
|
||||
/**
|
||||
* @param int $id_hotel
|
||||
* @return int|false
|
||||
*/
|
||||
public static function getPreparationTime($idHotel)
|
||||
{
|
||||
$idLang = Context::getContext()->language->id;
|
||||
$sql = 'SELECT hbi.`id`, hbl.`hotel_name` FROM `'._DB_PREFIX_.'htl_branch_info` hbi
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
|
||||
ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)$idLang.')
|
||||
WHERE hbi.`id` NOT IN (SELECT DISTINCT id_hotel FROM `'._DB_PREFIX_.'htl_order_restrict_date`)';
|
||||
$result = self::getDataByHotelId($idHotel);
|
||||
if (is_array($result) && count($result) && !$result['use_global_preparation_time']) {
|
||||
return (int) $result['preparation_time'];
|
||||
}
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
$globalPreparationTime = Configuration::get('GLOBAL_PREPARATION_TIME');
|
||||
if ($globalPreparationTime != '0') {
|
||||
return (int) $globalPreparationTime;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function validateOrderRestrictDateOnPayment(&$controller)
|
||||
@@ -88,23 +96,45 @@ class HotelOrderRestrictDate extends ObjectModel
|
||||
$obj_htl_bk_dtl = new HotelBookingDetail();
|
||||
$obj_rm_type = new HotelRoomType();
|
||||
|
||||
if ($cart_bk_data = $objCartBookingData->getOnlyCartBookingData(
|
||||
$context->cart->id,
|
||||
$context->cart->id_guest,
|
||||
$product['id_product']
|
||||
)) {
|
||||
$cart_data = array();
|
||||
foreach ($cart_bk_data as $data) {
|
||||
$objCartBookingData = new HotelCartBookingData($data['id']);
|
||||
if ($maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($objCartBookingData->id_hotel)) {
|
||||
if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($objCartBookingData->date_from)
|
||||
|| strtotime($maxOrderDate) < strtotime($objCartBookingData->date_to)
|
||||
) {
|
||||
$objBranchInfo = new HotelBranchInformation(
|
||||
$objCartBookingData->id_hotel,
|
||||
$context->language->id
|
||||
);
|
||||
$controller->errors[] = $moduleInstance->l('You can not Book room after date', 'HotelOrderRestrictDate').' \''.date('d-m-Y', strtotime($maxOrderDate)).'\' '.$moduleInstance->l('For hotel', 'HotelOrderRestrictDate').' \''.$objBranchInfo->hotel_name.'\'. '.$moduleInstance->l('Please remove rooms from cart from', 'HotelOrderRestrictDate').' \''.$objBranchInfo->hotel_name.'\' '.$moduleInstance->l('after date', 'HotelOrderRestrictDate').' \''.date('d-m-Y', strtotime($maxOrderDate)).'\' '.$moduleInstance->l('to proceed.', 'HotelOrderRestrictDate');
|
||||
if ($cart_bk_data = $objCartBookingData->getOnlyCartBookingData(
|
||||
$context->cart->id,
|
||||
$context->cart->id_guest,
|
||||
$product['id_product']
|
||||
)) {
|
||||
$cart_data = array();
|
||||
foreach ($cart_bk_data as $data) {
|
||||
$objCartBookingData = new HotelCartBookingData($data['id']);
|
||||
if ($maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($objCartBookingData->id_hotel)) {
|
||||
if (strtotime('-1 day', strtotime($maxOrderDate)) < strtotime($objCartBookingData->date_from)
|
||||
|| strtotime($maxOrderDate) < strtotime($objCartBookingData->date_to)
|
||||
) {
|
||||
$objBranchInfo = new HotelBranchInformation(
|
||||
$objCartBookingData->id_hotel,
|
||||
$context->language->id
|
||||
);
|
||||
$controller->errors[] = sprintf(
|
||||
'You can not book rooms for hotel \'%s\' after date %s. Please remove these rooms to proceed.',
|
||||
$objBranchInfo->hotel_name,
|
||||
Tools::displayDate($maxOrderDate)
|
||||
);
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
$preparationTime = HotelOrderRestrictDate::getPreparationTime($objCartBookingData->id_hotel);
|
||||
if ($preparationTime !== false) {
|
||||
$minOrderDate = date('Y-m-d', strtotime('+'. ($preparationTime) .' days'));
|
||||
if (strtotime($minOrderDate) > strtotime($objCartBookingData->date_from)
|
||||
|| strtotime($minOrderDate . ' +1 day')> strtotime($objCartBookingData->date_to)
|
||||
) {
|
||||
$objBranchInfo = new HotelBranchInformation(
|
||||
$objCartBookingData->id_hotel,
|
||||
$context->language->id
|
||||
);
|
||||
$controller->errors[] = sprintf(
|
||||
'You can not book rooms for hotel \'%s\' before date %s. Please remove these rooms to proceed.',
|
||||
$objBranchInfo->hotel_name,
|
||||
Tools::displayDate($minOrderDate)
|
||||
);
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +250,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,
|
||||
`max_order_date` datetime 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,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
||||
@@ -162,6 +162,16 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$smartyVars['hotelRefundRules'] = array_column($hotelRefundRules, 'id_refund_rule');
|
||||
}
|
||||
}
|
||||
|
||||
$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['enabledDisplayMap'] = Configuration::get('WK_GOOGLE_ACTIVE_MAP');
|
||||
@@ -197,6 +207,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');
|
||||
$latitude = Tools::getValue('loclatitude');
|
||||
$longitude = Tools::getValue('loclongitude');
|
||||
$map_formated_address = Tools::getValue('locformatedAddr');
|
||||
@@ -291,6 +305,27 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->errors[] = $this->l('Enter a Valid City Name.');
|
||||
}
|
||||
|
||||
if ($idHotel) {
|
||||
if (!$enableUseGlobalMaxOrderDate) {
|
||||
$maximumBookingDateFormatted = date('Y-m-d', strtotime($maximumBookingDate));
|
||||
if ($maximumBookingDate == '') {
|
||||
$this->errors[] = Tools::displayError('Maximum Global Date to book a room is a required field.');
|
||||
} elseif (!Validate::isDate($maximumBookingDateFormatted)) {
|
||||
$this->errors[] = Tools::displayError('Maximum Global Date to book a room is invalid.');
|
||||
} elseif (strtotime($maximumBookingDateFormatted) < strtotime(date('Y-m-d'))) {
|
||||
$this->errors[] = Tools::displayError('Maximum Global Date to book a room can not be a past date. Please use a future date.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$enableUseGlobalPreparationTime) {
|
||||
if ($preparationTime === '') {
|
||||
$this->errors[] = Tools::displayError('Preparation time is a required field.');
|
||||
} elseif ($preparationTime !== '0' && !Validate::isUnsignedInt($preparationTime)) {
|
||||
$this->errors[] = Tools::displayError('Preparation time is invalid.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
if ($idHotel) {
|
||||
$objHotelBranch = new HotelBranchInformation($idHotel);
|
||||
@@ -474,6 +509,28 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
if ($idHotel) {
|
||||
// save maximum booking date and preparation time
|
||||
$objHotelOrderRestrictDate = new HotelOrderRestrictDate();
|
||||
$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_preparation_time = $enableUseGlobalPreparationTime;
|
||||
if (!$enableUseGlobalPreparationTime) {
|
||||
$objHotelOrderRestrictDate->preparation_time = $preparationTime;
|
||||
}
|
||||
$objHotelOrderRestrictDate->save();
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
if ($idHotel) {
|
||||
Tools::redirectAdmin(
|
||||
|
||||
@@ -26,7 +26,6 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController
|
||||
$this->tpl_view_vars = array(
|
||||
'feature_price_setting_link' => $this->context->link->getAdminLink('AdminHotelFeaturePricesSettings'),
|
||||
'general_setting_link' => $this->context->link->getAdminLink('AdminHotelGeneralSettings'),
|
||||
'order_restrict_setting_link' => $this->context->link->getAdminLink('AdminOrderRestrictSettings'),
|
||||
'additional_demand_setting_link' => $this->context->link->getAdminLink('AdminRoomTypeGlobalDemand'),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AdminOrderRestrictSettingsController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'htl_order_restrict_date';
|
||||
$this->className = 'HotelOrderRestrictDate';
|
||||
$this->bootstrap = true;
|
||||
$this->identifier = 'id';
|
||||
$this->context = Context::getContext();
|
||||
|
||||
// START send access query information to the admin controller
|
||||
$this->access_select = ' SELECT a.`id` FROM '._DB_PREFIX_.'htl_order_restrict_date a';
|
||||
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'htl_branch_info hbi ON (hbi.id = a.id_hotel)';
|
||||
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
|
||||
$this->access_where = ' WHERE hbi.id IN ('.implode(',', $acsHtls).')';
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hb ON (a.`id_hotel` = hb.`id`)';
|
||||
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.`id_hotel` = hb.`id`)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl
|
||||
ON (hb.`id` = hbl.`id` AND hbl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = ad.`id_state`)';
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'country_lang` cl
|
||||
ON (cl.`id_country` = ad.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_select = 's.`name` as `state_name`, cl.`name` as country_name, hbl.`hotel_name`, ad.`city`, ';
|
||||
$this->fields_options = array(
|
||||
'orderrestrict' => array(
|
||||
'title' => $this->l('Order Restriction Setting'),
|
||||
'fields' => array(
|
||||
'MAX_GLOBAL_BOOKING_DATE' => array(
|
||||
'title' => $this->l('Maximum Global Date To Book a room'),
|
||||
'type' => 'text',
|
||||
'id' => 'max_global_book_date',
|
||||
'hint' => $this->l('Maximum date by which rooms of your hotels can be booked.'),
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save')),
|
||||
),
|
||||
);
|
||||
$this->fields_list = array(
|
||||
'id' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'hotel_name' => array(
|
||||
'title' => $this->l('Hotel Name'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'city' => array(
|
||||
'title' => $this->l('City'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'state_name' => array(
|
||||
'title' => $this->l('State'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 's!name',
|
||||
),
|
||||
'country_name' => array(
|
||||
'title' => $this->l('Country'),
|
||||
'align' => 'center',
|
||||
'filter_key' => 'cl!name',
|
||||
),
|
||||
'max_order_date' => array(
|
||||
'title' => $this->l('Maximum Booking Date'),
|
||||
'align' => 'center',
|
||||
'type' => 'date',
|
||||
),
|
||||
);
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'icon' => 'icon-trash',
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
$this->page_header_toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Add new Date'),
|
||||
);
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if ($this->display == 'add') {
|
||||
$order_restrict_date = new HotelOrderRestrictDate();
|
||||
$hotels_list = $order_restrict_date->getUnsavedHotelsForOrderRestrict();
|
||||
// filter hotels as per accessed hotels
|
||||
$hotels_list = HotelBranchInformation::filterDataByHotelAccess(
|
||||
$hotels_list,
|
||||
$this->context->employee->id_profile,
|
||||
1
|
||||
);
|
||||
$this->context->smarty->assign('hotels_list', $hotels_list);
|
||||
} elseif ($this->display == 'edit') {
|
||||
$id = Tools::getValue('id');
|
||||
$obj_order_restrict = new HotelOrderRestrictDate($id);
|
||||
$hotel_info_obj = new HotelBranchInformation(
|
||||
$obj_order_restrict->id_hotel,
|
||||
(int)$this->context->language->id
|
||||
);
|
||||
$ordr_restrict_data['hotel_name'] = $hotel_info_obj->hotel_name;
|
||||
$ordr_restrict_data['id_hotel'] = $obj_order_restrict->id_hotel;
|
||||
$ordr_restrict_data['max_date'] = date('d-m-Y', strtotime($obj_order_restrict->max_order_date));
|
||||
$ordr_restrict_data['hidden_max_date'] = date('Y-m-d', strtotime($obj_order_restrict->max_order_date));
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'ordr_restrict_hotel_data' => $ordr_restrict_data,
|
||||
'id' => $id,
|
||||
'edit' => 1
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->fields_form = array(
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function processSave()
|
||||
{
|
||||
$id = Tools::getValue('id');
|
||||
$hotel_id = Tools::getValue('hotel_id');
|
||||
$max_htl_book_date = Tools::getValue('max_htl_book_date');
|
||||
if (!$hotel_id) {
|
||||
$this->errors[] = $this->l('Please Select a Hotel.');
|
||||
}
|
||||
if (!$max_htl_book_date) {
|
||||
$this->errors[] = $this->l('Please select maximum order date of booking.');
|
||||
} else {
|
||||
$max_htl_book_date = date('Y-m-d', strtotime($max_htl_book_date));
|
||||
if (!Validate::isDate($max_htl_book_date)) {
|
||||
$this->errors[] = $this->l('Enter a valid date.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$obj_order_restrict = new HotelOrderRestrictDate();
|
||||
$ordr_restrict_data = $obj_order_restrict->getDataByHotelId($hotel_id);
|
||||
if (isset($ordr_restrict_data['id']) && $ordr_restrict_data['id']) {
|
||||
$obj_order_restrict = new HotelOrderRestrictDate($ordr_restrict_data['id']);
|
||||
}
|
||||
|
||||
$obj_order_restrict->id_hotel = $hotel_id;
|
||||
$obj_order_restrict->max_order_date = $max_htl_book_date;
|
||||
$obj_order_restrict->save();
|
||||
$new_id = $obj_order_restrict->id;
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
if (isset($new_id) && $new_id) {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&id='.(int) $new_id.'&update'.$this->table.'&conf=4&token='.$this->token
|
||||
);
|
||||
} else {
|
||||
Tools::redirectAdmin(
|
||||
self::$currentIndex.'&add'.$this->table.'&conf=4&token='.$this->token
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminOrderRestrictSettings').'&conf=4');
|
||||
}
|
||||
} else {
|
||||
$this->display = 'add';
|
||||
}
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitOptionshtl_order_restrict_date')) {
|
||||
$max_global_date = Tools::getValue('MAX_GLOBAL_BOOKING_DATE');
|
||||
$max_global_date_frm = date('Y-m-d', strtotime($max_global_date));
|
||||
if (!Validate::isDate($max_global_date_frm)) {
|
||||
$this->errors[] = $this->l('Enter a valid date.');
|
||||
} else if (strtotime(date('Y-m-d')) > strtotime($max_global_date_frm)) {
|
||||
$this->errors[] = $this->l('Maximum Global Date can not be before current date.');
|
||||
}
|
||||
if (!count($this->errors)) {
|
||||
parent::postProcess();
|
||||
}
|
||||
} else {
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
|
||||
$this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,6 @@ class HotelReservationSystem extends Module
|
||||
);
|
||||
|
||||
// Controllers without tabs
|
||||
$this->installTab('AdminOrderRestrictSettings', 'Order Restrict Configuration', false, false);
|
||||
$this->installTab('AdminHotelGeneralSettings', 'Hotel General configuration', false, false);
|
||||
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', false, false);
|
||||
$this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', false, false);
|
||||
|
||||
@@ -109,7 +109,7 @@ var GoogleMapsManager = {
|
||||
that.autocomplete.addListener('place_changed', function() {
|
||||
that.clearAllMarkers();
|
||||
var place = that.autocomplete.getPlace();
|
||||
|
||||
|
||||
if (place.geometry.viewport) {
|
||||
that.map.fitBounds(place.geometry.viewport);
|
||||
} else {
|
||||
@@ -136,7 +136,7 @@ var GoogleMapsManager = {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(cb && typeof cb === 'function') {
|
||||
cb();
|
||||
}
|
||||
@@ -903,7 +903,7 @@ $(document).ready(function() {
|
||||
|
||||
//$( "#max_global_book_date" ).datepicker( "option", "maxDate", '20 Mar 2020');
|
||||
/*END*/
|
||||
|
||||
|
||||
/* ---- AdminHotelFeaturePricesSettingsController Admin ---- */
|
||||
|
||||
$('#date_selection_type').on('change', function() {
|
||||
@@ -1159,6 +1159,29 @@ $(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 () {
|
||||
if (parseInt($(this).val())) {
|
||||
$('input[name="maximum_booking_date"]').closest('.form-group').hide(200);
|
||||
} else {
|
||||
$('input[name="maximum_booking_date"]').closest('.form-group').show(200);
|
||||
}
|
||||
});
|
||||
|
||||
$('input[name="enable_use_global_preparation_time"]').on('change', function () {
|
||||
if (parseInt($(this).val())) {
|
||||
$('input[name="preparation_time"]').closest('.form-group').hide(200);
|
||||
} else {
|
||||
$('input[name="preparation_time"]').closest('.form-group').show(200);
|
||||
}
|
||||
});
|
||||
|
||||
initGoogleMaps();
|
||||
});
|
||||
|
||||
|
||||
@@ -68,6 +68,12 @@
|
||||
{l s='Images' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#hotel-booking-restrictions" data-toggle="tab">
|
||||
<i class="icon-lock"></i>
|
||||
{l s='Restrictions' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#hotel-refund-policies" data-toggle="tab">
|
||||
<i class="icon-file"></i>
|
||||
@@ -353,6 +359,57 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="tab-pane" id="hotel-booking-restrictions">
|
||||
{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>
|
||||
</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'}</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'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
</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 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($smarty.post.maximum_booking_date)}{$smarty.post.maximum_booking_date|escape:'html':'UTF-8'}{elseif isset($edit) && isset($order_restrict_date_info.max_order_date)}{$order_restrict_date_info.max_order_date|escape:'htmlall':'UTF-8'}{/if}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">
|
||||
<span>{l s='Use Global preparation time :' 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_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'}</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'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
</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='Preparation time :' 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}" />
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<div class="alert alert-warning">
|
||||
{l s='Please save the hotel information before saving the hotel booking restrictions.' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="tab-pane" id="hotel-refund-policies">
|
||||
{if isset($hotel_info.id) && $hotel_info.id}
|
||||
<div class="form-group">
|
||||
|
||||
@@ -10,15 +10,6 @@
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$order_restrict_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
<span class="col-sm-2 col-xs-2"><i class="icon-list-alt"></i></span>
|
||||
<span class="setting-title col-sm-10 col-xs-10">{l s='Order Restrict' mod='hotelreservationsystem'}</span>
|
||||
</a>
|
||||
<a tabindex="0" class="btn btn-default col-sm-2 col-xs-2" role="button" data-toggle="popover" data-trigger="focus" title="{l s='Order Restrict Settings' mod='hotelreservationsystem'}" data-content="{l s='Configure if you want to restrict orders till a specific date for your hotels.' mod='hotelreservationsystem'}" data-placement="bottom">
|
||||
<i class="icon-question-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Setting to set prices for date range -->
|
||||
<div class="btn-group setting-link-div col-sm-3 col-xs-12">
|
||||
<a type="button" href="{$feature_price_setting_link}" class="setting-link btn btn-default col-sm-10 col-xs-10">
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
{if isset($edit)}
|
||||
<i class='icon-pencil'></i> {l s='Edit Order Restrict Date' mod='hotelreservationsystem'}
|
||||
{else}
|
||||
<i class='icon-plus'></i> {l s='Add New Order Restrict Date' mod='hotelreservationsystem'}
|
||||
{/if}
|
||||
</div>
|
||||
<form id="{$table|escape:'htmlall':'UTF-8'}_form" class="defaultForm form-horizontal" action="{$current|escape:'htmlall':'UTF-8'}&{if !empty($submit_action)}{$submit_action|escape:'htmlall':'UTF-8'}{/if}&token={$token|escape:'htmlall':'UTF-8'}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
{if isset($edit)}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3 required">{l s='Hotel Name :' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-sm-6">
|
||||
<p class="form-control-static">{$ordr_restrict_hotel_data['hotel_name']}</p>
|
||||
<input type="hidden" class="form-control" name="hotel_id" value="{$ordr_restrict_hotel_data['id_hotel']}" />
|
||||
</div>
|
||||
</div>
|
||||
{else}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3 required" for="resticted_hotel_id">{l s='Select Hotel :' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-sm-6">
|
||||
<div style="width: 195px;">
|
||||
<select class="form-control" name="hotel_id" id="resticted_hotel_id" value="">
|
||||
<option value='0' selected>{l s='Select Hotel' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotels_list) && $hotels_list}
|
||||
{foreach $hotels_list as $list}
|
||||
<option value="{$list['id']}">{$list['hotel_name']}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label required" for="max_htl_book_date">
|
||||
{l s='Maximun date For Booking :' mod='hotelreservationsystem'}
|
||||
</label>
|
||||
<div class="col-sm-2">
|
||||
<input autocomplete="off" type="text" class="form-control" id="max_htl_book_date" name="max_htl_book_date" {if isset($ordr_restrict_hotel_data['max_date']) && $ordr_restrict_hotel_data['max_date']}value="{$ordr_restrict_hotel_data['max_date']}"{/if} readonly/>
|
||||
<input autocomplete="off" type="hidden" class="form-control" id="max_htl_book_date_hidden" name="max_htl_book_date_hidden" {if isset($ordr_restrict_hotel_data['max_date']) && $ordr_restrict_hotel_data['hidden_max_date']}value="{$ordr_restrict_hotel_data['hidden_max_date']}"{/if}/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<a href="{$link->getAdminLink('AdminOrderRestrictSettings')|escape:'html':'UTF-8'}" class="btn btn-default">
|
||||
<i class="process-icon-cancel"></i>{l s='Cancel' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
<button type="submit" name="submitAdd{$table|escape:'html':'UTF-8'}" class="btn btn-default pull-right">
|
||||
<i class="process-icon-save"></i> {l s='Save' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
<button type="submit" name="submitAdd{$table|escape:'html':'UTF-8'}AndStay" class="btn btn-default pull-right">
|
||||
<i class="process-icon-save"></i> {l s='Save and stay' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../../../');
|
||||
exit;
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../../../');
|
||||
exit;
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 2010-2020 Webkul.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* All right is reserved,
|
||||
* Please go through this link for complete license : https://store.webkul.com/license.html
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to newer
|
||||
* versions in the future. If you wish to customize this module for your
|
||||
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
|
||||
*
|
||||
* @author Webkul IN <support@webkul.com>
|
||||
* @copyright 2010-2020 Webkul IN
|
||||
* @license https://store.webkul.com/license.html
|
||||
*/
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../../../');
|
||||
exit;
|
||||
@@ -137,6 +137,7 @@ class WkRoomSearchHelper
|
||||
foreach ($hotelsInfo as &$hotel) {
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel['id']);
|
||||
$hotel['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
|
||||
$hotel['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($hotel['id']);
|
||||
}
|
||||
$smartyVars['location_enabled'] = $locationEnabled;
|
||||
$smartyVars['total_active_hotels'] = $totalActiveHotels;
|
||||
@@ -145,6 +146,7 @@ class WkRoomSearchHelper
|
||||
|
||||
$maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
|
||||
$smartyVars['max_order_date'] = date('Y-m-d', strtotime($maxOrderDate));
|
||||
$smartyVars['preparation_time'] = (int) HotelOrderRestrictDate::getPreparationTime($idHotel);
|
||||
|
||||
Context::getContext()->smarty->assign($smartyVars);
|
||||
}
|
||||
|
||||
@@ -73,9 +73,10 @@ $(document).ready(function() {
|
||||
selectedDate.setDate(selectedDate.getDate()+1);
|
||||
$("#check_out_time").datepicker("option", "minDate", selectedDate);
|
||||
} else {
|
||||
$('#preparation_time').val()
|
||||
var date_format = new Date();
|
||||
var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date()));
|
||||
selectedDate.setDate(selectedDate.getDate()+1);
|
||||
selectedDate.setDate(selectedDate.getDate()+1 + parseInt($('#preparation_time').val()));
|
||||
$("#check_out_time").datepicker("option", "minDate", selectedDate);
|
||||
}
|
||||
}
|
||||
@@ -277,6 +278,20 @@ $(document).ready(function() {
|
||||
$("#check_in_time").datepicker("option", "maxDate", max_date_from);
|
||||
$("#check_out_time").datepicker("option", "maxDate", max_date_to);
|
||||
$("#max_order_date").val(max_order_date);
|
||||
let preparation_time = $(this).attr('data-preparation_time')
|
||||
let preparation_time_date = new Date();
|
||||
preparation_time_date.setDate(preparation_time_date.getDate() + parseInt(preparation_time));
|
||||
preparation_time_date.setHours(0, 0, 0, 0);
|
||||
if($("#check_in_time").datepicker("getDate") < preparation_time_date) {
|
||||
$("#check_in_time").val('');
|
||||
}
|
||||
preparation_time_date.setDate(preparation_time_date.getDate() + 1);
|
||||
if($("#check_out_time").datepicker("getDate") < preparation_time_date) {
|
||||
$("#check_out_time").val('');
|
||||
}
|
||||
$("#check_in_time").datepicker("option", "minDate", parseInt(preparation_time));
|
||||
$("#check_out_time").datepicker("option", "minDate", parseInt(preparation_time) + 1);
|
||||
$('#preparation_time').val(preparation_time);
|
||||
$('#id_hotel').val($(this).attr('data-id-hotel'));
|
||||
$('#hotel_cat_id').val($(this).attr('data-hotel-cat-id'));
|
||||
$('#hotel_cat_name').html($(this).html());
|
||||
@@ -298,6 +313,12 @@ $(document).ready(function() {
|
||||
$("#check_out_time").datepicker("option", "maxDate", max_date_to);
|
||||
}
|
||||
|
||||
var preparation_time = $('#preparation_time').val();
|
||||
if (preparation_time != '') {
|
||||
$("#check_in_time").datepicker("option", "minDate", parseInt(preparation_time));
|
||||
$("#check_out_time").datepicker("option", "minDate", parseInt(preparation_time) + 1);
|
||||
}
|
||||
|
||||
// validations on the submit of the search fields
|
||||
$('#search_room_submit').on('click', function(e) {
|
||||
var check_in_time = $("#check_in_time").val();
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
<div class="form-group {if count($hotels_info) <= 1 && !$show_hotel_name} hidden {/if}">
|
||||
{if !$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="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="text" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
|
||||
@@ -42,6 +43,7 @@
|
||||
{if isset($hotels_info) && count($hotels_info)}
|
||||
<div class="dropdown">
|
||||
<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="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|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}">
|
||||
|
||||
@@ -55,7 +57,7 @@
|
||||
<ul class="dropdown-menu hotel_dropdown_ul">
|
||||
{if isset($hotels_info) && $hotels_info}
|
||||
{foreach $hotels_info as $name_val}
|
||||
<li tabindex="-1" class="search_result_li" 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']}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
<li tabindex="-1" class="search_result_li" 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'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
@@ -51,12 +51,14 @@
|
||||
<input type="hidden" name="is_hotel_rooms_search" value="1">
|
||||
{if !$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="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="text" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
|
||||
{else}
|
||||
{if isset($hotels_info) && count($hotels_info)}
|
||||
<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}">
|
||||
<div class="dropdown">
|
||||
<input type="hidden" id="hotel_cat_id" name="hotel_cat_id">
|
||||
<input type="hidden" id="id_hotel" name="id_hotel">
|
||||
@@ -66,7 +68,7 @@
|
||||
<ul class="dropdown-menu hotel_dropdown_ul">
|
||||
{if isset($hotels_info) && $hotels_info}
|
||||
{foreach $hotels_info as $name_val}
|
||||
<li class="search_result_li" 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']|escape:'htmlall':'UTF-8'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
<li class="search_result_li" 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']|escape:'htmlall':'UTF-8'}" data-preparation_time="{$name_val['preparation_time']|escape:'htmlall':'UTF-8'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<div class="form-group wk-padding-5 {if isset($location_enabled) && $location_enabled}col-md-5{/if} col-sm-6 {if count($hotels_info) <= 1 && !$show_hotel_name} hidden {/if}">
|
||||
{if !$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="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="text" id="htl_name" class="form-control header-rmsearch-input" value="{$hotels_info[0]['hotel_name']}" readonly>
|
||||
@@ -72,6 +73,7 @@
|
||||
{if isset($hotels_info) && count($hotels_info)}
|
||||
<div class="dropdown">
|
||||
<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="preparation_time" name="preparation_time" value="{if isset($preparation_time)}{$preparation_time|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}">
|
||||
|
||||
@@ -85,7 +87,7 @@
|
||||
<ul class="dropdown-menu hotel_dropdown_ul">
|
||||
{if isset($hotels_info) && $hotels_info}
|
||||
{foreach $hotels_info as $name_val}
|
||||
<li tabindex="-1" class="search_result_li" 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']}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
<li tabindex="-1" class="search_result_li" 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'}">{$name_val['hotel_name']|escape:'htmlall':'UTF-8'}</li>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
@@ -1081,22 +1081,6 @@ $(document).ready(function() {
|
||||
BookingForm.refresh();
|
||||
});
|
||||
|
||||
/*Set maxDate for Order resrict date*/
|
||||
if (max_order_date) {
|
||||
var max_date_from = new Date(max_order_date);
|
||||
max_date_from.setDate(max_date_from.getDate() - 1);
|
||||
var max_date_to = new Date(max_order_date);
|
||||
if($("#room_check_in").datepicker("getDate") > max_date_from) {
|
||||
$("#room_check_in").val('');
|
||||
}
|
||||
if($("#room_check_out").datepicker("getDate") > max_date_to) {
|
||||
$("#room_check_out").val('');
|
||||
}
|
||||
$("#room_check_in").datepicker("option", "maxDate", max_date_from);
|
||||
$("#room_check_out").datepicker("option", "maxDate", max_date_to);
|
||||
}
|
||||
|
||||
|
||||
// Accordian for extra demand
|
||||
function close_accordion_section() {
|
||||
$('.accordion .accordion-section-title').removeClass('active');
|
||||
@@ -1161,7 +1145,7 @@ var BookingForm = {
|
||||
$("#room_check_in").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'dd-mm-yy',
|
||||
minDate: 0,
|
||||
minDate: preparation_time,
|
||||
beforeShow: function (input, instance) {
|
||||
// So that on translating page date is translated to NaN-NaN-NaN
|
||||
$('.ui-datepicker').addClass('notranslate');
|
||||
@@ -1196,6 +1180,7 @@ var BookingForm = {
|
||||
$("#room_check_out").datepicker({
|
||||
showOtherMonths: true,
|
||||
dateFormat: 'dd-mm-yy',
|
||||
minDate: preparation_time + 1,
|
||||
beforeShow: function (input, instance) {
|
||||
// So that on translating page date is translated to NaN-NaN-NaN
|
||||
$('.ui-datepicker').addClass('notranslate');
|
||||
@@ -1230,6 +1215,21 @@ var BookingForm = {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// set max order date
|
||||
if (max_order_date) {
|
||||
var maxDateFrom = new Date(max_order_date);
|
||||
maxDateFrom.setDate(maxDateFrom.getDate() - 1);
|
||||
var maxDateTo = new Date(max_order_date);
|
||||
if($('#room_check_in').datepicker('getDate') > maxDateFrom) {
|
||||
$('#room_check_in').val('');
|
||||
}
|
||||
if($('#room_check_out').datepicker('getDate') > maxDateTo) {
|
||||
$('#room_check_out').val('');
|
||||
}
|
||||
$('#room_check_in').datepicker('option', 'maxDate', maxDateFrom);
|
||||
$('#room_check_out').datepicker('option', 'maxDate', maxDateTo);
|
||||
}
|
||||
},
|
||||
getFormData: function () {
|
||||
var quantity = parseInt($('#quantity_wanted').val());
|
||||
|
||||
@@ -636,6 +636,7 @@
|
||||
{strip}
|
||||
{* By webkul variable needed in product.js *}
|
||||
{addJsDef max_order_date = $max_order_date}
|
||||
{addJsDef preparation_time = $preparation_time}
|
||||
{addJsDef booking_date_to = $date_to}
|
||||
{addJsDef booking_date_from = $date_from}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user