From 5b7f51a9181a09daccfd810cbdde2c3769e613cc Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 25 Apr 2025 18:01:28 +0530 Subject: [PATCH] Added: Hotel address in the invoice, removed hotel column from the room type table --- classes/order/Order.php | 11 +++++++++++ classes/pdf/HTMLTemplateInvoice.php | 9 +++++++++ pdf/invoice.addresses-tab.tpl | 7 ++++++- pdf/invoice.product-tab.tpl | 8 +------- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/classes/order/Order.php b/classes/order/Order.php index d479ac256..8899d7ea2 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2857,6 +2857,17 @@ class OrderCore extends ObjectModel return $result; } + /** + * Get the Hotel Id of the order + * @return int|bool Hotel Id of the order + */ + public function getOrderHotelId() + { + return Db::getInstance()->getValue( + 'SELECT `id_hotel` FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_order` = '.(int) $this->id + ); + } + /** * @param bool $useTax: if true, total with tax, if false, total without tax * @param bool $withDiscounts: if true, total including discount, if false, total excluding discount diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index e2a82cbf0..4dbacf732 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -314,10 +314,18 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $service_product_data = array(); $room_extra_demands = array(); $room_additinal_services = array(); + $formattedHotelAddress = false; if (Module::isInstalled('hotelreservationsystem')) { $obj_htl_bk_dtl = new HotelBookingDetail(); $obj_rm_type = new HotelRoomType(); $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); + $objHotelBranchInfo = new HotelBranchInformation((int) $order_obj->getOrderHotelId()); + // since hotel address has same firstname and lastname we are going to remove the lastname + $invoiceAddressPatternRules['avoid'] = array('lastname'); + if ($idHotelAddress = $objHotelBranchInfo->getHotelIdAddress()) { + $objHotelAddress = new Address((int) $idHotelAddress); + $formattedHotelAddress = AddressFormat::generateAddress($objHotelAddress, $invoiceAddressPatternRules, '
', ' '); + } $customer = new Customer($this->order->id_customer); if (!empty($order_details)) { @@ -591,6 +599,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate 'cart_rules' => $cart_rules, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, + 'hotel_address' => $formattedHotelAddress, 'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address), 'tax_excluded_display' => $tax_excluded_display, 'display_product_images' => $display_product_images, diff --git a/pdf/invoice.addresses-tab.tpl b/pdf/invoice.addresses-tab.tpl index 0b743c4f0..fe6efc706 100644 --- a/pdf/invoice.addresses-tab.tpl +++ b/pdf/invoice.addresses-tab.tpl @@ -31,7 +31,12 @@ {$delivery_address} {/if} --> - + + {l s='Hotel Detail' pdf='true'}

+ {if $hotel_address} + {$hotel_address} + {/if} + {l s='Customer Detail' pdf='true'}

diff --git a/pdf/invoice.product-tab.tpl b/pdf/invoice.product-tab.tpl index d6721f5d9..ed6859cf6 100644 --- a/pdf/invoice.product-tab.tpl +++ b/pdf/invoice.product-tab.tpl @@ -27,14 +27,13 @@ - + {if $display_product_images} {/if} - {* {if isset($layout.before_discount)} @@ -62,11 +61,6 @@ {$data_v['name']}

-
{l s='Rooms Details' pdf='true'}{l s='Rooms Details' pdf='true'}
{l s='Room Image' pdf='true'}{l s='Room Description' pdf='true'}{l s='Hotel' pdf='true'} {l s='Tax Rate(s)' pdf='true'}{l s='Base price' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
-

- {$data_v['hotel_name']} -

-
{$data_v['order_detail_tax_label']}