From c55156d79709014d0bdc8e0a03b9009c46c234eb Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 27 Feb 2023 20:13:18 +0530 Subject: [PATCH] fixed free order and room reallocate issue --- classes/PaymentModule.php | 20 ++++--- .../views/js/HotelReservationAdmin.js | 59 ------------------- .../views/js/admin/hotel_rooms_booking.js | 57 ++++++++++++++++++ .../hotel_rooms_booking/helpers/view/view.tpl | 2 +- 4 files changed, 70 insertions(+), 68 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index c1427a39f..44d4a95f1 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -379,19 +379,23 @@ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_ (float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_ ); - $order->amount_paid = (float)Tools::ps_round( - (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)), - _PS_PRICE_COMPUTE_PRECISION_ - ); + if ($totalOrder = $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, null, $id_carrier)) { + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $totalOrder), + _PS_PRICE_COMPUTE_PRECISION_ + ); + } } else { $order->advance_paid_amount = (float)Tools::ps_round( (float)$this->context->cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_ ); - $order->amount_paid = (float)Tools::ps_round( - (($order->advance_paid_amount * $amount_paid) / $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)), - _PS_PRICE_COMPUTE_PRECISION_ - ); + if ($orderTotal = $this->context->cart->getOrderTotal(true, Cart::BOTH, null, $id_carrier)) { + $order->amount_paid = (float)Tools::ps_round( + (($order->advance_paid_amount * $amount_paid) / $orderTotal), + _PS_PRICE_COMPUTE_PRECISION_ + ); + } } // Creating order diff --git a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js index e67d4faca..0c60a8389 100644 --- a/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js +++ b/modules/hotelreservationsystem/views/js/HotelReservationAdmin.js @@ -411,65 +411,6 @@ $(document).ready(function() { $(this).parents('.child_feature_row').remove(); }); - /*For swaping rooms in the modal*/ - $("#realloc_allocated_rooms").on('click', function(e) { - $(".error_text").text(''); - if ($('#realloc_avail_rooms').val() == 0) { - $("#realloc_sel_rm_err_p").text(slct_rm_err); - return false; - } - }); - $("#swap_allocated_rooms").on('click', function(e) { - $(".error_text").text(''); - if ($('#swap_avail_rooms').val() == 0) { - $("#swap_sel_rm_err_p").text(slct_rm_err); - return false; - } - }); - - $('#mySwappigModal').on('hidden.bs.modal', function(e) { - $(".modal_date_from").val(''); - $(".modal_date_to").val(''); - $(".modal_id_room").val(''); - $(".modal_curr_room_num").val(''); - $(".cust_name").text(''); - $(".cust_email").text(''); - $(".swp_rm_opts").remove(); - $(".realloc_rm_opts").remove(); - }); - - $('#mySwappigModal').on('shown.bs.modal', function(e) { - $(".modal_date_from").val(e.relatedTarget.dataset.date_from); - $(".modal_date_to").val(e.relatedTarget.dataset.date_to); - $(".modal_id_room").val(e.relatedTarget.dataset.id_room); - $(".modal_curr_room_num").val(e.relatedTarget.dataset.room_num); - $(".cust_name").text(e.relatedTarget.dataset.cust_name); - $(".cust_email").text(e.relatedTarget.dataset.cust_email); - html = ''; - if (e.relatedTarget.dataset.avail_rm_realloc) { - var json_arr_rm_swp = JSON.parse(e.relatedTarget.dataset.avail_rm_swap); - $.each(json_arr_rm_swp, function(key, val) { - html += ''; - }); - } - if (html != '') { - $("#swap_avail_rooms").append(html); - } - - html = ''; - if (e.relatedTarget.dataset.avail_rm_realloc) { - var json_arr_rm_realloc = JSON.parse(e.relatedTarget.dataset.avail_rm_realloc); - $.each(json_arr_rm_realloc, function(key, val) { - html += ''; - }); - } - if (html != '') { - $("#realloc_avail_rooms").append(html); - } - }); - - /* ---- Book Now page Admin ---- */ - /* ---- HotelConfigurationSettingController Admin ---- */ if ($('#WK_SHOW_MSG_ON_BO_on').prop('checked') === true) { diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index de5b4a126..233b65b4a 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -954,4 +954,61 @@ $(document).ready(function() { return [true, ""]; } } + + /*For swaping rooms in the modal*/ + $("#realloc_allocated_rooms").on('click', function(e) { + $(".error_text").text(''); + if ($('#realloc_avail_rooms').val() == 0) { + $("#realloc_sel_rm_err_p").text(slct_rm_err); + return false; + } + }); + $("#swap_allocated_rooms").on('click', function(e) { + $(".error_text").text(''); + if ($('#swap_avail_rooms').val() == 0) { + $("#swap_sel_rm_err_p").text(slct_rm_err); + return false; + } + }); + + $('#mySwappigModal').on('hidden.bs.modal', function(e) { + $(".modal_date_from").val(''); + $(".modal_date_to").val(''); + $(".modal_id_room").val(''); + $(".modal_curr_room_num").val(''); + $(".cust_name").text(''); + $(".cust_email").text(''); + $(".swp_rm_opts").remove(); + $(".realloc_rm_opts").remove(); + }); + + $('#mySwappigModal').on('shown.bs.modal', function(e) { + $(".modal_date_from").val(e.relatedTarget.dataset.date_from); + $(".modal_date_to").val(e.relatedTarget.dataset.date_to); + $(".modal_id_room").val(e.relatedTarget.dataset.id_room); + $(".modal_curr_room_num").val(e.relatedTarget.dataset.room_num); + $(".cust_name").text(e.relatedTarget.dataset.cust_name); + $(".cust_email").text(e.relatedTarget.dataset.cust_email); + html = ''; + if (e.relatedTarget.dataset.avail_rm_realloc) { + var json_arr_rm_swp = JSON.parse(e.relatedTarget.dataset.avail_rm_swap); + $.each(json_arr_rm_swp, function(key, val) { + html += ''; + }); + } + if (html != '') { + $("#swap_avail_rooms").append(html); + } + + html = ''; + if (e.relatedTarget.dataset.avail_rm_realloc) { + var json_arr_rm_realloc = JSON.parse(e.relatedTarget.dataset.avail_rm_realloc); + $.each(json_arr_rm_realloc, function(key, val) { + html += ''; + }); + } + if (html != '') { + $("#realloc_avail_rooms").append(html); + } + }); }); \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl index f8454e636..4b23997ad 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl @@ -218,7 +218,7 @@
-
+