diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index 53bd5a8a0..b1917b305 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -63,19 +63,21 @@ class RoomTypeServiceProductCartDetail extends ObjectModel $objRoomTypeServiceProductCartDetail->id_cart = $idCart; } - $updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity; + if ($updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity) { + if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { + $objHotelCartBookingData = new HotelCartBookingData($idHtlCartData); + $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); + $updateQty *= $numdays; - if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $objHotelCartBookingData = new HotelCartBookingData($idHtlCartData); - $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); - $updateQty *= $numdays; - - } - $way = $updateQty > 0 ? 'up' : 'down'; - $objRoomTypeServiceProductCartDetail->quantity = $quantity; - if ($objRoomTypeServiceProductCartDetail->save()) { - $objCart = new Cart($idCart); - return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way); + } + $way = $updateQty > 0 ? 'up' : 'down'; + $objRoomTypeServiceProductCartDetail->quantity = $quantity; + if ($objRoomTypeServiceProductCartDetail->save()) { + $objCart = new Cart($idCart); + return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way); + } + } else { + return true; } return false; diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index bc79fef42..12cd79467 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -509,8 +509,14 @@ $(document).ready(function() var newQuantity = parseInt(qtyfield.val()) + 1; if (qtyfield.data('max_quantity') && qtyfield.data('max_quantity') < newQuantity) { newQuantity = qtyfield.data('max_quantity'); - } - qtyfield.val(newQuantity).trigger('focusout'); + if (qtyfield.val() != qtyfield.data('max_quantity')) { + qtyfield.trigger('focusout'); + } else { + showSuccessMessage(txtMaxQuantityAdded); + } + } else { + qtyfield.val(newQuantity).trigger('focusout'); + } }); $(document).on('click', '#rooms_extra_services .qty_down', function(e) { @@ -520,7 +526,10 @@ $(document).ready(function() if (!isNaN(currentVal) && currentVal > 1) { qtyfield.val(currentVal - 1).trigger('focusout'); } else { - qtyfield.val(1).trigger('focusout'); + qtyfield.val(1); + if (currentVal != 1) { + qtyfield.trigger('focusout'); + } } }); diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index f63d65626..8cdc91e23 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -506,6 +506,7 @@ {capture}{l s='Update' js=1}{/capture} {addJsDefL name=liUpdate}{$smarty.capture.default|@addcslashes:'\''}{/addJsDefL} {addJsDefL name=txtExtraDemandSucc}{l s='Updated Successfully' js=1}{/addJsDefL} + {addJsDefL name=txtMaxQuantityAdded}{l s='Maximum quantity of service added' js=1}{/addJsDefL} {addJsDefL name=txtExtraDemandErr}{l s='Some error occurred while updating demands' js=1}{/addJsDefL} {/strip} {/if}