Add Hotel and Room type suggestions for filter inputs on admin orders list page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)}
|
||||
<option value="" selected="selected">-</option>
|
||||
{foreach from=$hotel_room_types item=hotel_room_type}
|
||||
<option value="{$hotel_room_type.id_product}">{$hotel_room_type.room_type}, {$hotel_name}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
@@ -152,7 +152,7 @@
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="panel collapse" id="list_filters_panel">
|
||||
<div class="panel" id="list_filters_panel">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="list_filters">
|
||||
@@ -246,7 +246,7 @@
|
||||
</div>
|
||||
{elseif $params.type == 'select'}
|
||||
{if isset($params.filter_key)}
|
||||
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if}" onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
|
||||
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if} {if isset($params.class)}{$params.class}{/if}" {if !isset($params.remove_onchange) || !$params.remove_onchange}onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();"{/if} name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
|
||||
<option value="" {if $params.value == ''} selected="selected" {/if}>-</option>
|
||||
{if isset($params.list) && is_array($params.list)}
|
||||
{foreach $params.list AS $option_value => $option_display}
|
||||
@@ -256,7 +256,7 @@
|
||||
</select>
|
||||
{/if}
|
||||
{else}
|
||||
<input type="text" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'html':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
|
||||
<input type="text" id="filter_input_{$key}" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'html':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.list_action_wrapper {
|
||||
|
||||
@@ -44,6 +44,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
protected $statuses_array = array();
|
||||
protected $all_order_sources = array();
|
||||
protected $hotelsArray = array();
|
||||
protected $roomTypesArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -97,6 +99,21 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->all_order_sources[$source['source']] = $source['source'];
|
||||
}
|
||||
|
||||
$hotelsArray = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1);
|
||||
foreach ($hotelsArray as $hotel) {
|
||||
$addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']);
|
||||
$this->hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city'];
|
||||
}
|
||||
|
||||
$roomTypesArray = array();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
foreach ($hotelsArray as $hotel) {
|
||||
$hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($hotel['id_hotel'], $this->context->language->id);
|
||||
foreach ($hotelRoomTypes as $room_type) {
|
||||
$this->roomTypesArray[$room_type['id_product']] = $room_type['room_type'].', '.$hotel['hotel_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_order' => array(
|
||||
'title' => $this->l('ID'),
|
||||
@@ -122,8 +139,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
),
|
||||
'hotel_name' => array(
|
||||
'title' => $this->l('Hotel'),
|
||||
'filter_key' => 'hbil!hotel_name',
|
||||
'type' => 'select',
|
||||
'filter_key' => 'hbd!id_hotel',
|
||||
'list' => $this->hotelsArray,
|
||||
'optional' => true,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'date_from' => array(
|
||||
@@ -140,9 +161,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
),
|
||||
'room_type_name' => array(
|
||||
'title' => $this->l('Room type'),
|
||||
'filter_key' => 'hbd!room_type_name',
|
||||
'type'=>'text',
|
||||
'displayed' => false,
|
||||
'type' => 'select',
|
||||
'filter_key' => 'hbd!id_product',
|
||||
'list' => $this->roomTypesArray,
|
||||
'optional' => true,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => true,
|
||||
),
|
||||
'total_guests' => array(
|
||||
'title' => $this->l('Guests'),
|
||||
@@ -1865,6 +1890,27 @@ class AdminOrdersControllerCore extends AdminController
|
||||
return $modal;
|
||||
}
|
||||
|
||||
public function ajaxProcessGetHotelRoomTypes()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($idHotel, $this->context->language->id);
|
||||
if (is_array($hotelRoomTypes) && count($hotelRoomTypes)) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id);
|
||||
$this->context->smarty->assign(array(
|
||||
'hotel_room_types' => $hotelRoomTypes,
|
||||
'hotel_name' => $objHotelBranchInformation->hotel_name,
|
||||
));
|
||||
|
||||
$response['status'] = true;
|
||||
$response['html_room_types'] = $this->context->smarty->fetch('controllers/orders/_filter_room_types.tpl');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessGetBookingDocuments()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
|
||||
Reference in New Issue
Block a user