From b420133e7b568a87fa4d384b5c39128689ebebf1 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 28 Aug 2023 15:56:25 +0530 Subject: [PATCH 01/13] Add Hotel and Room type suggestions for filter inputs on admin orders list page --- .../themes/default/sass/partials/_chosen.sass | 2 + .../controllers/orders/_filter_room_types.tpl | 25 +++++++++ .../orders/helpers/list/list_header.tpl | 36 +++++++++++-- controllers/admin/AdminOrdersController.php | 54 +++++++++++++++++-- 4 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 admin/themes/default/template/controllers/orders/_filter_room_types.tpl diff --git a/admin/themes/default/sass/partials/_chosen.sass b/admin/themes/default/sass/partials/_chosen.sass index 9f5f1f7e7..25ff66ef3 100644 --- a/admin/themes/default/sass/partials/_chosen.sass +++ b/admin/themes/default/sass/partials/_chosen.sass @@ -200,6 +200,8 @@ $chosen-sprite-path: '../img/chosen-sprite.png' input position: absolute @include left(-9000px) + &:before + visibility: hidden .chosen-container-multi .chosen-choices diff --git a/admin/themes/default/template/controllers/orders/_filter_room_types.tpl b/admin/themes/default/template/controllers/orders/_filter_room_types.tpl new file mode 100644 index 000000000..59d10a755 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/_filter_room_types.tpl @@ -0,0 +1,25 @@ +{** + * 2010-2023 Webkul. + * + * NOTICE OF LICENSE + * + * All right is reserved, + * Please go through LICENSE.txt file inside our module + * + * 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 CustomizationPolicy.txt file inside our module for more information. + * + * @author Webkul IN + * @copyright 2010-2023 Webkul IN + * @license LICENSE.txt + *} + +{if is_array($hotel_room_types) && count($hotel_room_types)} + + {foreach from=$hotel_room_types item=hotel_room_type} + + {/foreach} +{/if} diff --git a/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl b/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl index c5fa152c5..2b0f4a93f 100644 --- a/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/list/list_header.tpl @@ -152,7 +152,7 @@ {/if} -
+
@@ -246,7 +246,7 @@
{elseif $params.type == 'select'} {if isset($params.filter_key)} - {if isset($params.list) && is_array($params.list)} {foreach $params.list AS $option_value => $option_display} @@ -256,7 +256,7 @@ {/if} {else} - + {/if}
@@ -304,6 +304,36 @@ form.submit(); }); }); + + // manage Hotel and Room type filter inputs + $(document).on('change', '#filter_input_hotel_name', function () { + let filterInputHotelName = $('#filter_input_hotel_name'); + let filterInputRoomTypeName = $('#filter_input_room_type_name'); + + let idHotel = parseInt($(filterInputHotelName).val()); + $.ajax({ + url: currentIndex + '&token=' + token, + data: { + ajax: true, + action: 'GetHotelRoomTypes', + id_hotel: idHotel, + }, + type: 'POST', + dataType: 'JSON', + success: function(response) { + if (response.status) { + $(filterInputRoomTypeName).html(response.html_room_types); + + // destoy current chosen and re-initialize + $(filterInputRoomTypeName).chosen('destroy'); + $(filterInputRoomTypeName).chosen({ + disable_search_threshold: 10, + search_contains: true, + }); + } + }, + }); + });