From 2f973561ea43a8c0f45047f2f0daf6840e4ce2df Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 4 Jun 2025 19:23:08 +0530 Subject: [PATCH] added use reduct in get service product price function, removed hotel details from invoice for orders without hotel, fixed some minor issues --- .../template/controllers/orders/form.tpl | 2 ++ classes/pdf/HTMLTemplateInvoice.php | 18 +++++++++--------- controllers/admin/AdminOrdersController.php | 15 +++++++-------- controllers/front/ProductController.php | 8 ++++++++ .../classes/RoomTypeServiceProductPrice.php | 7 ++++--- .../classes/ServiceProductOrderDetail.php | 6 +++--- pdf/invoice.addresses-tab.tpl | 4 ++-- .../_partials/booking-form.tpl | 10 +++++----- 8 files changed, 40 insertions(+), 30 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 67e7ed00b..b189e2138 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1740,6 +1740,7 @@ $('#room_type_services_desc').show(); $('#add_new_room_services_block').hide(); $('#back_to_service_btn').hide(); + $('#btn_new_room_service').show(); }); // Add new custom service: Show hide new custom service form @@ -1747,6 +1748,7 @@ $('#add_new_room_services_block').show(); $('#back_to_service_btn').show(); $('#room_type_services_desc').hide(); + $('#btn_new_room_service').hide(); }); // Add new custom service: change auto added option diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 13f603a97..a277f4b66 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -318,12 +318,15 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate if (Module::isInstalled('hotelreservationsystem')) { $obj_htl_bk_dtl = new HotelBookingDetail(); $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $objHotelBranchInfo = new HotelBranchInformation((int) HotelBookingDetail::getIdHotelByIdOrder($order_obj->id), $context->language->id); $invoiceAddressPatternRules['avoid'][] = 'lastname'; - if ($idHotelAddress = $objHotelBranchInfo->getHotelIdAddress()) { - $objHotelAddress = new Address((int) $idHotelAddress); - $objHotelAddress->firstname = $objHotelBranchInfo->hotel_name; - $formattedHotelAddress = AddressFormat::generateAddress($objHotelAddress, $invoiceAddressPatternRules, '
', ' '); + if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order_obj->id)) { + $objHotelBranchInfo = new HotelBranchInformation((int) $idHotel, $context->language->id); + $invoiceAddressPatternRules['avoid'][] = 'lastname'; + if ($idHotelAddress = $objHotelBranchInfo->getHotelIdAddress()) { + $objHotelAddress = new Address((int) $idHotelAddress); + $objHotelAddress->firstname = $objHotelBranchInfo->hotel_name; + $formattedHotelAddress = AddressFormat::generateAddress($objHotelAddress, $invoiceAddressPatternRules, '
', ' '); + } } $customer = new Customer($this->order->id_customer); @@ -580,10 +583,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 0, $data_v['id'] )) { - $additionalServices['product_id'] = $type_value['product_id']; - $additionalServices['room_type_name'] = $type_value['product_name']; - $additionalServices['date_from'] = $data_v['date_from']; - $additionalServices['date_to'] = $data_v['date_to']; + $additionalServices[$data_v['id']]['product_id'] = $type_value['product_id']; $room_additinal_services[] = $additionalServices[$data_v['id']]; } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b5ac20aa9..1c3711995 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -986,14 +986,12 @@ class AdminOrdersControllerCore extends AdminController } if ($serviceProducts) { - if ($additionalServices) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - if (isset($additionalServices[$productLineData['id']]) - && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) - ) { - unset($serviceProducts[$key]); - } + foreach ($serviceProducts as $key => $servProduct) { + $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; + if (isset($additionalServices[$productLineData['id']]) + && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); } } @@ -1017,6 +1015,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['taxRulesGroups'] = $taxRulesGroups; $smartyVars['invoices_collection'] = $objOrder->getInvoicesCollection(); $smartyVars['customServiceAllowed'] = Configuration::get('PS_ALLOW_CREATE_CUSTOM_SERVICES_IN_BOOKING'); + $smartyVars['current_id_lang'] = $this->context->language->id; $this->context->smarty->assign($smartyVars); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 808f86496..2ea5cb9c3 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -891,6 +891,14 @@ class ProductControllerCore extends FrontController $useTax, $quantity ); + $smartyVars['service_price_without_reduction'] = RoomTypeServiceProductPrice::getPrice( + $this->product->id, + $idHotel, + $idProductOption, + $useTax, + $quantity, + false + ); if ($quantity) { $smartyVars['quantity'] = $quantity; } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php index 3aea55b0c..aca9e3b8a 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductPrice.php @@ -113,17 +113,18 @@ class RoomTypeServiceProductPrice extends ObjectModel $idHotel, $idProductOption = null, $useTax = null, - $quantity = 1 + $quantity = 1, + $useReduc = true ) { $idHotelAddress = Cart::getIdAddressForTaxCalculation($idProduct, $idHotel); - $price = ProductCore::getPriceStatic( + $price = Product::getPriceStatic( $idProduct, $useTax, $idProductOption, 6, null, false, - true, + $useReduc, $quantity, false, null, diff --git a/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php b/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php index 82f97f93a..8aa9dea49 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductOrderDetail.php @@ -140,15 +140,15 @@ class ServiceProductOrderDetail extends ObjectModel $sql = 'SELECT spod.*'; if (!$getTotalPrice) { - $sql .= ', hbd.`id_product` as `id_room_type`, od.`product_allow_multiple_quantity`, od.`product_price_calculation_method`, - hbd.`id_room`, hbd.`adults`, hbd.`children`, hbd.`id_product`, hbd.`date_from`, hbd.`date_to`, hbd.`room_type_name`, + $sql .= ', hbd.`id_product` as `id_room_type`, od.`product_price_calculation_method`, + hbd.`id_room`, hbd.`adults`, hbd.`children`, hbd.`date_from`, hbd.`date_to`, hbd.`room_type_name`, spod.`id_product` as id_product, od.`product_allow_multiple_quantity`, od.`product_price_calculation_method`, od.`product_auto_add`, od.`product_price_addition_type`'; } $sql .= ' FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'service_product_order_detail` spod ON(spod.`id_htl_booking_detail` = hbd.`id`)'; $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON(od.`id_order_detail` = spod.`id_order_detail`)'; - $sql .= ' WHERE 1'; + $sql .= ' WHERE spod.`id_htl_booking_detail` IS NOT NULL'; if ($idOrder) { $sql .= ' AND spod.`id_order` = '.(int)$idOrder; diff --git a/pdf/invoice.addresses-tab.tpl b/pdf/invoice.addresses-tab.tpl index fe6efc706..df5e70de0 100644 --- a/pdf/invoice.addresses-tab.tpl +++ b/pdf/invoice.addresses-tab.tpl @@ -32,8 +32,8 @@ {/if} --> - {l s='Hotel Detail' pdf='true'}

- {if $hotel_address} + {if !empty($hotel_address)} + {l s='Hotel Detail' pdf='true'}

{$hotel_address} {/if} diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index 89d45595d..1a592f740 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -280,12 +280,12 @@

+ {if $service_price && $service_price_without_reduction > $service_price} + + {convertPrice price=$service_price_without_reduction|floatval} + + {/if} {convertPrice price=$service_price} - {* {if !$priceDisplay || $priceDisplay == 2} - {convertPrice price=$product->getPrice(true, $smarty.const.NULL, 6)|floatval} - {elseif $priceDisplay == 1} - {convertPrice price=$product->getPrice(false, $smarty.const.NULL, 6)|floatval} - {/if} *}

{/block}