From 01aed22bfeb9041e0b403203e601f9d5e5d85200 Mon Sep 17 00:00:00 2001 From: shazar rahman Date: Mon, 2 Nov 2026 19:03:57 +0530 Subject: [PATCH 1/2] Fixed: admin order, cart, email, receipt and cart rule issues on back office Co-authored-by: Name --- .../helpers/list/_hotel_names_tooltip.tpl | 2 +- classes/order/Order.php | 21 +++++++++++++++++++ .../admin/AdminCartRulesController.php | 4 ++-- controllers/admin/AdminCartsController.php | 2 +- controllers/admin/AdminEmailsController.php | 4 ++-- controllers/admin/AdminOrdersController.php | 16 +++++++++++++- .../admin/AdminPaymentReceiptsController.php | 2 +- install-dev/data/xml/configuration.xml | 2 +- install-dev/langs/en/data/configuration.xml | 2 +- js/admin/orders.js | 6 ++++++ .../classes/HotelHelper.php | 4 ++-- 11 files changed, 53 insertions(+), 12 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl b/admin-dev/themes/default/template/controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl index eca4b71f3..79ec1a464 100644 --- a/admin-dev/themes/default/template/controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl +++ b/admin-dev/themes/default/template/controllers/cart_rules/helpers/list/_hotel_names_tooltip.tpl @@ -25,7 +25,7 @@ {if $hotel_names_remaining} {capture name='hotel_names_tooltip'}
-
{l s='Selected Hotels'}
+
{l s='Selected Properties'}
    {foreach from=$selected_hotels item='hotel'}
  • {$hotel|escape:'html':'UTF-8'}
  • diff --git a/classes/order/Order.php b/classes/order/Order.php index cca685821..969bab3fb 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2831,6 +2831,27 @@ class OrderCore extends ObjectModel return Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'orders WHERE id_cart = '.(int)$id_cart); } + /** + * Get all orders linked to a cart, either as the order's own cart or through a room + * added to an existing order from the back office (that creates a new cart whose + * rooms belong to the order, while orders.id_cart still points at the original cart). + * + * @param int $idCart + * @return array of orders + */ + public static function getAllOrdersLinkedToCart($idCart) + { + return Db::getInstance()->executeS( + 'SELECT o.* FROM `'._DB_PREFIX_.'orders` o + WHERE o.`id_cart` = '.(int) $idCart.' + OR o.`id_order` IN ( + SELECT hbd.`id_order` FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + WHERE hbd.`id_cart` = '.(int) $idCart.' + ) + ORDER BY o.`id_order` ASC' + ); + } + /** * Function to check if order has been completely refunded * @param integer action: can have 3 values as below diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index b534652bc..4c2c6aab0 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -47,7 +47,7 @@ class AdminCartRulesControllerCore extends AdminController $this->fields_list = array( 'id_cart_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), - 'hotel_names' => array('title' => $this->l('Hotels'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'), + 'hotel_names' => array('title' => $this->l('Property'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'), 'priority' => array('title' => $this->l('Priority'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'code' => array('title' => $this->l('Code'), 'class' => 'fixed-width-sm'), 'quantity' => array('title' => $this->l('Quantity'), 'align' => 'center', 'class' => 'fixed-width-xs'), @@ -274,7 +274,7 @@ class AdminCartRulesControllerCore extends AdminController Media::addJsDef( array( 'admin_cart_rule_tab_link' => $this->context->link->getAdminLink('AdminCartRules'), - 'room_access_err' => $this->l('You can only select room types which hotel(s) access is provided to this employee.'), + 'room_access_err' => $this->l('You can only select room types of the properties this employee has access to.'), 'room_rmv_txt' => $this->l('Unselect below room types'), ) ); diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index bbdf664fa..253266e3d 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -286,7 +286,7 @@ class AdminCartsControllerCore extends AdminController $summary = $cart->getSummaryDetails(); /* Display orders information */ - $cartOrders = Order::getAllOrdersByCartId($cart->id); + $cartOrders = Order::getAllOrdersLinkedToCart($cart->id); if ($cartOrders) { $objOrder = new Order($cartOrders[0]['id_order']); if (Validate::isLoadedObject($objOrder)) { diff --git a/controllers/admin/AdminEmailsController.php b/controllers/admin/AdminEmailsController.php index 77587ce49..3510af693 100644 --- a/controllers/admin/AdminEmailsController.php +++ b/controllers/admin/AdminEmailsController.php @@ -119,7 +119,7 @@ class AdminEmailsControllerCore extends AdminController 'type' => 'bool' ) ), - 'submit' => array('title' => $this->l('Save')) + 'submit' => array('title' => $this->l('Save'), 'name' => 'submitOptions') ), 'smtp' => array( 'title' => $this->l('Email'), @@ -181,7 +181,7 @@ class AdminEmailsControllerCore extends AdminController 'class' => 'fixed-width-sm' ), ), - 'submit' => array('title' => $this->l('Save')) + 'submit' => array('title' => $this->l('Save'), 'name' => 'submitOptions') ), 'test' => array( 'title' => $this->l('Test your email configuration'), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bbed3db59..ffe856f1d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -481,7 +481,15 @@ class AdminOrdersControllerCore extends AdminController } if ($this->tabAccess['edit'] === 1) { - if ((int) $order->isReturnable()) { + // nothing left to refund once every room and service line is deleted + // (amount is not checked: a free order can still be refunded) + $objHotelBookingDetail = new HotelBookingDetail(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + if ((int) $order->isReturnable() + && ($objHotelBookingDetail->getBookingDataByOrderId($order->id) + || $objServiceProductOrderDetail->getServiceProductsInOrder($order->id) + ) + ) { // always "Initiate refund" now, regardless of order status — // cancelling a booking happens through Room Status only $this->page_header_toolbar_btn['cancel'] = array( @@ -7219,6 +7227,12 @@ class AdminOrdersControllerCore extends AdminController $order_invoice->total_discount_tax_excl = 0; $res &= $order_invoice->update(); } + + // the order's own discount totals must follow the deleted cart rules + $order->total_discounts = 0; + $order->total_discounts_tax_incl = 0; + $order->total_discounts_tax_excl = 0; + $res &= $order->update(); } if (isset($order_invoice) && $order_invoice->id) { diff --git a/controllers/admin/AdminPaymentReceiptsController.php b/controllers/admin/AdminPaymentReceiptsController.php index 1ca890269..4e844f549 100644 --- a/controllers/admin/AdminPaymentReceiptsController.php +++ b/controllers/admin/AdminPaymentReceiptsController.php @@ -43,7 +43,7 @@ class AdminPaymentReceiptsControllerCore extends AdminControllerCore ), 'PS_PAYMENT_RECEIPTS_PREFIX' => array( 'title' => $this->l('Receipt prefix'), - 'desc' => $this->l('Prefix used for receipt name (e.g. #IN00001).'), + 'desc' => $this->l('Prefix used for receipt name (e.g. REC000001).'), 'size' => 6, 'type' => 'textLang' ), diff --git a/install-dev/data/xml/configuration.xml b/install-dev/data/xml/configuration.xml index 6c7728f25..24e4114ba 100644 --- a/install-dev/data/xml/configuration.xml +++ b/install-dev/data/xml/configuration.xml @@ -135,7 +135,7 @@ #IN - #IN + REC {"avoid":[]} diff --git a/install-dev/langs/en/data/configuration.xml b/install-dev/langs/en/data/configuration.xml index 610649713..e108a1b05 100644 --- a/install-dev/langs/en/data/configuration.xml +++ b/install-dev/langs/en/data/configuration.xml @@ -4,7 +4,7 @@ #IN - #IN + REC #DE diff --git a/js/admin/orders.js b/js/admin/orders.js index 0ab218d7d..262f2d6bc 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1643,10 +1643,16 @@ $(document).ready(function() { }); $(document).on('click', '#initiateRefund', function(e) { + if ($(this).data('submitted')) { + return false; + } + if ($.trim($('.cancellation_reason').val()) == '') { $('.cancellation_reason').focus().css('border', '1px solid red'); return false; } + + $(this).data('submitted', true); }); // End: CancelRoomBookingModal: Processes // ====================================== diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index d8f9b10d2..3ebcaffb3 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1532,7 +1532,7 @@ class HotelHelper ), array( 'id' => HotelBookingDetail::STATUS_NO_SHOW, - 'color' => '#DC143C', + 'color' => '#FF8C00', 'is_terminal' => 1, 'name' => array( 'en' => 'No-show', @@ -1545,7 +1545,7 @@ class HotelHelper ), array( 'id' => HotelBookingDetail::STATUS_CANCELLED, - 'color' => '#FF8C00', + 'color' => '#DC143C', 'is_terminal' => 1, 'name' => array( 'en' => 'Cancelled', From de84509965700ed04ec788158435837175d64096 Mon Sep 17 00:00:00 2001 From: shazar rahman Date: Mon, 2 Nov 2026 20:07:40 +0530 Subject: [PATCH 2/2] Fixed: code review changes made in cart rule page Co-authored-by: Name --- controllers/admin/AdminCartRulesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index 4c2c6aab0..a79ca2d5e 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -47,7 +47,7 @@ class AdminCartRulesControllerCore extends AdminController $this->fields_list = array( 'id_cart_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), - 'hotel_names' => array('title' => $this->l('Property'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'), + 'hotel_names' => array('title' => $this->l('Properties'), 'orderby' => false, 'havingFilter' => true, 'filter_key' => 'hotel_names', 'callback' => 'formatHotelNames'), 'priority' => array('title' => $this->l('Priority'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'code' => array('title' => $this->l('Code'), 'class' => 'fixed-width-sm'), 'quantity' => array('title' => $this->l('Quantity'), 'align' => 'center', 'class' => 'fixed-width-xs'),