Updated: The hotel and room type filters on the advance price rules listing

This commit is contained in:
vishalsingh.qlo325
2025-06-23 14:42:59 +05:30
parent bd7bfcfdf5
commit 0865fc8221
3 changed files with 185 additions and 1 deletions

View File

@@ -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));
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a 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
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../../../');
exit;

View File

@@ -0,0 +1,81 @@
{**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License version 3.0
* that is bundled with this package in the file LICENSE.md
* It is also available through the world-wide-web at this URL:
* https://opensource.org/license/osl-3-0-php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to support@qloapps.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to a 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
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{extends file="helpers/list/list_header.tpl"}
{block name="override_form_extra"}
<script>
$(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 = $('<select>').append($('<option>').attr('value', '').text('-').attr('selected', true));
$(response.room_types_info).each(function(index, roomType){
$(selectElem).append($('<option>').attr('value', roomType.id_product).text(roomType.room_type + ', '+ roomType.hotel_name));
if (!hasSelectedRoomType && roomType.id_product == selectedIdRoomType) {
hasSelectedRoomType = true;
}
});
$(filterInputRoomTypeName).html($(selectElem).html());
} else {
$(filterInputRoomTypeName).find('option').not(':first').remove();
}
if (hasSelectedRoomType && selectedIdRoomType) {
$(filterInputRoomTypeName).find('option[value="'+ selectedIdRoomType+'"]').attr('selected', true);
}
// destroy current chosen and re-initialize
$(filterInputRoomTypeName).chosen('destroy');
$(filterInputRoomTypeName).chosen({
disable_search_threshold: 5,
search_contains: true,
});
}
},
});
}
// manage Hotel filter input
$(document).on('change', '#filter_input_hotel_name', function () {
updateRoomTypeFilter();
});
});
</script>
{/block}