diff --git a/admin/themes/default/template/controllers/orders/_filter_hotel_rooms.tpl b/admin/themes/default/template/controllers/orders/_filter_hotel_rooms.tpl new file mode 100644 index 000000000..a49897bc6 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/_filter_hotel_rooms.tpl @@ -0,0 +1,25 @@ +{** + * 2010-2024 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-2024 Webkul IN + * @license LICENSE.txt + *} + +{if is_array($hotel_rooms_info) && count($hotel_rooms_info)} + + {foreach from=$hotel_rooms_info item=hotel_room} + + {/foreach} +{/if} 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..85a4111c7 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/_filter_room_types.tpl @@ -0,0 +1,25 @@ +{** + * 2010-2024 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-2024 Webkul IN + * @license LICENSE.txt + *} + +{if is_array($room_types_info) && count($room_types_info)} + + {foreach from=$room_types_info item=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..24385cc8e 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 @@ -122,25 +122,37 @@ {if ($params.type == 'date' || $params.type == 'datetime' || $params.type == 'range') && $params.value|is_array} {assign var="filter_value" value=''} {foreach $params.value as $value} - {if ($value|is_string && !empty($value))} - {if empty($filter_value)} + {if (isset($value) && ($value !== '' || $value === 0))} + {if !(isset($filter_value) && ($filter_value !== '' || $filter_value === 0))} {assign var="filter_value" value=$value} {else} {assign var="filter_value" value="`$filter_value` - `$value`"} {/if} {/if} {/foreach} - {if !empty($filter_value)} + {if (isset($filter_value) && ($filter_value !== '' || $filter_value === 0))} {$params['title']|escape:'html':'UTF-8'}: {$filter_value|escape:'html':'UTF-8'} {/if} - {else if $params.type == 'select'} - - {$params['title']|escape:'html':'UTF-8'}: {$params['list'][$params['value']]|escape:'html':'UTF-8'} - - + {elseif $params.type == 'select'} + {if isset($params.multiple) && $params.multiple} + + {$params['title']|escape:'html':'UTF-8'}: + + {foreach from=$params.value item=option name=foreachInfo} + {$params.list[$option]}{if !$smarty.foreach.foreachInfo.last}{if $params.operator == 'or'} | {else}, {/if}{/if} + {/foreach} + + + + {else} + + {$params['title']|escape:'html':'UTF-8'}: {$params['list'][$params['value']]|replace: ' ' : ''} + + + {/if} {else} {$params['title']|escape:'html':'UTF-8'}: {$params['value']|escape:'html':'UTF-8'} @@ -166,7 +178,7 @@ - {else if $params.type == 'bool'} + {elseif $params.type == 'bool'} - + {if isset($params.multiple) && $params.multiple} + + {else} + {if isset($params.filter_key)} + + {/if} {/if} {else} - + {/if} @@ -297,12 +319,112 @@ } else if (type == 'range') { $('#list_filters_panel').find('[name*="orderFilter_'+$(this).parent().data('filter_key')+'"]').val(''); } else if (type == 'select') { - $('#list_filters_panel').find('select[name="orderFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop("selected", false); + $('#list_filters_panel').find('select[name*="orderFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop('selected', false); } else { $('#list_filters_panel').find('input[name="orderFilter_'+$(this).parent().data('filter_key')+'"]').val(''); } + + // set post data for empty multi-select filters + $(form).find('select[multiple]').each(function (i, selectElement) { + if ($(selectElement).find('option:selected').length == 0) { + $(form).append(''); + } + }); + form.submit(); }); + + $('#form-order').submit(function () { + let form = $(this); + $(form).find('select[multiple]').each(function (i, selectElement) { + if ($(selectElement).val() == null) { + $(form).append(''); + } + }); + + return true; + }); + }); + + function updateRoomTypeFilter() { + let filterInputHotelName = $('#filter_input_hotel_name'); + let filterInputRoomTypeName = $('#filter_input_room_type_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) { + if (response.has_room_types) { + $(filterInputRoomTypeName).html(response.html_room_types); + } else { + $(filterInputRoomTypeName).find('option').not(':first').remove(); + } + + // destroy current chosen and re-initialize + $(filterInputRoomTypeName).chosen('destroy'); + $(filterInputRoomTypeName).chosen({ + disable_search_threshold: 5, + search_contains: true, + }); + } + }, + }); + } + + function updateHotelRoomsFilter(useRoomType = true) { + let filterInputHotelName = $('#filter_input_hotel_name'); + let filterInputRoomTypeName = $('#filter_input_room_type_name'); + let filterInputRoomNumber = $('#filter_input_id_room_information'); + + let idHotel = parseInt($(filterInputHotelName).val() || '0'); + let idProduct = parseInt($(filterInputRoomTypeName).val() || '0'); + + $.ajax({ + url: currentIndex + '&token=' + token, + data: { + ajax: true, + action: 'GetHotelRooms', + id_hotel: idHotel, + id_product: useRoomType ? idProduct : 0, + }, + type: 'POST', + dataType: 'JSON', + success: function(response) { + if (response.status) { + if (response.has_hotel_rooms) { + $(filterInputRoomNumber).html(response.html_hotel_rooms); + } else { + $(filterInputRoomNumber).find('option').not(':first').remove(); + } + + // destroy current chosen and re-initialize + $(filterInputRoomNumber).chosen('destroy'); + $(filterInputRoomNumber).chosen({ + disable_search_threshold: 5, + search_contains: true, + }); + } + }, + }); + } + + // manage Hotel and Room type filter inputs + $(document).on('change', '#filter_input_hotel_name', function () { + updateRoomTypeFilter(); + updateHotelRoomsFilter(false); + }); + + $(document).on('change', '#filter_input_room_type_name', function () { + updateHotelRoomsFilter(); });