diff --git a/classes/pdf/HTMLTemplateBookingVoucher.php b/classes/pdf/HTMLTemplateBookingVoucher.php index 03cf50a15..b3b2fece0 100644 --- a/classes/pdf/HTMLTemplateBookingVoucher.php +++ b/classes/pdf/HTMLTemplateBookingVoucher.php @@ -141,6 +141,8 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $serviceGroups = array(); $roomTypeRows = array(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + foreach ($bookings as $booking) { $nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']); if ($nights <= 0) { @@ -160,7 +162,6 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $bookingServices = array(); // Auto-added services bundled with room price (for cost calculation only) - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts( (int)$this->order->id, 0, 0, isset($booking['id_product']) ? (int)$booking['id_product'] : 0, @@ -245,6 +246,43 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } unset($roomTypeRow); + // --- Hotel products --- + $hotelProducts = array(); + + $products = $objServiceProductOrderDetail->getServiceProductsInOrder( + (int) $this->order->id, + 0, + 0, + Product::SELLING_PREFERENCE_WITH_HOTEL + ); + + if (is_array($products)) { + foreach ($products as $product) { + $taxLabel = self::l('No tax'); + if ($taxes = OrderDetail::getTaxListStatic((int) $product['id_order_detail'])) { + $taxTemp = array(); + foreach ($taxes as $tax) { + $objTax = new Tax($tax['id_tax']); + $taxTemp[] = sprintf(self::l('%1$s%2$s%%'), $objTax->rate + 0, ' '); + } + $taxLabel = implode(', ', $taxTemp); + } + $hotelName = ''; + if (!empty($product['id_hotel'])) { + $objProductHotel = new HotelBranchInformation((int) $product['id_hotel'], (int) $this->order->id_lang); + $hotelName = $objProductHotel->hotel_name; + } + $hotelProducts[] = array( + 'name' => $product['name'].(!empty($product['option_name']) ? ' : '.$product['option_name'] : ''), + 'hotel_name' => $hotelName, + 'tax_label' => $taxLabel, + 'quantity' => (int) $product['quantity'], + 'unit_price_tax_excl' => (float) $product['unit_price_tax_excl'], + 'total_price_tax_excl' => (float) $product['total_price_tax_excl'], + ); + } + } + $guestAddress = ''; $guest = new Customer((int)$this->order->id_customer); @@ -353,6 +391,7 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate 'total_room_nights' => (int)$totalRoomNights, 'room_type_rows' => array_values($roomTypeRows), 'service_groups' => $serviceGroups, + 'hotel_products' => $hotelProducts, 'payment_method' => $paymentMethod, 'footer' => $footer, 'payment_policy' => $paymentPolicy, diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 62885ecb6..fa3aafc6d 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -560,6 +560,7 @@ class GuestTrackingControllerCore extends FrontController 'refund_allowed' => false, 'invoiceAllowed' => (int)Configuration::get('PS_INVOICE'), 'is_guest' => true, + 'has_room_booking' => (bool) HotelBookingDetail::getIdHotelByIdOrder((int) $order->id, false), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 3b954dbc8..b3756f4be 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -464,6 +464,7 @@ class OrderDetailControllerCore extends FrontController 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, + 'has_room_booking' => (bool) HotelBookingDetail::getIdHotelByIdOrder((int) $order->id, false), 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, diff --git a/controllers/front/PdfBookingVoucherController.php b/controllers/front/PdfBookingVoucherController.php index 0ba3302c9..f29d8b3eb 100644 --- a/controllers/front/PdfBookingVoucherController.php +++ b/controllers/front/PdfBookingVoucherController.php @@ -59,6 +59,10 @@ class PdfBookingVoucherControllerCore extends FrontController die(Tools::displayError('The booking voucher was not found.')); } + if (!HotelBookingDetail::getIdHotelByIdOrder((int) $order->id, false)) { + die(Tools::displayError('The booking voucher was not found.')); + } + $this->order = $order; } diff --git a/pdf/booking-voucher.tpl b/pdf/booking-voucher.tpl index 25aae5901..bcc0fc8f0 100644 --- a/pdf/booking-voucher.tpl +++ b/pdf/booking-voucher.tpl @@ -198,6 +198,39 @@ {/if} + {if $hotel_products} +
| {l s='PRODUCTS DETAILS' pdf='true'} | +||||
|---|---|---|---|---|
| {l s='Product Name' pdf='true'} | +{l s='Tax' pdf='true'} | +{l s='Unit Price (tax excl.)' pdf='true'} | +{l s='Qty' pdf='true'} | +{l s='Total (tax excl.)' pdf='true'} | +
| {$product.name|escape:'html':'UTF-8'}{if $product.hotel_name} {$product.hotel_name|escape:'html':'UTF-8'}{/if} |
+ {$product.tax_label nofilter} | +{displayPrice currency=$order->id_currency price=$product.unit_price_tax_excl} | +{$product.quantity|intval} | +{displayPrice currency=$order->id_currency price=$product.total_price_tax_excl} | +