From bdf8538994c076be72d1aab37defb5f9cbbe7ade Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 1 Sep 2023 13:07:46 +0530 Subject: [PATCH] Display maximum quantity warning to admin during new booking creation --- .../controllers/orders/_cart_booking_demands.tpl | 5 ++++- .../default/template/controllers/orders/form.tpl | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl index 2c30b44e6..fc7204f50 100644 --- a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl +++ b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl @@ -134,7 +134,10 @@

{$product['name']|escape:'html':'UTF-8'}

{if $product.allow_multiple_quantity}
- + +

+ {l s='Maximum allowed quantity: %s' sprintf=$product.max_quantity} +

{/if} diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 99b5ab612..bb669eda0 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1579,6 +1579,17 @@ } }); + $(document).on('change', '.room_type_service_product_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(); + } + }); + function updateServiceProducts(element) { var operator = $(element).is(':checked') ? 'up' : 'down';