Add warning on order edit

This commit is contained in:
Abhishek Kumar
2023-11-20 17:45:33 +05:30
parent fa7acdcc65
commit a556eecf23
4 changed files with 21 additions and 4 deletions

View File

@@ -135,7 +135,7 @@
{if $product.allow_multiple_quantity}
<div class="qty_container">
<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}">
<p style="display:{if isset($selectedRoomServiceProduct['selected_service']) && $selectedRoomServiceProduct['selected_service'] && ($product['id_product']|array_key_exists:$selectedRoomServiceProduct['selected_service'])}block{else}none{/if}; margin-top: 4px;">
<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;">
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity}</span>
</p>
</div>

View File

@@ -53,10 +53,13 @@
<span class="badge badge-info label">{l s='Convenience fee'}</span>
{/if}
</td>
<td>
<td class="col-sm-4">
{if $service['allow_multiple_quantity']}
<div class="qty_container">
<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'}">
<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'}">
<p style="display:{if $service['quantity'] > $service['max_quantity']}block{else}none{/if}; margin-top: 4px;">
<span class="label label-warning">{l s='Maximum allowed quantity: %s' sprintf=$service['max_quantity']}</span>
</p>
</div>
{else}
--

View File

@@ -1753,6 +1753,17 @@
$('#room_extra_demand_content #back_to_service_btn').hide();
});
$(document).on('change', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) {
let quantityInputField = this;
let maximumQuantity = parseInt($(quantityInputField).attr('data-max-quantity'));
let currentQuantity = parseInt($(quantityInputField).val());
if (currentQuantity > maximumQuantity) {
$(quantityInputField).siblings('p').show();
} else {
$(quantityInputField).siblings('p').hide();
}
});
$(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) {
var qty_wntd = $(this).val();
if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) {

View File

@@ -196,13 +196,14 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
$sql = 'SELECT rsod.*';
if (!$getTotalPrice) {
$sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`,
$sql .= ', hbd.`id_product` as `room_type_id_product`, hbd.`id_room`, od.`product_allow_multiple_quantity`, p.`max_quantity`,
od.`product_auto_add`, od.`product_price_calculation_method`, od.`product_price_addition_type`';
}
$sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
INNER JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod ON(rsod.`id_htl_booking_detail` = hbd.`id`)';
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = rsod.`id_order_detail`)';
$sql .= ' INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = rsod.`id_product`)';
$sql .= ' WHERE hbd.`id` = '.(int)$idHotelBookingDetail;
@@ -229,6 +230,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'name' => $product['name'],
'quantity' => $product['quantity'],
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'max_quantity' => $product['max_quantity'],
'product_auto_add' => $product['product_auto_add'],
'product_price_addition_type' => $product['product_price_addition_type'],
'product_price_calculation_method' => $product['product_price_calculation_method'],
@@ -253,6 +255,7 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel
'name' => $product['name'],
'quantity' => $product['quantity'],
'allow_multiple_quantity' => $product['product_allow_multiple_quantity'],
'max_quantity' => $product['max_quantity'],
'product_auto_add' => $product['product_auto_add'],
'product_price_addition_type' => $product['product_price_addition_type'],
'product_price_calculation_method' => $product['product_price_calculation_method'],