From 3feb1667c57fa6e6388f20e30cb126b9bd17c5a3 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 24 May 2024 17:05:22 +0530 Subject: [PATCH 01/27] Fixed: Room pricing issue in backoffice book now page --- .../controllers/orders/_current_cart_details_data.tpl | 2 +- admin/themes/default/template/controllers/orders/form.tpl | 2 ++ controllers/admin/AdminCartsController.php | 7 ++++++- controllers/admin/AdminOrdersController.php | 1 + .../classes/HotelRoomTypeFeaturePricing.php | 8 +++++--- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index fb6f389c2..baa8b6e07 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -118,7 +118,7 @@ {assign var=shown_room_type_price value=$data.product_price_tax_excl} {/if}
- + {$currency->prefix}{$currency->suffix}
diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 933d0a6cc..2ee1b838f 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -666,6 +666,8 @@ tab: "AdminCarts", action: "updateProductPrice", params: params, + id_cart: id_cart, + id_customer: id_customer }, success : function(response) { updateCartLine(response.curr_booking_info, cart_row); diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 108b51a75..dd619a78e 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -923,6 +923,11 @@ class AdminCartsControllerCore extends AdminController $date_from = date('Y-m-d', strtotime($date_from)); $date_to = date('Y-m-d', strtotime($date_to)); + if ($this->context->cart->id_currency != (int)Configuration::get('PS_CURRENCY_DEFAULT')) { + $currency = Currency::getCurrencyInstance($this->context->cart->id_currency); + $price = Tools::ps_round($price/$currency->conversion_rate, 6); + } + if ($this->tabAccess['edit'] === '1') { HotelRoomTypeFeaturePricing::deleteByIdCart($id_cart, $id_product, $id_room, $date_from, $date_to); $feature_price_name = array(); @@ -954,7 +959,7 @@ class AdminCartsControllerCore extends AdminController if ($bookingInfo['id'] == $id_booking_data) { $amt_with_qty = $bookingInfo['amt_with_qty']; $bookingInfo['amt_with_qty'] = Tools::displayPrice($amt_with_qty); - $bookingInfo['total_price'] = Tools::displayPrice($amt_with_qty + $bookingInfo['demand_price'] + $bookingInfo['additional_service_price']); + $bookingInfo['total_price'] = Tools::displayPrice($amt_with_qty + $bookingInfo['demand_price'] + $bookingInfo['additional_service_price'] + $bookingInfo['additional_services_auto_add_price']); $response = array( 'curr_booking_info' => $bookingInfo, 'cart_info' => $this->ajaxReturnVars(), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index c08b5f111..862b5e039 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -6011,6 +6011,7 @@ class AdminOrdersControllerCore extends AdminController $obj_hotel_cart_detail = new HotelCartBookingData(); $deleted = $obj_hotel_cart_detail->deleteRowById($del_id); if ($deleted) { + HotelRoomTypeFeaturePricing::deleteByIdCart($cart_id, $id_product, $room_id, $dt_frm, $dt_to ); $obj_product_process = new HotelCartBookingData(); $date_from = date_create($dt_frm); $date_to = date_create($dt_to); diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index 5dbfbd1db..4c6749111 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -822,9 +822,11 @@ class HotelRoomTypeFeaturePricing extends ObjectModel { return Db::getInstance()->execute( 'DELETE FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` - WHERE `id_cart` = '.(int) $id_cart.($id_product ? ' AND `id_product` = '.(int) $id_product. - ' AND `id_room` = '.(int) $id_room.' AND `date_from` = "'.pSQL($date_from). - '" AND `date_to` = "'.pSQL($date_to).'"' : '') + WHERE `id_cart` = '.(int) $id_cart. + ($id_product ? ' AND `id_product` = '.(int) $id_product : ''). + ($id_room ? ' AND `id_room` = '.(int) $id_room : ''). + ($date_from ? ' AND `date_from` = "'.pSQL($date_from) .'"' : ''). + ($date_to ? ' AND `date_to` = "'.pSQL($date_to) .'"' : '') ); } From 8a0101090504622124b15ebae3503b25b4e2361a Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 4 Jun 2024 11:31:53 +0530 Subject: [PATCH 02/27] Fixed: inconsistent prices displayed in admin booking process --- .../admin/AdminHotelRoomsBookingController.php | 5 ++++- .../views/css/HotelReservationAdmin.css | 5 ++++- .../helpers/view/_partials/booking-cart.tpl | 17 ++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 0edf2d641..6c07fac71 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -412,8 +412,11 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $smartyVars['products_in_cart'] = $products_in_cart; $smartyVars['total_products_in_cart'] = (int)$rms_in_cart + (int)$products_in_cart; $cartAmountTotal = $this->context->cart->getOrderTotal(false); + $cartRoomsAmount = $this->context->cart->getOrderTotal(false, cart::ONLY_ROOMS) + $this->context->cart->getOrderTotal(false, cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE); $cartAmountConvenienceFee = $this->context->cart->getOrderTotal(false, cart::ONLY_CONVENIENCE_FEE); - $smartyVars['cart_tamount'] = $cartAmountTotal - $cartAmountConvenienceFee; + $smartyVars['cart_rooms_amount'] = $cartRoomsAmount; + $smartyVars['cart_amount_convenience_fee'] = $cartAmountConvenienceFee; + $smartyVars['cart_tamount'] = $cartAmountTotal; $this->context->smarty->assign($smartyVars); } diff --git a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css index ce44c95c6..8b7c30f7a 100644 --- a/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css +++ b/modules/hotelreservationsystem/views/css/HotelReservationAdmin.css @@ -261,6 +261,10 @@ p.room_cat_data font-weight: 600; font-size: 13px!important; } +.cart_amt_div .table tbody>tr>td, .cart_amt_div .table tbody>tr>th { + border: none; + padding: 2px 8px; +} .margin-div { @@ -323,7 +327,6 @@ p.room_cat_data .cart_table_container { max-height: 393px; - min-height: 150px; overflow-y: auto; } diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl index 8f59550ad..e32b07ce1 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl @@ -69,11 +69,22 @@
- - + + + + + + + + + -
{l s='Total Amount (Tax excl.):' mod='hotelreservationsystem'} + {l s='Rooms Amount (Tax excl.):' mod='hotelreservationsystem'} + {if isset($cart_rooms_amount)}{convertPrice price=$cart_rooms_amount}{else}{convertPrice price=0}{/if} +
{l s='Convenience Fee (Tax excl.):' mod='hotelreservationsystem'} + {if isset($cart_amount_convenience_fee)}{convertPrice price=$cart_amount_convenience_fee}{else}{convertPrice price=0}{/if} +
{l s='Total Amount (Tax excl.):' mod='hotelreservationsystem'} {if isset($cart_tamount)}{convertPrice price=$cart_tamount}{else}{convertPrice price=0}{/if}
From dac0788bb6966f88f53b592241d2f73d6c25f5f6 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 7 Jun 2024 15:26:26 +0530 Subject: [PATCH 03/27] Fixed: Invalid refund value for different round type --- classes/order/OrderReturn.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index aaace5681..9dde2114f 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -205,6 +205,9 @@ class OrderReturnCore extends ObjectModel $bookingRow['extra_service_total_price_tax_incl'] = 0; $bookingRow['room_paid_amount'] = 0; if ($bookingRow['total_price_tax_incl'] > 0) { + if ($objOrder->round_type == Order::ROUND_ITEM || $objOrder->round_type == Order::ROUND_LINE) { + $bookingRow['total_price_tax_incl'] = Tools::ps_round($bookingRow['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); + } if ($objOrder->total_paid_real > 0) { $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; } @@ -220,6 +223,9 @@ class OrderReturnCore extends ObjectModel if (count($roomSelectedDemands)) { foreach ($roomSelectedDemands as $demand) { if ($demand['total_price_tax_incl'] > 0) { + if ($objOrder->round_type == Order::ROUND_ITEM || $objOrder->round_type == Order::ROUND_LINE) { + $demand['total_price_tax_incl'] = Tools::ps_round($demand['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); + } if ($objOrder->total_paid_real > 0) { $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; } @@ -234,6 +240,9 @@ class OrderReturnCore extends ObjectModel if (count($roomSelectedServices['additional_services'])) { foreach ($roomSelectedServices['additional_services'] as $service) { if ($service['total_price_tax_incl'] > 0) { + if ($objOrder->round_type == Order::ROUND_ITEM || $objOrder->round_type == Order::ROUND_LINE) { + $service['total_price_tax_incl'] = Tools::ps_round($service['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); + } if ($objOrder->total_paid_real > 0) { $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; } From 27527981d490a2e93de72f8a038a0d4ef38b29bd Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 29 May 2024 16:27:17 +0530 Subject: [PATCH 04/27] Fixed: incorrect room paid amount when discount is applied on the order --- classes/order/OrderReturn.php | 6 +- .../AdminOrderRefundRequestsController.php | 102 +++++++++--------- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 9dde2114f..1ef5a2345 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -209,7 +209,7 @@ class OrderReturnCore extends ObjectModel $bookingRow['total_price_tax_incl'] = Tools::ps_round($bookingRow['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); } if ($objOrder->total_paid_real > 0) { - $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); } } $roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands( @@ -227,7 +227,7 @@ class OrderReturnCore extends ObjectModel $demand['total_price_tax_incl'] = Tools::ps_round($demand['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); } if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); } $bookingRow['extra_service_total_price_tax_incl'] += $demand['total_price_tax_incl']; } @@ -244,7 +244,7 @@ class OrderReturnCore extends ObjectModel $service['total_price_tax_incl'] = Tools::ps_round($service['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); } if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); } $bookingRow['extra_service_total_price_tax_incl'] += $service['total_price_tax_incl']; } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index fa74ab46a..24315ccf6 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -279,61 +279,65 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $orderTotalPaid = $objOrder->getTotalPaid(); $idRefundState = Tools::getValue('id_refund_state'); if (Validate::isLoadedObject($objRefundState = new OrderReturnState($idRefundState))) { - if ($objRefundState->refunded) { - $refundedAmounts = Tools::getValue('refund_amounts'); - if ((float) $orderTotalPaid > 0) { - if ($idsReturnDetail && count($idsReturnDetail)) { - if ($refundedAmounts) { - foreach ($idsReturnDetail as $idRetDetail) { - if (!isset($refundedAmounts[$idRetDetail]) || !Validate::isPrice($refundedAmounts[$idRetDetail])) { - $this->errors[] = $this->l('Invalid refund amount(s) entered.'); + if ($idRefundState != $objOrderReturn->state) { + if ($objRefundState->refunded) { + $refundedAmounts = Tools::getValue('refund_amounts'); + if ((float) $orderTotalPaid > 0) { + if ($idsReturnDetail && count($idsReturnDetail)) { + if ($refundedAmounts) { + foreach ($idsReturnDetail as $idRetDetail) { + if (!isset($refundedAmounts[$idRetDetail]) || !Validate::isPrice($refundedAmounts[$idRetDetail])) { + $this->errors[] = $this->l('Invalid refund amount(s) entered.'); + } + } + } else { + $this->errors[] = $this->l('Invalid refund amount(s) entered.'); + } + + // If there are no errors in the refund amounts the check validations depends on refund amount + if (!count($this->errors)) { + $totalRefundAmount = array_sum($refundedAmounts); + if (Tools::isSubmit('generateCreditSlip')) { + if ($totalRefundAmount <= 0) { + $this->errors[] = $this->l('Invalid refund amount(s) for generating credit slip.'); + } + } + if (Tools::isSubmit('generateDiscount')) { + if ($totalRefundAmount <= 0) { + $this->errors[] = $this->l('Invalid refund amount(s) for generating voucher.'); + } + } + + if (Tools::isSubmit('refundTransactionAmount')) { + if ($totalRefundAmount <= 0) { + $this->errors[] = $this->l('Invalid refund amount(s) for entering refund transaction details.'); + } else { + $paymentMode = Tools::getValue('payment_method'); + if (!$paymentMode) { + $paymentMode = Tools::getValue('other_payment_mode'); + if (!$paymentMode) { + $this->errors[] = $this->l('Please enter the payment mode of the refund transaction.'); + } elseif (!Validate::isGenericName($paymentMode)) { + $this->errors[] = $this->l('Invalid payment mode entered.'); + } + } + + $idTransaction = Tools::getValue('id_transaction'); + if (!$idTransaction) { + $this->errors[] = $this->l('Please enter the transaction id of the refund transaction.'); + } elseif (!Validate::isGenericName($idTransaction)) { + $this->errors[] = $this->l('Invalid transaction id entered.'); + } + } } } } else { - $this->errors[] = $this->l('Invalid refund amount(s) entered.'); + $this->errors[] = $this->l('Select at least one booking for refund.'); } - - // If there are no errors in the refund amounts the check validations depends on refund amount - if (!count($this->errors)) { - $totalRefundAmount = array_sum($refundedAmounts); - if (Tools::isSubmit('generateCreditSlip')) { - if ($totalRefundAmount <= 0) { - $this->errors[] = $this->l('Invalid refund amount(s) for generating credit slip.'); - } - } - if (Tools::isSubmit('generateDiscount')) { - if ($totalRefundAmount <= 0) { - $this->errors[] = $this->l('Invalid refund amount(s) for generating voucher.'); - } - } - - if (Tools::isSubmit('refundTransactionAmount')) { - if ($totalRefundAmount <= 0) { - $this->errors[] = $this->l('Invalid refund amount(s) for entering refund transaction details.'); - } else { - $paymentMode = Tools::getValue('payment_method'); - if (!$paymentMode) { - $paymentMode = Tools::getValue('other_payment_mode'); - if (!$paymentMode) { - $this->errors[] = $this->l('Please enter the payment mode of the refund transaction.'); - } elseif (!Validate::isGenericName($paymentMode)) { - $this->errors[] = $this->l('Invalid payment mode entered.'); - } - } - - $idTransaction = Tools::getValue('id_transaction'); - if (!$idTransaction) { - $this->errors[] = $this->l('Please enter the transaction id of the refund transaction.'); - } elseif (!Validate::isGenericName($idTransaction)) { - $this->errors[] = $this->l('Invalid transaction id entered.'); - } - } - } - } - } else { - $this->errors[] = $this->l('Select at least one booking for refund.'); } } + } else { + $this->errors[] = $this->l('Please select a different refund status.'); } } else { $this->errors[] = $this->l('Invalid refund state.'); From d8fc622fe1e88b99e2b97c9709f50b463916dbfa Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 4 Jun 2024 16:35:25 +0530 Subject: [PATCH 05/27] Fixed incorrect cancellation charges in partial payment --- .../classes/HotelOrderRefundRules.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index 32a6ad0e0..8cfb22850 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -157,7 +157,6 @@ class HotelOrderRefundRules extends ObjectModel 1, 1 ); - $paidAmount = $objHtlBooking->total_paid_amount + $totalDemandsPrice + $totalServicesPrice; if ($refundRules = $objHtlRefundRules->getHotelRefundRules($objHtlBooking->id_hotel, 0, 1)) { $orderCurrency = $objOrder->id_currency; @@ -185,7 +184,7 @@ class HotelOrderRefundRules extends ObjectModel if ($refRule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE) { $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE; - $bookingCancellationDetail['cancelation_charge'] = $paidAmount * ($refundValue / 100); + $bookingCancellationDetail['cancelation_charge'] = ($objHtlBooking->total_price_tax_incl + $totalDemandsPrice + $totalServicesPrice) * ($refundValue / 100); } else { $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_FIXED; if ($defaultCurrency != $orderCurrency) { @@ -197,11 +196,6 @@ class HotelOrderRefundRules extends ObjectModel } else { $bookingCancellationDetail['cancelation_charge'] = $refundValue; } - - // if deduction amount is more than the order total cost - if ($bookingCancellationDetail['cancelation_charge'] > $paidAmount) { - $bookingCancellationDetail['cancelation_charge'] = $paidAmount; - } } $ruleApplied = true; From d9c0246b4ad68ec0e9e3e127bda6494d3323f30a Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 4 Jun 2024 18:42:55 +0530 Subject: [PATCH 06/27] fixed error on refund request when room is deleted from row --- classes/order/OrderReturnDetail.php | 25 +++++++++++++++++++++ controllers/admin/AdminOrdersController.php | 3 +++ 2 files changed, 28 insertions(+) diff --git a/classes/order/OrderReturnDetail.php b/classes/order/OrderReturnDetail.php index b956347c1..bd1504282 100644 --- a/classes/order/OrderReturnDetail.php +++ b/classes/order/OrderReturnDetail.php @@ -48,4 +48,29 @@ class OrderReturnDetailCore extends ObjectModel 'refunded_amount' => array('type' => self::TYPE_FLOAT), ), ); + + public static function getReturnDetailByIdBookingDetail($idHtlBooking) + { + $idOrderReturnDetail = Db::getInstance()->getValue(' + SELECT `id_order_return_detail` FROM `'._DB_PREFIX_.'order_return_detail` ord + WHERE `id_htl_booking` = '.(int)$idHtlBooking + ); + + if ($idOrderReturnDetail) { + return new OrderReturnDetail($idOrderReturnDetail); + } + return null; + } + + public static function deleteReturnDetailByIdBookingDetail($idOrder, $idHtlBooking) + { + $objOrderReturnDetail = OrderReturnDetail::getReturnDetailByIdBookingDetail($idHtlBooking); + if ($objOrderReturnDetail->delete()) { + $objOrderReturn = new OrderReturn(); + if (empty($objOrderReturn->getOrderRefundRequestedBookings($idOrder, $objOrderReturnDetail->id_order_return, true))) { + $objOrderReturn = new OrderReturn($objOrderReturnDetail->id_order_return); + $objOrderReturn->delete(); + } + } + } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d56966e0c..18f19e0d7 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5288,6 +5288,9 @@ class AdminOrdersControllerCore extends AdminController $obj_htl_booking = new HotelBookingDetail(); $delete_room_order = $obj_htl_booking->deleteOrderedRoomFromOrder($id_order, $id_hotel, $id_room, $date_from, $date_to); + // delete refund request of the room if exists. + OrderReturnDetail::deleteReturnDetailByIdBookingDetail($id_order, $idHotelBooking); + // Assign to smarty informations in order to show the new product line $this->context->smarty->assign(array( 'order' => $order, From e13e2773c622243e87485e17be8639bc8eed0def Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 12 Jun 2024 16:36:40 +0530 Subject: [PATCH 07/27] Updated price display method when booking is done using partial payment --- classes/order/OrderReturn.php | 42 ++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 1ef5a2345..f7c18bfc2 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -200,18 +200,17 @@ class OrderReturnCore extends ObjectModel $objBookingDemands = new HotelBookingDemands(); $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); $objOrder = new Order($idOrder); + + $calcServicePriceFirst = false; + if ($objOrder->is_advance_payment && $objOrder->advance_paid_amount <= $objOrder->total_paid_real) { + $calcServicePriceFirst = true; + } + foreach ($returnDetails as &$bookingRow) { $bookingRow['extra_service_total_paid_amount'] = 0; $bookingRow['extra_service_total_price_tax_incl'] = 0; $bookingRow['room_paid_amount'] = 0; - if ($bookingRow['total_price_tax_incl'] > 0) { - if ($objOrder->round_type == Order::ROUND_ITEM || $objOrder->round_type == Order::ROUND_LINE) { - $bookingRow['total_price_tax_incl'] = Tools::ps_round($bookingRow['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); - } - if ($objOrder->total_paid_real > 0) { - $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); - } - } + $roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands( $idOrder, $bookingRow['id_product'], @@ -227,7 +226,11 @@ class OrderReturnCore extends ObjectModel $demand['total_price_tax_incl'] = Tools::ps_round($demand['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); } if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); + if ($calcServicePriceFirst) { + $bookingRow['extra_service_total_paid_amount'] += $demand['total_price_tax_incl']; + } else { + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); + } } $bookingRow['extra_service_total_price_tax_incl'] += $demand['total_price_tax_incl']; } @@ -244,13 +247,32 @@ class OrderReturnCore extends ObjectModel $service['total_price_tax_incl'] = Tools::ps_round($service['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); } if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); + if ($calcServicePriceFirst) { + $bookingRow['extra_service_total_paid_amount'] += $service['total_price_tax_incl']; + } else { + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); + } + } $bookingRow['extra_service_total_price_tax_incl'] += $service['total_price_tax_incl']; } } } } + if ($bookingRow['total_price_tax_incl'] > 0) { + if ($objOrder->round_type == Order::ROUND_ITEM || $objOrder->round_type == Order::ROUND_LINE) { + $bookingRow['total_price_tax_incl'] = Tools::ps_round($bookingRow['total_price_tax_incl'], _PS_PRICE_DISPLAY_PRECISION_); + } + if ($objOrder->total_paid_real > 0) { + if ($calcServicePriceFirst) { + $totalRoomShare = ($objOrder->total_paid_real*($bookingRow['total_price_tax_incl'] + $bookingRow['extra_service_total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl)); + $bookingRow['room_paid_amount'] += $totalRoomShare - $bookingRow['extra_service_total_price_tax_incl']; + } else { + $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl); + } + } + } + if ($customerView) { $dateJoin = $bookingRow['id_product'].'_'.strtotime($bookingRow['date_from']).strtotime($bookingRow['date_to']); if (isset($returnsCustView[$dateJoin]['num_rooms'])) { From 9b7cccc560673d05ddb2d718dbe7b49461271c0c Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 14 Jun 2024 14:54:49 +0530 Subject: [PATCH 08/27] Fixed: Cancelled room service is visible when same room is added again in order --- .../controllers/orders/helpers/view/view.tpl | 8 +- cache/smarty/cache/index.php | 4 +- cache/smarty/compile/index.php | 4 +- classes/PaymentModule.php | 93 +----- classes/order/OrderReturn.php | 5 +- classes/pdf/HTMLTemplateInvoice.php | 87 +----- controllers/admin/AdminOrdersController.php | 264 +++++++----------- controllers/front/OrderDetailController.php | 1 + js/admin/orders.js | 4 +- .../classes/HotelBookingDemands.php | 20 +- .../classes/HotelBookingDetail.php | 5 +- .../classes/HotelOrderRefundRules.php | 4 +- .../RoomTypeServiceProductOrderDetail.php | 11 +- 13 files changed, 159 insertions(+), 351 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 6c4efed72..2c2955ad5 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -912,6 +912,8 @@ {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} {assign var=service_products_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE)} {assign var=service_products_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE)} + {assign var=convenience_fee_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} + {assign var=convenience_fee_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} {assign var=additional_service_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $totalDemandsPriceTE)} {assign var=additional_service_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $totalDemandsPriceTI)} {if $room_price_tax_excl} @@ -927,7 +929,7 @@ {l s='Total Extra services (tax excl.)'} - {displayPrice price=($additional_service_price_tax_excl - $totalConvenienceFeeTE) currency=$currency->id} + {displayPrice price=($additional_service_price_tax_excl - $convenience_fee_price_tax_excl) currency=$currency->id} @@ -974,11 +976,11 @@ - {if isset($totalConvenienceFeeTI) && $totalConvenienceFeeTI > 0} + {if isset($convenience_fee_price_tax_incl) && $convenience_fee_price_tax_incl > 0} {l s='Convenience Fee'} - {displayPrice price=$totalConvenienceFeeTE currency=$currency->id} + {displayPrice price=$convenience_fee_price_tax_excl currency=$currency->id} diff --git a/cache/smarty/cache/index.php b/cache/smarty/cache/index.php index 369a7a3f3..ffdebb428 100644 --- a/cache/smarty/cache/index.php +++ b/cache/smarty/cache/index.php @@ -1,6 +1,6 @@ -* @copyright 2007-2014 PrestaShop SA +* @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ diff --git a/cache/smarty/compile/index.php b/cache/smarty/compile/index.php index 369a7a3f3..ffdebb428 100644 --- a/cache/smarty/compile/index.php +++ b/cache/smarty/compile/index.php @@ -1,6 +1,6 @@ -* @copyright 2007-2014 PrestaShop SA +* @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index d7e75b7d2..343b84e74 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1641,8 +1641,6 @@ abstract class PaymentModuleCore extends Module $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); $result['total_extra_demands_te'] = 0; $result['total_extra_demands_ti'] = 0; - $result['total_additional_services_te'] =0; - $result['total_additional_services_ti'] =0; $cart_htl_data = array(); if (!empty($products)) { foreach ($products as $type_key => $type_value) { @@ -1688,67 +1686,12 @@ abstract class PaymentModuleCore extends Module $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $roomTypeDateRangePrice['total_price_tax_incl']*$vart_quant; - // extra demands prices - $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $order->id, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'] - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $order->id, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 0 - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $order->id, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 1 - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti']); - $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']); - $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += ($data_v['total_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']); - $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']); + $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; + $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; } else { $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']); @@ -1800,28 +1743,6 @@ abstract class PaymentModuleCore extends Module $data_v['date_from'], $data_v['date_to'] ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1 - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0 - ); $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( $order->id, 0, @@ -1829,7 +1750,7 @@ abstract class PaymentModuleCore extends Module $type_value['product_id'], $data_v['date_from'], $data_v['date_to'], - $data_v['id_room'], + 0, 1, 1, 1, @@ -1842,7 +1763,7 @@ abstract class PaymentModuleCore extends Module $type_value['product_id'], $data_v['date_from'], $data_v['date_to'], - $data_v['id_room'], + 0, 1, 0, 1, @@ -1858,8 +1779,6 @@ abstract class PaymentModuleCore extends Module $result['total_extra_demands_te'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te']; $result['total_extra_demands_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti']; - $result['total_additional_services_te'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te']; - $result['total_additional_services_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti']; } } // calculate averages now diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index aaace5681..04f548f01 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -215,7 +215,10 @@ class OrderReturnCore extends ObjectModel $bookingRow['id_room'], $bookingRow['date_from'], $bookingRow['date_to'], - 0 + 0, + 0, + 1, + $bookingRow['id'] ); if (count($roomSelectedDemands)) { foreach ($roomSelectedDemands as $demand) { diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 3d28fca40..7019b83fc 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -372,60 +372,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $cart_htl_data[$type_key]['unit_price_tax_incl'] = $unit_price_tax_incl; if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) { - // $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - // $order_obj->id, - // $type_value['product_id'], - // 0, - // $data_v['date_from'], - // $data_v['date_to'] - // ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $order_obj->id, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 0 - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $order_obj->id, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 1 - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order_obj->id, - 0, - 0, - $data_v['id_product'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order_obj->id, - 0, - 0, - $data_v['id_product'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1; $cart_htl_data[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; $cart_htl_data[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; @@ -435,20 +381,13 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_excl']/$num_days; - $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']); + $cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; - $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']); + $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] += ($data_v['total_price_tax_excl']); // For order refund $cart_htl_data[$type_key]['date_diff'][$date_join]['id_room'] = $data_v['id_room']; } else { - // $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - // $order_obj->id, - // $type_value['product_id'], - // 0, - // $data_v['date_from'], - // $data_v['date_to'] - // ); $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands( $order_obj->id, $type_value['product_id'], @@ -509,7 +448,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $data_v['id_product'], $data_v['date_from'], $data_v['date_to'], - $data_v['id_room'], + 0, 1, 1, 1, @@ -522,7 +461,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $data_v['id_product'], $data_v['date_from'], $data_v['date_to'], - $data_v['id_room'], + 0, 1, 0, 1, @@ -555,7 +494,11 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $type_value['product_id'], $data_v['id_room'], $data_v['date_from'], - $data_v['date_to'] + $data_v['date_to'], + 1, + 0, + 1, + $data_v['id'] )) { $extraDemands = array_shift($extraDemands); $extraDemands['product_id'] = $type_value['product_id']; @@ -565,16 +508,12 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $room_extra_demands[] = $extraDemands; } - if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order_obj->id, + if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $data_v['id'], 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'] + 1, + 0 )) { - $additionalServices = array_shift($additionalServices); $additionalServices['product_id'] = $type_value['product_id']; $additionalServices['room_type_name'] = $type_value['product_name']; $additionalServices['date_from'] = $data_v['date_from']; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d56966e0c..d6d5c6f04 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -836,8 +836,9 @@ class AdminOrdersControllerCore extends AdminController && ($idRoom = Tools::getValue('id_room')) && ($dateFrom = Tools::getValue('date_from')) && ($dateTo = Tools::getValue('date_to')) + && ($productLineData = Tools::getValue('product_line_data')) ) { - $productLineData = json_decode(Tools::getValue('product_line_data'), true); + $productLineData = json_decode($productLineData, true); $smartyVars = array( 'order' => $objOrder, @@ -852,16 +853,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['currencySign'] = $objCurrency->sign; $smartyVars['link'] = $this->context->link; - $objBookingDemand = new HotelBookingDetail(); - $htlBookingDetail = $objBookingDemand->getRowByIdOrderIdProductInDateRange( - $idOrder, - $idProduct, - $dateFrom, - $dateTo, - $idRoom - ); - - $smartyVars['id_booking_detail'] = $htlBookingDetail['id']; + $smartyVars['id_booking_detail'] = $productLineData['id']; $objBookingDemand = new HotelBookingDemands(); @@ -870,10 +862,14 @@ class AdminOrdersControllerCore extends AdminController if ($extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( $idOrder, - $idProduct, - $idRoom, - $dateFrom, - $dateTo + 0, + 0, + 0, + 0, + 1, + 0, + 1, + $productLineData['id'] )) { $smartyVars['extraDemands'] = $extraDemands; } @@ -892,7 +888,7 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( - $htlBookingDetail['id'] + $productLineData['id'] )) { $smartyVars['additionalServices'] = $additionalServices; } @@ -2542,8 +2538,6 @@ class AdminOrdersControllerCore extends AdminController $total_room_tax = 0; $totalRoomsCostTE = 0; - $totalConvenienceFeeTE = 0; - $totalConvenienceFeeTI = 0; $totalDemandsPriceTE = 0; $totalDemandsPriceTI = 0; @@ -2559,7 +2553,11 @@ class AdminOrdersControllerCore extends AdminController $value['id_product'], $value['id_room'], $value['date_from'], - $value['date_to'] + $value['date_to'], + 1, + 0, + 1, + $value['id'] ); $order_detail_data[$key]['total_room_price_ti'] += $order_detail_data[$key]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands( $order->id, @@ -2569,7 +2567,8 @@ class AdminOrdersControllerCore extends AdminController $value['date_to'], 0, 1, - 1 + 1, + $value['id'] ); $totalDemandsPriceTI += $order_detail_data[$key]['extra_demands_price_ti']; $order_detail_data[$key]['total_room_price_te'] += $order_detail_data[$key]['extra_demands_price_te'] = $objBookingDemand->getRoomTypeBookingExtraDemands( @@ -2580,69 +2579,38 @@ class AdminOrdersControllerCore extends AdminController $value['date_to'], 0, 1, - 0 + 0, + $value['id'] ); $totalDemandsPriceTE += $order_detail_data[$key]['extra_demands_price_te']; - $order_detail_data[$key]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], - 0, - null, - null + $order_detail_data[$key]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'] ); - $order_detail_data[$key]['total_room_price_ti'] += $order_detail_data[$key]['additional_services_price_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], + $order_detail_data[$key]['total_room_price_ti'] += $order_detail_data[$key]['additional_services_price_ti'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], 1, - 1 - ); - $order_detail_data[$key]['total_room_price_te'] += $order_detail_data[$key]['additional_services_price_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], 1, 0 ); + $order_detail_data[$key]['total_room_price_te'] += $order_detail_data[$key]['additional_services_price_te'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], + 1, + 0, + 0 + ); - $order_detail_data[$key]['convenience_fee_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], + $order_detail_data[$key]['convenience_fee_ti'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], 1, 1, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT ); $order_detail_data[$key]['total_room_price_ti'] += $order_detail_data[$key]['convenience_fee_ti']; - $totalConvenienceFeeTI += $order_detail_data[$key]['convenience_fee_ti']; - $order_detail_data[$key]['convenience_fee_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], + $order_detail_data[$key]['convenience_fee_te'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], 1, 0, 1, @@ -2650,16 +2618,9 @@ class AdminOrdersControllerCore extends AdminController ); $order_detail_data[$key]['total_room_price_te'] += $order_detail_data[$key]['convenience_fee_te']; - $totalConvenienceFeeTE += $order_detail_data[$key]['convenience_fee_te']; - $order_detail_data[$key]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], + $order_detail_data[$key]['additional_services_price_auto_add_ti'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], 1, 1, 1, @@ -2667,14 +2628,8 @@ class AdminOrdersControllerCore extends AdminController ); $order_detail_data[$key]['total_room_price_ti'] += $order_detail_data[$key]['additional_services_price_auto_add_ti']; - $order_detail_data[$key]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $order->id, - 0, - 0, - $value['id_product'], - $value['date_from'], - $value['date_to'], - $value['id_room'], + $order_detail_data[$key]['additional_services_price_auto_add_te'] = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $value['id'], 1, 0, 1, @@ -2757,8 +2712,6 @@ class AdminOrdersControllerCore extends AdminController 'refundedAmount' => $refundedAmount, 'totalDemandsPriceTI' => $totalDemandsPriceTI, 'totalDemandsPriceTE' => $totalDemandsPriceTE, - 'totalConvenienceFeeTI' => $totalConvenienceFeeTI, - 'totalConvenienceFeeTE' => $totalConvenienceFeeTE, 'totalRoomsCostTE' => $totalRoomsCostTE, 'total_room_tax' => $total_room_tax, 'htl_booking_order_data' => $bookingOrderInfo, @@ -5065,41 +5018,20 @@ class AdminOrdersControllerCore extends AdminController $id_order = (int) Tools::getValue('id_order'); $order = new Order($id_order); /*By webkul To delete Order and cart entries when deleting rooms from the orderLine when editing the order*/ - - $date_from = Tools::getValue('date_from'); - $date_to = Tools::getValue('date_to'); - $id_hotel = Tools::getValue('id_hotel'); - $id_room = Tools::getValue('id_room'); - $id_product = Tools::getValue('id_product'); - $obj_booking_detail = new HotelBookingDetail(); - $product_quantity = (int) $obj_booking_detail->getNumberOfDays($date_from, $date_to); - /*By webkul to validate fields before deleting the cart and order data form the tables*/ - if ($id_hotel == '') { + /*By webkul to validate booking before deleting the cart and order data form the tables*/ + if (($idHotelBooking = Tools::getValue('id_htl_booking')) == '') { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Hotel Id is mising.'), + 'error' => Tools::displayError('Booking id not found.'), ))); - } elseif ($id_room == '') { + } elseif (!Validate::isLoadedObject($objBookingDetail = new HotelBookingDetail($idHotelBooking))) { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Room Id is missing.'), + 'error' => Tools::displayError('Booking Detail not found.'), ))); - } elseif ($date_from == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check In Date is missing.'), - ))); - } elseif ($date_to == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check Out Date is missing.'), - ))); - } elseif ($date_to == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check Out Date is missing.'), - ))); - } elseif (!Validate::isUnsignedInt($product_quantity)) { + } + $product_quantity = (int) $objBookingDetail->getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to); + if (!Validate::isUnsignedInt($product_quantity)) { die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Invalid quantity.'), @@ -5109,32 +5041,32 @@ class AdminOrdersControllerCore extends AdminController /*END*/ $this->doDeleteProductLineValidation($order_detail, $order); Hook::exec('actionOrderProductLineDeleteBefore', array('order' => $order)); - $bookingInfo = $obj_booking_detail->getRowByIdOrderIdProductInDateRange($id_order, $id_product, $date_from, $date_to, $id_room); - $idHotelBooking = $bookingInfo['id']; - - $bookingPriceTaxIncl = $bookingInfo['total_price_tax_incl']; - $bookingPriceTaxExcl = $bookingInfo['total_price_tax_excl']; + $bookingPriceTaxIncl = $objBookingDetail->total_price_tax_incl; + $bookingPriceTaxExcl = $objBookingDetail->total_price_tax_excl; + ddd($objBookingDetail); $objBookingDemand = new HotelBookingDemands(); $roomExtraDemandTI = $objBookingDemand->getRoomTypeBookingExtraDemands( $id_order, - $id_product, - $id_room, - $date_from, - $date_to, + $objBookingDetail->id_product, + $objBookingDetail->id_room, + $objBookingDetail->date_from, + $objBookingDetail->date_to, 0, 1, - 1 + 1, + $objBookingDetail->id ); $roomExtraDemandTE = $objBookingDemand->getRoomTypeBookingExtraDemands( $id_order, - $id_product, - $id_room, - $date_from, - $date_to, + $objBookingDetail->id_product, + $objBookingDetail->id_room, + $objBookingDetail->date_from, + $objBookingDetail->date_to, 0, 1, - 0 + 0, + $objBookingDetail->id ); $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); @@ -5283,10 +5215,15 @@ class AdminOrdersControllerCore extends AdminController /*By webkul to delete cart and order entries from cart and order tables of hotelreservationsystem when delete booking form the order line in order detaoil page*/ $obj_htl_cart_booking = new HotelCartBookingData(); - $delete_room_order = $obj_htl_cart_booking->deleteOrderedRoomFromCart($id_order, $id_hotel, $id_room, $date_from, $date_to); + $delete_room_order = $obj_htl_cart_booking->deleteCartBookingData( + $objBookingDetail->id_cart, + $objBookingDetail->id_product, + $objBookingDetail->id_room, + $objBookingDetail->date_from, + $objBookingDetail->date_to + ); - $obj_htl_booking = new HotelBookingDetail(); - $delete_room_order = $obj_htl_booking->deleteOrderedRoomFromOrder($id_order, $id_hotel, $id_room, $date_from, $date_to); + $objBookingDetail->delete(); // Assign to smarty informations in order to show the new product line $this->context->smarty->assign(array( @@ -5938,6 +5875,7 @@ class AdminOrdersControllerCore extends AdminController && ($idRoom = Tools::getValue('id_room')) && ($dateFrom = Tools::getValue('date_from')) && ($dateTo = Tools::getValue('date_to')) + && ($idHtlBooking = Tools::getValue('id_htl_booking')) ) { $smartyVars = array(); $objOrder = new Order($idOrder); @@ -5946,16 +5884,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['currencySign'] = $objCurrency->sign; $smartyVars['link'] = $this->context->link; - $objBookingDemand = new HotelBookingDetail(); - $htlBookingDetail = $objBookingDemand->getRowByIdOrderIdProductInDateRange( - $idOrder, - $idProduct, - $dateFrom, - $dateTo, - $idRoom - ); - - $smartyVars['id_booking_detail'] = $htlBookingDetail['id']; + $smartyVars['id_booking_detail'] = $idHtlBooking; $objBookingDemand = new HotelBookingDemands(); @@ -5967,14 +5896,18 @@ class AdminOrdersControllerCore extends AdminController $idProduct, $idRoom, $dateFrom, - $dateTo + $dateTo, + 1, + 0, + 1, + $idHtlBooking )) { $smartyVars['extraDemands'] = $extraDemands; } $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( - $htlBookingDetail['id'] + $idHtlBooking )) { $smartyVars['additionalServices'] = $additionalServices; } @@ -6002,7 +5935,7 @@ class AdminOrdersControllerCore extends AdminController die($response); } - public function processRenderServicesPanel($idOrder, $idProduct, $dateFrom, $dateTo, $idRoom, $orderEdit) + public function processRenderServicesPanel($idOrder, $idProduct, $dateFrom, $dateTo, $idRoom, $idHtlBookingDetail, $orderEdit) { $smartyVars = array(); $objOrder = new Order($idOrder); @@ -6011,19 +5944,10 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['currencySign'] = $objCurrency->sign; $smartyVars['link'] = $this->context->link; - $objBookingDemand = new HotelBookingDetail(); - $htlBookingDetail = $objBookingDemand->getRowByIdOrderIdProductInDateRange( - $idOrder, - $idProduct, - $dateFrom, - $dateTo, - $idRoom - ); - - $smartyVars['id_booking_detail'] = $htlBookingDetail['id']; + $smartyVars['id_booking_detail'] = $idHtlBookingDetail; $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); if ($additionalServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( - $htlBookingDetail['id'] + $idHtlBookingDetail )) { $smartyVars['additionalServices'] = $additionalServices; } @@ -6054,7 +5978,7 @@ class AdminOrdersControllerCore extends AdminController return $servicesTpl; } - public function processRenderFacilitiesBlock($idOrder, $idProduct, $dateFrom, $dateTo, $idRoom, $orderEdit) + public function processRenderFacilitiesBlock($idOrder, $idProduct, $dateFrom, $dateTo, $idRoom, $idHtlBookingDetail, $orderEdit) { $smartyVars = array(); $objOrder = new Order($idOrder); @@ -6062,17 +5986,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['orderCurrency'] = $objOrder->id_currency; $smartyVars['currencySign'] = $objCurrency->sign; $smartyVars['link'] = $this->context->link; - - $objBookingDemand = new HotelBookingDetail(); - $htlBookingDetail = $objBookingDemand->getRowByIdOrderIdProductInDateRange( - $idOrder, - $idProduct, - $dateFrom, - $dateTo, - $idRoom - ); - - $smartyVars['id_booking_detail'] = $htlBookingDetail['id']; + $smartyVars['id_booking_detail'] = $idHtlBookingDetail; // set context currency So that we can get prices in the order currency $this->context->currency = new Currency($objOrder->id_currency); @@ -6084,7 +5998,11 @@ class AdminOrdersControllerCore extends AdminController $idProduct, $idRoom, $dateFrom, - $dateTo + $dateTo, + 1, + 0, + 1, + $idHtlBookingDetail )) { $smartyVars['extraDemands'] = $extraDemands; } @@ -6202,6 +6120,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objHotelBookingDetail->id_room, + $objHotelBookingDetail->id, true ); } else { @@ -6253,6 +6172,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objHotelBookingDetail->id_room, + $objHotelBookingDetail->id, true ); } @@ -6501,6 +6421,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objHotelBookingDetail->id_room, + $objHotelBookingDetail->id, true ); } else { @@ -6629,6 +6550,7 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->date_from, $objBookingDetail->date_to, $objBookingDetail->id_room, + $objBookingDetail->id, true ); $response['success'] = true; @@ -6698,6 +6620,7 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->date_from, $objBookingDetail->date_to, $objBookingDetail->id_room, + $objBookingDetail->id, true ); $response['success'] = true; @@ -6742,6 +6665,7 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail->date_from, $objBookingDetail->date_to, $objBookingDetail->id_room, + $objBookingDetail->id, true ); $response['success'] = true; diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index afa1ea9e8..d19d597ed 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -228,6 +228,7 @@ class OrderDetailControllerCore extends FrontController 1, 1 ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; } diff --git a/js/admin/orders.js b/js/admin/orders.js index 097961a27..e1e6dd396 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1143,8 +1143,9 @@ function initRoomEvents() var date_from = tr_product.data('date_from'); var date_to = tr_product.data('date_to'); var id_order_detail = tr_product.data('id_order_detail'); + var id_htl_booking = tr_product.data('id_htl_booking'); //var id_order_detail = $(this).closest('.product-line-row').find('td .edit_product_id_order_detail').val(); - var query = 'ajax=1&action=deleteRoomLine&token='+token+'&id_order='+id_order+'&id_room='+id_room+'&id_product='+id_product+'&id_hotel='+id_hotel+'&date_from='+date_from+'&date_to='+date_to+'&id_order_detail='+id_order_detail; + var query = 'ajax=1&action=deleteRoomLine&token='+token+'&id_order='+id_order+'&id_htl_booking='+id_htl_booking+'&id_room='+id_room+'&id_product='+id_product+'&id_hotel='+id_hotel+'&date_from='+date_from+'&date_to='+date_to+'&id_order_detail='+id_order_detail; query += $(this).parent().parent().find('input, select:visible, .edit_product_id_order_detail').serialize(); $.ajax({ type: 'POST', @@ -1542,6 +1543,7 @@ $(document).ready(function() { id_order: idOrder, date_from: dateFrom, date_to: dateTo, + id_htl_booking: idHtlBooking, orderEdit: orderEdit, action: 'getRoomTypeBookingDemands', ajax: true diff --git a/modules/hotelreservationsystem/classes/HotelBookingDemands.php b/modules/hotelreservationsystem/classes/HotelBookingDemands.php index 8b98d69f4..a018e952a 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDemands.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDemands.php @@ -74,7 +74,8 @@ class HotelBookingDemands extends ObjectModel $dateTo = 0, $groupByRoom = 1, $getTotalPrice = 0, - $useTax = 1 + $useTax = 1, + $idHtlBookingDetail = 0 ) { $moduleObj = Module::getInstanceByName('hotelreservationsystem'); $context = Context::getContext(); @@ -88,21 +89,24 @@ class HotelBookingDemands extends ObjectModel $totalDemandsPrice = 0; $sql = 'SELECT hb.`id_room`, hb.`adults`, hb.`children`, hd.* FROM `'._DB_PREFIX_.'htl_booking_demands` hd LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hb ON (hd.`id_htl_booking` = hb.`id`) - WHERE hd.`id_htl_booking` IN - (SELECT `id` FROM `'._DB_PREFIX_.'htl_booking_detail` - WHERE `id_order`='.(int) $idOrder; + WHERE hb.`id_order` ='.(int) $idOrder; + if ($idProduct) { - $sql .= ' AND `id_product`='.(int)$idProduct; + $sql .= ' AND hb.`id_product`='.(int)$idProduct; } if ($idRoom) { - $sql .= ' AND `id_room`='.(int)$idRoom; + $sql .= ' AND hb.`id_room`='.(int)$idRoom; } if ($dateFrom && $dateTo) { $dateFrom = date('Y-m-d', strtotime($dateFrom)); $dateTo = date('Y-m-d', strtotime($dateTo)); - $sql .= ' AND `date_from`=\''.pSQL($dateFrom).'\' AND `date_to`= \''.pSQL($dateTo).'\''; + $sql .= ' AND hb.`date_from`=\''.pSQL($dateFrom).'\' AND hb.`date_to`= \''.pSQL($dateTo).'\''; } - $sql .= ')'; + + if ($idHtlBookingDetail) { + $sql .= ' AND hb.`id` = '.(int)$idHtlBookingDetail; + } + if ($getTotalPrice) { $totalDemandsPrice = 0; } diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 047e1de46..97fdc022e 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -2888,7 +2888,10 @@ class HotelBookingDetail extends ObjectModel $this->id_room, $this->date_from, $this->date_to, - 0 + 0, + 0, + 1, + $this->id )) { foreach ($roomDemands as $roomDemand) { $objHotelBookingDemands = new HotelBookingDemands($roomDemand['id_booking_demand']); diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index 32a6ad0e0..1c941b2c2 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -149,7 +149,9 @@ class HotelOrderRefundRules extends ObjectModel $objHtlBooking->date_from, $objHtlBooking->date_to, 1, - 1 + 1, + 1, + $objHtlBooking->id ); $totalServicesPrice = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php index b26cf751d..278c7dfa9 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php @@ -187,7 +187,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel public function getSelectedServicesForRoom( $idHotelBookingDetail, $getTotalPrice = 0, - $useTax = null + $useTax = null, + $autoAddToCart = null, + $priceAdditionType = null ) { if ($useTax === null) { @@ -207,6 +209,13 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel $sql .= ' WHERE hbd.`id` = '.(int)$idHotelBookingDetail; + if (!is_null($autoAddToCart)) { + $sql .= ' AND od.`product_auto_add` = '. (int)$autoAddToCart; + if ($autoAddToCart == 1 && !is_null($priceAdditionType)) { + $sql .= ' AND od.`product_price_addition_type` = '.$priceAdditionType; + } + } + if ($getTotalPrice) { $totalPrice = 0; } From 9401ca6a4d2a6a0d6a3ab0edf3cf4057582fd46e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 28 Jun 2024 17:34:41 +0530 Subject: [PATCH 09/27] Fixed: Design issue in order page and kpi when printing page --- .../themes/default/sass/partials/_print.sass | 39 ++++- .../controllers/orders/_overbookings.tpl | 4 +- .../controllers/orders/_product_line.tpl | 162 ++---------------- js/admin/orders.js | 20 +++ 4 files changed, 76 insertions(+), 149 deletions(-) diff --git a/admin/themes/default/sass/partials/_print.sass b/admin/themes/default/sass/partials/_print.sass index 118b98014..9a8097f89 100644 --- a/admin/themes/default/sass/partials/_print.sass +++ b/admin/themes/default/sass/partials/_print.sass @@ -65,7 +65,7 @@ margin-bottom: 0 !important #addressInvoice width: 49% !important - float: right !important + float: right !important margin-bottom: 0 !important #status tr:first-child td @@ -84,9 +84,7 @@ margin: 30px 0 20px 0 !important border: solid 1px black !important .box-stats - padding: 10px 0 !important height: auto !important - width: 25% !important font-size: 8pt !important i font-size: 20pt !important @@ -99,3 +97,38 @@ margin: 0 !important .panel-total td font-size: 13pt!important + + + #customer_cart_details + thead + display: none + tr + display: block + border: 1px solid #ccc + -webkit-box-shadow: #EAEDEF 0 2px 0 0 + box-shadow: #EAEDEF 0 2px 0 0 + width: 100% + margin-bottom: 6px + td + display: block + display: grid + grid-template-columns: 2fr 3fr + text-align: center !important + position: relative + width: 100% !important + text-align: left !important + line-height: 2em !important + font-size: 1.15em !important + white-space: nowrap + overflow: hidden + text-overflow: ellipsis + > span + padding: 0px 5px + > span:nth-child(1) + border-right: 1px solid #EAEDEF + padding-right: 10px + white-space: nowrap + color: #aaa + text-align: right + font-size: .9em + font-style: italic \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_overbookings.tpl b/admin/themes/default/template/controllers/orders/_overbookings.tpl index b2b89fa6c..d68e38021 100644 --- a/admin/themes/default/template/controllers/orders/_overbookings.tpl +++ b/admin/themes/default/template/controllers/orders/_overbookings.tpl @@ -42,7 +42,7 @@ {dateFormat date=$data['date_from']} {l s='To'} {dateFormat date=$data['date_to']} {if $order->with_occupancy && $data['children']} - {else} - {if $data['adults']}{$data['adults']}{/if} {if $data['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} + {if $data['adults']}{$data['adults']}{/if} {if $data['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} {/if} diff --git a/admin/themes/default/template/controllers/orders/_product_line.tpl b/admin/themes/default/template/controllers/orders/_product_line.tpl index 18ceebacc..68823d0e1 100644 --- a/admin/themes/default/template/controllers/orders/_product_line.tpl +++ b/admin/themes/default/template/controllers/orders/_product_line.tpl @@ -35,33 +35,11 @@

{$data.room_type}

- {dateFormat date=$data.date_from} - {dateFormat date=$data.date_to} - - {if $can_edit} - - {/if} + {dateFormat date=$data.date_from} - {dateFormat date=$data.date_to} {if $data['children']} - {else} - {if $data['adults']}{$data['adults']}{/if} {if $data['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} + {if $data['adults']}{$data['adults']}{/if} {if $data['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$data['children']}}, {$data['children']} {if $data['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} {/if} - - -

- - {convertPriceWithCurrency price=$data['total_price_tax_excl'] currency=$currency->id} - -

-

{l s='Per day price:'} {convertPriceWithCurrency price=$data['paid_unit_price_tax_excl'] currency=$currency->id}

-
- +

+ + {convertPriceWithCurrency price=$data['total_price_tax_excl'] currency=$currency->id} + +

+

{l s='Per day price:'} {convertPriceWithCurrency price=$data['paid_unit_price_tax_excl'] currency=$currency->id}

- - {convertPriceWithCurrency price=($data['extra_demands_price_te'] + $data['additional_services_price_te'] + $data['convenience_fee_te'] + $data['additional_services_price_auto_add_te']) currency=$currency->id} - {if $data['extra_demands']|count || $data['additional_services']|count} - - - - {/if} - - - - - {convertPriceWithCurrency price=($data['total_room_tax']) currency=$currency->id} - - - {convertPriceWithCurrency price=($data['total_room_price_ti']) currency=$currency->id} - {if $can_edit} - {/if} + + {convertPriceWithCurrency price=($data['total_room_tax']) currency=$currency->id} + + + {convertPriceWithCurrency price=($data['total_room_price_ti']) currency=$currency->id} + {if (isset($refundReqBookings) && $refundReqBookings) || (isset($isCancelledRoom) && $isCancelledRoom)} {if $data.is_cancelled} @@ -212,19 +99,6 @@ {/if} {if ($can_edit && !$order->hasBeenDelivered())} - - {if sizeof($invoices_collection)} - - {else} -   - {/if} -
{if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_cancelled} diff --git a/js/admin/orders.js b/js/admin/orders.js index 097961a27..c5147d809 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -31,6 +31,26 @@ $(document).ready(function() { init(); $('img.js-disabled-action').css({"opacity":0.5}); + + // change table design for printing + $(window).on('beforeprint', function() { + $('#customer_cart_details thead tr th').each(function(i, val) { + $('#customer_cart_details tbody td:nth-child('+(i+1)+')').each(function () { + let span = $('').addClass('print-class-container') + .append($('').addClass('print-class-title').html($(val).html())) + .append($('').addClass('print-class-content').html( + $(this).html() + ) + ); + $(this).html($(span).html()); + }); + }); + }); + $(window).on('afterprint', function() { + $('#customer_cart_details tbody td').each(function () { + $(this).html($(this).find('span.print-class-content').html()); + }); + }); }); function stopAjaxQuery() { From 54685db83e4f1f5a9be44793de4aad180f7de003 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 4 Jul 2024 12:32:20 +0530 Subject: [PATCH 10/27] fixed cancellation charges should be equal to total amount when no rules are assigned to hotel --- .../classes/HotelOrderRefundRules.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php index 8cfb22850..d4ddc8984 100644 --- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php +++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php @@ -157,6 +157,7 @@ class HotelOrderRefundRules extends ObjectModel 1, 1 ); + $totalAmount = $objHtlBooking->total_price_tax_incl + $totalDemandsPrice + $totalServicesPrice; if ($refundRules = $objHtlRefundRules->getHotelRefundRules($objHtlBooking->id_hotel, 0, 1)) { $orderCurrency = $objOrder->id_currency; @@ -184,7 +185,7 @@ class HotelOrderRefundRules extends ObjectModel if ($refRule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE) { $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE; - $bookingCancellationDetail['cancelation_charge'] = ($objHtlBooking->total_price_tax_incl + $totalDemandsPrice + $totalServicesPrice) * ($refundValue / 100); + $bookingCancellationDetail['cancelation_charge'] = $totalAmount * ($refundValue / 100); } else { $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_FIXED; if ($defaultCurrency != $orderCurrency) { @@ -204,12 +205,12 @@ class HotelOrderRefundRules extends ObjectModel } if (!$ruleApplied) { - $bookingCancellationDetail['cancelation_charge'] = $paidAmount; + $bookingCancellationDetail['cancelation_charge'] = $totalAmount; $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE; $bookingCancellationDetail['reduction_value'] = 100; } } else { - $bookingCancellationDetail['cancelation_charge'] = $paidAmount; + $bookingCancellationDetail['cancelation_charge'] = $totalAmount; $bookingCancellationDetail['reduction_type'] = HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE; $bookingCancellationDetail['reduction_value'] = 100; } From cffab70e117e015af08378bbf536715f9fa59ef0 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 11 Jul 2024 19:58:12 +0530 Subject: [PATCH 11/27] removed dump added in code --- controllers/admin/AdminOrdersController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 2a5ee2178..9699b1a59 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5132,7 +5132,6 @@ class AdminOrdersControllerCore extends AdminController $bookingPriceTaxIncl = $objBookingDetail->total_price_tax_incl; $bookingPriceTaxExcl = $objBookingDetail->total_price_tax_excl; - ddd($objBookingDetail); $objBookingDemand = new HotelBookingDemands(); $roomExtraDemandTI = $objBookingDemand->getRoomTypeBookingExtraDemands( $id_order, From 2c80a61a73b9982bd504e8c4797f0deaf1cdedf1 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 12 Jul 2024 15:17:57 +0530 Subject: [PATCH 12/27] Fix refund options not availabe if error occurs in refund request page --- .../templates/admin/order_refund_requests/helpers/view/view.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index e69a38a28..11758f12b 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -5,7 +5,7 @@  {l s='Order Cancellation Request Information' mod='hotelreservationsystem'}

-
+
{if isset($customer_name)}
From ffc554bf40b5fb606f349507a94341ceccc683e5 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 18 Jul 2024 16:47:02 +0530 Subject: [PATCH 13/27] fixed kpi pannel height issue --- admin/themes/default/sass/partials/_kpi.sass | 1 + admin/themes/default/sass/partials/_print.sass | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/admin/themes/default/sass/partials/_kpi.sass b/admin/themes/default/sass/partials/_kpi.sass index e6ccfe8cb..6e2e15fbf 100644 --- a/admin/themes/default/sass/partials/_kpi.sass +++ b/admin/themes/default/sass/partials/_kpi.sass @@ -16,6 +16,7 @@ $kpi-gap: 10px flex-wrap: wrap margin-left: -($kpi-gap / 2) margin-right: -($kpi-gap / 2) + flex-grow: 1 .kpi-wrap display: inline-block width: 20% diff --git a/admin/themes/default/sass/partials/_print.sass b/admin/themes/default/sass/partials/_print.sass index 9a8097f89..2732a42aa 100644 --- a/admin/themes/default/sass/partials/_print.sass +++ b/admin/themes/default/sass/partials/_print.sass @@ -81,13 +81,14 @@ i display: none !important .kpi-container.panel - margin: 30px 0 20px 0 !important border: solid 1px black !important + .actions-wrap + display: none .box-stats height: auto !important font-size: 8pt !important - i - font-size: 20pt !important + span.arrow + display: none .alert border: 1px solid black !important &:before From a66b446726889c238b4d3e8edd546489850adf13 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 18 Jul 2024 19:57:52 +0530 Subject: [PATCH 14/27] fixed voucher amount is not converted when changing currency while creating booking from back office --- classes/CartRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/CartRule.php b/classes/CartRule.php index 634434e53..508552f1d 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -909,7 +909,7 @@ class CartRuleCore extends ObjectModel $reduction_value = 0; $objHotelAdvancePayment = new HotelAdvancedPayment(); - $cache_id = 'getContextualValue_'.(int)$this->id.'_'.(int)$use_tax.'_'.(int)$context->cart->id.'_'.(int)$filter.'_'.(int)$only_advance_payment_products; + $cache_id = 'getContextualValue_'.(int)$this->id.'_'.(int)$use_tax.'_'.(int)$context->cart->id.'_'.(int)$context->currency->id.'_'.(int)$filter.'_'.(int)$only_advance_payment_products; foreach ($package['products'] as $key => $product) { if ($only_advance_payment_products) { if ($advancePaymentInfo = $objHotelAdvancePayment->getIdAdvPaymentByIdProduct($product['id_product'])) { From 53762de8200a4052da268fdcf5c4fd3e3cfff6c9 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Mon, 22 Jul 2024 13:17:58 +0530 Subject: [PATCH 15/27] fixed total amount in cart popup in admin book now page --- .../controllers/admin/AdminHotelRoomsBookingController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index a62990a59..cc7edbc92 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -414,12 +414,11 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $smartyVars['rms_in_cart'] = $objHotelCartBookingData->getCountRoomsInCart($this->id_cart, $this->id_guest); $smartyVars['products_in_cart'] = $products_in_cart; $smartyVars['total_products_in_cart'] = (int)$rms_in_cart + (int)$products_in_cart; - $cartAmountTotal = $this->context->cart->getOrderTotal(false); $cartRoomsAmount = $this->context->cart->getOrderTotal(false, cart::ONLY_ROOMS) + $this->context->cart->getOrderTotal(false, cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE); $cartAmountConvenienceFee = $this->context->cart->getOrderTotal(false, cart::ONLY_CONVENIENCE_FEE); $smartyVars['cart_rooms_amount'] = $cartRoomsAmount; $smartyVars['cart_amount_convenience_fee'] = $cartAmountConvenienceFee; - $smartyVars['cart_tamount'] = $cartAmountTotal; + $smartyVars['cart_tamount'] = $cartRoomsAmount + $cartAmountConvenienceFee; $this->context->smarty->assign($smartyVars); } From 1743ca82f5a7bf979865be50244c1b8dc0243941 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 31 Jul 2024 17:42:02 +0530 Subject: [PATCH 16/27] Added: Confirmation modal when deleting cart rules and while changes credit slip status --- .../cart_rules/modal_confirm_bulk_delete.tpl | 46 ++++++ .../cart_rules/modal_confirm_delete.tpl | 59 +++++++ .../controllers/slip/_status_change_link.tpl | 2 +- .../controllers/slip/modal_confirm_update.tpl | 49 ++++++ admin/themes/default/template/modal.tpl | 8 +- classes/CartRule.php | 24 +++ .../admin/AdminCartRulesController.php | 91 ++++++++++- controllers/admin/AdminSlipController.php | 42 +++++ js/admin/cart-rules.js | 144 ++++++++++++++++++ js/admin/slips.js | 52 +++++++ 10 files changed, 511 insertions(+), 6 deletions(-) create mode 100644 admin/themes/default/template/controllers/cart_rules/modal_confirm_bulk_delete.tpl create mode 100644 admin/themes/default/template/controllers/cart_rules/modal_confirm_delete.tpl create mode 100644 admin/themes/default/template/controllers/slip/modal_confirm_update.tpl create mode 100644 js/admin/cart-rules.js diff --git a/admin/themes/default/template/controllers/cart_rules/modal_confirm_bulk_delete.tpl b/admin/themes/default/template/controllers/cart_rules/modal_confirm_bulk_delete.tpl new file mode 100644 index 000000000..b4403b359 --- /dev/null +++ b/admin/themes/default/template/controllers/cart_rules/modal_confirm_bulk_delete.tpl @@ -0,0 +1,46 @@ +{* +* Since 2010 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html +*} + + \ No newline at end of file diff --git a/admin/themes/default/template/controllers/cart_rules/modal_confirm_delete.tpl b/admin/themes/default/template/controllers/cart_rules/modal_confirm_delete.tpl new file mode 100644 index 000000000..fe60f1a2b --- /dev/null +++ b/admin/themes/default/template/controllers/cart_rules/modal_confirm_delete.tpl @@ -0,0 +1,59 @@ +{* +* Since 2010 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html +*} + + \ No newline at end of file diff --git a/admin/themes/default/template/controllers/slip/_status_change_link.tpl b/admin/themes/default/template/controllers/slip/_status_change_link.tpl index 958a76581..c1d720530 100644 --- a/admin/themes/default/template/controllers/slip/_status_change_link.tpl +++ b/admin/themes/default/template/controllers/slip/_status_change_link.tpl @@ -17,7 +17,7 @@ * @license LICENSE.txt *} - + {l s='Change Status'} diff --git a/admin/themes/default/template/controllers/slip/modal_confirm_update.tpl b/admin/themes/default/template/controllers/slip/modal_confirm_update.tpl new file mode 100644 index 000000000..a8942c335 --- /dev/null +++ b/admin/themes/default/template/controllers/slip/modal_confirm_update.tpl @@ -0,0 +1,49 @@ +{* +* Since 2010 Webkul. +* +* NOTICE OF LICENSE +* +* All right is reserved, +* Please go through this link for complete license : https://store.webkul.com/license.html +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to newer +* versions in the future. If you wish to customize this module for your +* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul IN +* @license https://store.webkul.com/license.html +*} + + \ No newline at end of file diff --git a/admin/themes/default/template/modal.tpl b/admin/themes/default/template/modal.tpl index e785c99d4..360e1cc48 100644 --- a/admin/themes/default/template/modal.tpl +++ b/admin/themes/default/template/modal.tpl @@ -26,10 +26,10 @@