Skip to content

Commit ee3d783

Browse files
authored
Merge pull request #807 from abhishek-webkul/gli-1327
Added: Warning for maximum quantity of service products in Extra Services popup when creating or editing a booking at back office
2 parents 0268e72 + a556eec commit ee3d783

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl

+4-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@
134134
<p>{$product['name']|escape:'html':'UTF-8'}</p>
135135
{if $product.allow_multiple_quantity}
136136
<div class="qty_container">
137-
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" min="1" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}{$selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity']}{else}1{/if}">
137+
<input type="number" class="form-control room_type_service_product_qty qty" id="qty_{$product.id_product}" name="service_product_qty_{$product.id_product}" data-id-product="{$product.id_product}" min="1" data-max-quantity="{$product.max_quantity}" value="{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}{$selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity']}{else}1{/if}">
138+
<p style="display:{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'][$product['id_product']]['quantity'] > $product.max_quantity}block{else}none{/if}; margin-top: 4px;">
139+
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity}</span>
140+
</p>
138141
</div>
139142
{/if}
140143
</div>

admin/themes/default/template/controllers/orders/_room_services_block.tpl

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@
5353
<span class="badge badge-info label">{l s='Convenience fee'}</span>
5454
{/if}
5555
</td>
56-
<td>
56+
<td class="col-sm-4">
5757
{if $service['allow_multiple_quantity']}
5858
<div class="qty_container">
59-
<input type="number" class="form-control qty" min="1" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}">
59+
<input type="number" class="form-control qty" min="1" data-max-quantity="{$service['max_quantity']}" data-id_room_type_service_product_order_detail="{$service['id_room_type_service_product_order_detail']}" data-id_product="{$service['id_product']|escape:'html':'UTF-8'}" value="{$service['quantity']|escape:'html':'UTF-8'}">
60+
<p style="display:{if $service['quantity'] > $service['max_quantity']}block{else}none{/if}; margin-top: 4px;">
61+
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$service['max_quantity']}</span>
62+
</p>
6063
</div>
6164
{else}
6265
--

admin/themes/default/template/controllers/orders/form.tpl

+11
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,17 @@
15831583
}
15841584
});
15851585
1586+
$(document).on('change', '.room_type_service_product_qty', function(e) {
1587+
let quantityInputField = this;
1588+
let maximumQuantity = parseInt($(quantityInputField).attr('data-max-quantity'));
1589+
let currentQuantity = parseInt($(quantityInputField).val());
1590+
if (currentQuantity > maximumQuantity) {
1591+
$(quantityInputField).siblings('p').show();
1592+
} else {
1593+
$(quantityInputField).siblings('p').hide();
1594+
}
1595+
});
1596+
15861597
function updateServiceProducts(element)
15871598
{
15881599
var operator = $(element).is(':checked') ? 'up' : 'down';

admin/themes/default/template/controllers/orders/helpers/view/view.tpl

+11
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,17 @@
17551755
$('#room_extra_demand_content #back_to_service_btn').hide();
17561756
});
17571757
1758+
$(document).on('change', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) {
1759+
let quantityInputField = this;
1760+
let maximumQuantity = parseInt($(quantityInputField).attr('data-max-quantity'));
1761+
let currentQuantity = parseInt($(quantityInputField).val());
1762+
if (currentQuantity > maximumQuantity) {
1763+
$(quantityInputField).siblings('p').show();
1764+
} else {
1765+
$(quantityInputField).siblings('p').hide();
1766+
}
1767+
});
1768+
17581769
$(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) {
17591770
var qty_wntd = $(this).val();
17601771
if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) {

modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,14 @@ public function getSelectedServicesForRoom(
196196

197197
$sql = 'SELECT rsod.*';
198198
if (!$getTotalPrice) {
199-
$sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`,
199+
$sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`, p.`max_quantity`,
200200
od.`product_auto_add`, od.`product_price_calculation_method`, od.`product_price_addition_type`';
201201
}
202202
$sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
203203
INNER JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
204204

205205
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = rsod.`id_order_detail`)';
206+
$sql .= ' INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rsod.`id_product`)';
206207

207208
$sql .= ' WHERE hbd.`id` = '.(int)$idHotelBookingDetail;
208209

@@ -229,6 +230,7 @@ public function getSelectedServicesForRoom(
229230
'name' => $product['name'],
230231
'quantity' => $product['quantity'],
231232
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
233+
'max_quantity' => $product['max_quantity'],
232234
'product_auto_add' => $product['product_auto_add'],
233235
'product_price_addition_type' => $product['product_price_addition_type'],
234236
'product_price_calculation_method' => $product['product_price_calculation_method'],
@@ -253,6 +255,7 @@ public function getSelectedServicesForRoom(
253255
'name' => $product['name'],
254256
'quantity' => $product['quantity'],
255257
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
258+
'max_quantity' => $product['max_quantity'],
256259
'product_auto_add' => $product['product_auto_add'],
257260
'product_price_addition_type' => $product['product_price_addition_type'],
258261
'product_price_calculation_method' => $product['product_price_calculation_method'],

0 commit comments

Comments
 (0)