From 4eb25bf1a5a0d35ebeb74a3e93a4e553ad49e3c0 Mon Sep 17 00:00:00 2001 From: lakshya chauhan Date: Mon, 1 Aug 2022 20:18:17 +0530 Subject: [PATCH 1/2] added minimum length of stay --- .../controllers/products/lengthofstay.tpl | 284 +++++++++++++ .../admin/AdminPPreferencesController.php | 8 + controllers/admin/AdminProductsController.php | 142 ++++++- .../classes/HotelBookingDetail.php | 35 +- .../classes/HotelRoomType.php | 15 +- .../HotelRoomTypeRestrictionDateRange.php | 202 ++++++++++ modules/hotelreservationsystem/define.php | 3 +- modules/hotelreservationsystem/install.sql | 377 ++++++++++++++++++ 8 files changed, 1058 insertions(+), 8 deletions(-) create mode 100644 admin/themes/default/template/controllers/products/lengthofstay.tpl create mode 100644 modules/hotelreservationsystem/classes/HotelRoomTypeRestrictionDateRange.php create mode 100644 modules/hotelreservationsystem/install.sql diff --git a/admin/themes/default/template/controllers/products/lengthofstay.tpl b/admin/themes/default/template/controllers/products/lengthofstay.tpl new file mode 100644 index 000000000..3e0541b04 --- /dev/null +++ b/admin/themes/default/template/controllers/products/lengthofstay.tpl @@ -0,0 +1,284 @@ +{if isset($product->id)} +
+

{l s='Length Of Stay'}

+ + +
+
+ {l s='Please read below important points regarding length of stay management'} +
    +
  • {l s='Set 1 day for setting no limit on Minimum length of stay'}
  • +
  • {l s='Set 0 day for setting no limit on Maximum length of stay'}
  • +
  • {l s='Enable "Length of stay for date ranges" for setting values of \"Minimum length of stay\" and \"Maximum length of stay\" according to different date ranges'}
  • +
  • {l s='Length of stays (minimum|maximum) of all the dates which does not fall under the date ranges of \"Length of stay for date ranges\", will be taken from the global values of length of stays of this room type.'}
  • +
  • {l s='\"Date to\" will not be included in the date range of \"Length of stay for date ranges\".'}
  • +
