From e37b8be5ac1ff00ac93248492e78fd48efce53db Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 7 Jun 2024 17:13:59 +0530 Subject: [PATCH 01/13] Added: Hooks in all room search function queries --- .../classes/HotelBookingDetail.php | 212 +++++++++++++----- 1 file changed, 161 insertions(+), 51 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 047e1de46..207c67d0e 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -292,32 +292,34 @@ class HotelBookingDetail extends ObjectModel // Unavailable Rooms if ($search_unavai) { - $params = array( + $searchParams = array( 'idHotel' => $hotel_id, 'dateFrom' => $date_from, 'dateTo' => $date_to, 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'applyLosRestriction' => $applyLosRestriction, + 'extra_params' => $params, ); - $unavailRoomTypes = $this->getSearchUnavailableRooms($params); + $unavailRoomTypes = $this->getSearchUnavailableRooms($searchParams); } // Cart Rooms if ($search_cart_rms) { - $params = array( + $searchParams = array( 'idHotel' => $hotel_id, 'idCart' => $id_cart, 'idGuest' => $id_guest, 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, + 'extra_params' => $params, ); - $cartRoomTypes = $this->getSearchCartRooms($params); + $cartRoomTypes = $this->getSearchCartRooms($searchParams); } // Available Rooms if ($search_available) { - $params = array( + $searchParams = array( 'idHotel' => $hotel_id, 'dateFrom' => $date_from, 'dateTo' => $date_to, @@ -327,8 +329,9 @@ class HotelBookingDetail extends ObjectModel 'searchOccupancy' => $occupancy, 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'applyLosRestriction' => $applyLosRestriction, + 'extra_params' => $params, ); - $availableRoomTypes = $this->getSearchAvailableRooms($params); + $availableRoomTypes = $this->getSearchAvailableRooms($searchParams); if ($availableRoomTypes['unavailableRoomTypes'] && $search_unavai) { foreach ($availableRoomTypes['unavailableRoomTypes'] as $idProduct => $roomTypeDetail) { if (!isset($unavailRoomTypes[$idProduct])) { @@ -345,19 +348,20 @@ class HotelBookingDetail extends ObjectModel // Booked Rooms if ($search_booked) { - $params = array( + $searchParams = array( 'idHotel' => $hotel_id, 'dateFrom' => $date_from, 'dateTo' => $date_to, 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, + 'extra_params' => $params, ); - $bookedRoomTypes = $this->getSearchBookedRooms($params); + $bookedRoomTypes = $this->getSearchBookedRooms($searchParams); } // Partially available Rooms if ($search_partial) { - $params = array( + $searchParams = array( 'idHotel' => $hotel_id, 'dateFrom' => $date_from, 'dateTo' => $date_to, @@ -366,9 +370,10 @@ class HotelBookingDetail extends ObjectModel 'idRoomType' => $id_room_type, 'searchOccupancy' => $occupancy, 'allowedIdRoomTypes' => $allowedIdRoomTypes, + 'extra_params' => $params, ); - $partiallyAvailRoomTypes = $this->getSearchPartiallyAvailRooms($params); + $partiallyAvailRoomTypes = $this->getSearchPartiallyAvailRooms($searchParams); if ($partiallyAvailRoomTypes['unavailableRoomTypes'] && $search_unavai) { foreach ($partiallyAvailRoomTypes['unavailableRoomTypes'] as $idProduct => $roomTypeDetail) { @@ -501,28 +506,42 @@ class HotelBookingDetail extends ObjectModel $stayStartDate = date('Y-m-d', strtotime($dateFrom)); // Room status inactive - $sql1 = 'SELECT `id` AS `id_room`, `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment` + $sql = array(); + $sql[] = 'SELECT `id` AS `id_room`, `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment` FROM `'._DB_PREFIX_.'htl_room_information` WHERE `id_hotel`='.(int)$idHotel.' AND `id_status` = '. HotelRoomInformation::STATUS_INACTIVE.' AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; // check room is temperory inactive - $sql2 = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` + $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd. id_room = hri.`id`) WHERE hri.`id_hotel`='.$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND hrdd.`date_from` <= \''.pSql($dateFrom).'\' AND hrdd.`date_to` >= \''.pSql($dateTo).'\' AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; - $sql = $sql1.' UNION '.$sql2; if ($applyLosRestriction) { - $sql3 = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` + $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_restriction_date_range` AS hrtr ON (hrt.`id_product` = hrtr.`id_product` AND (hrtr.`date_from` <= \''.pSQL($stayStartDate).'\' AND hrtr.`date_to` > \''.pSQL($stayStartDate).'\')) WHERE hri.`id_hotel`='.(int)$idHotel.' AND (IFNULL(hrtr.`min_los`, hrt.`min_los`) >'. (int)$lengthOfStay.' OR IF(IFNULL(hrtr.`max_los`, hrt.`max_los`) > 0, IFNULL(hrtr.`max_los`, hrt.`max_los`) < '.(int)$lengthOfStay.', 0)) AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; - $sql = $sql.' UNION '.$sql3; } + $hookParams = array( + 'sql' => &$sql, + 'params' => array( + 'id_hotel' => $idHotel, + 'id_product' => $idRoomType, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); + if (isset($extra_params)) { + $hookParams['params']['extra_params'] = $extra_params; + } + Hook::exec('actionUnavailRoomSearchSqlModifier', $hookParams); + + $sql = implode(' UNION ', $sql); $sql .= ' ORDER BY id_room ASC'; $unavailRoomTypes = array(); @@ -550,10 +569,43 @@ class HotelBookingDetail extends ObjectModel $cartRoomTypes = array(); if ($idCart && $idGuest) { - $sql = 'SELECT cbd.`id_product`, cbd.`id_room`, cbd.`id_hotel`, cbd.`booking_type`, cbd.`comment`, rf.`room_num`, cbd.`date_from`, cbd.`date_to` - FROM `'._DB_PREFIX_.'htl_cart_booking_data` AS cbd - INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = cbd.`id_room`) - WHERE cbd.`id_hotel`= '.(int)$idHotel.' AND cbd.`id_cart` = '.(int)$idCart.' AND cbd.`id_guest` ='.(int)$idGuest.' AND cbd.`is_refunded` = 0 AND cbd.`is_back_order` = 0 AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` IN ('.$allowedIdRoomTypes.')'; + $selectCartRoomSearch = 'SELECT cbd.`id_product`, cbd.`id_room`, cbd.`id_hotel`, cbd.`booking_type`, + cbd.`comment`, rf.`room_num`, cbd.`date_from`, cbd.`date_to`'; + $joinCartRoomSearch = 'INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = cbd.`id_room`)'; + $whereCartRoomSearch = 'WHERE cbd.`id_hotel`= '.(int)$idHotel.' AND cbd.`id_cart` = '.(int)$idCart.' + AND cbd.`id_guest` ='.(int)$idGuest.' AND cbd.`is_refunded` = 0 AND cbd.`is_back_order` = 0 + AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` + IN ('.$allowedIdRoomTypes.')'; + $groupByCartRoomSearch = ''; + $orderByCartRoomSearch = ''; + $orderWayCartRoomSearch = ''; + + $hookParams = array( + 'select' => $selectCartRoomSearch, + 'join' => &$joinCartRoomSearch, + 'where' => &$whereCartRoomSearch, + 'group_by' => &$groupByCartRoomSearch, + 'order_by' => &$orderByCartRoomSearch, + 'order_way' => &$orderWayCartRoomSearch, + 'params' => array( + 'id_hotel' => $idHotel, + 'id_product' => $idRoomType, + 'idCart' => $idCart, + 'idGuest' => $idGuest, + ) + ); + if (isset($extra_params)) { + $hookParams['params']['extra_params'] = $extra_params; + } + Hook::exec('actionCartRoomSearchSqlModifier', $hookParams); + + $sql = $selectCartRoomSearch; + $sql .= ' FROM `'._DB_PREFIX_.'htl_cart_booking_data` AS cbd'; + $sql .= ' '.$joinCartRoomSearch; + $sql .= ' '.$whereCartRoomSearch; + $sql .= ' '.$groupByCartRoomSearch; + $sql .= ' '.$orderByCartRoomSearch; + $sql .= ' '.$orderWayCartRoomSearch; if ($cartRooms = Db::getInstance()->executeS($sql)) { foreach ($cartRooms as $cartRoomDetail) { @@ -606,7 +658,8 @@ class HotelBookingDetail extends ObjectModel } // Exculde Booked rooms - $exclude_ids = 'SELECT `id_room` + $exclude_ids = array(); + $exclude_ids['checked_out'] = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_hotel` = '.(int)$idHotel.' AND `is_back_order` = 0 AND `is_refunded` = 0 AND IF(`id_status` = '. self::STATUS_CHECKED_OUT.', ( (DATE_FORMAT(`check_out`, "%Y-%m-%d") > \''.pSQL($dateFrom).'\' AND DATE_FORMAT(`check_out`, "%Y-%m-%d") <= \''.PSQL($dateTo).'\') AND ( @@ -624,16 +677,14 @@ class HotelBookingDetail extends ObjectModel // We have removed cart rooms after finally getting available rooms from booking // Exclude temporary disable rooms - $exclude_ids .= ' UNION - SELECT hri.`id` AS id_room + $exclude_ids['disabled'] = 'SELECT hri.`id` AS id_room FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd.`id_room` = hri.`id`) WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (hrdd.`date_from` < \''.pSql($dateTo).'\' AND hrdd.`date_to` > \''.pSql($dateFrom).'\') AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; // LOS Restriction. Also, Remember to check max LOS restriction is greater than zero if ($applyLosRestriction) { - $exclude_ids .= ' UNION - SELECT hri.`id` AS `id_room` + $exclude_ids['length_of_stay'] = 'SELECT hri.`id` AS `id_room` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_restriction_date_range` AS hrtr ON (hrt.`id_product` = hrtr.`id_product` AND (hrtr.`date_from` <= \''.pSQL($stayStartDate).'\' AND hrtr.`date_to` > \''.pSQL($stayStartDate).'\')) @@ -644,33 +695,37 @@ class HotelBookingDetail extends ObjectModel $joinAvailRoomSearch = 'INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = ri.`id_product`)'; - $whereAvailRoomSearch = 'WHERE ri.`id_hotel`='.(int)$idHotel.' AND ri.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE.' AND ri.`id` NOT IN ('.$exclude_ids.') AND IF('.(int)$idRoomType.' > 0, ri.`id_product` = '.(int)$idRoomType.', 1) AND ri.`id_product` IN ('.$allowedIdRoomTypes.')'; + $whereAvailRoomSearch = 'WHERE ri.`id_hotel`='.(int)$idHotel.' AND ri.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE.' AND IF('.(int)$idRoomType.' > 0, ri.`id_product` = '.(int)$idRoomType.', 1) AND ri.`id_product` IN ('.$allowedIdRoomTypes.')'; $groupByAvailRoomSearch = ''; $orderByAvailRoomSearch = 'ORDER BY ri.`id`'; $orderWayAvailRoomSearch = 'ASC'; - Hook::exec('actionAvailRoomSearchSqlModifier', - array( - 'select' => $selectAvailRoomSearch, - 'join' => &$joinAvailRoomSearch, - 'where' => &$whereAvailRoomSearch, - 'group_by' => &$groupByAvailRoomSearch, - 'order_by' => &$orderByAvailRoomSearch, - 'order_way' => &$orderWayAvailRoomSearch, - 'params' => array( - 'id_hotel' => $idHotel, - 'id_product' => $idRoomType, - 'date_from' => $dateFrom, - 'date_to' => $dateTo - ) + $hookParams = array( + 'select' => $selectAvailRoomSearch, + 'join' => &$joinAvailRoomSearch, + 'where' => &$whereAvailRoomSearch, + 'exclude_ids' => &$exclude_ids, + 'group_by' => &$groupByAvailRoomSearch, + 'order_by' => &$orderByAvailRoomSearch, + 'order_way' => &$orderWayAvailRoomSearch, + 'params' => array( + 'id_hotel' => $idHotel, + 'id_product' => $idRoomType, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, ) ); + if (isset($extra_params)) { + $hookParams['params']['extra_params'] = $extra_params; + } + Hook::exec('actionAvailRoomSearchSqlModifier', $hookParams); $sql = $selectAvailRoomSearch; $sql .= ' FROM `'._DB_PREFIX_.'htl_room_information` AS ri'; $sql .= ' '.$joinAvailRoomSearch; $sql .= ' '.$whereAvailRoomSearch; + $sql .= ' AND ri.`id` NOT IN ('.implode(' UNION ', $exclude_ids).')'; $sql .= ' '.$groupByAvailRoomSearch; $sql .= ' '.$orderByAvailRoomSearch; $sql .= ' '.$orderWayAvailRoomSearch; @@ -921,7 +976,8 @@ class HotelBookingDetail extends ObjectModel { extract($params); - $sql1 = 'SELECT bd.`id_product`, bd.`id_room`, bd.`id_hotel`, bd.`id_customer`, bd.`booking_type`, bd.`id_status` AS booking_status, bd.`comment` AS `room_comment`, rf.`room_num`, bd.`date_from`, IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', bd.`check_out`, bd.`date_to`) AS `date_to`, hrt.`max_adults` AS `max_adult`, hrt.`max_children`, hrt.`max_guests` AS `max_occupancy` + $sql = array(); + $sql[] = 'SELECT bd.`id_product`, bd.`id_room`, bd.`id_hotel`, bd.`id_customer`, bd.`booking_type`, bd.`id_status` AS booking_status, bd.`comment` AS `room_comment`, rf.`room_num`, bd.`date_from`, IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', bd.`check_out`, bd.`date_to`) AS `date_to`, hrt.`max_adults` AS `max_adult`, hrt.`max_children`, hrt.`max_guests` AS `max_occupancy` FROM `'._DB_PREFIX_.'htl_booking_detail` AS bd INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = bd.`id_room`) INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = rf.`id_product`) @@ -937,7 +993,7 @@ class HotelBookingDetail extends ObjectModel (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`date_to` < \''.pSQL($dateTo).'\') )) AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` IN ('.$allowedIdRoomTypes.')'; - $sql2 = 'SELECT hri.`id_product`, hrdd.`id_room`, hri.`id_hotel`, 0 AS `id_customer`, 0 AS `booking_type`, 0 AS `booking_status`, 0 AS `room_comment`, hri.`room_num`, hrdd.`date_from`, hrdd.`date_to`, hrt.`max_adults` AS `max_adult`, hrt.`max_children`, hrt.`max_guests` AS `max_occupancy` + $sql[] = 'SELECT hri.`id_product`, hrdd.`id_room`, hri.`id_hotel`, 0 AS `id_customer`, 0 AS `booking_type`, 0 AS `booking_status`, 0 AS `room_comment`, hri.`room_num`, hrdd.`date_from`, hrdd.`date_to`, hrt.`max_adults` AS `max_adult`, hrt.`max_children`, hrt.`max_guests` AS `max_occupancy` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`) INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd.`id_room` = hri.`id`) @@ -947,7 +1003,23 @@ class HotelBookingDetail extends ObjectModel (hrdd.`date_from` > \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` < \''.pSQL($dateTo).'\') ) AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; - $sql = $sql1.' UNION '.$sql2.' ORDER BY id_room ASC'; + $hookParams = array( + 'sql' => &$sql, + 'params' => array( + 'id_hotel' => $idHotel, + 'id_product' => $idRoomType, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); + if (isset($extra_params)) { + $hookParams['params']['extra_params'] = $extra_params; + } + Hook::exec('actionPartiallyAvailRoomSearchSqlModifier', $hookParams); + + $sql = implode(' UNION ', $sql); + $sql .= ' ORDER BY id_room ASC'; + $part_arr = Db::getInstance()->executeS($sql); // Get date wise available rooms @@ -1246,11 +1318,41 @@ class HotelBookingDetail extends ObjectModel { extract($params); - $sql = 'SELECT bd.`id`, bd.`id_product`, bd.`id_room`, bd.`id_hotel`, bd.`id_customer`, bd.`booking_type`, bd.`id_status` AS booking_status, bd.`comment`, rf.`room_num`, bd.`date_from`, bd.`date_to` - FROM `'._DB_PREFIX_.'htl_booking_detail` AS bd - INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = bd.`id_room`) - WHERE bd.`id_hotel`='.(int)$idHotel.' AND bd.`is_refunded` = 0 AND bd.`is_back_order` = 0 AND IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`check_out` >= \''.pSQL($dateTo).'\', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.date_to >= \''.pSQL($dateTo).'\') AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` IN ('.$allowedIdRoomTypes.') - ORDER BY bd.`id_room` ASC'; + $selectBookedRoomSearch = 'SELECT bd.`id`, bd.`id_product`, bd.`id_room`, bd.`id_hotel`, bd.`id_customer`, + bd.`booking_type`, bd.`id_status` AS booking_status, bd.`comment`, rf.`room_num`, bd.`date_from`, + bd.`date_to`'; + $joinBookedRoomSearch = 'INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = bd.`id_room`)'; + $whereBookedRoomSearch = 'WHERE bd.`id_hotel`='.(int)$idHotel.' AND bd.`is_refunded` = 0 AND bd.`is_back_order` = 0 AND IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`check_out` >= \''.pSQL($dateTo).'\', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.date_to >= \''.pSQL($dateTo).'\') AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` IN ('.$allowedIdRoomTypes.')'; + $groupByBookedRoomSearch = ''; + $orderByBookedRoomSearch = 'ORDER BY bd.`id_room` ASC'; + $orderWayBookedRoomSearch = ''; + + $hookParams = array( + 'select' => $selectBookedRoomSearch, + 'join' => &$joinBookedRoomSearch, + 'where' => &$whereBookedRoomSearch, + 'group_by' => &$groupByBookedRoomSearch, + 'order_by' => &$orderByBookedRoomSearch, + 'order_way' => &$orderWayBookedRoomSearch, + 'params' => array( + 'id_hotel' => $idHotel, + 'id_product' => $idRoomType, + 'date_from' => $dateFrom, + 'date_to' => $dateTo, + ) + ); + if (isset($extra_params)) { + $hookParams['params']['extra_params'] = $extra_params; + } + Hook::exec('actionBookedRoomSearchSqlModifier', $hookParams); + + $sql = $selectBookedRoomSearch; + $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` AS bd'; + $sql .= ' '.$joinBookedRoomSearch; + $sql .= ' '.$whereBookedRoomSearch; + $sql .= ' '.$groupByBookedRoomSearch; + $sql .= ' '.$orderByBookedRoomSearch; + $sql .= ' '.$orderWayBookedRoomSearch; $bookedRoomTypes = array(); if ($booked_rooms = Db::getInstance()->executeS($sql)) { @@ -1517,10 +1619,18 @@ class HotelBookingDetail extends ObjectModel $this->context = Context::getContext(); - $bookingParams['search_available'] = 1; - $bookingParams['search_partial'] = 0; - $bookingParams['search_booked'] = 0; - $bookingParams['search_unavai'] = 0; + if (!isset($bookingParams['search_available'])) { + $bookingParams['search_available'] = 1; + } + if (!isset($bookingParams['search_partial'])) { + $bookingParams['search_partial'] = 0; + } + if (!isset($bookingParams['search_booked'])) { + $bookingParams['search_booked'] = 0; + } + if (!isset($bookingParams['search_unavai'])) { + $bookingParams['search_unavai'] = 0; + } $bookingData = $this->getBookingData($bookingParams); From 337c37c96fb6abd9642febba50032077e1dc25cc Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 12 Jul 2024 19:24:10 +0530 Subject: [PATCH 02/13] Updated: Rooms search algo|passed addition parameters in search hooks for data manipulation --- .../classes/HotelBookingDetail.php | 162 +++++++++++------- .../classes/HotelRoomInformation.php | 28 ++- .../AdminHotelRoomsBookingController.php | 2 +- .../views/css/HotelReservationAdmin.css | 14 +- .../views/js/admin/hotel_rooms_booking.js | 60 +++++++ .../helpers/view/_partials/booking-rooms.tpl | 24 ++- .../helpers/view/_partials/search-stats.tpl | 3 + 7 files changed, 223 insertions(+), 70 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 51b89bedf..9a6dfab3d 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -211,6 +211,9 @@ class HotelBookingDetail extends ObjectModel if (!isset($params['search_cart_rms'])) { $params['search_cart_rms'] = 0; } + if (!isset($params['hourly_booking'])) { + $params['hourly_booking'] = false; + } if (!isset($params['only_active_roomtype'])) { $params['only_active_roomtype'] = 1; @@ -329,17 +332,28 @@ class HotelBookingDetail extends ObjectModel 'searchOccupancy' => $occupancy, 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'applyLosRestriction' => $applyLosRestriction, + 'hourlyBooking' => $hourly_booking, 'extra_params' => $params, ); $availableRoomTypes = $this->getSearchAvailableRooms($searchParams); if ($availableRoomTypes['unavailableRoomTypes'] && $search_unavai) { + // format unavailable room types foreach ($availableRoomTypes['unavailableRoomTypes'] as $idProduct => $roomTypeDetail) { - if (!isset($unavailRoomTypes[$idProduct])) { - $unavailRoomTypes[$idProduct] = array(); + foreach ($roomTypeDetail as $idRoom => $roomDetail) { + if (!isset($unavailRoomTypes[$idProduct][$idRoom])) { + $unavailRoomTypes[$idProduct][$idRoom] = array( + 'id_product' => $roomDetail['id_product'], + 'id_room' => $roomDetail['id_room'], + 'id_hotel' => $roomDetail['id_hotel'], + 'room_num' => $roomDetail['room_num'], + 'detail' => array() + ); + } + $unavailRoomTypes[$idProduct][$idRoom]['detail'][] = array( + 'id_status' => $roomDetail['id_status'], + 'room_comment' => $roomDetail['room_comment'] + ); } - - // FYI: used array_merge because we have int index - $unavailRoomTypes[$idProduct] = array_merge($unavailRoomTypes[$idProduct], $roomTypeDetail); } } @@ -370,22 +384,14 @@ class HotelBookingDetail extends ObjectModel 'idRoomType' => $id_room_type, 'searchOccupancy' => $occupancy, 'allowedIdRoomTypes' => $allowedIdRoomTypes, + 'hourlyBooking' => $hourly_booking, 'extra_params' => $params, ); $partiallyAvailRoomTypes = $this->getSearchPartiallyAvailRooms($searchParams); - if ($partiallyAvailRoomTypes['unavailableRoomTypes'] && $search_unavai) { - foreach ($partiallyAvailRoomTypes['unavailableRoomTypes'] as $idProduct => $roomTypeDetail) { - if (!isset($unavailRoomTypes[$idProduct])) { - $unavailRoomTypes[$idProduct] = array(); - } - - // FYI: used array_merge because we have int index - $unavailRoomTypes[$idProduct] = array_merge($unavailRoomTypes[$idProduct], $roomTypeDetail); - } - } - + // Unavailable rooms and booked rooms are already included in there respective search + // So, no need to seperate them here $partiallyAvailRoomsCount = $partiallyAvailRoomTypes['partiallyAvailRoomsCount']; $partiallyAvailRoomTypes = $partiallyAvailRoomTypes['partiallyAvailRooms']; } @@ -485,6 +491,7 @@ class HotelBookingDetail extends ObjectModel * 'idRoomType' => ..., * 'allowedIdRoomTypes' => ..., * 'applyLosRestriction' => ..., + * 'extra_params' => ..., * ); */ protected function getSearchUnavailableRooms($params) @@ -507,19 +514,24 @@ class HotelBookingDetail extends ObjectModel // Room status inactive $sql = array(); - $sql[] = 'SELECT `id` AS `id_room`, `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment` + $sql[] = 'SELECT `id` AS `id_room`, `id_product`, `id_hotel`, `room_num`, `comment` AS `room_comment`, `id_status`, NULL AS `date_from`, NULL AS `date_to` FROM `'._DB_PREFIX_.'htl_room_information` WHERE `id_hotel`='.(int)$idHotel.' AND `id_status` = '. HotelRoomInformation::STATUS_INACTIVE.' AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; // check room is temperory inactive - $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` + $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment`, hri.`id_status`, hrdd.`date_from` AS `date_from`, hrdd.`date_to` AS `date_to` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd. id_room = hri.`id`) - WHERE hri.`id_hotel`='.$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND hrdd.`date_from` <= \''.pSql($dateFrom).'\' AND hrdd.`date_to` >= \''.pSql($dateTo).'\' AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; + WHERE hri.`id_hotel`='.$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND ( + (hrdd.`date_from` <= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR + (hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR + (hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` >= \''.pSQL($dateTo).'\') OR + (hrdd.`date_from` <= \''.pSql($dateFrom).'\' AND hrdd.`date_to` >= \''.pSql($dateTo).'\') + ) AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; if ($applyLosRestriction) { - $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment` + $sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment`, '.HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED.' AS `id_status`, NULL AS `date_from`, NULL AS `date_to` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_restriction_date_range` AS hrtr ON (hrt.`id_product` = hrtr.`id_product` AND (hrtr.`date_from` <= \''.pSQL($stayStartDate).'\' AND hrtr.`date_to` > \''.pSQL($stayStartDate).'\')) @@ -542,12 +554,26 @@ class HotelBookingDetail extends ObjectModel Hook::exec('actionUnavailRoomSearchSqlModifier', $hookParams); $sql = implode(' UNION ', $sql); - $sql .= ' ORDER BY id_room ASC'; + $sql .= ' ORDER BY `id_room`, `date_from` ASC'; $unavailRoomTypes = array(); if ($unavailRooms = Db::getInstance()->executeS($sql)) { foreach ($unavailRooms as $unavailRoomDetail) { - $unavailRoomTypes[$unavailRoomDetail['id_product']][] = $unavailRoomDetail; + if (!isset($unavailRoomTypes[$unavailRoomDetail['id_product']][$unavailRoomDetail['id_room']])) { + $unavailRoomTypes[$unavailRoomDetail['id_product']][$unavailRoomDetail['id_room']] = array( + 'id_product' => $unavailRoomDetail['id_product'], + 'id_room' => $unavailRoomDetail['id_room'], + 'id_hotel' => $unavailRoomDetail['id_hotel'], + 'room_num' => $unavailRoomDetail['room_num'], + 'detail' => array() + ); + } + $unavailRoomTypes[$unavailRoomDetail['id_product']][$unavailRoomDetail['id_room']]['detail'][] = array( + 'id_status' => $unavailRoomDetail['id_status'], + 'room_comment' => $unavailRoomDetail['room_comment'], + 'date_from' => $unavailRoomDetail['date_from'], + 'date_to' => $unavailRoomDetail['date_to'], + ); } } @@ -561,6 +587,7 @@ class HotelBookingDetail extends ObjectModel * 'idGuest' => ..., * 'idRoomType' => ..., * 'allowedIdRoomTypes' => ..., + * 'extra_params' => ..., * ); */ protected function getSearchCartRooms($params) @@ -620,15 +647,17 @@ class HotelBookingDetail extends ObjectModel /** * $params = array( - * 'idHotel' => ..., - * 'dateFrom' => ..., - * 'dateTo' => ..., - * 'idCart' => ..., - * 'idGuest' => ..., - * 'idRoomType' => ..., - * 'searchOccupancy' => ..., - * 'allowedIdRoomTypes' => ..., - * 'applyLosRestriction' => ..., + * 'idHotel' => ..., + * 'dateFrom' => ..., + * 'dateTo' => ..., + * 'idCart' => ..., + * 'idGuest' => ..., + * 'idRoomType' => ..., + * 'searchOccupancy' => ..., + * 'allowedIdRoomTypes' => ..., + * 'applyLosRestriction' => ..., + * 'hourlyBooking' => ..., + * 'extra_params' => ..., * ); */ protected function getSearchAvailableRooms($params) @@ -661,13 +690,12 @@ class HotelBookingDetail extends ObjectModel $exclude_ids = array(); $exclude_ids['checked_out'] = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` - WHERE `id_hotel` = '.(int)$idHotel.' AND `is_back_order` = 0 AND `is_refunded` = 0 AND IF(`id_status` = '. self::STATUS_CHECKED_OUT.', ( - (DATE_FORMAT(`check_out`, "%Y-%m-%d") > \''.pSQL($dateFrom).'\' AND DATE_FORMAT(`check_out`, "%Y-%m-%d") <= \''.PSQL($dateTo).'\') AND ( + WHERE `id_hotel` = '.(int)$idHotel.' AND `is_back_order` = 0 AND `is_refunded` = 0 AND IF(`id_status` = '. self::STATUS_CHECKED_OUT.', + IF('.(int) $hourlyBooking.', 1, (DATE_FORMAT(`check_out`, "%Y-%m-%d") != DATE_FORMAT(\''.pSQL($dateFrom).'\', "%Y-%m-%d")) AND (`check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.PSQL($dateTo).'\')) AND ( (`date_from` <= \''.pSQL($dateFrom).'\' AND `check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.PSQL($dateTo).'\') OR (`date_from` >= \''.pSQL($dateFrom).'\' AND `check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.pSQL($dateTo).'\') OR (`date_from` >= \''.pSQL($dateFrom).'\' AND `date_from` < \''.pSQL($dateTo).'\' AND `check_out` >= \''.pSQL($dateTo).'\') OR (`date_from` <= \''.pSQL($dateFrom).'\' AND `check_out` >= \''.pSQL($dateTo).'\') - ) ), ( (`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` > \''.pSQL($dateFrom).'\' AND `date_to` <= \''.PSQL($dateTo).'\') OR (`date_from` >= \''.pSQL($dateFrom).'\' AND `date_to` <= \''.pSQL($dateTo).'\') OR @@ -675,7 +703,6 @@ class HotelBookingDetail extends ObjectModel (`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` >= \''.pSQL($dateTo).'\') )) AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; - // We have removed cart rooms after finally getting available rooms from booking // Exclude temporary disable rooms $exclude_ids['disabled'] = 'SELECT hri.`id` AS id_room FROM `'._DB_PREFIX_.'htl_room_information` AS hri @@ -690,6 +717,7 @@ class HotelBookingDetail extends ObjectModel LEFT JOIN `'._DB_PREFIX_.'htl_room_type_restriction_date_range` AS hrtr ON (hrt.`id_product` = hrtr.`id_product` AND (hrtr.`date_from` <= \''.pSQL($stayStartDate).'\' AND hrtr.`date_to` > \''.pSQL($stayStartDate).'\')) WHERE hri.`id_hotel`='.(int)$idHotel.' AND (IFNULL(hrtr.`min_los`, hrt.`min_los`) >'. (int)$lengthOfStay.' OR IF(IFNULL(hrtr.`max_los`, hrt.`max_los`) > 0, IFNULL(hrtr.`max_los`, hrt.`max_los`) < '.(int)$lengthOfStay.', 0)) AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; } + // We will remove cart rooms after finally getting available rooms from booking $selectAvailRoomSearch = 'SELECT ri.`id` AS `id_room`, ri.`id_product`, ri.`id_hotel`, ri.`room_num`, ri.`comment` AS `room_comment`, hrt.`max_adults` AS max_adult, hrt.`max_children`, hrt.`max_guests` AS max_occupancy'; @@ -763,7 +791,19 @@ class HotelBookingDetail extends ObjectModel if ($QLO_SEARCH_TYPE == HotelBookingDetail::SEARCH_TYPE_OWS && $searchOccupancy) { $availableRoomTypes = $this->getAvailableRoomSatisfingOccupancy($searchOccupancy, $availableRoomTypes, $QLO_OWS_SEARCH_ALGO_TYPE); + + // segregating available and unavailable roomTypes $unavailableRoomTypes = $availableRoomTypes['unavailableRoomTypes']; + if ($unavailableRoomTypes) { + // Adding an id_status key to the unavailable rooms array to identify rooms unavailable due to unsatisfied occupancy search criteria. + // if in case we need to add multiple keys then we can use array union operator + // Instead of looping here, we can do this in the getavailableRoomSatisfingOccupancy function + foreach ($unavailableRoomTypes as $idProduct => $roomTypeDetail) { + foreach ($roomTypeDetail as $idRoom => $roomDetail) { + $unavailableRoomTypes[$idProduct][$roomDetail['id_room']]['id_status'] = HotelRoomInformation::STATUS_SEARCH_OCCUPANCY_UNSATISFIED; + } + } + } $availableRoomTypes = $availableRoomTypes['availableRoomTypes']; } @@ -970,6 +1010,8 @@ class HotelBookingDetail extends ObjectModel * 'idRoomType' => ..., * 'searchOccupancy' => ..., * 'allowedIdRoomTypes' => ..., + * 'hourlyBooking' => ..., + * 'extra_params' => ..., * ); */ protected function getSearchPartiallyAvailRooms($params) @@ -981,12 +1023,10 @@ class HotelBookingDetail extends ObjectModel FROM `'._DB_PREFIX_.'htl_booking_detail` AS bd INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = bd.`id_room`) INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = rf.`id_product`) - WHERE bd.`id_hotel`='.(int)$idHotel.' AND rf.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE .' AND bd.`is_back_order` = 0 AND bd.`is_refunded` = 0 AND IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', ( - (DATE_FORMAT(`check_out`, "%Y-%m-%d") > \''.pSQL($dateFrom).'\' AND DATE_FORMAT(`check_out`, "%Y-%m-%d") < \''.PSQL($dateTo).'\') AND ( - (bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`check_out` > \''.pSQL($dateFrom).'\' AND bd.`check_out` < \''.pSQL($dateTo).'\') OR - (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`check_out` >= \''.pSQL($dateTo).'\') OR - (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`check_out` > \''.pSQL($dateFrom).'\' AND bd.`check_out` < \''.pSQL($dateTo).'\') - ) + WHERE bd.`id_hotel`='.(int)$idHotel.' AND rf.`id_status` != '. HotelRoomInformation::STATUS_INACTIVE .' AND bd.`is_back_order` = 0 AND bd.`is_refunded` = 0 AND IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', IF('.(int) $hourlyBooking.', 1, (DATE_FORMAT(`check_out`, "%Y-%m-%d") != DATE_FORMAT(\''.pSQL($dateFrom).'\', "%Y-%m-%d")) AND (`check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.PSQL($dateTo).'\')) AND ( + (bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`check_out` > \''.pSQL($dateFrom).'\' AND bd.`check_out` < \''.pSQL($dateTo).'\') OR + (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`check_out` >= \''.pSQL($dateTo).'\') OR + (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`check_out` > \''.pSQL($dateFrom).'\' AND bd.`check_out` < \''.pSQL($dateTo).'\') ), ( (bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`date_to` > \''.pSQL($dateFrom).'\' AND bd.`date_to` < \''.pSQL($dateTo).'\') OR (bd.`date_from` > \''.pSQL($dateFrom).'\' AND bd.`date_from` < \''.pSQL($dateTo).'\' AND bd.`date_to` >= \''.pSQL($dateTo).'\') OR @@ -1279,16 +1319,14 @@ class HotelBookingDetail extends ObjectModel } } else { // If all dates are not covered then move all partially available room types to unavailable - foreach ($partiallyAvailRooms as $roomDetail) { - if (!isset($unavailableRoomTypes[$roomDetail['id_product']][$roomDetail['id_room']])) { - $unavailableRoomTypes[$roomDetail['id_product']][$roomDetail['id_room']] = array( - 'id_room' => $roomDetail['id_room'], - 'id_product' => $roomDetail['id_product'], - 'id_hotel' => $roomDetail['id_hotel'], - 'room_num' => $roomDetail['room_num'], - 'room_comment' => '' - ); - } + foreach ($partiallyAvailRooms as $partAvailRoomDetail) { + $unavailableRoomTypes[$partAvailRoomDetail['id_product']][$partAvailRoomDetail['id_room']] = array( + 'id_room' => $partAvailRoomDetail['id_room'], + 'id_product' => $partAvailRoomDetail['id_product'], + 'id_hotel' => $partAvailRoomDetail['id_hotel'], + 'room_num' => $partAvailRoomDetail['room_num'], + 'room_comment' => '' + ); } $partiallyAvailRooms = array(); @@ -1318,13 +1356,21 @@ class HotelBookingDetail extends ObjectModel { extract($params); - $selectBookedRoomSearch = 'SELECT bd.`id`, bd.`id_product`, bd.`id_room`, bd.`id_hotel`, bd.`id_customer`, - bd.`booking_type`, bd.`id_status` AS booking_status, bd.`comment`, rf.`room_num`, bd.`date_from`, - bd.`date_to`'; - $joinBookedRoomSearch = 'INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS rf ON (rf.`id` = bd.`id_room`)'; - $whereBookedRoomSearch = 'WHERE bd.`id_hotel`='.(int)$idHotel.' AND bd.`is_refunded` = 0 AND bd.`is_back_order` = 0 AND IF(bd.`id_status` = '. self::STATUS_CHECKED_OUT .', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.`check_out` >= \''.pSQL($dateTo).'\', bd.`date_from` <= \''.pSQL($dateFrom).'\' AND bd.date_to >= \''.pSQL($dateTo).'\') AND IF('.(int)$idRoomType.' > 0, rf.`id_product` = '.(int)$idRoomType.', 1) AND rf.`id_product` IN ('.$allowedIdRoomTypes.')'; + $selectBookedRoomSearch = 'SELECT `id`, `id_order`, `id_product`, `id_room`, `id_hotel`, `id_customer`, `booking_type`, `id_status` AS booking_status, `comment`, `room_num`, `date_from`, IF(`id_status` = '. self::STATUS_CHECKED_OUT.', `check_out`,`date_to`) AS `date_to`, `check_in`, `check_out`, `date_to` AS `booking_date_to`'; + $joinBookedRoomSearch = ''; + $whereBookedRoomSearch = 'WHERE `id_hotel` = '.(int)$idHotel.' AND `is_back_order` = 0 AND `is_refunded` = 0 AND IF(`id_status` = '. self::STATUS_CHECKED_OUT.', ( + (`date_from` <= \''.pSQL($dateFrom).'\' AND `check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.PSQL($dateTo).'\') OR + (`date_from` >= \''.pSQL($dateFrom).'\' AND `check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.pSQL($dateTo).'\') OR + (`date_from` >= \''.pSQL($dateFrom).'\' AND `date_from` < \''.pSQL($dateTo).'\' AND `check_out` >= \''.pSQL($dateTo).'\') OR + (`date_from` <= \''.pSQL($dateFrom).'\' AND `check_out` >= \''.pSQL($dateTo).'\') + ), ( + (`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` > \''.pSQL($dateFrom).'\' AND `date_to` <= \''.PSQL($dateTo).'\') OR + (`date_from` >= \''.pSQL($dateFrom).'\' AND `date_to` <= \''.pSQL($dateTo).'\') OR + (`date_from` >= \''.pSQL($dateFrom).'\' AND `date_from` < \''.pSQL($dateTo).'\' AND `date_to` >= \''.pSQL($dateTo).'\') OR + (`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` >= \''.pSQL($dateTo).'\') + )) AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; $groupByBookedRoomSearch = ''; - $orderByBookedRoomSearch = 'ORDER BY bd.`id_room` ASC'; + $orderByBookedRoomSearch = 'ORDER BY `id_room`, `date_from` ASC'; $orderWayBookedRoomSearch = ''; $hookParams = array( @@ -1347,7 +1393,7 @@ class HotelBookingDetail extends ObjectModel Hook::exec('actionBookedRoomSearchSqlModifier', $hookParams); $sql = $selectBookedRoomSearch; - $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` AS bd'; + $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail`'; $sql .= ' '.$joinBookedRoomSearch; $sql .= ' '.$whereBookedRoomSearch; $sql .= ' '.$groupByBookedRoomSearch; diff --git a/modules/hotelreservationsystem/classes/HotelRoomInformation.php b/modules/hotelreservationsystem/classes/HotelRoomInformation.php index 26ffbbb5d..47eb7b53e 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomInformation.php +++ b/modules/hotelreservationsystem/classes/HotelRoomInformation.php @@ -34,6 +34,9 @@ class HotelRoomInformation extends ObjectModel const STATUS_INACTIVE = 2; const STATUS_TEMPORARY_INACTIVE = 3; + const STATUS_SEARCH_LOS_UNSATISFIED = 4; + const STATUS_SEARCH_OCCUPANCY_UNSATISFIED = 5; + public static $definition = array( 'table' => 'htl_room_information', 'primary' => 'id', @@ -138,25 +141,40 @@ class HotelRoomInformation extends ObjectModel public function getAllRoomStatus() { - $moduleInstance = Module::getInstanceByName('hotelreservationsystem'); - $status = array( 'STATUS_ACTIVE' => array( 'id' => self::STATUS_ACTIVE, - 'status' => $moduleInstance->l('Active', 'hotelreservationsystem') + 'status' => self::getRoomStatusTitle(self::STATUS_ACTIVE) ), 'STATUS_INACTIVE' => array( 'id' => self::STATUS_INACTIVE, - 'status' => $moduleInstance->l('Inactive', 'hotelreservationsystem') + 'status' => self::getRoomStatusTitle(self::STATUS_INACTIVE) ), 'STATUS_TEMPORARY_INACTIVE' => array( 'id' => self::STATUS_TEMPORARY_INACTIVE, - 'status' => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem') + 'status' => self::getRoomStatusTitle(self::STATUS_TEMPORARY_INACTIVE) ), ); return $status; } + public static function getRoomStatusTitle($idStatus = false) + { + $moduleInstance = Module::getInstanceByName('hotelreservationsystem'); + $status = array( + self::STATUS_ACTIVE => $moduleInstance->l('Active', 'hotelreservationsystem'), + self::STATUS_INACTIVE => $moduleInstance->l('Inactive', 'hotelreservationsystem'), + self::STATUS_TEMPORARY_INACTIVE => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem'), + self::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Lenght of stay', 'hotelreservationsystem'), + self::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy', 'hotelreservationsystem'), + ); + + if ($idStatus) { + return isset($status[$idStatus]) ? $status[$idStatus] : false; + } + return $status; + } + /** * [getHotelRoomInfoByProductId :: To get all rooms information belong to a room type(product) by product id] * @param [int] $id_product [Id of the product] diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index c8a575056..0557ebfeb 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -854,7 +854,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController } } } - + // ddd($booking_data); return $booking_data; } diff --git a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css index 4a18f60be..2961a99cf 100644 --- a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css +++ b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css @@ -216,7 +216,13 @@ p.room_cat_data font-weight: 700; margin-bottom: 0px; } - +.status-info { + position: relative; + display: inline-block; + left: 100%; + margin-left: -10px; + padding: 0px; +} .color_indicate { width: 10px; @@ -239,6 +245,7 @@ p.room_cat_data margin: 10px 0px; } + .cart-table-thead { border-bottom: 1px solid #555!important; @@ -275,7 +282,10 @@ p.room_cat_data font-size: 14px!important; font-weight: 600!important; } - +#htl_rooms_list table td { + padding-top: 10px; + padding-bottom: 10px; +} #room-status-tabs li { font-size: 14px; diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index e7a4d00cd..8bf7f0eff 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -954,10 +954,70 @@ $(document).ready(function() { success: function(result) { if (result.success) { $(".htl_room_data_cont").html(result.data.stats_panel); + initstatstooltip(); } } }); } + initstatstooltip(); + + function initstatstooltip() + { + console.log($(".htl_room_data_cont").find('.status-info')); + $(".htl_room_data_cont").find('.status-info').tooltip({ + // content: function() + // { + // $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_format); + // $.each(info.event.extendedProps.data.stats, function(elem, val) { + // if (elem == 'num_part_avai') { + // $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); + // } else { + // $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); + // } + // }); + // return $('#date-stats-tooltop').html(); + // }, + // items: "div", + trigger : 'hover', + show: { + delay: 100, + }, + hide: { + delay: 300, + }, + open: function(event, ui) + { + if(event.buttons == 1 || event.buttons == 3){ + ui.tooltip.remove(); + } + + if (typeof(event.originalEvent) === 'undefined') { + return false; + } + + var $id = $(ui.tooltip).attr('id'); + + // close any lingering tooltips + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + + // ajax function to pull in data and add it to the tooltip goes here + }, + close: function(event, ui) + { + ui.tooltip.hover(function() { + $(this).stop(true).fadeTo(300, 1); + }, + function() { + $(this).fadeOut('300', function() + { + $(this).remove(); + }); + }); + } + }); + } var allotmentTypes = { auto: ALLOTMENT_AUTO, diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index 579eb756a..b5b37fac6 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -203,6 +203,7 @@ {l s='Room No.' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} + {l s='Order' mod='hotelreservationsystem'} {l s='Message' mod='hotelreservationsystem'} {l s='Allotment Type' mod='hotelreservationsystem'} {l s='Reallocate' mod='hotelreservationsystem'} @@ -216,6 +217,7 @@ {$booked_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$booked_v key=$rm_dtl_k type='booked'} {/if} {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_to']))} + #{$rm_dtl_v['id_order']} {$rm_dtl_v['comment']|escape:'htmlall':'UTF-8'} {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}{l s='Auto Allotment' mod='hotelreservationsystem'}{elseif $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_MANUAL}{l s='Manual Allotment' mod='hotelreservationsystem'}{/if} @@ -242,15 +244,29 @@ {l s='Room No.' mod='hotelreservationsystem'} + {l s='Status' mod='hotelreservationsystem'} + {l s='Duration' mod='hotelreservationsystem'} {l s='Message' mod='hotelreservationsystem'} {foreach from=$book_v['data']['unavailable'] key=unavai_k item=unavai_v} - - {$unavai_v['room_num']|escape:'htmlall':'UTF-8'} - {$unavai_v['room_comment']|escape:'htmlall':'UTF-8'} - + {foreach from=$unavai_v['detail'] key=rm_dtl_k item=unavail_dtl_v} + + {if $unavail_dtl_v@first} + {$unavai_v['room_num']|escape:'htmlall':'UTF-8'} + {/if} + {HotelRoomInformation::getRoomStatusTitle($unavail_dtl_v['id_status'])|escape:'htmlall':'UTF-8'} + + {if $unavail_dtl_v['date_from'] && $unavail_dtl_v['date_to']} + {dateFormat date=date('Y-m-d', strtotime($unavail_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($unavail_dtl_v['date_to']))} + {else} + -- + {/if} + + {$unavail_dtl_v['room_comment']|escape:'htmlall':'UTF-8'} + + {/foreach} {/foreach} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl index 560836b5b..c672c941b 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl @@ -1,4 +1,7 @@
+
+ +
From a859845a7298a09606969c7dea4156f54459e426 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 13 Aug 2024 20:20:08 +0530 Subject: [PATCH 03/13] added hook actionBookingDataParamsModifier --- .../classes/HotelBookingDetail.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 82018d6b5..2fc79a1ca 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -239,6 +239,8 @@ class HotelBookingDetail extends ObjectModel $params['only_search_data'] = 0; } + Hook::exec('actionBookingDataParamsModifier', array('params' => &$params)); + return $params; } @@ -1548,25 +1550,24 @@ class HotelBookingDetail extends ObjectModel * @param [date] $dateTo [End date of the booking] * * @return [int] [Returns number of days between two dates] - * @deprecated use hotelBookingDetail::getDays() instead + * @deprecated use HotelHelper::getNumberOfDays() instead */ public function getNumberOfDays($dateFrom, $dateTo) { - return self::getDays($dateFrom, $dateTo); - // $startDate = new DateTime($dateFrom); - // $endDate = new DateTime($dateTo); - // $daysDifference = $startDate->diff($endDate)->days; - - // return $daysDifference; + return HotelHelper::getNumberOfDays($dateFrom, $dateTo); } + /** + * + * @param [date] $dateFrom [Start date of the booking] + * @param [date] $dateTo [End date of the booking] + * + * @return [int] [Returns number of days between two dates] + * @deprecated use HotelHelper::getNumberOfDays() instead + */ public static function getDays($dateFrom, $dateTo) { - $startDate = new DateTime($dateFrom); - $endDate = new DateTime($dateTo); - $daysDifference = $startDate->diff($endDate)->days; - - return $daysDifference; + return HotelHelper::getNumberOfDays($dateFrom, $dateTo); } public function generateRoomOccupancyWeight($availRoomTypeCount, $totalOccupancy, $totalAdult, $totalChildren) From bc42e57e7d2fe1a68caa396b60743fe449f3b250 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 14 Aug 2024 14:38:25 +0530 Subject: [PATCH 04/13] Fixed: The price tooltip at the order confirmation and updated the design for the booked services and demands popup --- .../front/OrderConfirmationController.php | 2 - .../_partials/order-extra-services.tpl | 91 +++++++++---------- .../css/order-confirmation.css | 22 ++++- .../css/order-detail.css | 16 ++-- .../js/order-confirmation.js | 39 +++++++- 5 files changed, 109 insertions(+), 61 deletions(-) diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index a60326859..2b5709135 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -469,8 +469,6 @@ class OrderConfirmationControllerCore extends FrontController { if (Tools::getValue('ajax') != 'true') { parent::setMedia(); - $this->addCSS(_THEME_CSS_DIR_.'history.css'); - $this->addJS(_THEME_JS_DIR_.'history.js'); $this->addJS(_THEME_JS_DIR_.'order-confirmation.js'); $this->addCSS(_THEME_CSS_DIR_.'order-confirmation.css'); $this->addJqueryPlugin(array('fancybox')); //fancybox not found for some client theme diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index 695b47c28..5e643b6f0 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -25,53 +25,12 @@ {if (isset($extraDemands) && $extraDemands) || (isset($additionalServices) && $additionalServices)}
- {if isset($extraDemands) && $extraDemands} -
-
-

{l s='Facilities chosen for this booking.'}

-
- {assign var=roomCount value=1} - {foreach $extraDemands as $roomDemand} -
-
- {l s='Room'} {$roomCount|string_format:'%02d'}  - ({if {$roomDemand['adults']} <= 9}0{$roomDemand['adults']}{else}{$roomDemand['adults']}{/if} {if $roomDemand['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomDemand['children'] > 0}, {if {$roomDemand['children']} <= 9}0{$roomDemand['children']}{else}{$roomDemand['children']}{/if} {if $roomDemand['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) -
-
- {foreach $roomDemand['extra_demands'] as $demand} -
-
{$demand['name']|escape:'html':'UTF-8'}
-
- - {if $useTax} - {displayPrice price="{$demand['total_price_tax_incl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} - {else} - {displayPrice price="{$demand['total_price_tax_excl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} - {/if} - -
-
- {/foreach} -
-
- {assign var=roomCount value=$roomCount+1} - {/foreach} -
- {/if} - - {if isset($additionalServices) && $additionalServices} -
-
-

{l s='Services chosen for this booking.'}

-
+
+ {if isset($additionalServices) && $additionalServices} {assign var=roomCount value=1} {foreach $additionalServices as $key => $roomAdditionalService}
@@ -105,8 +64,46 @@
{assign var=roomCount value=$roomCount+1} {/foreach} -
- {/if} + {else} +
+ {l s='No service found.'} +
+ {/if} +
+
+ {if isset($extraDemands) && $extraDemands} + {assign var=roomCount value=1} + {foreach $extraDemands as $roomDemand} +
+
+ {l s='Room'} {$roomCount|string_format:'%02d'}  + ({if {$roomDemand['adults']} <= 9}0{$roomDemand['adults']}{else}{$roomDemand['adults']}{/if} {if $roomDemand['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomDemand['children'] > 0}, {if {$roomDemand['children']} <= 9}0{$roomDemand['children']}{else}{$roomDemand['children']}{/if} {if $roomDemand['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) +
+
+ {foreach $roomDemand['extra_demands'] as $demand} +
+
{$demand['name']|escape:'html':'UTF-8'}
+
+ + {if $useTax} + {displayPrice price="{$demand['total_price_tax_incl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} + {else} + {displayPrice price="{$demand['total_price_tax_excl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} + {/if} + +
+
+ {/foreach} +
+
+ {assign var=roomCount value=$roomCount+1} + {/foreach} + {else} +
+ {l s='No facility found.'} +
+ {/if} +
{/if} diff --git a/themes/hotel-reservation-theme/css/order-confirmation.css b/themes/hotel-reservation-theme/css/order-confirmation.css index 654658b95..f7f16bdbe 100644 --- a/themes/hotel-reservation-theme/css/order-confirmation.css +++ b/themes/hotel-reservation-theme/css/order-confirmation.css @@ -190,4 +190,24 @@ #rooms_extra_services .nav-tabs > li.active:after { content: unset; -} \ No newline at end of file +} + +#rooms_extra_services .services_not_booked { + text-align: center; + margin: 30px 0px; + font-size: 14px; +} + +.price-info-tooltip-cont { + min-width: 180px; +} + +.price-info-tooltip-cont .list-row { + display: flex; + justify-content: space-between; + margin: 5px 0; +} + +.price-info-tooltip-cont .list-row p { + margin: 0; +} diff --git a/themes/hotel-reservation-theme/css/order-detail.css b/themes/hotel-reservation-theme/css/order-detail.css index d05fc1e30..3f7544dcd 100644 --- a/themes/hotel-reservation-theme/css/order-detail.css +++ b/themes/hotel-reservation-theme/css/order-detail.css @@ -750,16 +750,6 @@ display: none; } -.ui-tooltip.price-tootip { - box-shadow: 0 2px 6px 0 rgb(0 0 0 / 20%); - background: #FFFFFF; - border: unset; - color: #333; - padding: 2px 10px; - max-height: 310px; - overflow-y: auto; -} - .price-info-tooltip-cont { min-width: 180px; } @@ -1084,6 +1074,12 @@ margin-bottom: 12px; } +#popup-view-extra-services .services_not_booked { + text-align: center; + margin: 30px 0px; + font-size: 14px; +} + /* Guest Tracking page styles - start */ .transform-account .card-text p { margin: 0; diff --git a/themes/hotel-reservation-theme/js/order-confirmation.js b/themes/hotel-reservation-theme/js/order-confirmation.js index 87175d20f..a150a491e 100644 --- a/themes/hotel-reservation-theme/js/order-confirmation.js +++ b/themes/hotel-reservation-theme/js/order-confirmation.js @@ -70,4 +70,41 @@ $(document).ready(function(){ }, }); }); -}); \ No newline at end of file + + initPriceTooltip(); +}); + +function initPriceTooltip() { + if ($('.order-price-info').length) { + $('.order-price-info').each(function () { + $(this).tooltip({ + content: $(this).closest('td').find('.price-info-container').html(), + items: 'span', + trigger: 'hover', + tooltipClass: 'price-tootip', + open: function (event, ui) { + if (typeof (event.originalEvent) === 'undefined') { + return false; + } + + var $id = $(ui.tooltip).attr('id'); + + // close any lingering tooltips + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + }, + close: function (event, ui) { + ui.tooltip.hover(function () { + $(this).stop(true).fadeTo(400, 1); + }, + function () { + $(this).fadeOut('400', function () { + $(this).remove(); + }); + }); + } + }); + }); + } +} \ No newline at end of file From 50127a4c5d32f086f4a4bb452b82226d352c9213 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 16 Aug 2024 10:28:27 +0530 Subject: [PATCH 05/13] Updated: The menu of hotel reservation system --- modules/hotelreservationsystem/hotelreservationsystem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index f5294a76d..757825c77 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -557,9 +557,8 @@ class HotelReservationSystem extends Module public function callInstallTab() { $this->installTab('AdminHotelReservationSystemManagement', 'Hotel Reservation System'); - $this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement'); - $this->installTab('AdminHotelConfigurationSetting', 'Settings', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement'); + $this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelFeatures', 'Manage Hotel Features', 'AdminHotelReservationSystemManagement'); $this->installTab( 'AdminOrderRefundRules', @@ -572,6 +571,7 @@ class HotelReservationSystem extends Module 'AdminHotelReservationSystemManagement' ); + $this->installTab('AdminHotelConfigurationSetting', 'General Settings', 'AdminHotelReservationSystemManagement'); // Controllers without tabs $this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false); $this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false); From 918d7a981fbacc7b3042f71d63243afb6cbe7687 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 16 Aug 2024 10:30:02 +0530 Subject: [PATCH 06/13] revert: The menu of hotel reservation system --- modules/hotelreservationsystem/hotelreservationsystem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index 757825c77..f5294a76d 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -557,8 +557,9 @@ class HotelReservationSystem extends Module public function callInstallTab() { $this->installTab('AdminHotelReservationSystemManagement', 'Hotel Reservation System'); - $this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement'); + $this->installTab('AdminHotelConfigurationSetting', 'Settings', 'AdminHotelReservationSystemManagement'); + $this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelFeatures', 'Manage Hotel Features', 'AdminHotelReservationSystemManagement'); $this->installTab( 'AdminOrderRefundRules', @@ -571,7 +572,6 @@ class HotelReservationSystem extends Module 'AdminHotelReservationSystemManagement' ); - $this->installTab('AdminHotelConfigurationSetting', 'General Settings', 'AdminHotelReservationSystemManagement'); // Controllers without tabs $this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false); $this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false); From fbc0dddb1360715724e6cf67de28de89f2aeef08 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 16 Aug 2024 12:00:02 +0530 Subject: [PATCH 07/13] fixed undefined link object --- .../controllers/admin/AdminHotelRoomsBookingController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 0557ebfeb..5eb13aeab 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -379,6 +379,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'occupancy_required_for_booking' => $occupancyRequiredForBooking, 'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'), 'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'), + 'link' => $this->context->link )); if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) { From 60c0c4fddcf25f15869f77b7d625684a327b0a7b Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 16 Aug 2024 12:03:52 +0530 Subject: [PATCH 08/13] remove debug code --- .../controllers/admin/AdminHotelRoomsBookingController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 5eb13aeab..00581eaff 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -855,7 +855,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController } } } - // ddd($booking_data); + return $booking_data; } From 5d05b21efca2982b7a62093b8ae91af515138b65 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 22 Aug 2024 11:14:34 +0530 Subject: [PATCH 09/13] update room unavailable message --- .../classes/HotelRoomInformation.php | 11 ++++------- .../views/css/HotelReservationAdmin.css | 2 +- .../views/js/admin/hotel_rooms_booking.js | 16 +--------------- .../helpers/view/_partials/booking-rooms.tpl | 2 +- .../helpers/view/_partials/search-stats.tpl | 2 +- 5 files changed, 8 insertions(+), 25 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelRoomInformation.php b/modules/hotelreservationsystem/classes/HotelRoomInformation.php index 47eb7b53e..1fe2da0ef 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomInformation.php +++ b/modules/hotelreservationsystem/classes/HotelRoomInformation.php @@ -158,21 +158,18 @@ class HotelRoomInformation extends ObjectModel return $status; } - public static function getRoomStatusTitle($idStatus = false) + public static function getRoomStatusTitle($idStatus) { $moduleInstance = Module::getInstanceByName('hotelreservationsystem'); $status = array( self::STATUS_ACTIVE => $moduleInstance->l('Active', 'hotelreservationsystem'), self::STATUS_INACTIVE => $moduleInstance->l('Inactive', 'hotelreservationsystem'), self::STATUS_TEMPORARY_INACTIVE => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem'), - self::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Lenght of stay', 'hotelreservationsystem'), - self::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy', 'hotelreservationsystem'), + self::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Searched duration outside room length of stay requirements', 'hotelreservationsystem'), + self::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy exceeds room capacity', 'hotelreservationsystem'), ); - if ($idStatus) { - return isset($status[$idStatus]) ? $status[$idStatus] : false; - } - return $status; + return isset($status[$idStatus]) ? $status[$idStatus] : ''; } /** diff --git a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css index 2961a99cf..5cb295ecf 100644 --- a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css +++ b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css @@ -216,7 +216,7 @@ p.room_cat_data font-weight: 700; margin-bottom: 0px; } -.status-info { +.status-info-tooltip { position: relative; display: inline-block; left: 100%; diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index 8bf7f0eff..6cf0c7d5f 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -963,21 +963,7 @@ $(document).ready(function() { function initstatstooltip() { - console.log($(".htl_room_data_cont").find('.status-info')); - $(".htl_room_data_cont").find('.status-info').tooltip({ - // content: function() - // { - // $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_format); - // $.each(info.event.extendedProps.data.stats, function(elem, val) { - // if (elem == 'num_part_avai') { - // $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); - // } else { - // $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); - // } - // }); - // return $('#date-stats-tooltop').html(); - // }, - // items: "div", + $(".htl_room_data_cont").find('.status-info-tooltip').tooltip({ trigger : 'hover', show: { delay: 100, diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index b5b37fac6..5783f4798 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -217,7 +217,7 @@ {$booked_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$booked_v key=$rm_dtl_k type='booked'} {/if} {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_from']))} - {dateFormat date=date('Y-m-d', strtotime($rm_dtl_v['date_to']))} - #{$rm_dtl_v['id_order']} + #{$rm_dtl_v['id_order']} {$rm_dtl_v['comment']|escape:'htmlall':'UTF-8'} {if $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_AUTO}{l s='Auto Allotment' mod='hotelreservationsystem'}{elseif $rm_dtl_v['booking_type'] == HotelBookingDetail::ALLOTMENT_MANUAL}{l s='Manual Allotment' mod='hotelreservationsystem'}{/if} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl index c672c941b..11690bc24 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl @@ -1,5 +1,5 @@
-
+
From 0c95a3273936033947eb2049e8c11ec2a11bc257 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 23 Aug 2024 11:55:36 +0530 Subject: [PATCH 10/13] Added: Feature in tree select all children node when parent node is selected --- .../normal_products/helpers/tree/tree.tpl | 39 ------------------- .../default/template/helpers/tree/tree.tpl | 16 ++++++++ classes/helper/HelperTree.php | 14 +++++++ .../admin/AdminNormalProductsController.php | 1 + .../classes/HotelHelper.php | 6 +-- 5 files changed, 32 insertions(+), 44 deletions(-) delete mode 100644 admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl diff --git a/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl b/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl deleted file mode 100644 index ce2479919..000000000 --- a/admin/themes/default/template/controllers/normal_products/helpers/tree/tree.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{* -* Since 2010 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 Since 2010 Webkul IN -* @license https://store.webkul.com/license.html -*} -{extends file="helpers/tree/tree.tpl"} - \ No newline at end of file diff --git a/admin/themes/default/template/helpers/tree/tree.tpl b/admin/themes/default/template/helpers/tree/tree.tpl index c4ecff65f..30c4283c6 100644 --- a/admin/themes/default/template/helpers/tree/tree.tpl +++ b/admin/themes/default/template/helpers/tree/tree.tpl @@ -84,6 +84,22 @@ }); {/if} + {if isset($auto_select_children) && $auto_select_children == true} + $('#{$id|escape:'html':'UTF-8'}').find(':input[type=checkbox]').on('click', function(){ + if ($(this).is(":checked")) { + $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){ + $(this).prop('checked', true); + $(this).parent().addClass('tree-selected'); + }); + } else { + $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){ + $(this).prop('checked', false); + $(this).parent().removeClass('tree-selected'); + }); + } + }); + {/if} + $(document).ready(function () { var tree = $("#{$id|escape:'html':'UTF-8'}").tree('collapseAll'); diff --git a/classes/helper/HelperTree.php b/classes/helper/HelperTree.php index 0a3824205..d79bea095 100644 --- a/classes/helper/HelperTree.php +++ b/classes/helper/HelperTree.php @@ -29,6 +29,7 @@ class HelperTreeCore extends TreeCore private $_use_bulk_actions; private $_use_checkbox; private $_show_collapse_expand_button = true; + private $_auto_select_children = false; private $_max_height = 350; @@ -43,6 +44,18 @@ class HelperTreeCore extends TreeCore return (isset($this->_use_search) && $this->_use_search); } + public function setAutoSelectChildren($value) + { + $this->_auto_select_children = (bool)$value; + return $this; + } + + public function autoSelectChildren() + { + return (isset($this->_auto_select_children) && $this->_auto_select_children); + } + + public function setUseBulkActions($value) { $this->_use_bulk_actions = (bool)$value; @@ -119,6 +132,7 @@ class HelperTreeCore extends TreeCore ); $this->setAttribute('use_search', $this->useSearch()); } + $this->setAttribute('auto_select_children', $this->autoSelectChildren()); if ($this->showCollapseExpandButton()) { $collapse_all = new TreeToolbarLink( diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 0e52ca53f..c584a46b6 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -3507,6 +3507,7 @@ class AdminNormalProductsControllerCore extends AdminController 'selectedElements' => $selectedElements ])) ->setUseCheckBox(true) + ->setAutoSelectChildren(true) ->setUseBulkActions(true) ->setUseSearch(true); $data->assign('hotel_tree', $tree->render()); diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index d44240626..dc442e32d 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2730,11 +2730,7 @@ class HotelHelper if (isset($rooms[$roomType['value']])) { $roomType['children'] = $rooms[$roomType['value']]; } - $roomType['hint'] = 'This is Room type hint'; - $roomType['badge'] = array( - 'class' => 'badge-danger', - 'title' => 'Disabled' - ); + if ($previousElements) { $return[$roomType['id_hotel']][] = $roomType; } else { From 1428f7d8d37c3e87b9ff6c12879b0534bfc72fd0 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 23 Aug 2024 13:18:00 +0530 Subject: [PATCH 11/13] Udpated the popup design for services and demands on order detail and order confirmation page in the front --- .../_partials/order-extra-services.tpl | 15 ++++++--------- themes/hotel-reservation-theme/css/global.css | 1 - .../css/order-confirmation.css | 2 +- .../hotel-reservation-theme/css/order-detail.css | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index 5e643b6f0..41c1d338a 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -25,8 +25,12 @@ {if (isset($extraDemands) && $extraDemands) || (isset($additionalServices) && $additionalServices)}
@@ -64,10 +68,6 @@
{assign var=roomCount value=$roomCount+1} {/foreach} - {else} -
- {l s='No service found.'} -
{/if}
@@ -98,9 +98,6 @@
{assign var=roomCount value=$roomCount+1} {/foreach} - {else} -
- {l s='No facility found.'}
{/if}
diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index ab37bfe6a..cd790b7c6 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -8981,7 +8981,6 @@ a.open_rooms_extra_services_panel { margin-bottom: 18px;} */ #rooms_extra_services .room_demand_block { - margin-bottom: 15px; color: #333; font-size: 14px;} #rooms_extra_services .checkbox { diff --git a/themes/hotel-reservation-theme/css/order-confirmation.css b/themes/hotel-reservation-theme/css/order-confirmation.css index f7f16bdbe..d5b416c63 100644 --- a/themes/hotel-reservation-theme/css/order-confirmation.css +++ b/themes/hotel-reservation-theme/css/order-confirmation.css @@ -115,10 +115,10 @@ #rooms_extra_services .nav-tabs { border-bottom: none; + margin-left: 15px; } #rooms_extra_services .nav-tabs > li { - width: 50%; text-align: center; margin: 0; } diff --git a/themes/hotel-reservation-theme/css/order-detail.css b/themes/hotel-reservation-theme/css/order-detail.css index 3f7544dcd..81666c2cf 100644 --- a/themes/hotel-reservation-theme/css/order-detail.css +++ b/themes/hotel-reservation-theme/css/order-detail.css @@ -1005,10 +1005,10 @@ #popup-view-extra-services .nav-tabs { border-bottom: none; + margin-left: 15px; } #popup-view-extra-services .nav-tabs > li { - width: 50%; text-align: center; margin: 0; } From a6dc63552076ef409da0d1d39f385e9ffb224c34 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 23 Aug 2024 19:24:14 +0530 Subject: [PATCH 12/13] Removed the non required css and opimized the code --- .../_partials/order-extra-services.tpl | 140 +++++++++--------- .../css/order-confirmation.css | 6 +- .../css/order-detail.css | 6 +- 3 files changed, 77 insertions(+), 75 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index 41c1d338a..8a101f3cb 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -23,85 +23,83 @@
{if (isset($extraDemands) && $extraDemands) || (isset($additionalServices) && $additionalServices)} -
- -
+ +
+ {if isset($additionalServices) && $additionalServices}
- {if isset($additionalServices) && $additionalServices} - {assign var=roomCount value=1} - {foreach $additionalServices as $key => $roomAdditionalService} -
-
- {l s='Room'} {$roomCount|string_format:'%02d'}  - ({if {$roomAdditionalService['adults']} <= 9}0{$roomAdditionalService['adults']}{else}{$roomAdditionalService['adults']}{/if} {if $roomAdditionalService['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomAdditionalService['children'] > 0}, {if {$roomAdditionalService['children']} <= 9}0{$roomAdditionalService['children']}{else}{$roomAdditionalService['children']}{/if} {if $roomAdditionalService['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) -
-
- {foreach $roomAdditionalService['additional_services'] as $additionalService} -
+ {assign var=roomCount value=1} + {foreach $additionalServices as $key => $roomAdditionalService} +
+
+ {l s='Room'} {$roomCount|string_format:'%02d'}  + ({if {$roomAdditionalService['adults']} <= 9}0{$roomAdditionalService['adults']}{else}{$roomAdditionalService['adults']}{/if} {if $roomAdditionalService['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomAdditionalService['children'] > 0}, {if {$roomAdditionalService['children']} <= 9}0{$roomAdditionalService['children']}{else}{$roomAdditionalService['children']}{/if} {if $roomAdditionalService['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) +
+
+ {foreach $roomAdditionalService['additional_services'] as $additionalService} +
+
-
- {$additionalService['name']|escape:'html':'UTF-8'} - {if $additionalService['allow_multiple_quantity']} - {l s='(Quantity: %s)' sprintf=[$additionalService['quantity']|string_format:'%02d']} - {/if} -
-
-
- - {if $useTax} - {displayPrice price=$additionalService['total_price_tax_incl']|escape:'html':'UTF-8' currency=$objOrder->id_currency} - {else} - {displayPrice price=$additionalService['total_price_tax_excl']|escape:'html':'UTF-8' currency=$objOrder->id_currency} - {/if} - + {$additionalService['name']|escape:'html':'UTF-8'} + {if $additionalService['allow_multiple_quantity']} + {l s='(Quantity: %s)' sprintf=[$additionalService['quantity']|string_format:'%02d']} + {/if}
- {/foreach} -
-
- {assign var=roomCount value=$roomCount+1} - {/foreach} - {/if} -
-
- {if isset($extraDemands) && $extraDemands} - {assign var=roomCount value=1} - {foreach $extraDemands as $roomDemand} -
-
- {l s='Room'} {$roomCount|string_format:'%02d'}  - ({if {$roomDemand['adults']} <= 9}0{$roomDemand['adults']}{else}{$roomDemand['adults']}{/if} {if $roomDemand['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomDemand['children'] > 0}, {if {$roomDemand['children']} <= 9}0{$roomDemand['children']}{else}{$roomDemand['children']}{/if} {if $roomDemand['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) -
-
- {foreach $roomDemand['extra_demands'] as $demand} -
-
{$demand['name']|escape:'html':'UTF-8'}
-
- - {if $useTax} - {displayPrice price="{$demand['total_price_tax_incl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} - {else} - {displayPrice price="{$demand['total_price_tax_excl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} - {/if} - -
+
+ + {if $useTax} + {displayPrice price=$additionalService['total_price_tax_incl']|escape:'html':'UTF-8' currency=$objOrder->id_currency} + {else} + {displayPrice price=$additionalService['total_price_tax_excl']|escape:'html':'UTF-8' currency=$objOrder->id_currency} + {/if} +
- {/foreach} -
+
+ {/foreach}
- {assign var=roomCount value=$roomCount+1} - {/foreach}
- {/if} + {assign var=roomCount value=$roomCount+1} + {/foreach}
-
+ {/if} + {if isset($extraDemands) && $extraDemands} +
+ {assign var=roomCount value=1} + {foreach $extraDemands as $roomDemand} +
+
+ {l s='Room'} {$roomCount|string_format:'%02d'}  + ({if {$roomDemand['adults']} <= 9}0{$roomDemand['adults']}{else}{$roomDemand['adults']}{/if} {if $roomDemand['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $roomDemand['children'] > 0}, {if {$roomDemand['children']} <= 9}0{$roomDemand['children']}{else}{$roomDemand['children']}{/if} {if $roomDemand['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) +
+
+ {foreach $roomDemand['extra_demands'] as $demand} +
+
{$demand['name']|escape:'html':'UTF-8'}
+
+ + {if $useTax} + {displayPrice price="{$demand['total_price_tax_incl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} + {else} + {displayPrice price="{$demand['total_price_tax_excl']|escape:'html':'UTF-8'}" currency=$objOrder->id_currency} + {/if} + +
+
+ {/foreach} +
+
+ {assign var=roomCount value=$roomCount+1} + {/foreach} +
+
+ {/if}
{/if}
diff --git a/themes/hotel-reservation-theme/css/order-confirmation.css b/themes/hotel-reservation-theme/css/order-confirmation.css index d5b416c63..68c5a778d 100644 --- a/themes/hotel-reservation-theme/css/order-confirmation.css +++ b/themes/hotel-reservation-theme/css/order-confirmation.css @@ -113,9 +113,12 @@ } /* card-tabs - end */ +#rooms_extra_services .card-body{ + padding: 0px 18px; +} + #rooms_extra_services .nav-tabs { border-bottom: none; - margin-left: 15px; } #rooms_extra_services .nav-tabs > li { @@ -160,7 +163,6 @@ } #rooms_extra_services .tab-content .room_demands { - padding: 0 18px; margin-top: 20px; } diff --git a/themes/hotel-reservation-theme/css/order-detail.css b/themes/hotel-reservation-theme/css/order-detail.css index 81666c2cf..cbcd0c446 100644 --- a/themes/hotel-reservation-theme/css/order-detail.css +++ b/themes/hotel-reservation-theme/css/order-detail.css @@ -1003,9 +1003,12 @@ line-height: 24px; } +#popup-view-extra-services .card-body{ + padding: 0px 18px; +} + #popup-view-extra-services .nav-tabs { border-bottom: none; - margin-left: 15px; } #popup-view-extra-services .nav-tabs > li { @@ -1049,7 +1052,6 @@ } #popup-view-extra-services .tab-content .room_demands { - padding: 0 18px; margin-top: 20px; } From aa957ac9012e3eb25a4bf7d4eefdadf8fe5cace3 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 26 Aug 2024 15:37:13 +0530 Subject: [PATCH 13/13] updated getBookingData function hook calls --- .../classes/HotelBookingDetail.php | 81 ++++++++----------- .../classes/HotelRoomInformation.php | 24 +++--- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 0563578d1..074dc1ea5 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -185,7 +185,7 @@ class HotelBookingDetail extends ObjectModel return $result; } - public function getBookingDataParams($params) + public function getBookingDataParams(&$params) { if (!isset($params['id_room_type'])) { $params['id_room_type'] = 0; @@ -304,7 +304,7 @@ class HotelBookingDetail extends ObjectModel 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'applyLosRestriction' => $applyLosRestriction, - 'extra_params' => $params, + 'allParams' => $params, ); $unavailRoomTypes = $this->getSearchUnavailableRooms($searchParams); } @@ -317,7 +317,7 @@ class HotelBookingDetail extends ObjectModel 'idGuest' => $id_guest, 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, - 'extra_params' => $params, + 'allParams' => $params, ); $cartRoomTypes = $this->getSearchCartRooms($searchParams); } @@ -335,7 +335,7 @@ class HotelBookingDetail extends ObjectModel 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'applyLosRestriction' => $applyLosRestriction, 'hourlyBooking' => $hourly_booking, - 'extra_params' => $params, + 'allParams' => $params, ); $availableRoomTypes = $this->getSearchAvailableRooms($searchParams); if ($availableRoomTypes['unavailableRoomTypes'] && $search_unavai) { @@ -370,7 +370,7 @@ class HotelBookingDetail extends ObjectModel 'dateTo' => $date_to, 'idRoomType' => $id_room_type, 'allowedIdRoomTypes' => $allowedIdRoomTypes, - 'extra_params' => $params, + 'allParams' => $params, ); $bookedRoomTypes = $this->getSearchBookedRooms($searchParams); } @@ -387,7 +387,7 @@ class HotelBookingDetail extends ObjectModel 'searchOccupancy' => $occupancy, 'allowedIdRoomTypes' => $allowedIdRoomTypes, 'hourlyBooking' => $hourly_booking, - 'extra_params' => $params, + 'allParams' => $params, ); $partiallyAvailRoomTypes = $this->getSearchPartiallyAvailRooms($searchParams); @@ -493,7 +493,7 @@ class HotelBookingDetail extends ObjectModel * 'idRoomType' => ..., * 'allowedIdRoomTypes' => ..., * 'applyLosRestriction' => ..., - * 'extra_params' => ..., + * 'allParams' => ..., * ); */ protected function getSearchUnavailableRooms($params) @@ -541,19 +541,16 @@ class HotelBookingDetail extends ObjectModel } - $hookParams = array( + Hook::exec('actionUnavailRoomSearchSqlModifier', array( 'sql' => &$sql, 'params' => array( 'id_hotel' => $idHotel, 'id_product' => $idRoomType, 'date_from' => $dateFrom, 'date_to' => $dateTo, + 'all_params' => $allParams ) - ); - if (isset($extra_params)) { - $hookParams['params']['extra_params'] = $extra_params; - } - Hook::exec('actionUnavailRoomSearchSqlModifier', $hookParams); + )); $sql = implode(' UNION ', $sql); $sql .= ' ORDER BY `id_room`, `date_from` ASC'; @@ -589,7 +586,7 @@ class HotelBookingDetail extends ObjectModel * 'idGuest' => ..., * 'idRoomType' => ..., * 'allowedIdRoomTypes' => ..., - * 'extra_params' => ..., + * 'allParams' => ..., * ); */ protected function getSearchCartRooms($params) @@ -609,7 +606,7 @@ class HotelBookingDetail extends ObjectModel $orderByCartRoomSearch = ''; $orderWayCartRoomSearch = ''; - $hookParams = array( + Hook::exec('actionCartRoomSearchSqlModifier', array( 'select' => $selectCartRoomSearch, 'join' => &$joinCartRoomSearch, 'where' => &$whereCartRoomSearch, @@ -621,12 +618,9 @@ class HotelBookingDetail extends ObjectModel 'id_product' => $idRoomType, 'idCart' => $idCart, 'idGuest' => $idGuest, + 'all_params' => $allParams ) - ); - if (isset($extra_params)) { - $hookParams['params']['extra_params'] = $extra_params; - } - Hook::exec('actionCartRoomSearchSqlModifier', $hookParams); + )); $sql = $selectCartRoomSearch; $sql .= ' FROM `'._DB_PREFIX_.'htl_cart_booking_data` AS cbd'; @@ -659,7 +653,7 @@ class HotelBookingDetail extends ObjectModel * 'allowedIdRoomTypes' => ..., * 'applyLosRestriction' => ..., * 'hourlyBooking' => ..., - * 'extra_params' => ..., + * 'allParams' => ..., * ); */ protected function getSearchAvailableRooms($params) @@ -689,8 +683,8 @@ class HotelBookingDetail extends ObjectModel } // Exculde Booked rooms - $exclude_ids = array(); - $exclude_ids['checked_out'] = 'SELECT `id_room` + $excludeRoomId = array(); + $excludeRoomId['checked_out'] = 'SELECT `id_room` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_hotel` = '.(int)$idHotel.' AND `is_back_order` = 0 AND `is_refunded` = 0 AND IF(`id_status` = '. self::STATUS_CHECKED_OUT.', IF('.(int) $hourlyBooking.', 1, (DATE_FORMAT(`check_out`, "%Y-%m-%d") != DATE_FORMAT(\''.pSQL($dateFrom).'\', "%Y-%m-%d")) AND (`check_out` > \''.pSQL($dateFrom).'\' AND `check_out` <= \''.PSQL($dateTo).'\')) AND ( @@ -706,14 +700,14 @@ class HotelBookingDetail extends ObjectModel )) AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; // Exclude temporary disable rooms - $exclude_ids['disabled'] = 'SELECT hri.`id` AS id_room + $excludeRoomId['disabled'] = 'SELECT hri.`id` AS id_room FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd.`id_room` = hri.`id`) WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (hrdd.`date_from` < \''.pSql($dateTo).'\' AND hrdd.`date_to` > \''.pSql($dateFrom).'\') AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; // LOS Restriction. Also, Remember to check max LOS restriction is greater than zero if ($applyLosRestriction) { - $exclude_ids['length_of_stay'] = 'SELECT hri.`id` AS `id_room` + $excludeRoomId['length_of_stay'] = 'SELECT hri.`id` AS `id_room` FROM `'._DB_PREFIX_.'htl_room_information` AS hri INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_restriction_date_range` AS hrtr ON (hrt.`id_product` = hrtr.`id_product` AND (hrtr.`date_from` <= \''.pSQL($stayStartDate).'\' AND hrtr.`date_to` > \''.pSQL($stayStartDate).'\')) @@ -731,11 +725,11 @@ class HotelBookingDetail extends ObjectModel $orderByAvailRoomSearch = 'ORDER BY ri.`id`'; $orderWayAvailRoomSearch = 'ASC'; - $hookParams = array( + Hook::exec('actionAvailRoomSearchSqlModifier', array( 'select' => $selectAvailRoomSearch, 'join' => &$joinAvailRoomSearch, 'where' => &$whereAvailRoomSearch, - 'exclude_ids' => &$exclude_ids, + 'exclude_room_id' => &$excludeRoomId, 'group_by' => &$groupByAvailRoomSearch, 'order_by' => &$orderByAvailRoomSearch, 'order_way' => &$orderWayAvailRoomSearch, @@ -744,18 +738,15 @@ class HotelBookingDetail extends ObjectModel 'id_product' => $idRoomType, 'date_from' => $dateFrom, 'date_to' => $dateTo, + 'all_params' => $allParams ) - ); - if (isset($extra_params)) { - $hookParams['params']['extra_params'] = $extra_params; - } - Hook::exec('actionAvailRoomSearchSqlModifier', $hookParams); + )); $sql = $selectAvailRoomSearch; $sql .= ' FROM `'._DB_PREFIX_.'htl_room_information` AS ri'; $sql .= ' '.$joinAvailRoomSearch; $sql .= ' '.$whereAvailRoomSearch; - $sql .= ' AND ri.`id` NOT IN ('.implode(' UNION ', $exclude_ids).')'; + $sql .= ' AND ri.`id` NOT IN ('.implode(' UNION ', $excludeRoomId).')'; $sql .= ' '.$groupByAvailRoomSearch; $sql .= ' '.$orderByAvailRoomSearch; $sql .= ' '.$orderWayAvailRoomSearch; @@ -1013,7 +1004,7 @@ class HotelBookingDetail extends ObjectModel * 'searchOccupancy' => ..., * 'allowedIdRoomTypes' => ..., * 'hourlyBooking' => ..., - * 'extra_params' => ..., + * 'allParams' => ..., * ); */ protected function getSearchPartiallyAvailRooms($params) @@ -1045,19 +1036,16 @@ class HotelBookingDetail extends ObjectModel (hrdd.`date_from` > \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` < \''.pSQL($dateTo).'\') ) AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')'; - $hookParams = array( + Hook::exec('actionPartiallyAvailRoomSearchSqlModifier', array( 'sql' => &$sql, 'params' => array( 'id_hotel' => $idHotel, 'id_product' => $idRoomType, 'date_from' => $dateFrom, 'date_to' => $dateTo, + 'all_params' => $allParams ) - ); - if (isset($extra_params)) { - $hookParams['params']['extra_params'] = $extra_params; - } - Hook::exec('actionPartiallyAvailRoomSearchSqlModifier', $hookParams); + )); $sql = implode(' UNION ', $sql); $sql .= ' ORDER BY id_room ASC'; @@ -1372,10 +1360,10 @@ class HotelBookingDetail extends ObjectModel (`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` >= \''.pSQL($dateTo).'\') )) AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')'; $groupByBookedRoomSearch = ''; - $orderByBookedRoomSearch = 'ORDER BY `id_room`, `date_from` ASC'; - $orderWayBookedRoomSearch = ''; + $orderByBookedRoomSearch = 'ORDER BY `id_room`, `date_from`'; + $orderWayBookedRoomSearch = 'ASC'; - $hookParams = array( + Hook::exec('actionBookedRoomSearchSqlModifier', array( 'select' => $selectBookedRoomSearch, 'join' => &$joinBookedRoomSearch, 'where' => &$whereBookedRoomSearch, @@ -1387,12 +1375,9 @@ class HotelBookingDetail extends ObjectModel 'id_product' => $idRoomType, 'date_from' => $dateFrom, 'date_to' => $dateTo, + 'all_params' => $allParams ) - ); - if (isset($extra_params)) { - $hookParams['params']['extra_params'] = $extra_params; - } - Hook::exec('actionBookedRoomSearchSqlModifier', $hookParams); + )); $sql = $selectBookedRoomSearch; $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail`'; diff --git a/modules/hotelreservationsystem/classes/HotelRoomInformation.php b/modules/hotelreservationsystem/classes/HotelRoomInformation.php index 8b5941a5a..d1f8dc2de 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomInformation.php +++ b/modules/hotelreservationsystem/classes/HotelRoomInformation.php @@ -79,7 +79,7 @@ class HotelRoomInformation extends ObjectModel { if ($idRoom = $this->id) { // delete rooms from cart which are set inactive - if ($this->id_status == self::STATUS_INACTIVE) { + if ($this->id_status == HotelRoomInformation::STATUS_INACTIVE) { $objCartBookingData = new HotelCartBookingData(); if (!$objCartBookingData->deleteCartBookingData(0, 0, $idRoom)) { return false; @@ -143,16 +143,16 @@ class HotelRoomInformation extends ObjectModel { $status = array( 'STATUS_ACTIVE' => array( - 'id' => self::STATUS_ACTIVE, - 'status' => self::getRoomStatusTitle(self::STATUS_ACTIVE) + 'id' => HotelRoomInformation::STATUS_ACTIVE, + 'status' => self::getRoomStatusTitle(HotelRoomInformation::STATUS_ACTIVE) ), 'STATUS_INACTIVE' => array( - 'id' => self::STATUS_INACTIVE, - 'status' => self::getRoomStatusTitle(self::STATUS_INACTIVE) + 'id' => HotelRoomInformation::STATUS_INACTIVE, + 'status' => self::getRoomStatusTitle(HotelRoomInformation::STATUS_INACTIVE) ), 'STATUS_TEMPORARY_INACTIVE' => array( - 'id' => self::STATUS_TEMPORARY_INACTIVE, - 'status' => self::getRoomStatusTitle(self::STATUS_TEMPORARY_INACTIVE) + 'id' => HotelRoomInformation::STATUS_TEMPORARY_INACTIVE, + 'status' => self::getRoomStatusTitle(HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) ), ); return $status; @@ -162,11 +162,11 @@ class HotelRoomInformation extends ObjectModel { $moduleInstance = Module::getInstanceByName('hotelreservationsystem'); $status = array( - self::STATUS_ACTIVE => $moduleInstance->l('Active', 'hotelreservationsystem'), - self::STATUS_INACTIVE => $moduleInstance->l('Inactive', 'hotelreservationsystem'), - self::STATUS_TEMPORARY_INACTIVE => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem'), - self::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Searched duration outside room length of stay requirements', 'hotelreservationsystem'), - self::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy exceeds room capacity', 'hotelreservationsystem'), + HotelRoomInformation::STATUS_ACTIVE => $moduleInstance->l('Active', 'hotelreservationsystem'), + HotelRoomInformation::STATUS_INACTIVE => $moduleInstance->l('Inactive', 'hotelreservationsystem'), + HotelRoomInformation::STATUS_TEMPORARY_INACTIVE => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem'), + HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Length of stay restriction not satisfied', 'hotelreservationsystem'), + HotelRoomInformation::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy exceeds room capacity', 'hotelreservationsystem'), ); return isset($status[$idStatus]) ? $status[$idStatus] : '';