From 90590940c409407ecc2371867db4c0bdd53352ce Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 2 Aug 2024 16:44:12 +0530 Subject: [PATCH 1/7] Fixed: Error on the customer cart page on the back office after admin removes a room from the booking --- controllers/admin/AdminOrdersController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b6c287554..56d85e196 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5411,6 +5411,10 @@ 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); + // Reducing the quantity from the cart after removing the room from the order + $objCart = new Cart($bookingInfo['id_cart']); + $objCart->updateQty($product_quantity, $bookingInfo['id_product'], null, false, 'down', 0, null, true); + // Assign to smarty informations in order to show the new product line $this->context->smarty->assign(array( 'order' => $order, From 9601f3acce0e3cc53350a05f3f24ac874c3ca7a3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 7 Aug 2024 10:16:53 +0530 Subject: [PATCH 2/7] Fixed: The cart was not updated after a room was updated from the order detail page --- controllers/admin/AdminOrdersController.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 56d85e196..9e4b5c388 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4558,8 +4558,6 @@ class AdminOrdersControllerCore extends AdminController $res = true; $id_order = (int) Tools::getValue('id_order'); $order = new Order($id_order); - $cart = new Cart($order->id_cart); - $customer = new Cart($order->id_customer); //$order_detail = new OrderDetail((int)Tools::getValue('product_id_order_detail')); $order_detail = new OrderDetail((int) Tools::getValue('id_order_detail'));//by webkul id_order_detail from our table $this->doEditRoomValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null); @@ -4586,6 +4584,9 @@ class AdminOrdersControllerCore extends AdminController $children = $occupancy['children']; $child_ages = $occupancy['child_ages']; + $bookingInfo = $obj_booking_detail->getRowByIdOrderIdProductInDateRange($id_order, $id_product, $old_date_from, $old_date_to, $id_room); + $cart = new Cart($bookingInfo['id_cart']); + // By webkul to calculate rates of the product from hotelreservationsystem tables with feature prices.... // add feature price for updated price @@ -4759,6 +4760,17 @@ class AdminOrdersControllerCore extends AdminController $res &= $order_invoice->update(); } + if ($qty_diff != 0) { + $cartQty = $qty_diff; + $op = 'up'; + if ($qty_diff < 0) { + $op = 'down'; + $cartQty = -$cartQty; + } + + $cart->updateQty($cartQty, $bookingInfo['id_product'], null, false, $op, 0, null, true); + } + // Update product available quantity StockAvailable::updateQuantity($order_detail->product_id, $order_detail->product_attribute_id, ($old_quantity - $order_detail->product_quantity), $order->id_shop); From 5b764fb66c51c7fb25db646eb10e0f8d14252369 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 20 Aug 2024 19:28:24 +0530 Subject: [PATCH 3/7] Fixed: issues occured during updation process --- classes/pdf/HTMLTemplateInvoice.php | 2 ++ controllers/admin/AdminOrdersController.php | 36 +++++++++++-------- .../classes/HotelBookingDemands.php | 4 +-- .../classes/HotelBookingDetail.php | 9 +++-- .../classes/HotelRoomTypeDemand.php | 5 ++- .../RoomTypeServiceProductOrderDetail.php | 7 ++-- 6 files changed, 38 insertions(+), 25 deletions(-) diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index b134abcee..75d696ffd 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -397,6 +397,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 0, 1, 0, + 0, $type_value['id_order_detail'] ); $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = $objBookingDemand->getRoomTypeBookingExtraDemands( @@ -408,6 +409,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 0, 1, 1, + 0, $type_value['id_order_detail'] ); $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index e61172aa3..975c4f668 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4621,6 +4621,9 @@ class AdminOrdersControllerCore extends AdminController $order_invoice = new OrderInvoice((int) Tools::getValue('product_invoice')); } /*By webkul To edit Order and cart entries when edit rooms from the orderLine when editing the order*/ + $obj_booking_detail = new HotelBookingDetail((int) Tools::getValue('id_booking_detail')); + $cart = new Cart($obj_booking_detail->id_cart); + $product_informations = $_POST['edit_product']; $new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from']))); $new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to']))); @@ -4630,7 +4633,6 @@ class AdminOrdersControllerCore extends AdminController $id_room = trim(Tools::getValue('id_room')); $id_product = trim(Tools::getValue('id_product')); $room_unit_price = trim(Tools::getValue('room_unit_price')); - $obj_booking_detail = new HotelBookingDetail(); $product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to); $old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to); $qty_diff = $product_quantity - $old_product_quantity; @@ -4639,9 +4641,6 @@ class AdminOrdersControllerCore extends AdminController $children = $occupancy['children']; $child_ages = $occupancy['child_ages']; - $bookingInfo = $obj_booking_detail->getRowByIdOrderIdProductInDateRange($id_order, $id_product, $old_date_from, $old_date_to, $id_room); - $cart = new Cart($bookingInfo['id_cart']); - // By webkul to calculate rates of the product from hotelreservationsystem tables with feature prices.... // add feature price for updated price @@ -4823,7 +4822,7 @@ class AdminOrdersControllerCore extends AdminController $cartQty = -$cartQty; } - $cart->updateQty($cartQty, $bookingInfo['id_product'], null, false, $op, 0, null, true); + $cart->updateQty($cartQty, $obj_booking_detail->id_product, null, false, $op, 0, null, true); } // Update product available quantity @@ -4890,20 +4889,26 @@ class AdminOrdersControllerCore extends AdminController 0, 0, 0, - $old_date_from, - $old_date_to, + 0, + 0, $id_room, 0, null, - null + 0, + null, + $obj_booking_detail->id ); $extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( $id_order, 0, $id_room, - $old_date_from, - $old_date_to + 0, + 0, + 1, + 0, + 1, + $obj_booking_detail->id ); // set occupancy details @@ -4919,7 +4924,7 @@ class AdminOrdersControllerCore extends AdminController 'tax_incl' => $totalRoomPriceAfterTI, ); - if ($update_htl_tables = $obj_booking_detail->UpdateHotelCartHotelOrderOnOrderEdit( + if ($obj_booking_detail->updateHotelCartHotelOrderOnOrderEdit( $id_order, $id_room, $old_date_from, @@ -4927,7 +4932,8 @@ class AdminOrdersControllerCore extends AdminController $new_date_from, $new_date_to, $occupancy, - $new_total_price + $new_total_price, + $obj_booking_detail->id )) { // update extra demands total prices if dates are changes (price calc method for each day) if ($extraDemands) { @@ -5465,8 +5471,8 @@ class AdminOrdersControllerCore extends AdminController OrderReturnDetail::deleteReturnDetailByIdBookingDetail($id_order, $idHotelBooking); // Reducing the quantity from the cart after removing the room from the order - $objCart = new Cart($bookingInfo['id_cart']); - $objCart->updateQty($product_quantity, $bookingInfo['id_product'], null, false, 'down', 0, null, true); + $objCart = new Cart($objBookingDetail->id_cart); + $objCart->updateQty($product_quantity, $objBookingDetail->id_product, null, false, 'down', 0, null, true); // Assign to smarty informations in order to show the new product line $this->context->smarty->assign(array( @@ -6211,7 +6217,7 @@ class AdminOrdersControllerCore extends AdminController $oldTotalPriceTaxExcl = $objRoomTypeServiceProductOrderDetail->total_price_tax_excl; $oldTotalPriceTaxIncl = $objRoomTypeServiceProductOrderDetail->total_price_tax_incl; $oldQuantity = $objRoomTypeServiceProductOrderDetail->quantity; - if ($oldPriceTaxExcl > 0) { + if ($oldUnitPriceTaxExcl > 0) { $oldTaxMultiplier = $oldUnitPriceTaxIncl / $oldUnitPriceTaxExcl; } else { $oldTaxMultiplier = 1; diff --git a/modules/hotelreservationsystem/classes/HotelBookingDemands.php b/modules/hotelreservationsystem/classes/HotelBookingDemands.php index 57904d0a4..fc613a6c0 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDemands.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDemands.php @@ -75,8 +75,8 @@ class HotelBookingDemands extends ObjectModel $groupByRoom = 1, $getTotalPrice = 0, $useTax = 1, - $idOrderDetail = 0, - $idHtlBookingDetail = 0 + $idHtlBookingDetail = 0, + $idOrderDetail = 0 ) { $moduleObj = Module::getInstanceByName('hotelreservationsystem'); $context = Context::getContext(); diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 2cf3dac59..191793ca4 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -2369,7 +2369,7 @@ class HotelBookingDetail extends ObjectModel return Db::getInstance()->executeS($sql); } - public function UpdateHotelCartHotelOrderOnOrderEdit( + public function updateHotelCartHotelOrderOnOrderEdit( $idOrder, $idRoom, $oldDateFrom, @@ -2377,11 +2377,10 @@ class HotelBookingDetail extends ObjectModel $newDateFrom, $newDateTo, $occupancy, - $newTotalPrice = null + $newTotalPrice = null, + $idHotelBookingDetail ) { - // retrieve HotelBookingDetail row - $roomBookingData = $this->getRoomBookingData($idRoom, $idOrder, $oldDateFrom, $oldDateTo); - $objHotelBookingDetail = new self($roomBookingData['id']); + $objHotelBookingDetail = new self((int) $idHotelBookingDetail); if (Validate::isLoadedObject($objHotelBookingDetail)) { // retrieve HotelCartBookingData row $idHotelCartBookingData = Db::getInstance()->getValue( diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php b/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php index e02bdf307..3d37f9083 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php @@ -336,8 +336,11 @@ class HotelRoomTypeDemand extends ObjectModel $price = $objGlobalDemand->price; } } + + // since this will update the custom price according to the default currency, which is not required for custom price + $price = Tools::convertPrice($price, $idCurrency); } - $price = Tools::convertPrice($price, $idCurrency); + // Tax calculation section $address->id_country = $idCountry; $address->id_state = $idState; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php index f7e4bc2c0..8692ee1e4 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductOrderDetail.php @@ -69,9 +69,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel $useTax = null, $autoAddToCart = 0, $priceAdditionType = null, - $idOrderDetail = 0 + $idOrderDetail = 0, + $idHtlBookingDetail = 0 ) { - if ($useTax === null) { $useTax = Product::$_taxCalculationMethod == PS_TAX_EXC ? false : true; } @@ -111,6 +111,9 @@ class RoomTypeServiceProductOrderDetail extends ObjectModel if ($idRoom) { $sql .= ' AND hbd.`id_room`='.(int) $idRoom; } + if ($idHtlBookingDetail) { + $sql .= ' AND hbd.`id` = '.(int)$idHtlBookingDetail; + } $sql .= ' ORDER BY hbd.`id`'; if ($getTotalPrice) { From 7784f69704789f8d167c83babf5efca443a994d5 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 20 Aug 2024 20:06:20 +0530 Subject: [PATCH 4/7] removed the extra changes made in the previous commit --- controllers/admin/AdminOrdersController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 975c4f668..79dd91cff 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4889,8 +4889,8 @@ class AdminOrdersControllerCore extends AdminController 0, 0, 0, - 0, - 0, + $old_date_from, + $old_date_to, $id_room, 0, null, @@ -4903,8 +4903,8 @@ class AdminOrdersControllerCore extends AdminController $id_order, 0, $id_room, - 0, - 0, + $old_date_from, + $old_date_to, 1, 0, 1, From 751d02f0e27a9f209a1d78c2786bffac6d5c5719 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 21 Aug 2024 14:49:49 +0530 Subject: [PATCH 5/7] Fixed: undefined error issue for order history and invoice for extra demands, also fixed the wrong price is added while adding service in order if specific price for that service is created --- classes/order/OrderHistory.php | 2 + controllers/admin/AdminOrdersController.php | 44 +++++++-------------- pdf/invoice.extra-demands-tab.tpl | 2 +- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 1d09988c0..75f5df519 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -317,6 +317,8 @@ class OrderHistoryCore extends ObjectModel // if order is created by API then create a direct object instead of creating an object from module if ($order->module == 'wsorder') { $payment_method = new WebserviceOrder(); + } else if ($order->module == 'bo_order') { + $payment_method = new BoOrder(); } else { $payment_method = Module::getInstanceByName($order->module); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 79dd91cff..993e38995 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -6403,10 +6403,10 @@ class AdminOrdersControllerCore extends AdminController ); // add services in room + $order = new Order($objHotelBookingDetail->id_order); if (!$response['hasError']) { + $this->context->currency = new Currency($order->id_currency); foreach ($selectedServices as $service) { - $order = new Order($objHotelBookingDetail->id_order); - // Create new cart $cart = new Cart(); $cart->id_shop_group = $order->id_shop_group; @@ -6478,49 +6478,33 @@ class AdminOrdersControllerCore extends AdminController $roomHtlCartInfo['id']) ) { $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $id_room_type_service_product_cart_detail); - $totalPriceChangeTaxExcl += $totalPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice( - (int)$product['id_product'], - 0, - $objRoomTypeServiceProductCartDetail->quantity, - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to, - false, - $cart->id - ); - $totalPriceChangeTaxIncl += $totalPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice( - (int)$product['id_product'], - 0, - $objRoomTypeServiceProductCartDetail->quantity, - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to, - true, - $cart->id - ); - $numDays = 1; if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); } - $product['cart_quantity'] = $objRoomTypeServiceProductCartDetail->quantity * $numDays; + $product['cart_quantity'] = $objRoomTypeServiceProductCartDetail->quantity * $numDays; $unitPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice( (int)$product['id_product'], - 0, + $roomHtlCartInfo['id_product'], 1, - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to, + null, + null, false, $cart->id - )/ $numDays; + ); $unitPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice( (int)$product['id_product'], - 0, + $roomHtlCartInfo['id_product'], 1, - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to, + null, + null, true, $cart->id - )/ $numDays; + ); + + $totalPriceChangeTaxExcl += $totalPriceTaxExcl = ($unitPriceTaxExcl * $product['cart_quantity']); + $totalPriceChangeTaxIncl += $totalPriceTaxIncl = ($unitPriceTaxIncl * $product['cart_quantity']); switch (Configuration::get('PS_ROUND_TYPE')) { case Order::ROUND_TOTAL: $product['total'] = $totalPriceTaxExcl; diff --git a/pdf/invoice.extra-demands-tab.tpl b/pdf/invoice.extra-demands-tab.tpl index 108603e75..a80fab4b0 100644 --- a/pdf/invoice.extra-demands-tab.tpl +++ b/pdf/invoice.extra-demands-tab.tpl @@ -140,7 +140,7 @@ {$service['name']} - {if $service['product_tax_label']}{$service['product_tax_label']}{else}{l s='No tax' pdf='true'}{/if} + {if isset($service['product_tax_label']) && $service['product_tax_label']}{$service['product_tax_label']}{else}{l s='No tax' pdf='true'}{/if} {if $service['allow_multiple_quantity']} From bcba5c9cfa6933c469cb741c05bca6d76e4b0565 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 22 Aug 2024 09:58:44 +0530 Subject: [PATCH 6/7] Fixed: the service price was not updated on room updation --- controllers/admin/AdminOrdersController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 993e38995..168597c63 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4894,8 +4894,9 @@ class AdminOrdersControllerCore extends AdminController $id_room, 0, null, - 0, null, + null, + 0, $obj_booking_detail->id ); From a72fea51639283360ba1f0c8da7b859986f77470 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Thu, 22 Aug 2024 10:07:43 +0530 Subject: [PATCH 7/7] removed extra comments --- modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php b/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php index 3d37f9083..7be39da7f 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeDemand.php @@ -337,7 +337,6 @@ class HotelRoomTypeDemand extends ObjectModel } } - // since this will update the custom price according to the default currency, which is not required for custom price $price = Tools::convertPrice($price, $idCurrency); }