+
+ +
+ +
+
+ + {l s='Day(s)'} +
+
+
+ +
+ +
+
+ + {l s='Day(s)'} +
+
+
+
+ +
+ +
+ + + + + + + + + +
+
+ +
+ + + + + + + + + + {if isset($smarty.post.active_restriction_dates) && $smarty.post.active_restriction_dates && isset($smarty.post.restriction_date_from) && $smarty.post.restriction_date_from} + {assign var="restrictionDataRange" value=[]} + {foreach from=$smarty.post.restriction_date_from item=restrictionDateFromVal key=restrictionKey} + {assign var="restrictionDataRangeTemp" value=['date_from' => $restrictionDateFromVal, 'date_to' => $smarty.post.restriction_date_to[$restrictionKey], 'min_los' => $smarty.post.restriction_min_los[$restrictionKey], 'max_los' => $smarty.post.restriction_max_los[$restrictionKey]]} + + {if isset($smarty.post.id_rt_restriction) && isset($smarty.post.id_rt_restriction[$restrictionKey])} + {$restrictionDataRangeTemp['id_rt_restriction'] = $smarty.post.id_rt_restriction[$restrictionKey]} + {/if} + + {$restrictionDataRange[] = $restrictionDataRangeTemp} + {/foreach} + {elseif isset($roomTypeInfo['restrictionDataRange']) && $roomTypeInfo['restrictionDataRange']} + {assign var="restrictionDataRange" value=$roomTypeInfo['restrictionDataRange']} + {else} + {assign var="restrictionDataRange" value=[['date_from' => '', 'date_to' => '', 'min_los' => '', 'max_los' => '']]} + {/if} + + {foreach from=$restrictionDataRange item=restrictionInfo} + + + + + + + + {/foreach} + +
{l s='Date From'}{l s='Date To'}{l s='Minimum length of stay'}{l s='Maximum length of stay'}
+
+ + +
+
+
+ + +
+
+
+ + {l s='day(s)'} +
+
+
+ + {l s='day(s)'} +
+
+ {if isset($restrictionInfo['id_rt_restriction'])} + + {/if} + +
+ +
+ + +
+{/if} + + \ No newline at end of file diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 1dc360f64..bbca0b75c 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -108,6 +108,14 @@ class AdminPPreferencesControllerCore extends AdminController 'cast' => 'intval', 'required' => false, 'type' => 'bool' + ), + 'PS_LOS_RESTRICTION_BO' => array( + 'title' => $this->l('Apply Min and Max lenght of stay restrictions for back-office bookings'), + 'hint' => $this->l('While creating bookings from back-office, apply minimum and maximum lenght of stay restrictions'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'required' => false, + 'type' => 'bool' ) ), 'submit' => array('title' => $this->l('Save')) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 8a558d516..d5e8515bc 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -112,6 +112,7 @@ class AdminProductsControllerCore extends AdminController 'Warehouses' => $this->l('Warehouses'), 'Configuration' => $this->l('Configuration'), 'Occupancy' => $this->l('Occupancy'), + 'LengthOfStay' => $this->l('Length of Stay'), 'Booking' => $this->l('Booking Information'), ); @@ -133,7 +134,8 @@ class AdminProductsControllerCore extends AdminController //'Suppliers' => 13, 'Configuration' => 14, 'Occupancy' => 15, - 'Booking' => 16, + 'LengthOfStay' => 16, + 'Booking' => 17, )); } @@ -2223,6 +2225,9 @@ class AdminProductsControllerCore extends AdminController if ($this->isTabSubmitted('Occupancy')) { $this->processOccupancy(); } + if ($this->isTabSubmitted('LengthOfStay')) { + $this->processLengthOfStay(); + } if ($this->isTabSubmitted('Configuration')) { $this->processConfiguration(); } @@ -3487,6 +3492,141 @@ class AdminProductsControllerCore extends AdminController } } + // send information for the length of stay tab + public function initFormLengthOfStay($product) + { + $data = $this->createTemplate($this->tpl_form); + if ($product->id) { + if ($this->product_exists_in_shop) { + // Check if any hotel is created or not + $objRoomType = new HotelRoomType(); + if ($roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($product->id)) { + if ($roomTypeInfo['id_hotel']) { + // send length of stay date ranges for this room type + $objRoomTypeRestrictionDates = new HotelRoomTypeRestrictionDateRange(); + $roomTypeInfo['restrictionDataRange'] = $objRoomTypeRestrictionDates->getRoomTypeLengthOfStayRestriction($product->id); + $smartyVars['roomTypeInfo'] = $roomTypeInfo; + } else { + $this->displayWarning($this->l('No hotel is attached to this room type.')); + } + } else { + $this->displayWarning($this->l('Room type information is missing.')); + } + } else { + $this->displayWarning($this->l('You must save room type before managing length of stay.')); + } + } else { + $this->displayWarning($this->l('You must save room type before managing length of stay.')); + } + + $smartyVars['product'] = $product; + $data->assign($smartyVars); + $this->tpl_form_vars['custom_form'] = $data->fetch(); + } + + public function processLengthOfStay() + { + if ($this->tabAccess['edit'] == 1) { + + $idProduct = Tools::getValue('id_product'); + if (Validate::isLoadedObject($product = new Product((int)$idProduct))) { + $objRoomType = new HotelRoomType(); + if ($roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($idProduct)) { + $roomTypeMinLos = Tools::getValue('min_los'); + $roomTypeMaxLos = Tools::getValue('max_los'); + + // validate length of stay global values for room type + if (!$roomTypeMinLos || $roomTypeMinLos == null) { + $this->errors[] = Tools::displayError('Global minimum length of stay is a required field.'); + } elseif (!Validate::isUnsignedInt($roomTypeMinLos)) { + $this->errors[] = Tools::displayError('Global minimum length of stay value is invalid. Please enter integer value. Set 1 day incase of setting no limit on global minimum length of stay.'); + } + + if ($roomTypeMaxLos == null) { + $this->errors[] = Tools::displayError('Global maximum length of stay is a required field.'); + } elseif (!Validate::isUnsignedInt($roomTypeMaxLos)) { + $this->errors[] = Tools::displayError('Invalid value entered for global maximum length of stay field. Please enter integer value. Set 0 day incase of setting no limit on maximum length of stay.'); + } elseif ($roomTypeMinLos && $roomTypeMaxLos > 0 && ($roomTypeMinLos > $roomTypeMaxLos)) { + $this->errors[] = Tools::displayError('Value of global maximum length of stay must be greater than global minimum length of stay.'); + } + + if (Tools::getValue('active_restriction_dates')) { + if (Tools::getValue('restriction_date_from') && Tools::getValue('restriction_date_to')) { + $objRoomTypeRestrictDateRange = new HotelRoomTypeRestrictionDateRange(); + $dateFromRestriction = Tools::getValue('restriction_date_from'); + $dateToRestriction = Tools::getValue('restriction_date_to'); + $minLosDays = Tools::getValue('restriction_min_los'); + $maxLosDays = Tools::getValue('restriction_max_los'); + + $this->errors = array_merge($this->errors, $objRoomTypeRestrictDateRange->validateRoomTypeLengthOfStayRestriction($dateFromRestriction, $dateToRestriction, $minLosDays, $maxLosDays)); + } else { + $this->errors[] = Tools::displayError('Please add at least one Minimum & maximum length of stay restriction for date range if \'Length of stay for date ranges\' option is enable.'); + } + } + + if (!$this->errors) { + $objRoomType = new HotelRoomType($roomTypeInfo['id']); + $objRoomType->min_los = $roomTypeMinLos; + $objRoomType->max_los = $roomTypeMaxLos; + if ($objRoomType->save()) { + if (Tools::getValue('active_restriction_dates') && Tools::getValue('restriction_date_from')) { + // @ToDo: we should validate this room type restriction ids belongs to this room type + $idRoomTypeRestriction = Tools::getValue('id_rt_restriction'); + + foreach ($dateFromRestriction as $restrictionKey => $dateFrom) { + // change into database compatible format + $dateFrom = date('Y-m-d', strtotime($dateFrom)); + $dateTo = date('Y-m-d', strtotime($dateToRestriction[$restrictionKey])); + + if ($idRoomTypeRestriction[$restrictionKey]) { + $objRoomTypeRestrictDateRange = new HotelRoomTypeRestrictionDateRange($idRoomTypeRestriction[$restrictionKey]); + } else { + $objRoomTypeRestrictDateRange = new HotelRoomTypeRestrictionDateRange(); + } + + $objRoomTypeRestrictDateRange->id_product = $idProduct; + $objRoomTypeRestrictDateRange->date_from = $dateFrom; + $objRoomTypeRestrictDateRange->date_to = $dateTo; + $objRoomTypeRestrictDateRange->min_los = $minLosDays[$restrictionKey]; + $objRoomTypeRestrictDateRange->max_los = $maxLosDays[$restrictionKey]; + $objRoomTypeRestrictDateRange->save(); + } + } else { + // if disabled length of stay for date ranges then delete all previously saved + $objRoomTypeRestrictDateRange = new HotelRoomTypeRestrictionDateRange(); + if ($losRestrictions = $objRoomTypeRestrictDateRange->getRoomTypeLengthOfStayRestriction($idProduct)) { + foreach ($losRestrictions as $losDate) { + $objRoomTypeRestrictDateRange = new HotelRoomTypeRestrictionDateRange($losDate['id_rt_restriction']); + $objRoomTypeRestrictDateRange->delete(); + } + } + } + } else { + $this->errors[] = Tools::displayError('Something went wrong while saving global minimum & maximum length of stay values. Please try again !!'); + } + } + } + } + } else { + $this->errors[] = Tools::displayError('You do not have the right permission.'); + } + } + + // delete the rows of length of stay on date range + public function ajaxProcessDeleteRoomTypeLengthOfStayRestriction() + { + if ($this->tabAccess['edit'] == 1) { + $objRoomTypeRestrictionDates = new HotelRoomTypeRestrictionDateRange(Tools::getValue('id_rt_restriction')); + if ($objRoomTypeRestrictionDates->delete()) { + die(json_encode(array('success' => $this->l('Successfully deleted')))); + } else { + die(json_encode(array('error' => $this->l('Something went wrong. Please reload the page and try again !!')))); + } + } else { + die(json_encode(array('error' => $this->l('You do not have the right permission')))); + } + } + public function validateDisableDateRanges($disableDates) { if (count($disableDates)) { diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 0eb8610cd..557434661 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -225,6 +225,7 @@ class HotelBookingDetail extends ObjectModel */ public function getBookingData($params) { + $this->context = Context::getContext(); // extract all keys and values of the array [$params] into variables and values extract($this->getBookingDataParams($params)); if ($date_from && $date_to && $hotel_id) { @@ -248,12 +249,19 @@ class HotelBookingDetail extends ObjectModel $num_cart = 0; $new_part_arr = array(); $booking_data = array(); + $applyLosRestriction = true; if ($search_partial) { $this->partAvaiDates = array(); $this->allReqDates = $this->createDateRangeArray($date_from, $date_to, 1); } + if (isset(Context::getContext()->employee->id)) { + if (!Configuration::get('PS_LOS_RESTRICTION_BO')) { + $applyLosRestriction = false; + } + } + foreach ($room_types as $key => $room_type) { if ($search_partial) { $this->dltDates = array(); @@ -261,6 +269,10 @@ class HotelBookingDetail extends ObjectModel $total_rooms += $obj_room_info->getHotelRoomInfo($room_type['id_product'], $hotel_id, 1); + // Get min & max LOS + $objRoomTypeRestriction = new HotelRoomTypeRestrictionDateRange(); + $losRestriction = $objRoomTypeRestriction->getRoomTypeLengthOfStay($room_type['id_product'], $date_from); + $obj_product = new Product((int) $room_type['id_product']); $product_name = $obj_product->name[Configuration::get('PS_LANG_DEFAULT')]; @@ -309,7 +321,15 @@ class HotelBookingDetail extends ObjectModel if ($search_unavai) { $sql1 = 'SELECT `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment` FROM `'._DB_PREFIX_.'htl_room_information` - WHERE `id_hotel`='.(int)$hotel_id.' AND `id_product` ='.(int)$room_type['id_product'].' AND `id_status` = '. HotelRoomInformation::STATUS_INACTIVE; + WHERE `id_hotel`='.(int)$hotel_id.' AND `id_product` ='.(int)$room_type['id_product'].' AND (`id_status` = '. HotelRoomInformation::STATUS_INACTIVE; + if ($applyLosRestriction) { + $sql1 .= ' OR ( DATEDIFF(\''.$date_to.'\', \''.$date_from.'\') < '.(int)$losRestriction['min_los']; + if ((int)$losRestriction['max_los']) { + $sql1 .= ' OR DATEDIFF(\''.$date_to.'\', \''.$date_from.'\') > '.(int)$losRestriction['max_los']; + } + $sql1 .= ')'; + } + $sql1 .= ')'; $sql2 = 'SELECT hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` FROM `'._DB_PREFIX_.'htl_room_information` AS hri @@ -357,7 +377,18 @@ class HotelBookingDetail extends ObjectModel $joinAvailRoomSearch = ''; - $whereAvailRoomSearch = 'WHERE ri.`id_hotel`='.(int)$hotel_id.' AND ri.`id_product`='.(int)$room_type['id_product'].' AND ri.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE .' AND ri.`id` NOT IN ('.$exclude_ids.')'; + $whereAvailRoomSearch = 'WHERE ri.`id_hotel`='.(int)$hotel_id.' AND ri.`id_product`='.(int)$room_type['id_product'].' AND ri.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE; + + // Check min & max LOS restrictions + if ($applyLosRestriction) { + $whereAvailRoomSearch .= ' AND DATEDIFF(\''.$date_to.'\', \''.$date_from.'\') >= '.(int)$losRestriction['min_los']; + // check max LOS restriction is greater than zero + if ((int)$losRestriction['max_los']) { + $whereAvailRoomSearch .= ' AND DATEDIFF(\''.$date_to.'\', \''.$date_from.'\') <= '.(int)$losRestriction['max_los']; + } + } + + $whereAvailRoomSearch .= ' AND ri.`id` NOT IN ('.$exclude_ids.')'; $groupByAvailRoomSearch = ''; $orderByAvailRoomSearch = ''; diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index dc070b202..49cde494f 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -25,6 +25,8 @@ class HotelRoomType extends ObjectModel public $id_hotel; public $adult; public $children; + public $min_los; + public $max_los; public $date_add; public $date_upd; @@ -36,6 +38,8 @@ class HotelRoomType extends ObjectModel 'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'adult' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'children' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), + 'min_los' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'default' => 1), + 'max_los' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'default' => 0), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), @@ -211,14 +215,17 @@ class HotelRoomType extends ObjectModel * * @return [array|false] [If data found returns array containing information of the room type else returns false] */ - public function getRoomTypeInfoByIdProduct($id_product) + public function getRoomTypeInfoByIdProduct($id_product, $idLang = false) { - $idLang = Context::getContext()->language->id; - $sql = 'SELECT hrt.`id`,hrt.`id_hotel`, hrt.`adult`, hrt.`children`, hbl.`hotel_name` + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + $sql = 'SELECT hrt.`id`,hrt.`id_hotel`, hrt.`adult`, hrt.`children`, hbl.`hotel_name`, hrt.`min_los`, hrt.`max_los` FROM `'._DB_PREFIX_.'htl_room_type` AS hrt INNER JOIN `'._DB_PREFIX_.'htl_branch_info_lang` AS hbl ON (hbl.`id` = hrt.`id_hotel` AND hbl.`id_lang` = '.(int)$idLang.') - WHERE `id_product` = '.(int)$id_product; + WHERE hrt.`id_product` = '.(int)$id_product; return Db::getInstance()->getRow($sql); } diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeRestrictionDateRange.php b/modules/hotelreservationsystem/classes/HotelRoomTypeRestrictionDateRange.php new file mode 100644 index 000000000..1d8806597 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeRestrictionDateRange.php @@ -0,0 +1,202 @@ + +* @copyright 2010-2021 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class HotelRoomTypeRestrictionDateRange extends ObjectModel +{ + public $id_rt_restriction; + public $id_product; + public $min_los; + public $max_los; + public $date_from; + public $date_to; + public $date_add; + public $date_upd; + + const WK_ROOM_TYPE_MIN_LOS = 1; + const WK_ROOM_TYPE_MAX_LOS = 2; + + public static $definition = array( + 'table' => 'htl_room_type_restriction_date_range', + 'primary' => 'id_rt_restriction', + 'fields' => array( + 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), + 'min_los' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true, 'default' => 1), + 'max_los' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true, 'default' => 0), + 'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate') + ), + ); + + protected $webserviceParameters = array( + 'objectMethods' => array( + 'add' => 'addWs', + 'update' => 'updateWs', + 'delete' => 'deleteWs', + ), + 'objectsNodeName' => 'restriction_date_ranges', + 'objectNodeName' => 'restriction_date_range', + 'fields' => array( + 'id_product' => array( + 'xlink_resource' => array( + 'resourceName' => 'room_types', + ) + ), + ), + ); + + public function getRoomTypeLengthOfStayRestriction($idRoomType) + { + $sql = 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_restriction_date_range` WHERE `id_product` = '.(int)$idRoomType; + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); + } + + public function getRoomTypeLengthOfStay($idRoomType, $date = false, $losRestrictionType = false) + { + $losRestriction = array(); + + // if date is given the return LOS for date range + if ($date) { + $date = date('Y-m-d', strtotime($date)); + + $sql = 'SELECT `min_los`, `max_los` + FROM `'._DB_PREFIX_.'htl_room_type_restriction_date_range` + WHERE `id_product` = '.(int) $idRoomType.' AND `date_from` <= \''.pSQL($date).'\' AND `date_to` > \''.pSQL($date).'\''; + + $losRestriction = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); + } + + // if no LOS for date range the find it for room type + if (!$losRestriction) { + $sql = 'SELECT `min_los`, `max_los` + FROM `'._DB_PREFIX_.'htl_room_type` + WHERE `id_product` = '.(int) $idRoomType; + + $losRestriction = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); + } + + if ($losRestriction) { + if ($losRestrictionType) { + if ($losRestrictionType == self::WK_ROOM_TYPE_MIN_LOS) { + return $losRestriction['min_los']; + } elseif ($losRestrictionType == self::WK_ROOM_TYPE_MAX_LOS) { + return $losRestriction['max_los']; + } + } + + return $losRestriction; + } + + return false; + } + + public function validateRoomTypeLengthOfStayRestriction($dateFromRestriction, $dateToRestriction, $minLosDays, $maxLosDays) + { + $errors = array(); + $objModule = Module::getinstanceByName('hotelreservationsystem'); + foreach ($dateFromRestriction as $dateFromKey => $dateFrom) { + $dateTo = $dateToRestriction[$dateFromKey]; + $minDay = $minLosDays[$dateFromKey]; + $maxDay = $maxLosDays[$dateFromKey]; + + // validate the fields before saving in the table + if (!$minDay) { + $errors[] = $objModule->l('Minimum length of stay is required.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } elseif (!Validate::isUnsignedInt($minDay)) { + $errors[] = $objModule->l('Minimum length of stay is invalid.', 'HotelRoomTypeLosDateRanges').' + [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } + + if ($maxDay == null) { + $errors[] = $objModule->l('Maximum length of stay is required.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } elseif (!Validate::isUnsignedInt($maxDay)) { + $errors[] = $objModule->l('Maximum length of stay is invalid.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } elseif ($minDay && $maxDay > 0 && ($minDay > $maxDay)) { + $this->errors[] = Tools::displayError('Value of global maximum length of stay must be greater than global minimum length of stay.'); + } + + if (!$dateFrom || $dateFrom == '') { + $errors[] = $objModule->l('Date from is required.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } else { + $dateFrom = date('Y-m-d', strtotime($dateFrom)); + if (!Validate::isDate($dateFrom)) { + $errors[] = $objModule->l('Date from is invalid.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } + } + + if (!$dateTo || $dateTo == '') { + $errors[] = $objModule->l('Date to is required.', 'HotelRoomTypeLosDateRanges').' + [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } else { + $dateTo = date('Y-m-d', strtotime($dateTo)); + if (!Validate::isDate($dateTo)) { + $errors[] = $objModule->l('Date to is invalid.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } elseif (strtotime($dateTo) <= strtotime($dateFrom)) { + $errors[] = $dateFrom.' and '.$dateTo . $objModule->l('\'Date to\' must be a greater than \'date from\'.', 'HotelRoomTypeLosDateRanges'). + ' [ '.$objModule->l('LOS for date range in row no.', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).' ]'; + } else { + // validate date ranges from other date ranges + foreach ($dateToRestriction as $dateToKey => $newDateTo) { + if ($dateFromKey > $dateToKey) { + if (!((strtotime($dateFrom) < strtotime($dateFromRestriction[$dateToKey]) && strtotime($dateTo) <= strtotime($dateFromRestriction[$dateToKey])) || (strtotime($dateFrom) >= strtotime($newDateTo) && strtotime($dateTo) > strtotime($newDateTo)))) { + $errors[] = $objModule->l('Date ranges are conflicting with each other.', 'HotelRoomTypeLosDateRanges').' [ '.$objModule->l('Conflicting rows are', 'HotelRoomTypeLosDateRanges').' : '.($dateFromKey+1).', '.($dateToKey+1).' ]'; + } + } + } + } + } + } + + return $errors; + } + + // Webservice :: webservice add function + public function addWs($autodate = true, $null_values = false) + { + $objRoomType = new HotelRoomType(); + if ($roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($this->id_product)) { + return $this->add($autodate, $null_values); + } + return false; + } + + // Webservice :: webservice update function + public function updateWs($null_values = false) + { + $objRoomType = new HotelRoomType(); + if ($roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($this->id_product)) { + return $this->update($null_values); + } + return false; + } + + // Webservice :: webservice delete function + public function deleteWs() + { + return $this->delete(); + } +} diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index ad5b54880..d3fa42701 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -40,6 +40,7 @@ require_once 'classes/HotelRoomTypeGlobalDemand.php'; require_once 'classes/HotelRoomTypeGlobalDemandAdvanceOption.php'; require_once 'classes/HotelRoomTypeDemandPrice.php'; require_once 'classes/HotelRoomTypeDemand.php'; +require_once 'classes/HotelRoomTypeRestrictionDateRange.php'; require_once 'classes/QloWebservice.php'; require_once 'classes/QloRoomType.php'; @@ -48,4 +49,4 @@ require_once 'classes/HotelBranchRefundRules.php'; // Web services classes require_once 'classes/WebserviceSpecificManagementQlo.php'; -require_once 'classes/WebserviceSpecificManagementHotelImages.php'; \ No newline at end of file +require_once 'classes/WebserviceSpecificManagementHotelImages.php'; diff --git a/modules/hotelreservationsystem/install.sql b/modules/hotelreservationsystem/install.sql new file mode 100644 index 000000000..f0606449c --- /dev/null +++ b/modules/hotelreservationsystem/install.sql @@ -0,0 +1,377 @@ +/** +* 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 +* @copyright 2010-2020 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `id_hotel` int(11) NOT NULL, + `adult` smallint(6) NOT NULL, + `children` smallint(6) NOT NULL, + `min_los` smallint(6) NOT NULL DEFAULT '1', + `max_los` smallint(6) NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_information` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `id_hotel` int(11) NOT NULL, + `room_num` varchar(225) NOT NULL, + `id_status` int(11) NOT NULL, + `floor` text NOT NULL, + `comment` text NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info` ( + `id` int(10) unsigned NOT NULL auto_increment, + `id_category` int(10) unsigned NOT NULL, + `phone` varchar(32) DEFAULT NULL, + `email` varchar(128) NOT NULL, + `check_in` varchar(255) DEFAULT NULL, + `check_out` varchar(255) DEFAULT NULL, + `rating` int(2) unsigned NOT NULL, + `city` varchar(64) NOT NULL, + `state_id` int(10) unsigned NOT NULL, + `country_id` int(10) unsigned NOT NULL, + `zipcode` varchar(12) NOT NULL, + `address` text DEFAULT NULL, + `active` tinyint(1) unsigned NOT NULL DEFAULT '0', + `latitude` decimal(10,8) NOT NULL, + `longitude` decimal(11,8) NOT NULL, + `map_formated_address` text NOT NULL, + `map_input_text` text NOT NULL, + `active_refund` tinyint(1) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info_lang` ( + `id` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `hotel_name` varchar(255) DEFAULT NULL, + `short_description` text, + `description` text, + `policies` text, + PRIMARY KEY (`id`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_image` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_hotel` int(10) unsigned NOT NULL, + `hotel_image_id` varchar(32) NOT NULL, + `cover` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_features` ( + `id` int(10) unsigned NOT NULL auto_increment, + `id_hotel` int(10) unsigned NOT NULL, + `feature_id` varchar(255) DEFAULT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_features` ( + `id` int(10) unsigned NOT NULL auto_increment, + `parent_feature_id` int(10) unsigned NOT NULL, + `position` int(10) unsigned NOT NULL, + `active` int(2) NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_features_lang` ( + `id` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_cart_booking_data` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_cart` int(11) NOT NULL, + `id_guest` int(11) NOT NULL, + `id_order` int(11) NOT NULL, + `id_customer` int(11) NOT NULL, + `id_currency` int(11) NOT NULL, + `id_product` int(11) NOT NULL, + `id_room` int(11) NOT NULL, + `id_hotel` int(11) NOT NULL, + `quantity` int(11) NOT NULL, + `booking_type` tinyint(4) NOT NULL, + `comment` text NOT NULL, + `is_back_order` tinyint(4) NOT NULL, + `extra_demands` text NOT NULL, + `date_from` datetime NOT NULL, + `date_to` datetime NOT NULL, + `is_refunded` tinyint(1) NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_detail` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `id_order` int(11) NOT NULL, + `id_order_detail` int(11) NOT NULL, + `id_cart` int(11) NOT NULL, + `id_room` int(11) NOT NULL, + `id_hotel` int(11) NOT NULL, + `id_customer` int(11) NOT NULL, + `booking_type` tinyint(4) NOT NULL, + `id_status` int(11) NOT NULL, + `comment` text NOT NULL, + `check_in` datetime NOT NULL, + `check_out` datetime NOT NULL, + `date_from` datetime NOT NULL, + `date_to` datetime NOT NULL, + `total_price_tax_excl` decimal(20,6) NOT NULL, + `total_price_tax_incl` decimal(20,6) NOT NULL, + `total_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.000000', + `is_back_order` tinyint(4) NOT NULL, + `hotel_name` varchar(255) DEFAULT NULL, + `room_type_name` varchar(255) DEFAULT NULL, + `city` varchar(255) NOT NULL, + `state` varchar(255) DEFAULT NULL, + `country` varchar(255) DEFAULT NULL, + `zipcode` varchar(12) DEFAULT NULL, + `phone` varchar(32) DEFAULT NULL, + `email` varchar(128) DEFAULT NULL, + `check_in_time` varchar(32) DEFAULT NULL, + `check_out_time` varchar(32) DEFAULT NULL, + `room_num` varchar(225) DEFAULT NULL, + `adult` smallint(6) NOT NULL DEFAULT '0', + `children` smallint(6) NOT NULL DEFAULT '0', + `is_refunded` tinyint(1) NOT NULL DEFAULT '0', + -- `available_for_order` tinyint(1) NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands` ( + `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, + `id_htl_booking` int(11) NOT NULL, + `name` varchar(255) character set utf8 NOT NULL, + `unit_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', + `unit_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', + `total_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', + `total_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', + `price_calc_method` int(11) unsigned DEFAULT '0', + `id_tax_rules_group` int(11) unsigned DEFAULT '0', + `tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_booking_demand`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands_tax` ( + `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, + `id_tax` int(11) NOT NULL, + `unit_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', + `total_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', + PRIMARY KEY (`id_booking_demand`, `id_tax`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_status` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `status` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_allotment_type` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `type` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_advance_payment` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `payment_type` tinyint(4) NOT NULL, + `value` decimal(20,6) NOT NULL, + `id_currency` int(11) NOT NULL, + `tax_include` tinyint(4) NOT NULL, + `calculate_from` tinyint(4) NOT NULL, + `active` tinyint(4) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules` ( + `id_refund_rule` int(11) NOT NULL AUTO_INCREMENT, + `payment_type` int(2) unsigned NOT NULL, + `deduction_value_full_pay` decimal(20,6) NOT NULL, + `deduction_value_adv_pay` decimal(20,6) NOT NULL, + `days` decimal(35,0) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_refund_rule`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules_lang` ( + `id_refund_rule` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `name` varchar(255) DEFAULT NULL, + `description` text, + PRIMARY KEY (`id_refund_rule`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_refund_rules` ( + `id_hotel_refund_rule` int(11) NOT NULL AUTO_INCREMENT, + `id_refund_rule` int(10) unsigned NOT NULL, + `id_hotel` int(10) unsigned NOT NULL, + `position` int(10) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_hotel_refund_rule`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_restrict_date` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_hotel` int(11) NOT NULL, + `max_order_date` datetime NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing` ( + `id_feature_price` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `date_from` date NOT NULL, + `date_to` date NOT NULL, + `is_special_days_exists` tinyint(1) NOT NULL, + `date_selection_type` tinyint(1) NOT NULL, + `special_days` text, + `impact_way` tinyint(1) NOT NULL, + `impact_type` tinyint(1) NOT NULL, + `impact_value` decimal(20,6) NOT NULL DEFAULT '0.000000', + `active` tinyint(1) unsigned NOT NULL DEFAULT '0', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_feature_price`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing_lang` ( + `id_feature_price` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `feature_price_name` varchar(255) character set utf8 NOT NULL, + PRIMARY KEY (`id_feature_price`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE `PREFIX_htl_room_type_feature_pricing_group` ( + `id_feature_price` int(10) unsigned NOT NULL, + `id_group` int(10) unsigned NOT NULL, + PRIMARY KEY (`id_feature_price`,`id_group`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand` ( + `id_global_demand` int(11) NOT NULL AUTO_INCREMENT, + `price` decimal(20,6) NOT NULL DEFAULT '0.000000', + `id_tax_rules_group` int(10) unsigned NOT NULL DEFAULT '0', + `price_calc_method` tinyint(1) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_global_demand`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_lang` ( + `id_global_demand` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `name` varchar(255) character set utf8 NOT NULL, + PRIMARY KEY (`id_global_demand`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option` ( + `id_option` int(11) NOT NULL AUTO_INCREMENT, + `id_global_demand` int(11) NOT NULL, + `price` decimal(20,6) NOT NULL DEFAULT '0.000000', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_option`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option_lang` ( + `id_option` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `name` varchar(255) character set utf8 NOT NULL, + PRIMARY KEY (`id_option`, `id_lang`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand_price` ( + `id_room_type_demand_price` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(10) unsigned NOT NULL, + `id_global_demand` int(10) unsigned NOT NULL, + `id_option` int(10) unsigned NOT NULL, + `price` decimal(20,6) NOT NULL DEFAULT '0.000000', + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_room_type_demand_price`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand` ( + `id_room_type_demand` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(10) unsigned NOT NULL, + `id_global_demand` int(10) unsigned NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_room_type_demand`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_disable_dates` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `id_room_type` int(11) NOT NULL, + `id_room` int(11) NOT NULL, + `date_from` date NOT NULL, + `date_to` date NOT NULL, + `reason` text, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_restriction_date_range` ( + `id_rt_restriction` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `min_los` smallint(6) unsigned NOT NULL DEFAULT '1', + `max_los` smallint(6) unsigned NOT NULL DEFAULT '0', + `date_from` date NOT NULL, + `date_to` date NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_rt_restriction`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `PREFIX_htl_access` ( + `id_profile` int(10) unsigned NOT NULL, + `id_hotel` int(10) unsigned NOT NULL, + `access` int(11) NOT NULL, + PRIMARY KEY (`id_profile`, `id_hotel`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; From f33e7cbcb83e91405ac25550d82e01a7b3405241 Mon Sep 17 00:00:00 2001 From: lakshya chauhan Date: Mon, 1 Aug 2022 21:47:02 +0530 Subject: [PATCH 2/2] update sql file --- .../classes/HotelReservationSystemDb.php | 15 + modules/hotelreservationsystem/install.sql | 377 ------------------ 2 files changed, 15 insertions(+), 377 deletions(-) delete mode 100644 modules/hotelreservationsystem/install.sql diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 4ec8282c2..bb01c7229 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -29,6 +29,8 @@ class HotelReservationSystemDb `id_hotel` int(11) NOT NULL, `adult` smallint(6) NOT NULL, `children` smallint(6) NOT NULL, + `min_los` smallint(6) NOT NULL DEFAULT '1', + `max_los` smallint(6) NOT NULL DEFAULT '0', `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id`) @@ -355,6 +357,18 @@ class HotelReservationSystemDb PRIMARY KEY (`id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_restriction_date_range` ( + `id_rt_restriction` int(11) NOT NULL AUTO_INCREMENT, + `id_product` int(11) NOT NULL, + `min_los` smallint(6) unsigned NOT NULL DEFAULT '1', + `max_los` smallint(6) unsigned NOT NULL DEFAULT '0', + `date_from` date NOT NULL, + `date_to` date NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_rt_restriction`) + ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_access` ( `id_profile` int(10) unsigned NOT NULL, `id_hotel` int(10) unsigned NOT NULL, @@ -411,6 +425,7 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_room_type_demand_price`, `'._DB_PREFIX_.'htl_room_type_demand`, `'._DB_PREFIX_.'htl_room_disable_dates`, + `'._DB_PREFIX_.'htl_room_type_restriction_date_range`, `'._DB_PREFIX_.'htl_access`' ); } diff --git a/modules/hotelreservationsystem/install.sql b/modules/hotelreservationsystem/install.sql deleted file mode 100644 index f0606449c..000000000 --- a/modules/hotelreservationsystem/install.sql +++ /dev/null @@ -1,377 +0,0 @@ -/** -* 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 -* @copyright 2010-2020 Webkul IN -* @license https://store.webkul.com/license.html -*/ - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `adult` smallint(6) NOT NULL, - `children` smallint(6) NOT NULL, - `min_los` smallint(6) NOT NULL DEFAULT '1', - `max_los` smallint(6) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_information` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `room_num` varchar(225) NOT NULL, - `id_status` int(11) NOT NULL, - `floor` text NOT NULL, - `comment` text NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_category` int(10) unsigned NOT NULL, - `phone` varchar(32) DEFAULT NULL, - `email` varchar(128) NOT NULL, - `check_in` varchar(255) DEFAULT NULL, - `check_out` varchar(255) DEFAULT NULL, - `rating` int(2) unsigned NOT NULL, - `city` varchar(64) NOT NULL, - `state_id` int(10) unsigned NOT NULL, - `country_id` int(10) unsigned NOT NULL, - `zipcode` varchar(12) NOT NULL, - `address` text DEFAULT NULL, - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `latitude` decimal(10,8) NOT NULL, - `longitude` decimal(11,8) NOT NULL, - `map_formated_address` text NOT NULL, - `map_input_text` text NOT NULL, - `active_refund` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_info_lang` ( - `id` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `hotel_name` varchar(255) DEFAULT NULL, - `short_description` text, - `description` text, - `policies` text, - PRIMARY KEY (`id`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_image` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `id_hotel` int(10) unsigned NOT NULL, - `hotel_image_id` varchar(32) NOT NULL, - `cover` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_features` ( - `id` int(10) unsigned NOT NULL auto_increment, - `id_hotel` int(10) unsigned NOT NULL, - `feature_id` varchar(255) DEFAULT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features` ( - `id` int(10) unsigned NOT NULL auto_increment, - `parent_feature_id` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL, - `active` int(2) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_features_lang` ( - `id` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) NOT NULL, - PRIMARY KEY (`id`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_cart_booking_data` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_cart` int(11) NOT NULL, - `id_guest` int(11) NOT NULL, - `id_order` int(11) NOT NULL, - `id_customer` int(11) NOT NULL, - `id_currency` int(11) NOT NULL, - `id_product` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `quantity` int(11) NOT NULL, - `booking_type` tinyint(4) NOT NULL, - `comment` text NOT NULL, - `is_back_order` tinyint(4) NOT NULL, - `extra_demands` text NOT NULL, - `date_from` datetime NOT NULL, - `date_to` datetime NOT NULL, - `is_refunded` tinyint(1) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_detail` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `id_order` int(11) NOT NULL, - `id_order_detail` int(11) NOT NULL, - `id_cart` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `id_hotel` int(11) NOT NULL, - `id_customer` int(11) NOT NULL, - `booking_type` tinyint(4) NOT NULL, - `id_status` int(11) NOT NULL, - `comment` text NOT NULL, - `check_in` datetime NOT NULL, - `check_out` datetime NOT NULL, - `date_from` datetime NOT NULL, - `date_to` datetime NOT NULL, - `total_price_tax_excl` decimal(20,6) NOT NULL, - `total_price_tax_incl` decimal(20,6) NOT NULL, - `total_paid_amount` decimal(20,6) NOT NULL DEFAULT '0.000000', - `is_back_order` tinyint(4) NOT NULL, - `hotel_name` varchar(255) DEFAULT NULL, - `room_type_name` varchar(255) DEFAULT NULL, - `city` varchar(255) NOT NULL, - `state` varchar(255) DEFAULT NULL, - `country` varchar(255) DEFAULT NULL, - `zipcode` varchar(12) DEFAULT NULL, - `phone` varchar(32) DEFAULT NULL, - `email` varchar(128) DEFAULT NULL, - `check_in_time` varchar(32) DEFAULT NULL, - `check_out_time` varchar(32) DEFAULT NULL, - `room_num` varchar(225) DEFAULT NULL, - `adult` smallint(6) NOT NULL DEFAULT '0', - `children` smallint(6) NOT NULL DEFAULT '0', - `is_refunded` tinyint(1) NOT NULL DEFAULT '0', - -- `available_for_order` tinyint(1) NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands` ( - `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_htl_booking` int(11) NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - `unit_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `unit_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `total_price_tax_excl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `total_price_tax_incl` decimal(20,6) NOT NULL DEFAULT '0.000000', - `price_calc_method` int(11) unsigned DEFAULT '0', - `id_tax_rules_group` int(11) unsigned DEFAULT '0', - `tax_computation_method` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_booking_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_booking_demands_tax` ( - `id_booking_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_tax` int(11) NOT NULL, - `unit_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - `total_amount` DECIMAL(16, 6) NOT NULL DEFAULT '0.00', - PRIMARY KEY (`id_booking_demand`, `id_tax`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_status` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `status` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_allotment_type` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `type` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_advance_payment` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `payment_type` tinyint(4) NOT NULL, - `value` decimal(20,6) NOT NULL, - `id_currency` int(11) NOT NULL, - `tax_include` tinyint(4) NOT NULL, - `calculate_from` tinyint(4) NOT NULL, - `active` tinyint(4) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules` ( - `id_refund_rule` int(11) NOT NULL AUTO_INCREMENT, - `payment_type` int(2) unsigned NOT NULL, - `deduction_value_full_pay` decimal(20,6) NOT NULL, - `deduction_value_adv_pay` decimal(20,6) NOT NULL, - `days` decimal(35,0) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_refund_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_refund_rules_lang` ( - `id_refund_rule` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) DEFAULT NULL, - `description` text, - PRIMARY KEY (`id_refund_rule`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_branch_refund_rules` ( - `id_hotel_refund_rule` int(11) NOT NULL AUTO_INCREMENT, - `id_refund_rule` int(10) unsigned NOT NULL, - `id_hotel` int(10) unsigned NOT NULL, - `position` int(10) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_hotel_refund_rule`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_order_restrict_date` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_hotel` int(11) NOT NULL, - `max_order_date` datetime NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing` ( - `id_feature_price` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `date_from` date NOT NULL, - `date_to` date NOT NULL, - `is_special_days_exists` tinyint(1) NOT NULL, - `date_selection_type` tinyint(1) NOT NULL, - `special_days` text, - `impact_way` tinyint(1) NOT NULL, - `impact_type` tinyint(1) NOT NULL, - `impact_value` decimal(20,6) NOT NULL DEFAULT '0.000000', - `active` tinyint(1) unsigned NOT NULL DEFAULT '0', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_feature_price`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_feature_pricing_lang` ( - `id_feature_price` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `feature_price_name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_feature_price`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE `PREFIX_htl_room_type_feature_pricing_group` ( - `id_feature_price` int(10) unsigned NOT NULL, - `id_group` int(10) unsigned NOT NULL, - PRIMARY KEY (`id_feature_price`,`id_group`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand` ( - `id_global_demand` int(11) NOT NULL AUTO_INCREMENT, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `id_tax_rules_group` int(10) unsigned NOT NULL DEFAULT '0', - `price_calc_method` tinyint(1) NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_global_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_lang` ( - `id_global_demand` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_global_demand`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option` ( - `id_option` int(11) NOT NULL AUTO_INCREMENT, - `id_global_demand` int(11) NOT NULL, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_option`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_global_demand_advance_option_lang` ( - `id_option` int(10) unsigned NOT NULL, - `id_lang` int(10) unsigned NOT NULL, - `name` varchar(255) character set utf8 NOT NULL, - PRIMARY KEY (`id_option`, `id_lang`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand_price` ( - `id_room_type_demand_price` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(10) unsigned NOT NULL, - `id_global_demand` int(10) unsigned NOT NULL, - `id_option` int(10) unsigned NOT NULL, - `price` decimal(20,6) NOT NULL DEFAULT '0.000000', - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_room_type_demand_price`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_demand` ( - `id_room_type_demand` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(10) unsigned NOT NULL, - `id_global_demand` int(10) unsigned NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_room_type_demand`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_disable_dates` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `id_room_type` int(11) NOT NULL, - `id_room` int(11) NOT NULL, - `date_from` date NOT NULL, - `date_to` date NOT NULL, - `reason` text, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_room_type_restriction_date_range` ( - `id_rt_restriction` int(11) NOT NULL AUTO_INCREMENT, - `id_product` int(11) NOT NULL, - `min_los` smallint(6) unsigned NOT NULL DEFAULT '1', - `max_los` smallint(6) unsigned NOT NULL DEFAULT '0', - `date_from` date NOT NULL, - `date_to` date NOT NULL, - `date_add` datetime NOT NULL, - `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_rt_restriction`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - -CREATE TABLE IF NOT EXISTS `PREFIX_htl_access` ( - `id_profile` int(10) unsigned NOT NULL, - `id_hotel` int(10) unsigned NOT NULL, - `access` int(11) NOT NULL, - PRIMARY KEY (`id_profile`, `id_hotel`) -) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;