From 0865fc8221d2391c3acd4f09a8dd4f5331e66c1b Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Mon, 23 Jun 2025 14:42:59 +0530 Subject: [PATCH] Updated: The hotel and room type filters on the advance price rules listing --- .../admin/AdminHotelFeaturePricesSettings.php | 73 ++++++++++++++++- .../hotel_features/helpers/list/index.php | 32 ++++++++ .../helpers/list/list_header.tpl | 81 +++++++++++++++++++ 3 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/list/index.php create mode 100644 modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/list/list_header.tpl diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index 6bfbd4ee7..6ce0733cd 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -70,6 +70,24 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController ); $priorities = Configuration::get('HTL_FEATURE_PRICING_PRIORITY'); + $hotelsArray = array(); + $roomTypesArray = array(); + $objHotelRoomType = new HotelRoomType(); + if ($accsHlts = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1)) { + foreach ($accsHlts as $hotel) { + $addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']); + $hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city']; + } + + foreach ($accsHlts as $hotel) { + if ($hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($hotel['id_hotel'], $this->context->language->id)) { + foreach ($hotelRoomTypes as $room_type) { + $roomTypesArray[$room_type['id_product']] = $room_type['room_type'].', '.$hotel['hotel_name']; + } + } + } + } + $this->context->smarty->assign('featurePricePriority', explode(';', $priorities)); $this->fields_options = array('feature_price_priority' => array()); $this->fields_list = array( @@ -85,12 +103,19 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController 'product_name' => array( 'title' => $this->l('Room Type'), 'align' => 'center', - 'havingFilter' => true, + 'type' => 'select', 'callback' => 'getRoomTypeLink', + 'filter_key' => 'a!id_product', + 'list' => $roomTypesArray, + 'class' => 'chosen', ), 'hotel_name' => array( 'title' => $this->l('Hotel'), 'align' => 'center', + 'type' => 'select', + 'filter_key' => 'hrt!id_hotel', + 'list' => $hotelsArray, + 'class' => 'chosen' ), 'impact_way' => array( 'title' => $this->l('Impact Way'), @@ -663,4 +688,50 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'); $this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js'); } + + public function ajaxProcessGetHotelRoomTypes() + { + $response = array('status' => false); + + $idHotel = (int) Tools::getValue('id_hotel'); + $objHotelRoomType = new HotelRoomType(); + $hotelRoomTypes = array(); + + if ($idHotel > 0) { + if ($hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($idHotel, $this->context->language->id)) { + $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); + foreach ($hotelRoomTypes as &$hotelRoomType) { + $hotelRoomType['hotel_name'] = $objHotelBranchInformation->hotel_name; + } + } + } else if ($allHotelRoomTypes = $objHotelRoomType->getAllRoomTypes()) { + $hotels = array(); + foreach ($allHotelRoomTypes as $hotelRoomType) { + if (!array_key_exists($hotelRoomType['id_hotel'], $hotels)) { + $hotels[$hotelRoomType['id_hotel']] = new HotelBranchInformation( + $hotelRoomType['id_hotel'], + $this->context->language->id + ); + } + + $objProduct = new Product($hotelRoomType['id_product'], false, $this->context->language->id); + $hotelRoomTypes[] = array( + 'id_product' => $hotelRoomType['id_product'], + 'room_type' => $objProduct->name, + 'hotel_name' => $hotels[$hotelRoomType['id_hotel']]->hotel_name, + ); + } + } + + if ($hotelRoomTypes) { + $response['status'] = true; + $response['has_room_types'] = true; + $response['room_types_info'] = $hotelRoomTypes; + } else { + $response['has_room_types'] = false; + $response['status'] = true; + } + + $this->ajaxDie(json_encode($response)); + } } diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/list/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/list/index.php new file mode 100644 index 000000000..409280877 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/list/index.php @@ -0,0 +1,32 @@ + + $(document).ready(function(){ + updateRoomTypeFilter(); + function updateRoomTypeFilter() { + let filterInputHotelName = $('#filter_input_hotel_name'); + let filterInputRoomTypeName = $('#filter_input_product_name'); + + let idHotel = parseInt($(filterInputHotelName).val() || '0'); + + $.ajax({ + url: currentIndex + '&token=' + token, + data: { + ajax: true, + action: 'GetHotelRoomTypes', + id_hotel: idHotel, + }, + type: 'POST', + dataType: 'JSON', + success: function(response) { + if (response.status) { + let selectedIdRoomType = parseInt($(filterInputRoomTypeName).val() || '0'); + let hasSelectedRoomType = false; + if (response.has_room_types) { + let selectElem = $('