From ca6139bc506763ce596b733949cf32d0f1207098 Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Fri, 1 May 2026 12:12:31 +0530 Subject: [PATCH 01/14] Added feature: Booking Voucher PDF in order detail page Co-authored-by: Name --- classes/pdf/HTMLTemplateBookingVoucher.php | 846 ++++++++++++++++++ classes/pdf/PDF.php | 1 + controllers/admin/AdminOrdersController.php | 15 +- controllers/admin/AdminPdfController.php | 26 + pdf/booking-voucher.tpl | 428 +++++++++ themes/hotel-reservation-theme/css/global.css | 7 +- 6 files changed, 1315 insertions(+), 8 deletions(-) create mode 100644 classes/pdf/HTMLTemplateBookingVoucher.php create mode 100644 pdf/booking-voucher.tpl diff --git a/classes/pdf/HTMLTemplateBookingVoucher.php b/classes/pdf/HTMLTemplateBookingVoucher.php new file mode 100644 index 000000000..e1e4a8d7e --- /dev/null +++ b/classes/pdf/HTMLTemplateBookingVoucher.php @@ -0,0 +1,846 @@ +order = $order; + $this->smarty = $smarty; + $this->date = Tools::displayDate(date('Y-m-d')); + $this->title = sprintf(self::l('Booking Voucher - %s'), $this->order->reference); + $this->shop = new Shop((int)$this->order->id_shop); + } + + /** + * @return string HTML header + */ + public function getHeader() + { + $this->assignCommonHeaderData(); + $this->smarty->assign(array('header' => self::l('Booking Voucher'))); + + return $this->smarty->fetch($this->getTemplate('header')); + } + + /** + * Assembles all voucher data inline and renders the template. + * + * @return string HTML content + */ + public function getContent() + { + // --- Bookings --- + $objHotelBookingDetail = new HotelBookingDetail(); + $bookings = $objHotelBookingDetail->getBookingDataByOrderId((int)$this->order->id); + if (!is_array($bookings)) { + $bookings = array(); + } + + // --- Order state --- + $orderState = $this->order->getCurrentStateFull((int)$this->order->id_lang); + if (!is_array($orderState)) { + $orderState = array('name' => self::l('Confirmed')); + } elseif (empty($orderState['name'])) { + $orderState['name'] = self::l('Confirmed'); + } + + // --- Hotel / property --- + $hotelName = Configuration::get('PS_SHOP_NAME', null, null, (int)$this->order->id_shop); + $hotelPhone = Configuration::get('PS_SHOP_PHONE', null, null, (int)$this->order->id_shop); + $hotelEmail = Configuration::get('PS_SHOP_EMAIL', null, null, (int)$this->order->id_shop); + $hotelAddress = ''; + $checkInTime = '--'; + $checkOutTime = '--'; + $paymentPolicy = ''; + $cancellationPolicy = ''; + + if (!empty($bookings)) { + $firstBooking = reset($bookings); + if (!empty($firstBooking['id_hotel'])) { + $objHotel = new HotelBranchInformation((int)$firstBooking['id_hotel'], (int)$this->order->id_lang); + if (Validate::isLoadedObject($objHotel)) { + $idHotel = (int)$objHotel->id; + $hotelName = $objHotel->hotel_name ? $objHotel->hotel_name : $hotelName; + $hotelPhone = $objHotel->phone ? $objHotel->phone : $hotelPhone; + $hotelEmail = $objHotel->email ? $objHotel->email : $hotelEmail; + $checkInTime = $objHotel->check_in ?: '--'; + $checkOutTime = $objHotel->check_out ?: '--'; + $policies = is_array($objHotel->policies) ? '' : (string)$objHotel->policies; + if ($policies) { + $policyText = html_entity_decode($policies, ENT_QUOTES, 'UTF-8'); + $policyText = preg_replace('//i', "\n", $policyText); + $policyText = strip_tags($policyText); + $policyText = preg_replace("/[\r\n]+/", "\n", $policyText); + $paymentPolicy = nl2br(trim($policyText)); + } + $cancellationPolicy = $this->getFormattedCancellationPolicy($idHotel); + + if ($idHotelAddress = $objHotel->getHotelIdAddress()) { + $objHotelAddress = new Address((int)$idHotelAddress); + if (Validate::isLoadedObject($objHotelAddress)) { + $objHotelAddress->firstname = $hotelName; + $hotelAddress = AddressFormat::generateAddress( + $objHotelAddress, + array('avoid' => array('lastname')), + '
', + ' ' + ); + } + } + } + } + } + + if (!$hotelAddress) { + $shopAddress = $this->shop->getAddress(); + if ($shopAddress instanceof Address) { + $hotelAddress = AddressFormat::generateAddress($shopAddress, array(), '
', ' '); + } + } + + // --- Room and service data --- + $roomAndServiceData = $this->getRoomAndServiceData($bookings); + + // --- Guest details --- + $guestName = ''; + $guestEmail = ''; + $guestPhone = ''; + $guestAddress = ''; + + $customer = new Customer((int)$this->order->id_customer); + if (Validate::isLoadedObject($customer)) { + $guestName = trim($customer->firstname.' '.$customer->lastname); + $guestEmail = $customer->email; + $guestPhone = $customer->phone; + } + $addressId = (int)$this->order->id_address_invoice ?: (int)$this->order->id_address_delivery; + if ($addressId) { + $address = new Address($addressId); + if (Validate::isLoadedObject($address)) { + $guestPhone = $address->phone_mobile ? $address->phone_mobile : $address->phone; + $guestAddress = AddressFormat::generateAddress($address, array(), '
', ' '); + } + } + // Override with primary guest if this is a guest booking + if ($idCustomerGuestDetail = OrderCustomerGuestDetail::isCustomerGuestBooking((int)$this->order->id)) { + $traveler = new OrderCustomerGuestDetail((int)$idCustomerGuestDetail); + if (Validate::isLoadedObject($traveler)) { + $guestName = trim($traveler->firstname.' '.$traveler->lastname); + $guestEmail = $traveler->email; + $guestPhone = $traveler->phone; + } + } + + $footer = $this->getTotalsData($roomAndServiceData); + + // --- Payment --- + $paymentMethods = array(); + $payments = $this->order->getOrderPaymentDetail(); + if (is_array($payments) && $payments) { + foreach ($payments as $paymentDetail) { + $method = isset($paymentDetail['payment_method']) ? trim($paymentDetail['payment_method']) : ''; + if (!$method) { + $method = $this->order->payment; + } + $amount = isset($paymentDetail['real_paid_amount']) + ? (float)$paymentDetail['real_paid_amount'] + : (float)$paymentDetail['amount']; + $idCurrency = isset($paymentDetail['id_currency']) + ? (int)$paymentDetail['id_currency'] + : (int)$this->order->id_currency; + $paymentMethods[] = $method.' - '.Tools::displayPrice($amount, $idCurrency); + } + } + $paymentMethod = $paymentMethods ? implode('

', $paymentMethods) : $this->order->payment; + + $data = array( + 'order' => $this->order, + 'order_status' => $orderState['name'], + 'booking_date' => Tools::displayDate($this->order->date_add, null, false), + 'issue_date' => Tools::displayDate(date('Y-m-d'), null, false), + // hotel / property + 'hotel_name' => $hotelName, + 'hotel_phone' => $hotelPhone, + 'hotel_email' => $hotelEmail, + 'hotel_address' => $hotelAddress, + // guest + 'guest_name' => $guestName, + 'guest_email' => $guestEmail, + 'guest_phone' => $guestPhone, + 'guest_address' => $guestAddress, + 'total_guests' => (int)$roomAndServiceData['total_guests'], + // booking summary + 'total_rooms' => (int)$roomAndServiceData['total_rooms'], + 'total_room_nights' => (int)$roomAndServiceData['total_room_nights'], + // room and service tables + 'room_type_rows' => $roomAndServiceData['room_type_rows'], + 'service_rows' => $roomAndServiceData['service_rows'], + // payment + 'payment_method' => $paymentMethod, + 'payment_status' => $orderState['name'], + 'is_advance_payment' => (int)$this->order->is_advance_payment, + // totals + 'footer' => $footer, + // policies + 'check_in_time' => ($checkInTime && $checkInTime !== '--') + ? date('h:i a', strtotime($checkInTime)) : '--', + 'check_out_time' => ($checkOutTime && $checkOutTime !== '--') + ? date('h:i a', strtotime($checkOutTime)) : '--', + 'payment_policy' => $paymentPolicy + ? $paymentPolicy + : self::l('Please contact the property for policy details.'), + 'cancellation_policy' => $cancellationPolicy, + 'has_cancellation_policy' => (bool)trim(strip_tags($cancellationPolicy)), + // tax + 'tax_breakdown' => $this->getTaxBreakdownData(), + ); + + if (Tools::getValue('debug')) { + die(json_encode($data)); + } + $this->smarty->assign($data); + + return $this->smarty->fetch($this->getTemplate('booking-voucher')); + } + + /** + * Builds per-room and per-room-type rows, services, price breakdown, and occupancy totals. + * + * @param array $bookings + * @return array + */ + protected function getRoomAndServiceData($bookings) + { + $rooms = array(); + $serviceRows = array(); + $servicesByRoom = array(); + $priceBreakdown = array(); + $roomTypeRows = array(); + $totalRoomNights = 0; + $totalGuests = 0; + + foreach ($bookings as $booking) { + $nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']); + if ($nights <= 0) { + $nights = 1; + } + + $roomReference = !empty($booking['room_num']) ? $booking['room_num'] : 'BK-'.(int)$booking['id']; + $adults = (int)$booking['adults']; + $children = (int)$booking['children']; + $totalGuests += $adults + $children; + $totalRoomNights += $nights; + + $serviceData = $this->getRoomServiceData($booking, $roomReference); + $servicesByRoom[$roomReference] = $serviceData['services']; + $serviceRows = array_merge($serviceRows, $serviceData['rows']); + + $roomTotalTaxExcl = (float)$booking['total_price_tax_excl']; + $roomTotalWithAutoServicesTaxExcl = $roomTotalTaxExcl + $serviceData['auto_added_room_total_tax_excl']; + $unitPriceTaxExcl = $nights ? Tools::ps_round( + $roomTotalWithAutoServicesTaxExcl / $nights, + _PS_PRICE_COMPUTE_PRECISION_, + $this->order->round_mode + ) : 0; + + // Group by room type + date range to aggregate multi-room rows + $roomTypeRowKey = implode('|', array( + (int)$booking['id_order_detail'], + isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + isset($booking['date_from']) ? $booking['date_from'] : '', + isset($booking['date_to']) ? $booking['date_to'] : '', + )); + + if (!isset($roomTypeRows[$roomTypeRowKey])) { + $idOrderDetail = (int)$booking['id_order_detail']; + $detailTaxes = $idOrderDetail ? OrderDetail::getTaxListStatic($idOrderDetail) : null; + $orderDetailTaxLabel = self::l('No tax'); + if ($detailTaxes) { + $taxTemp = array(); + foreach ($detailTaxes as $tax) { + $objTax = new Tax($tax['id_tax']); + $taxTemp[] = sprintf(self::l('%1$s%2$s%%'), $objTax->rate + 0, ' '); + } + $orderDetailTaxLabel = implode(', ', $taxTemp); + } + + $roomTypeRows[$roomTypeRowKey] = array( + 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + 'order_detail_tax_label' => $orderDetailTaxLabel, + 'rooms' => 0, + 'adults' => 0, + 'children' => 0, + 'nights' => $nights, + 'check_in_date' => $this->formatDisplayDate($booking['date_from']), + 'check_out_date' => $this->formatDisplayDate($booking['date_to']), + 'unit_price_tax_excl' => 0, + 'total_price_tax_excl' => 0, + ); + } + + $roomTypeRows[$roomTypeRowKey]['rooms'] += 1; + $roomTypeRows[$roomTypeRowKey]['adults'] += $adults; + $roomTypeRows[$roomTypeRowKey]['children'] += $children; + $roomTypeRows[$roomTypeRowKey]['total_price_tax_excl'] += $roomTotalWithAutoServicesTaxExcl; + + $rooms[] = array( + 'room_ref' => $roomReference, + 'room_num' => isset($booking['room_num']) ? $booking['room_num'] : '', + 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + 'check_in_date' => $this->formatDisplayDate($booking['date_from']), + 'check_out_date' => $this->formatDisplayDate($booking['date_to']), + 'nights' => $nights, + 'adults' => $adults, + 'children' => $children, + 'unit_price_tax_excl' => $unitPriceTaxExcl, + 'total_price_tax_excl' => $roomTotalWithAutoServicesTaxExcl, + ); + + $priceBreakdown[] = array( + 'room_ref' => $roomReference, + 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + 'nights' => $nights, + 'unit_price_tax_excl' => $unitPriceTaxExcl, + 'room_total_tax_excl' => $roomTotalWithAutoServicesTaxExcl, + 'services_total_tax_excl' => $serviceData['total_price_tax_excl'], + 'subtotal_tax_excl' => $roomTotalWithAutoServicesTaxExcl + $serviceData['total_price_tax_excl'], + ); + } + + foreach ($roomTypeRows as &$roomTypeRow) { + $denominator = (int)$roomTypeRow['nights'] * (int)$roomTypeRow['rooms']; + if ($denominator > 0) { + $roomTypeRow['unit_price_tax_excl'] = Tools::ps_round( + $roomTypeRow['total_price_tax_excl'] / $denominator, + 6, + $this->order->round_mode + ); + } + } + unset($roomTypeRow); + + return array( + 'rooms' => $rooms, + 'room_type_rows' => array_values($roomTypeRows), + 'service_rows' => $serviceRows, + 'services_by_room' => $servicesByRoom, + 'price_breakdown' => $priceBreakdown, + 'total_rooms' => count($rooms), + 'total_room_nights' => $totalRoomNights, + 'total_guests' => $totalGuests, + ); + } + + protected function getRoomServiceData($booking, $roomReference) + { + $rows = array(); + $services = array(); + $totalPriceTaxExcl = 0; + + $objBookingDemand = new HotelBookingDemands(); + $extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + (int)$booking['id'], + (int)$booking['id_order_detail'] + ); + + if (is_array($extraDemands)) { + foreach ($extraDemands as $demand) { + $services[] = array( + 'room_ref' => $roomReference, + 'check_in_out' => $this->formatDisplayDate($booking['date_from']).' - '.$this->formatDisplayDate($booking['date_to']), + 'name' => $demand['name'], + 'quantity' => 1, + 'total_price_tax_excl' => (float)$demand['total_price_tax_excl'], + ); + $rows[] = array( + 'room_ref' => $roomReference, + 'check_in_date' => $this->formatDisplayDate($booking['date_from']), + 'check_out_date' => $this->formatDisplayDate($booking['date_to']), + 'name' => $demand['name'], + 'quantity' => 1, + ); + $totalPriceTaxExcl += (float)$demand['total_price_tax_excl']; + } + } + + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + $autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts( + (int)$this->order->id, + 0, + 0, + isset($booking['id_product']) ? (int)$booking['id_product'] : 0, + isset($booking['date_from']) ? $booking['date_from'] : 0, + isset($booking['date_to']) ? $booking['date_to'] : 0, + isset($booking['id_room']) ? (int)$booking['id_room'] : 0, + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + + $additionalServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, null, 0, (int)$booking['id'] + ); + + if (isset($additionalServices[(int)$booking['id']]['additional_services'])) { + foreach ($additionalServices[(int)$booking['id']]['additional_services'] as $service) { + $services[] = array( + 'room_ref' => $roomReference, + 'check_in_out' => $this->formatDisplayDate($booking['date_from']).' - '.$this->formatDisplayDate($booking['date_to']), + 'name' => $service['name'], + 'quantity' => (int)$service['quantity'], + 'total_price_tax_excl' => (float)$service['total_price_tax_excl'], + 'product_tax_label' => isset($service['product_tax_label']) ? $service['product_tax_label'] : self::l('No tax'), + ); + $rows[] = array( + 'room_ref' => $roomReference, + 'check_in_date' => $this->formatDisplayDate($booking['date_from']), + 'check_out_date' => $this->formatDisplayDate($booking['date_to']), + 'name' => $service['name'], + 'quantity' => (int)$service['quantity'], + 'total_price_tax_excl' => (float)$service['total_price_tax_excl'], + 'product_tax_label' => isset($service['product_tax_label']) ? $service['product_tax_label'] : self::l('No tax'), + ); + $totalPriceTaxExcl += (float)$service['total_price_tax_excl']; + } + } + + return array( + 'services' => $services, + 'rows' => $rows, + 'total_price_tax_excl' => $totalPriceTaxExcl, + 'auto_added_room_total_tax_excl' => $autoAddedWithRoomPriceTaxExcl, + ); + } + + /** + * Computes all cost totals using Order's existing methods. + * Mirrors the $footer calculation in HTMLTemplateInvoice::getContent(). + * + * @param array $roomAndServiceData + * @return array + */ + protected function getTotalsData($roomAndServiceData) + { + $objBookingDemand = new HotelBookingDemands(); + $totalDemandsPriceTE = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, 0, 0, 0, 0, 1, 1, 0 + ); + $totalDemandsPriceTI = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, 0, 0, 0, 0, 1, 1, 1 + ); + + $idsOrderDetail = $this->getOrderDetailIds(); + + $roomsCost = 0; + $roomsCostTaxIncl = 0; + $serviceProductsCost = 0; + $serviceProductsCostTaxIncl = 0; + $additionalServicesCost = 0; + $additionalServicesCostTaxIncl = 0; + $convenienceFee = 0; + $convenienceFeeTaxIncl = 0; + $productDiscountsTaxExcl = (float)$this->order->total_discounts_tax_excl; + $productDiscountsTaxIncl = (float)$this->order->total_discounts_tax_incl; + + foreach ($this->order->getCartRules() as $cartRule) { + if (!empty($cartRule['free_shipping'])) { + $productDiscountsTaxExcl -= (float)$this->order->total_shipping_tax_excl; + $productDiscountsTaxIncl -= (float)$this->order->total_shipping_tax_incl; + } + } + + if ($productDiscountsTaxExcl < 0) { + $productDiscountsTaxExcl = 0; + } + if ($productDiscountsTaxIncl < 0) { + $productDiscountsTaxIncl = 0; + } + + if (!empty($idsOrderDetail)) { + $roomsCost = (float)$this->order->getTotalProductsWithoutTaxes( + false, true, null, null, null, $idsOrderDetail + ) + (float)$this->order->getTotalProductsWithoutTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail + ); + $roomsCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( + false, true, null, null, null, $idsOrderDetail + ) + (float)$this->order->getTotalProductsWithTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail + ); + + $serviceProductsCost = (float)$this->order->getTotalProductsWithoutTaxes( + false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail + ) + (float)$this->order->getTotalProductsWithoutTaxes( + false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail + ); + $serviceProductsCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( + false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail + ) + (float)$this->order->getTotalProductsWithTaxes( + false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail + ); + + $additionalServicesCost = (float)$this->order->getTotalProductsWithoutTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail + ) + $totalDemandsPriceTE; + $additionalServicesCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail + ) + $totalDemandsPriceTI; + + $convenienceFee = (float)$this->order->getTotalProductsWithoutTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail + ); + $convenienceFeeTaxIncl = (float)$this->order->getTotalProductsWithTaxes( + false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail + ); + } + + $grandTotal = (float)$this->order->total_paid_tax_incl; + $totalPaidReal = (float)$this->order->getTotalPaid(); + $totalWithoutDiscountTaxExcl = $roomsCost + $serviceProductsCost + $additionalServicesCost + $convenienceFee; + $totalWithoutDiscountTaxIncl = $roomsCostTaxIncl + $serviceProductsCostTaxIncl + $additionalServicesCostTaxIncl + $convenienceFeeTaxIncl; + $totalTaxes = $totalWithoutDiscountTaxIncl - $totalWithoutDiscountTaxExcl; + if ($totalTaxes < 0) { + $totalTaxes = 0; + } + + $amountDue = $grandTotal - $totalPaidReal; + if ($amountDue < 0) { + $amountDue = 0; + } + + return array( + 'total_rooms' => (int)$roomAndServiceData['total_rooms'], + 'total_room_nights' => (int)$roomAndServiceData['total_room_nights'], + 'total_guests' => (int)$roomAndServiceData['total_guests'], + 'rooms_cost' => $roomsCost, + 'room_price_tax_excl' => $roomsCost, + 'room_price_tax_incl' => $roomsCostTaxIncl, + 'service_products_price_tax_excl' => $serviceProductsCost, + 'service_products_price_tax_incl' => $serviceProductsCostTaxIncl, + 'additional_service_price_tax_excl' => $additionalServicesCost, + 'additional_service_price_tax_incl' => $additionalServicesCostTaxIncl, + 'extra_services_cost' => $additionalServicesCost + $serviceProductsCost, + 'convenience_fee' => $convenienceFee, + 'total_convenience_fee_te' => $convenienceFee, + 'total_convenience_fee_ti' => $convenienceFeeTaxIncl, + 'total_paid_tax_excl' => (float)$this->order->total_paid_tax_excl, + 'total_taxes' => $totalTaxes, + 'total_rooms_tax' => $totalTaxes, + 'extra_services_tax' => 0, + 'total_without_discount_te' => $totalWithoutDiscountTaxExcl, + 'total_without_discount_ti' => $totalWithoutDiscountTaxIncl, + 'total_tax_without_discount' => $totalTaxes, + 'product_discounts_tax_excl' => $productDiscountsTaxExcl, + 'product_discounts_tax_incl' => $productDiscountsTaxIncl, + 'grand_total' => $grandTotal, + 'total_paid' => $totalPaidReal, + 'total_paid_real' => $totalPaidReal, + 'total_paid_tax_incl' => $grandTotal, + 'amount_due' => Tools::ps_round($amountDue, _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode), + ); + } + + /** + * Builds tax breakdown by product type, handling both order detail taxes and extra demand taxes separately. + * Extracted: two-pass algorithm with per-type bucketing. + * + * @return array + */ + protected function getTaxBreakdownData() + { + $breakdowns = array( + 'room_tax' => array(), + 'additional_services_tax' => array(), + 'convenience_fee_tax' => array(), + 'extra_demands_tax' => array(), + 'service_products_tax' => array(), + ); + + $orderDetails = OrderDetail::getList((int)$this->order->id); + if (is_array($orderDetails)) { + foreach ($orderDetails as $orderDetail) { + $breakdownType = $this->getTaxBreakdownType($orderDetail); + if (!$breakdownType) { + continue; + } + + $taxes = OrderDetail::getTaxListStatic((int)$orderDetail['id_order_detail']); + if (!$taxes) { + $taxAmount = (float)$orderDetail['total_price_tax_incl'] - (float)$orderDetail['total_price_tax_excl']; + if ($taxAmount <= 0) { + continue; + } + $taxes = array(array( + 'id_tax' => 0, + 'rate' => (float)$orderDetail['total_price_tax_excl'] > 0 + ? (($taxAmount / (float)$orderDetail['total_price_tax_excl']) * 100) : 0, + 'total_amount' => $taxAmount, + )); + } + + foreach ($taxes as $taxDetail) { + $objTax = new Tax((int)$taxDetail['id_tax']); + $rate = Validate::isLoadedObject($objTax) + ? (float)$objTax->rate + : (isset($taxDetail['rate']) ? (float)$taxDetail['rate'] : 0); + $key = sprintf('%.3f', $rate); + + if (!isset($breakdowns[$breakdownType][$key])) { + $breakdowns[$breakdownType][$key] = array( + 'total_price_tax_excl' => 0, + 'total_tax_excl' => 0, + 'total_amount' => 0, + 'id_tax' => (int)$taxDetail['id_tax'], + 'rate' => sprintf('%.3f', $rate), + 'name' => Validate::isLoadedObject($objTax) + ? $objTax->name[(int)$this->order->id_lang] : '', + ); + } + + $breakdowns[$breakdownType][$key]['total_price_tax_excl'] += (float)$orderDetail['total_price_tax_excl']; + $breakdowns[$breakdownType][$key]['total_tax_excl'] += (float)$orderDetail['total_price_tax_excl']; + $breakdowns[$breakdownType][$key]['total_amount'] += (float)$taxDetail['total_amount']; + } + } + } + + $objBookingDemand = new HotelBookingDemands(); + $extraDemandTaxes = $objBookingDemand->getExtraDemandsTaxesDetails( + (int)$this->order->id, + $this->getOrderDetailIds() + ); + + if (is_array($extraDemandTaxes)) { + foreach ($extraDemandTaxes as $taxDetail) { + $rate = isset($taxDetail['rate']) ? (float)$taxDetail['rate'] : 0; + $key = sprintf('%.3f', $rate); + + if (!isset($breakdowns['extra_demands_tax'][$key])) { + $breakdowns['extra_demands_tax'][$key] = array( + 'total_price_tax_excl' => 0, + 'total_tax_excl' => 0, + 'total_amount' => 0, + 'id_tax' => (int)$taxDetail['id_tax'], + 'rate' => sprintf('%.3f', $rate), + 'name' => isset($taxDetail['name']) ? $taxDetail['name'] : '', + ); + } + + $taxBase = isset($taxDetail['total_tax_base']) + ? (float)$taxDetail['total_tax_base'] + : (float)$taxDetail['total_price_tax_excl']; + $breakdowns['extra_demands_tax'][$key]['total_price_tax_excl'] += $taxBase; + $breakdowns['extra_demands_tax'][$key]['total_tax_excl'] += $taxBase; + $breakdowns['extra_demands_tax'][$key]['total_amount'] += (float)$taxDetail['total_amount']; + } + } + + foreach ($breakdowns as $type => &$breakdown) { + if (empty($breakdown)) { + unset($breakdowns[$type]); + continue; + } + foreach ($breakdown as &$line) { + $line['total_price_tax_excl'] = Tools::ps_round( + $line['total_price_tax_excl'], + _PS_PRICE_COMPUTE_PRECISION_, + $this->order->round_mode + ); + $line['total_tax_excl'] = $line['total_price_tax_excl']; + $line['total_amount'] = Tools::ps_round( + $line['total_amount'], + _PS_PRICE_COMPUTE_PRECISION_, + $this->order->round_mode + ); + } + unset($line); + } + unset($breakdown); + + return $breakdowns; + } + + /** + * Classifies an OrderDetail row into a tax breakdown bucket. + * Extracted: complex multi-condition classification called inside a loop. + * + * @param array $orderDetail + * @return string|false + */ + protected function getTaxBreakdownType($orderDetail) + { + if (!empty($orderDetail['is_booking_product']) + || ((int)$orderDetail['product_auto_add'] + && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE + && (int)$orderDetail['product_price_addition_type'] === (int)Product::PRICE_ADDITION_TYPE_WITH_ROOM) + ) { + return 'room_tax'; + } + + if (!(int)$orderDetail['is_booking_product'] + && !(int)$orderDetail['product_auto_add'] + && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE + ) { + return 'additional_services_tax'; + } + + if (!(int)$orderDetail['is_booking_product'] + && (int)$orderDetail['product_auto_add'] + && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE + && (int)$orderDetail['product_price_addition_type'] === (int)Product::PRICE_ADDITION_TYPE_INDEPENDENT + ) { + return 'convenience_fee_tax'; + } + + if (!(int)$orderDetail['is_booking_product'] + && ((int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_STANDALONE + || (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + ) { + return 'service_products_tax'; + } + + return false; + } + + /** + * Returns order detail IDs for this order. + * Reused by getTotalsData() and getTaxBreakdownData(). + * + * @return array + */ + protected function getOrderDetailIds() + { + $orderDetails = OrderDetail::getList((int)$this->order->id); + + if (!is_array($orderDetails)) { + return array(); + } + + return array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail'))); + } + + /** + * Formats a date for display; returns '--' for empty/zero dates. + * Reused across getRoomAndServiceData and getRoomServiceData loops. + * + * @param string $date + * @return string + */ + protected function formatDisplayDate($date) + { + if (!$date || $date === '0000-00-00 00:00:00') { + return '--'; + } + + return Tools::displayDate($date, null, false); + } + + /** + * Fetches and formats the hotel's cancellation/refund rules as HTML. + * + * @param int $idHotel + * @return string + */ + protected function getFormattedCancellationPolicy($idHotel) + { + if (!(int)$idHotel) { + return ''; + } + + $objBranchRefundRules = new HotelBranchRefundRules(); + $refundRules = $objBranchRefundRules->getHotelRefundRules( + (int)$idHotel, 0, 1, (int)$this->order->id_lang, 1 + ); + + if (!is_array($refundRules) || empty($refundRules)) { + return ''; + } + + $policyBlocks = array(); + foreach ($refundRules as $rule) { + $ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : ''; + $ruleDescription = isset($rule['description']) ? trim($rule['description']) : ''; + + if ($ruleName === '' && $ruleDescription === '') { + continue; + } + + $block = ''; + if ($ruleName !== '') { + $block .= ''.Tools::safeOutput($ruleName).''; + } + if ($ruleDescription !== '') { + if ($block !== '') { + $block .= ': '; + } + $block .= $ruleDescription; + } + $policyBlocks[] = $block; + } + + if (empty($policyBlocks)) { + return ''; + } + + return implode('

', $policyBlocks); + } + + /** + * @return string + */ + public function getBulkFilename() + { + return self::l('BookingVouchers').'.pdf'; + } + + /** + * @return string + */ + public function getFilename() + { + return sprintf(self::l('BOOKING VOUCHER - Refrence No. #%s.pdf'), $this->order->reference); + } +} diff --git a/classes/pdf/PDF.php b/classes/pdf/PDF.php index 626d3a51a..3ab61b01b 100644 --- a/classes/pdf/PDF.php +++ b/classes/pdf/PDF.php @@ -41,6 +41,7 @@ class PDFCore const TEMPLATE_ORDER_SLIP = 'OrderSlip'; const TEMPLATE_DELIVERY_SLIP = 'DeliverySlip'; const TEMPLATE_SUPPLY_ORDER_FORM = 'SupplyOrderForm'; + const TEMPLATE_BOOKING_VOUCHER = 'BookingVoucher'; /** * @param $objects diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 30026bcca..b8095b2de 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -499,12 +499,15 @@ class AdminOrdersControllerCore extends AdminController ); } - $this->toolbar_btn['print'] = array( - 'short' => $this->l('Print'), - 'href' => 'javascript:window.print()', - 'desc' => $this->l('Print order'), - 'class' => 'icon-print', - ); + if (HotelBookingDetail::getIdHotelByIdOrder($order->id, false) && !$this->lite_display) { + $this->toolbar_btn['booking_voucher'] = array( + 'short' => $this->l('Booking Voucher'), + 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateBookingVoucherPDF&id_order='.$order->id, + 'desc' => $this->l('View booking voucher'), + 'class' => 'icon-file-text', + 'target' => true, + ); + } if ($this->tabAccess['edit'] === 1) { if (((int) $order->isReturnable()) diff --git a/controllers/admin/AdminPdfController.php b/controllers/admin/AdminPdfController.php index 7fba0f8e1..16eb82dc9 100644 --- a/controllers/admin/AdminPdfController.php +++ b/controllers/admin/AdminPdfController.php @@ -64,6 +64,15 @@ class AdminPdfControllerCore extends AdminController } } + public function processGenerateBookingVoucherPDF() + { + if (Tools::isSubmit('id_order')) { + $this->generateBookingVoucherPDFByIdOrder(Tools::getValue('id_order')); + } else { + die(Tools::displayError('The order ID is missing.')); + } + } + public function processGenerateOrderSlipPDF() { $order_slip = new OrderSlip((int)Tools::getValue('id_order_slip')); @@ -202,6 +211,23 @@ class AdminPdfControllerCore extends AdminController $this->generatePDF($order_invoice, PDF::TEMPLATE_INVOICE); } + public function generateBookingVoucherPDFByIdOrder($id_order) + { + $order = new Order((int)$id_order); + if (!Validate::isLoadedObject($order)) { + die(Tools::displayError('The order cannot be found within your database.')); + } + + $objHotelBookingDetail = new HotelBookingDetail(); + $bookingDetails = $objHotelBookingDetail->getBookingDataByOrderId((int)$order->id); + if (empty($bookingDetails)) { + die(Tools::displayError('No booking voucher is available for this order.')); + } + + $pdf = new PDF($order, PDF::TEMPLATE_BOOKING_VOUCHER, Context::getContext()->smarty); + $pdf->render('I'); + } + public function generatePDF($object, $template) { $pdf = new PDF($object, $template, Context::getContext()->smarty); diff --git a/pdf/booking-voucher.tpl b/pdf/booking-voucher.tpl new file mode 100644 index 000000000..c5b9ec805 --- /dev/null +++ b/pdf/booking-voucher.tpl @@ -0,0 +1,428 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +{assign var=pdf_style_template value=$smarty.const._PS_PDF_DIR_|cat:'invoice.style-tab.tpl'} +{include file=$pdf_style_template} + + + + + + + + + + + + + + + + + + + + + + + + + +
{l s='BOOKING INFORMATION' pdf='true'}
{l s='Booking Reference' pdf='true'}{$order->reference|escape:'html':'UTF-8'}{l s='Booking Date' pdf='true'}{$booking_date|escape:'html':'UTF-8'}{l s='Voucher Issue Date' pdf='true'}{$issue_date|escape:'html':'UTF-8'}
{l s='Status' pdf='true'}{$order_status|escape:'html':'UTF-8'}{l s='Total Rooms' pdf='true'}{$total_rooms|intval}{l s='Total Nights' pdf='true'}{$total_room_nights|intval}
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{l s='PROPERTY DETAILS' pdf='true'}{l s='GUEST INFORMATION' pdf='true'}
{l s='Property' pdf='true'}{$hotel_name|escape:'html':'UTF-8'}{l s='Primary Guest' pdf='true'}{$guest_name|escape:'html':'UTF-8'}
{l s='Email' pdf='true'}{$hotel_email|escape:'html':'UTF-8'}{l s='Email' pdf='true'}{$guest_email|escape:'html':'UTF-8'}
{l s='Phone' pdf='true'}{$hotel_phone|escape:'html':'UTF-8'}{l s='Phone' pdf='true'}{$guest_phone|escape:'html':'UTF-8'}
{l s='Address' pdf='true'}{if $hotel_address}{$hotel_address nofilter}{else}--{/if}{l s='Address' pdf='true'}{if $guest_address|strip_tags|trim}{$guest_address nofilter}{else}--{/if}
{l s='Total Guests' pdf='true'}{$total_guests|intval}
+ + + + + +
+ + + + + + + + + + + + + + + + + + {if $room_type_rows} + {foreach from=$room_type_rows item=room_type_row} + {cycle values="color_line_even,color_line_odd" assign=bgcolor_class} + + + + + + + + + + {/foreach} + {else} + + + + {/if} + +
{l s='ROOM DETAILS' pdf='true'}
{l s='Room Description' pdf='true'}{l s='Tax Rate(s)' pdf='true'}{l s='Unit Price' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{l s='Rooms' pdf='true'}{l s='Check-in Date' pdf='true'}{l s='Check-out Date' pdf='true'}{l s='Total' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{$room_type_row.room_type_name|escape:'html':'UTF-8'}{$room_type_row.order_detail_tax_label}{displayPrice currency=$order->id_currency price=$room_type_row.unit_price_tax_excl} + {if $room_type_row.adults <= 9}0{/if}{$room_type_row.adults|intval} {if $room_type_row.adults > 1}{l s='Adults' pdf='true'}{else}{l s='Adult' pdf='true'}{/if}{if $room_type_row.children}, {if $room_type_row.children <= 9}0{/if}{$room_type_row.children|intval} {if $room_type_row.children > 1}{l s='Children' pdf='true'}{else}{l s='Child' pdf='true'}{/if}{/if}
{if $room_type_row.rooms <= 9}0{/if}{$room_type_row.rooms|intval} {if $room_type_row.rooms > 1}{l s='Rooms' pdf='true'}{else}{l s='Room' pdf='true'}{/if} +
{$room_type_row.check_in_date|escape:'html':'UTF-8'}{$room_type_row.check_out_date|escape:'html':'UTF-8'}{displayPrice currency=$order->id_currency price=$room_type_row.total_price_tax_excl}
{l s='No room details available.' pdf='true'}
+ +{if $service_rows} + + + + +
+ + + + + + + + + + + + + + + {foreach from=$service_rows item=service} + {cycle values="color_line_even,color_line_odd" assign=bgcolor_class} + + + + + + + {/foreach} + +
{l s='SERVICES DETAILS' pdf='true'}
{l s='Room Ref' pdf='true'}{l s='Check-in / Check-out' pdf='true'}{l s='Service Name' pdf='true'}{l s='Qty' pdf='true'}
{$service.room_ref|escape:'html':'UTF-8'}{$service.check_in_date|escape:'html':'UTF-8'} - {$service.check_out_date|escape:'html':'UTF-8'}{$service.name|escape:'html':'UTF-8'}{$service.quantity|intval}
+{/if} + + + + + +
+ +{assign var=payment_method_rendered value=false} +{assign var=payment_status_rendered value=false} + + + + + + + + + + {if isset($footer.room_price_tax_excl) && $footer.room_price_tax_excl} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + {if isset($footer.service_products_price_tax_excl) && $footer.service_products_price_tax_excl} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + {if isset($footer.additional_service_price_tax_excl) && $footer.additional_service_price_tax_excl} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + {if isset($footer.total_convenience_fee_te) && $footer.total_convenience_fee_te} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {if $footer.total_tax_without_discount > 0} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + {if isset($footer.product_discounts_tax_incl) && $footer.product_discounts_tax_incl > 0} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {if $footer.amount_due > 0} + + {if !$payment_method_rendered} + + + {assign var=payment_method_rendered value=true} + {elseif !$payment_status_rendered} + + + {assign var=payment_status_rendered value=true} + {else} + + + {/if} + + + + + {/if} + +
{l s='PAYMENT INFORMATION' pdf='true'}{l s='TOTAL AMOUNT' pdf='true'}
{l s='Payment Method' pdf='true'}{$payment_method nofilter}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Rooms Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.room_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Products cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.service_products_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Extra Services Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.additional_service_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Convenience Fee (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_convenience_fee_te}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total (Tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_without_discount_te}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Tax' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_tax_without_discount}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Discounts' pdf='true'}- {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_incl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Final Booking Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_paid_tax_incl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Due Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.amount_due}
+ +{if $has_cancellation_policy} + + + + +
+ + + + + + + + + + + + +
{l s='CANCELLATION POLICY' pdf='true'}
{$cancellation_policy nofilter}
+{/if} + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
{l s='PROPERTY POLICIES' pdf='true'}
{l s='Check-in time' pdf='true'}{$check_in_time|escape:'html':'UTF-8'}
{l s='Check-out time' pdf='true'}{$check_out_time|escape:'html':'UTF-8'}
{l s='Policies' pdf='true'}{$payment_policy nofilter}
+ +{if isset($HOOK_DISPLAY_PDF) && $HOOK_DISPLAY_PDF} + + + + + + + +
{$HOOK_DISPLAY_PDF}
+{/if} diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index 1c8ecf2e3..7fb667b55 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -5776,10 +5776,13 @@ textarea { background: #fff; } #columns { + padding: 0; +} +#columns:has(#center_column > *) { position: relative; padding-bottom: 50px; - padding-top: 15px; } - + padding-top: 15px; +} #index .tab-content { margin-top: 35px; margin-bottom: 34px; } From fa22d23f75b667dd4e0728dc15044b3c28f61dde Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Fri, 1 May 2026 13:09:48 +0530 Subject: [PATCH 02/14] removed print order button --- controllers/admin/AdminOrdersController.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 29bb57991..b28a6baa9 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -391,13 +391,6 @@ class AdminOrdersControllerCore extends AdminController ); } - $this->page_header_toolbar_btn['print'] = array( - 'short' => $this->l('Print'), - 'href' => 'javascript:window.print()', - 'desc' => $this->l('Print order'), - 'class' => 'icon-print', - ); - if ($this->tabAccess['edit'] === 1) { if (((int) $order->isReturnable()) && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0) From 971df08c5f0ddf439789debf13cf866e2563df8d Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Fri, 1 May 2026 13:21:27 +0530 Subject: [PATCH 03/14] fixed: removed pdf button from inittoolbar function, and added in initPageHeaderToolbar Co-authored-by: Name --- controllers/admin/AdminOrdersController.php | 62 ++++----------------- 1 file changed, 10 insertions(+), 52 deletions(-) diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b28a6baa9..e9be3b80a 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -391,6 +391,16 @@ class AdminOrdersControllerCore extends AdminController ); } + if (HotelBookingDetail::getIdHotelByIdOrder($order->id, false) && !$this->lite_display) { + $this->page_header_toolbar_btn['booking_voucher'] = array( + 'short' => $this->l('Booking Voucher'), + 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateBookingVoucherPDF&id_order='.$order->id, + 'desc' => $this->l('View booking voucher'), + 'class' => 'icon-file-text', + 'target' => true, + ); + } + if ($this->tabAccess['edit'] === 1) { if (((int) $order->isReturnable()) && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0) @@ -518,58 +528,6 @@ class AdminOrdersControllerCore extends AdminController public function initToolbar() { - if ($this->display == 'view') { - /** @var Order $order */ - if (Validate::isLoadedObject($order = $this->loadObject())) { - // hotel link in header - if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) { - $this->toolbar_btn['hotel'] = array( - 'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info', - 'desc' => $this->l('View Hotel'), - 'class' => 'icon-building', - 'target' => true, - ); - } - - if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) { - $this->toolbar_btn['file'] = array( - 'short' => $this->l('Invoice'), - 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id, - 'desc' => $this->l('View invoice'), - 'class' => 'icon-file-text', - 'target' => true, - ); - } - - if (HotelBookingDetail::getIdHotelByIdOrder($order->id, false) && !$this->lite_display) { - $this->toolbar_btn['booking_voucher'] = array( - 'short' => $this->l('Booking Voucher'), - 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateBookingVoucherPDF&id_order='.$order->id, - 'desc' => $this->l('View booking voucher'), - 'class' => 'icon-file-text', - 'target' => true, - ); - } - - if ($this->tabAccess['edit'] === 1) { - if (((int) $order->isReturnable()) - && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0) - ) { - $orderTotalPaid = $order->getTotalPaid(); - $orderDiscounts = $order->getCartRules(); - $hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false; - $this->toolbar_btn['cancel'] = array( - 'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'), - 'id' => 'desc-order-standard_refund', - 'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'), - 'class' => 'icon-exchange', - 'target' => true, - ); - } - } - } - } - $res = parent::initToolbar(); if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && isset($this->toolbar_btn['new']) && Shop::isFeatureActive()) { unset($this->toolbar_btn['new']); From 0f76539a171ee1965b62f29a03b6e5d5b66d5830 Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Sat, 2 May 2026 13:56:21 +0530 Subject: [PATCH 04/14] combined code in getcontent funciton, and fixed pdf page change issue --- classes/pdf/HTMLTemplateBookingVoucher.php | 682 ++++++--------------- pdf/booking-voucher.tpl | 4 +- 2 files changed, 179 insertions(+), 507 deletions(-) diff --git a/classes/pdf/HTMLTemplateBookingVoucher.php b/classes/pdf/HTMLTemplateBookingVoucher.php index e1e4a8d7e..af465930f 100644 --- a/classes/pdf/HTMLTemplateBookingVoucher.php +++ b/classes/pdf/HTMLTemplateBookingVoucher.php @@ -22,6 +22,10 @@ * @license https://opensource.org/license/osl-3.0-php Open Software License version 3.0 */ +/** + * Builds and renders the Booking Voucher PDF for a given Order. + * Data assembly follows the same inline pattern as HTMLTemplateInvoice::getContent(). + */ class HTMLTemplateBookingVoucherCore extends HTMLTemplate { /** @var Order */ @@ -95,6 +99,7 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $hotelEmail = $objHotel->email ? $objHotel->email : $hotelEmail; $checkInTime = $objHotel->check_in ?: '--'; $checkOutTime = $objHotel->check_out ?: '--'; + $policies = is_array($objHotel->policies) ? '' : (string)$objHotel->policies; if ($policies) { $policyText = html_entity_decode($policies, ENT_QUOTES, 'UTF-8'); @@ -103,7 +108,31 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $policyText = preg_replace("/[\r\n]+/", "\n", $policyText); $paymentPolicy = nl2br(trim($policyText)); } - $cancellationPolicy = $this->getFormattedCancellationPolicy($idHotel); + + if ($idHotel) { + $objBranchRefundRules = new HotelBranchRefundRules(); + $refundRules = $objBranchRefundRules->getHotelRefundRules( + $idHotel, 0, 1, (int)$this->order->id_lang, 1 + ); + if (is_array($refundRules) && !empty($refundRules)) { + $policyBlocks = array(); + foreach ($refundRules as $rule) { + $ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : ''; + $ruleDescription = isset($rule['description']) ? trim($rule['description']) : ''; + if ($ruleName === '' && $ruleDescription === '') { + continue; + } + $block = $ruleName !== '' ? ''.Tools::safeOutput($ruleName).'' : ''; + if ($ruleDescription !== '') { + $block .= ($block !== '' ? ': ' : '').$ruleDescription; + } + $policyBlocks[] = $block; + } + if (!empty($policyBlocks)) { + $cancellationPolicy = implode('

', $policyBlocks); + } + } + } if ($idHotelAddress = $objHotel->getHotelIdAddress()) { $objHotelAddress = new Address((int)$idHotelAddress); @@ -128,8 +157,136 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } } - // --- Room and service data --- - $roomAndServiceData = $this->getRoomAndServiceData($bookings); + // --- Rooms, services, occupancy --- + $totalRooms = 0; + $serviceRows = array(); + $roomTypeRows = array(); + $totalRoomNights = 0; + $totalGuests = 0; + + foreach ($bookings as $booking) { + $nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']); + if ($nights <= 0) { + $nights = 1; + } + + $roomReference = !empty($booking['room_num']) ? $booking['room_num'] : 'BK-'.(int)$booking['id']; + $adults = (int)$booking['adults']; + $children = (int)$booking['children']; + $totalGuests += $adults + $children; + $totalRoomNights += $nights; + + $dateFrom = ($booking['date_from'] && $booking['date_from'] !== '0000-00-00 00:00:00') + ? Tools::displayDate($booking['date_from'], null, false) : '--'; + $dateTo = ($booking['date_to'] && $booking['date_to'] !== '0000-00-00 00:00:00') + ? Tools::displayDate($booking['date_to'], null, false) : '--'; + + // Extra demands for this room + $autoAddedWithRoomPriceTaxExcl = 0; + $roomServiceRows = array(); + + $objBookingDemand = new HotelBookingDemands(); + $extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, 0, 0, 0, 0, 0, 0, 0, + (int)$booking['id'], (int)$booking['id_order_detail'] + ); + if (is_array($extraDemands)) { + foreach ($extraDemands as $demand) { + $roomServiceRows[] = array( + 'room_ref' => $roomReference, + 'check_in_date' => $dateFrom, + 'check_out_date' => $dateTo, + 'name' => $demand['name'], + 'quantity' => 1, + ); + } + } + + // Auto-added services bundled with room price + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + $autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts( + (int)$this->order->id, 0, 0, + isset($booking['id_product']) ? (int)$booking['id_product'] : 0, + isset($booking['date_from']) ? $booking['date_from'] : 0, + isset($booking['date_to']) ? $booking['date_to'] : 0, + isset($booking['id_room']) ? (int)$booking['id_room'] : 0, + 1, 0, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + + // Additional services chosen by guest + $additionalServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, null, 0, (int)$booking['id'] + ); + if (isset($additionalServices[(int)$booking['id']]['additional_services'])) { + foreach ($additionalServices[(int)$booking['id']]['additional_services'] as $service) { + $roomServiceRows[] = array( + 'room_ref' => $roomReference, + 'check_in_date' => $dateFrom, + 'check_out_date' => $dateTo, + 'name' => $service['name'], + 'quantity' => (int)$service['quantity'], + ); + } + } + + $serviceRows = array_merge($serviceRows, $roomServiceRows); + + $roomTotalTaxExcl = (float)$booking['total_price_tax_excl']; + $roomTotalWithAutoServicesTaxExcl = $roomTotalTaxExcl + $autoAddedWithRoomPriceTaxExcl; + + // Aggregate per room type + date range + $roomTypeRowKey = implode('|', array( + (int)$booking['id_order_detail'], + isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + isset($booking['date_from']) ? $booking['date_from'] : '', + isset($booking['date_to']) ? $booking['date_to'] : '', + )); + + if (!isset($roomTypeRows[$roomTypeRowKey])) { + $idOrderDetail = (int)$booking['id_order_detail']; + $detailTaxes = $idOrderDetail ? OrderDetail::getTaxListStatic($idOrderDetail) : null; + $orderDetailTaxLabel = self::l('No tax'); + if ($detailTaxes) { + $taxTemp = array(); + foreach ($detailTaxes as $tax) { + $objTax = new Tax($tax['id_tax']); + $taxTemp[] = sprintf(self::l('%1$s%2$s%%'), $objTax->rate + 0, ' '); + } + $orderDetailTaxLabel = implode(', ', $taxTemp); + } + + $roomTypeRows[$roomTypeRowKey] = array( + 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + 'order_detail_tax_label' => $orderDetailTaxLabel, + 'rooms' => 0, + 'adults' => 0, + 'children' => 0, + 'nights' => $nights, + 'check_in_date' => $dateFrom, + 'check_out_date' => $dateTo, + 'unit_price_tax_excl' => 0, + 'total_price_tax_excl' => 0, + ); + } + + $roomTypeRows[$roomTypeRowKey]['rooms'] += 1; + $roomTypeRows[$roomTypeRowKey]['adults'] += $adults; + $roomTypeRows[$roomTypeRowKey]['children'] += $children; + $roomTypeRows[$roomTypeRowKey]['total_price_tax_excl'] += $roomTotalWithAutoServicesTaxExcl; + $totalRooms++; + } + + foreach ($roomTypeRows as &$roomTypeRow) { + $denominator = (int)$roomTypeRow['nights'] * (int)$roomTypeRow['rooms']; + if ($denominator > 0) { + $roomTypeRow['unit_price_tax_excl'] = Tools::ps_round( + $roomTypeRow['total_price_tax_excl'] / $denominator, + 6, + $this->order->round_mode + ); + } + } + unset($roomTypeRow); // --- Guest details --- $guestName = ''; @@ -161,7 +318,8 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } } - $footer = $this->getTotalsData($roomAndServiceData); + // --- Totals --- + $footer = $this->getTotalsData($totalRooms, $totalRoomNights, $totalGuests); // --- Payment --- $paymentMethods = array(); @@ -198,18 +356,17 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate 'guest_email' => $guestEmail, 'guest_phone' => $guestPhone, 'guest_address' => $guestAddress, - 'total_guests' => (int)$roomAndServiceData['total_guests'], + 'total_guests' => (int)$totalGuests, // booking summary - 'total_rooms' => (int)$roomAndServiceData['total_rooms'], - 'total_room_nights' => (int)$roomAndServiceData['total_room_nights'], + 'total_rooms' => (int)$totalRooms, + 'total_room_nights' => (int)$totalRoomNights, // room and service tables - 'room_type_rows' => $roomAndServiceData['room_type_rows'], - 'service_rows' => $roomAndServiceData['service_rows'], + 'room_type_rows' => array_values($roomTypeRows), + 'service_rows' => $serviceRows, // payment 'payment_method' => $paymentMethod, 'payment_status' => $orderState['name'], - 'is_advance_payment' => (int)$this->order->is_advance_payment, - // totals + // totals — key named $footer to match invoice convention 'footer' => $footer, // policies 'check_in_time' => ($checkInTime && $checkInTime !== '--') @@ -221,8 +378,6 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate : self::l('Please contact the property for policy details.'), 'cancellation_policy' => $cancellationPolicy, 'has_cancellation_policy' => (bool)trim(strip_tags($cancellationPolicy)), - // tax - 'tax_breakdown' => $this->getTaxBreakdownData(), ); if (Tools::getValue('debug')) { @@ -234,231 +389,16 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } /** - * Builds per-room and per-room-type rows, services, price breakdown, and occupancy totals. - * - * @param array $bookings - * @return array - */ - protected function getRoomAndServiceData($bookings) - { - $rooms = array(); - $serviceRows = array(); - $servicesByRoom = array(); - $priceBreakdown = array(); - $roomTypeRows = array(); - $totalRoomNights = 0; - $totalGuests = 0; - - foreach ($bookings as $booking) { - $nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']); - if ($nights <= 0) { - $nights = 1; - } - - $roomReference = !empty($booking['room_num']) ? $booking['room_num'] : 'BK-'.(int)$booking['id']; - $adults = (int)$booking['adults']; - $children = (int)$booking['children']; - $totalGuests += $adults + $children; - $totalRoomNights += $nights; - - $serviceData = $this->getRoomServiceData($booking, $roomReference); - $servicesByRoom[$roomReference] = $serviceData['services']; - $serviceRows = array_merge($serviceRows, $serviceData['rows']); - - $roomTotalTaxExcl = (float)$booking['total_price_tax_excl']; - $roomTotalWithAutoServicesTaxExcl = $roomTotalTaxExcl + $serviceData['auto_added_room_total_tax_excl']; - $unitPriceTaxExcl = $nights ? Tools::ps_round( - $roomTotalWithAutoServicesTaxExcl / $nights, - _PS_PRICE_COMPUTE_PRECISION_, - $this->order->round_mode - ) : 0; - - // Group by room type + date range to aggregate multi-room rows - $roomTypeRowKey = implode('|', array( - (int)$booking['id_order_detail'], - isset($booking['room_type_name']) ? $booking['room_type_name'] : '', - isset($booking['date_from']) ? $booking['date_from'] : '', - isset($booking['date_to']) ? $booking['date_to'] : '', - )); - - if (!isset($roomTypeRows[$roomTypeRowKey])) { - $idOrderDetail = (int)$booking['id_order_detail']; - $detailTaxes = $idOrderDetail ? OrderDetail::getTaxListStatic($idOrderDetail) : null; - $orderDetailTaxLabel = self::l('No tax'); - if ($detailTaxes) { - $taxTemp = array(); - foreach ($detailTaxes as $tax) { - $objTax = new Tax($tax['id_tax']); - $taxTemp[] = sprintf(self::l('%1$s%2$s%%'), $objTax->rate + 0, ' '); - } - $orderDetailTaxLabel = implode(', ', $taxTemp); - } - - $roomTypeRows[$roomTypeRowKey] = array( - 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', - 'order_detail_tax_label' => $orderDetailTaxLabel, - 'rooms' => 0, - 'adults' => 0, - 'children' => 0, - 'nights' => $nights, - 'check_in_date' => $this->formatDisplayDate($booking['date_from']), - 'check_out_date' => $this->formatDisplayDate($booking['date_to']), - 'unit_price_tax_excl' => 0, - 'total_price_tax_excl' => 0, - ); - } - - $roomTypeRows[$roomTypeRowKey]['rooms'] += 1; - $roomTypeRows[$roomTypeRowKey]['adults'] += $adults; - $roomTypeRows[$roomTypeRowKey]['children'] += $children; - $roomTypeRows[$roomTypeRowKey]['total_price_tax_excl'] += $roomTotalWithAutoServicesTaxExcl; - - $rooms[] = array( - 'room_ref' => $roomReference, - 'room_num' => isset($booking['room_num']) ? $booking['room_num'] : '', - 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', - 'check_in_date' => $this->formatDisplayDate($booking['date_from']), - 'check_out_date' => $this->formatDisplayDate($booking['date_to']), - 'nights' => $nights, - 'adults' => $adults, - 'children' => $children, - 'unit_price_tax_excl' => $unitPriceTaxExcl, - 'total_price_tax_excl' => $roomTotalWithAutoServicesTaxExcl, - ); - - $priceBreakdown[] = array( - 'room_ref' => $roomReference, - 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', - 'nights' => $nights, - 'unit_price_tax_excl' => $unitPriceTaxExcl, - 'room_total_tax_excl' => $roomTotalWithAutoServicesTaxExcl, - 'services_total_tax_excl' => $serviceData['total_price_tax_excl'], - 'subtotal_tax_excl' => $roomTotalWithAutoServicesTaxExcl + $serviceData['total_price_tax_excl'], - ); - } - - foreach ($roomTypeRows as &$roomTypeRow) { - $denominator = (int)$roomTypeRow['nights'] * (int)$roomTypeRow['rooms']; - if ($denominator > 0) { - $roomTypeRow['unit_price_tax_excl'] = Tools::ps_round( - $roomTypeRow['total_price_tax_excl'] / $denominator, - 6, - $this->order->round_mode - ); - } - } - unset($roomTypeRow); - - return array( - 'rooms' => $rooms, - 'room_type_rows' => array_values($roomTypeRows), - 'service_rows' => $serviceRows, - 'services_by_room' => $servicesByRoom, - 'price_breakdown' => $priceBreakdown, - 'total_rooms' => count($rooms), - 'total_room_nights' => $totalRoomNights, - 'total_guests' => $totalGuests, - ); - } - - protected function getRoomServiceData($booking, $roomReference) - { - $rows = array(); - $services = array(); - $totalPriceTaxExcl = 0; - - $objBookingDemand = new HotelBookingDemands(); - $extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( - (int)$this->order->id, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - (int)$booking['id'], - (int)$booking['id_order_detail'] - ); - - if (is_array($extraDemands)) { - foreach ($extraDemands as $demand) { - $services[] = array( - 'room_ref' => $roomReference, - 'check_in_out' => $this->formatDisplayDate($booking['date_from']).' - '.$this->formatDisplayDate($booking['date_to']), - 'name' => $demand['name'], - 'quantity' => 1, - 'total_price_tax_excl' => (float)$demand['total_price_tax_excl'], - ); - $rows[] = array( - 'room_ref' => $roomReference, - 'check_in_date' => $this->formatDisplayDate($booking['date_from']), - 'check_out_date' => $this->formatDisplayDate($booking['date_to']), - 'name' => $demand['name'], - 'quantity' => 1, - ); - $totalPriceTaxExcl += (float)$demand['total_price_tax_excl']; - } - } - - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts( - (int)$this->order->id, - 0, - 0, - isset($booking['id_product']) ? (int)$booking['id_product'] : 0, - isset($booking['date_from']) ? $booking['date_from'] : 0, - isset($booking['date_to']) ? $booking['date_to'] : 0, - isset($booking['id_room']) ? (int)$booking['id_room'] : 0, - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - - $additionalServices = $objServiceProductOrderDetail->getRoomTypeServiceProducts( - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, null, 0, (int)$booking['id'] - ); - - if (isset($additionalServices[(int)$booking['id']]['additional_services'])) { - foreach ($additionalServices[(int)$booking['id']]['additional_services'] as $service) { - $services[] = array( - 'room_ref' => $roomReference, - 'check_in_out' => $this->formatDisplayDate($booking['date_from']).' - '.$this->formatDisplayDate($booking['date_to']), - 'name' => $service['name'], - 'quantity' => (int)$service['quantity'], - 'total_price_tax_excl' => (float)$service['total_price_tax_excl'], - 'product_tax_label' => isset($service['product_tax_label']) ? $service['product_tax_label'] : self::l('No tax'), - ); - $rows[] = array( - 'room_ref' => $roomReference, - 'check_in_date' => $this->formatDisplayDate($booking['date_from']), - 'check_out_date' => $this->formatDisplayDate($booking['date_to']), - 'name' => $service['name'], - 'quantity' => (int)$service['quantity'], - 'total_price_tax_excl' => (float)$service['total_price_tax_excl'], - 'product_tax_label' => isset($service['product_tax_label']) ? $service['product_tax_label'] : self::l('No tax'), - ); - $totalPriceTaxExcl += (float)$service['total_price_tax_excl']; - } - } - - return array( - 'services' => $services, - 'rows' => $rows, - 'total_price_tax_excl' => $totalPriceTaxExcl, - 'auto_added_room_total_tax_excl' => $autoAddedWithRoomPriceTaxExcl, - ); - } - - /** - * Computes all cost totals using Order's existing methods. + * Computes all cost totals using Order's own methods. * Mirrors the $footer calculation in HTMLTemplateInvoice::getContent(). + * Extracted because it is 100+ lines of calculation that would obscure the data assembly above. * - * @param array $roomAndServiceData + * @param int $totalRooms + * @param int $totalRoomNights + * @param int $totalGuests * @return array */ - protected function getTotalsData($roomAndServiceData) + protected function getTotalsData($totalRooms, $totalRoomNights, $totalGuests) { $objBookingDemand = new HotelBookingDemands(); $totalDemandsPriceTE = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( @@ -468,7 +408,10 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate (int)$this->order->id, 0, 0, 0, 0, 1, 1, 1 ); - $idsOrderDetail = $this->getOrderDetailIds(); + $orderDetails = OrderDetail::getList((int)$this->order->id); + $idsOrderDetail = is_array($orderDetails) + ? array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail'))) + : array(); $roomsCost = 0; $roomsCostTaxIncl = 0; @@ -478,19 +421,14 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $additionalServicesCostTaxIncl = 0; $convenienceFee = 0; $convenienceFeeTaxIncl = 0; - $productDiscountsTaxExcl = (float)$this->order->total_discounts_tax_excl; $productDiscountsTaxIncl = (float)$this->order->total_discounts_tax_incl; foreach ($this->order->getCartRules() as $cartRule) { if (!empty($cartRule['free_shipping'])) { - $productDiscountsTaxExcl -= (float)$this->order->total_shipping_tax_excl; $productDiscountsTaxIncl -= (float)$this->order->total_shipping_tax_incl; } } - if ($productDiscountsTaxExcl < 0) { - $productDiscountsTaxExcl = 0; - } if ($productDiscountsTaxIncl < 0) { $productDiscountsTaxIncl = 0; } @@ -552,282 +490,18 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } return array( - 'total_rooms' => (int)$roomAndServiceData['total_rooms'], - 'total_room_nights' => (int)$roomAndServiceData['total_room_nights'], - 'total_guests' => (int)$roomAndServiceData['total_guests'], - 'rooms_cost' => $roomsCost, 'room_price_tax_excl' => $roomsCost, - 'room_price_tax_incl' => $roomsCostTaxIncl, 'service_products_price_tax_excl' => $serviceProductsCost, - 'service_products_price_tax_incl' => $serviceProductsCostTaxIncl, 'additional_service_price_tax_excl' => $additionalServicesCost, - 'additional_service_price_tax_incl' => $additionalServicesCostTaxIncl, - 'extra_services_cost' => $additionalServicesCost + $serviceProductsCost, - 'convenience_fee' => $convenienceFee, 'total_convenience_fee_te' => $convenienceFee, - 'total_convenience_fee_ti' => $convenienceFeeTaxIncl, - 'total_paid_tax_excl' => (float)$this->order->total_paid_tax_excl, - 'total_taxes' => $totalTaxes, - 'total_rooms_tax' => $totalTaxes, - 'extra_services_tax' => 0, 'total_without_discount_te' => $totalWithoutDiscountTaxExcl, - 'total_without_discount_ti' => $totalWithoutDiscountTaxIncl, 'total_tax_without_discount' => $totalTaxes, - 'product_discounts_tax_excl' => $productDiscountsTaxExcl, 'product_discounts_tax_incl' => $productDiscountsTaxIncl, - 'grand_total' => $grandTotal, - 'total_paid' => $totalPaidReal, - 'total_paid_real' => $totalPaidReal, 'total_paid_tax_incl' => $grandTotal, 'amount_due' => Tools::ps_round($amountDue, _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode), ); } - /** - * Builds tax breakdown by product type, handling both order detail taxes and extra demand taxes separately. - * Extracted: two-pass algorithm with per-type bucketing. - * - * @return array - */ - protected function getTaxBreakdownData() - { - $breakdowns = array( - 'room_tax' => array(), - 'additional_services_tax' => array(), - 'convenience_fee_tax' => array(), - 'extra_demands_tax' => array(), - 'service_products_tax' => array(), - ); - - $orderDetails = OrderDetail::getList((int)$this->order->id); - if (is_array($orderDetails)) { - foreach ($orderDetails as $orderDetail) { - $breakdownType = $this->getTaxBreakdownType($orderDetail); - if (!$breakdownType) { - continue; - } - - $taxes = OrderDetail::getTaxListStatic((int)$orderDetail['id_order_detail']); - if (!$taxes) { - $taxAmount = (float)$orderDetail['total_price_tax_incl'] - (float)$orderDetail['total_price_tax_excl']; - if ($taxAmount <= 0) { - continue; - } - $taxes = array(array( - 'id_tax' => 0, - 'rate' => (float)$orderDetail['total_price_tax_excl'] > 0 - ? (($taxAmount / (float)$orderDetail['total_price_tax_excl']) * 100) : 0, - 'total_amount' => $taxAmount, - )); - } - - foreach ($taxes as $taxDetail) { - $objTax = new Tax((int)$taxDetail['id_tax']); - $rate = Validate::isLoadedObject($objTax) - ? (float)$objTax->rate - : (isset($taxDetail['rate']) ? (float)$taxDetail['rate'] : 0); - $key = sprintf('%.3f', $rate); - - if (!isset($breakdowns[$breakdownType][$key])) { - $breakdowns[$breakdownType][$key] = array( - 'total_price_tax_excl' => 0, - 'total_tax_excl' => 0, - 'total_amount' => 0, - 'id_tax' => (int)$taxDetail['id_tax'], - 'rate' => sprintf('%.3f', $rate), - 'name' => Validate::isLoadedObject($objTax) - ? $objTax->name[(int)$this->order->id_lang] : '', - ); - } - - $breakdowns[$breakdownType][$key]['total_price_tax_excl'] += (float)$orderDetail['total_price_tax_excl']; - $breakdowns[$breakdownType][$key]['total_tax_excl'] += (float)$orderDetail['total_price_tax_excl']; - $breakdowns[$breakdownType][$key]['total_amount'] += (float)$taxDetail['total_amount']; - } - } - } - - $objBookingDemand = new HotelBookingDemands(); - $extraDemandTaxes = $objBookingDemand->getExtraDemandsTaxesDetails( - (int)$this->order->id, - $this->getOrderDetailIds() - ); - - if (is_array($extraDemandTaxes)) { - foreach ($extraDemandTaxes as $taxDetail) { - $rate = isset($taxDetail['rate']) ? (float)$taxDetail['rate'] : 0; - $key = sprintf('%.3f', $rate); - - if (!isset($breakdowns['extra_demands_tax'][$key])) { - $breakdowns['extra_demands_tax'][$key] = array( - 'total_price_tax_excl' => 0, - 'total_tax_excl' => 0, - 'total_amount' => 0, - 'id_tax' => (int)$taxDetail['id_tax'], - 'rate' => sprintf('%.3f', $rate), - 'name' => isset($taxDetail['name']) ? $taxDetail['name'] : '', - ); - } - - $taxBase = isset($taxDetail['total_tax_base']) - ? (float)$taxDetail['total_tax_base'] - : (float)$taxDetail['total_price_tax_excl']; - $breakdowns['extra_demands_tax'][$key]['total_price_tax_excl'] += $taxBase; - $breakdowns['extra_demands_tax'][$key]['total_tax_excl'] += $taxBase; - $breakdowns['extra_demands_tax'][$key]['total_amount'] += (float)$taxDetail['total_amount']; - } - } - - foreach ($breakdowns as $type => &$breakdown) { - if (empty($breakdown)) { - unset($breakdowns[$type]); - continue; - } - foreach ($breakdown as &$line) { - $line['total_price_tax_excl'] = Tools::ps_round( - $line['total_price_tax_excl'], - _PS_PRICE_COMPUTE_PRECISION_, - $this->order->round_mode - ); - $line['total_tax_excl'] = $line['total_price_tax_excl']; - $line['total_amount'] = Tools::ps_round( - $line['total_amount'], - _PS_PRICE_COMPUTE_PRECISION_, - $this->order->round_mode - ); - } - unset($line); - } - unset($breakdown); - - return $breakdowns; - } - - /** - * Classifies an OrderDetail row into a tax breakdown bucket. - * Extracted: complex multi-condition classification called inside a loop. - * - * @param array $orderDetail - * @return string|false - */ - protected function getTaxBreakdownType($orderDetail) - { - if (!empty($orderDetail['is_booking_product']) - || ((int)$orderDetail['product_auto_add'] - && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - && (int)$orderDetail['product_price_addition_type'] === (int)Product::PRICE_ADDITION_TYPE_WITH_ROOM) - ) { - return 'room_tax'; - } - - if (!(int)$orderDetail['is_booking_product'] - && !(int)$orderDetail['product_auto_add'] - && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - ) { - return 'additional_services_tax'; - } - - if (!(int)$orderDetail['is_booking_product'] - && (int)$orderDetail['product_auto_add'] - && (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - && (int)$orderDetail['product_price_addition_type'] === (int)Product::PRICE_ADDITION_TYPE_INDEPENDENT - ) { - return 'convenience_fee_tax'; - } - - if (!(int)$orderDetail['is_booking_product'] - && ((int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_STANDALONE - || (int)$orderDetail['selling_preference_type'] === (int)Product::SELLING_PREFERENCE_HOTEL_STANDALONE) - ) { - return 'service_products_tax'; - } - - return false; - } - - /** - * Returns order detail IDs for this order. - * Reused by getTotalsData() and getTaxBreakdownData(). - * - * @return array - */ - protected function getOrderDetailIds() - { - $orderDetails = OrderDetail::getList((int)$this->order->id); - - if (!is_array($orderDetails)) { - return array(); - } - - return array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail'))); - } - - /** - * Formats a date for display; returns '--' for empty/zero dates. - * Reused across getRoomAndServiceData and getRoomServiceData loops. - * - * @param string $date - * @return string - */ - protected function formatDisplayDate($date) - { - if (!$date || $date === '0000-00-00 00:00:00') { - return '--'; - } - - return Tools::displayDate($date, null, false); - } - - /** - * Fetches and formats the hotel's cancellation/refund rules as HTML. - * - * @param int $idHotel - * @return string - */ - protected function getFormattedCancellationPolicy($idHotel) - { - if (!(int)$idHotel) { - return ''; - } - - $objBranchRefundRules = new HotelBranchRefundRules(); - $refundRules = $objBranchRefundRules->getHotelRefundRules( - (int)$idHotel, 0, 1, (int)$this->order->id_lang, 1 - ); - - if (!is_array($refundRules) || empty($refundRules)) { - return ''; - } - - $policyBlocks = array(); - foreach ($refundRules as $rule) { - $ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : ''; - $ruleDescription = isset($rule['description']) ? trim($rule['description']) : ''; - - if ($ruleName === '' && $ruleDescription === '') { - continue; - } - - $block = ''; - if ($ruleName !== '') { - $block .= ''.Tools::safeOutput($ruleName).''; - } - if ($ruleDescription !== '') { - if ($block !== '') { - $block .= ': '; - } - $block .= $ruleDescription; - } - $policyBlocks[] = $block; - } - - if (empty($policyBlocks)) { - return ''; - } - - return implode('

', $policyBlocks); - } - /** * @return string */ diff --git a/pdf/booking-voucher.tpl b/pdf/booking-voucher.tpl index c5b9ec805..68aab5051 100644 --- a/pdf/booking-voucher.tpl +++ b/pdf/booking-voucher.tpl @@ -189,14 +189,12 @@ {assign var=payment_method_rendered value=false} {assign var=payment_status_rendered value=false} - + - - {if isset($footer.room_price_tax_excl) && $footer.room_price_tax_excl} {if !$payment_method_rendered} From 860669d4a9e088dd25af8dcfdf703ec503811e3c Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Wed, 13 May 2026 17:21:07 +0530 Subject: [PATCH 05/14] Fixed: Fixed the table structure of booking voucher pdf, removed unnecessary varaible and function calls Co-authored-by: Name --- classes/pdf/HTMLTemplateBookingVoucher.php | 408 +++++--------- pdf/booking-voucher.tpl | 615 +++++++++------------ 2 files changed, 401 insertions(+), 622 deletions(-) diff --git a/classes/pdf/HTMLTemplateBookingVoucher.php b/classes/pdf/HTMLTemplateBookingVoucher.php index af465930f..c4e5d17df 100644 --- a/classes/pdf/HTMLTemplateBookingVoucher.php +++ b/classes/pdf/HTMLTemplateBookingVoucher.php @@ -72,97 +72,74 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate // --- Order state --- $orderState = $this->order->getCurrentStateFull((int)$this->order->id_lang); - if (!is_array($orderState)) { - $orderState = array('name' => self::l('Confirmed')); - } elseif (empty($orderState['name'])) { - $orderState['name'] = self::l('Confirmed'); - } // --- Hotel / property --- - $hotelName = Configuration::get('PS_SHOP_NAME', null, null, (int)$this->order->id_shop); - $hotelPhone = Configuration::get('PS_SHOP_PHONE', null, null, (int)$this->order->id_shop); - $hotelEmail = Configuration::get('PS_SHOP_EMAIL', null, null, (int)$this->order->id_shop); - $hotelAddress = ''; - $checkInTime = '--'; - $checkOutTime = '--'; - $paymentPolicy = ''; - $cancellationPolicy = ''; - - if (!empty($bookings)) { - $firstBooking = reset($bookings); - if (!empty($firstBooking['id_hotel'])) { - $objHotel = new HotelBranchInformation((int)$firstBooking['id_hotel'], (int)$this->order->id_lang); - if (Validate::isLoadedObject($objHotel)) { - $idHotel = (int)$objHotel->id; - $hotelName = $objHotel->hotel_name ? $objHotel->hotel_name : $hotelName; - $hotelPhone = $objHotel->phone ? $objHotel->phone : $hotelPhone; - $hotelEmail = $objHotel->email ? $objHotel->email : $hotelEmail; - $checkInTime = $objHotel->check_in ?: '--'; - $checkOutTime = $objHotel->check_out ?: '--'; - - $policies = is_array($objHotel->policies) ? '' : (string)$objHotel->policies; - if ($policies) { - $policyText = html_entity_decode($policies, ENT_QUOTES, 'UTF-8'); - $policyText = preg_replace('//i', "\n", $policyText); - $policyText = strip_tags($policyText); - $policyText = preg_replace("/[\r\n]+/", "\n", $policyText); - $paymentPolicy = nl2br(trim($policyText)); - } - - if ($idHotel) { - $objBranchRefundRules = new HotelBranchRefundRules(); - $refundRules = $objBranchRefundRules->getHotelRefundRules( - $idHotel, 0, 1, (int)$this->order->id_lang, 1 - ); - if (is_array($refundRules) && !empty($refundRules)) { - $policyBlocks = array(); - foreach ($refundRules as $rule) { - $ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : ''; - $ruleDescription = isset($rule['description']) ? trim($rule['description']) : ''; - if ($ruleName === '' && $ruleDescription === '') { - continue; - } - $block = $ruleName !== '' ? ''.Tools::safeOutput($ruleName).'' : ''; - if ($ruleDescription !== '') { - $block .= ($block !== '' ? ': ' : '').$ruleDescription; - } - $policyBlocks[] = $block; - } - if (!empty($policyBlocks)) { - $cancellationPolicy = implode('

', $policyBlocks); - } - } - } - - if ($idHotelAddress = $objHotel->getHotelIdAddress()) { - $objHotelAddress = new Address((int)$idHotelAddress); - if (Validate::isLoadedObject($objHotelAddress)) { - $objHotelAddress->firstname = $hotelName; - $hotelAddress = AddressFormat::generateAddress( - $objHotelAddress, - array('avoid' => array('lastname')), - '
', - ' ' - ); - } - } - } + $objHotel = null; + $idHotel = HotelBookingDetail::getIdHotelByIdOrder((int)$this->order->id); + if ($idHotel) { + $objHotel = new HotelBranchInformation((int)$idHotel, (int)$this->order->id_lang); + if (!Validate::isLoadedObject($objHotel)) { + $objHotel = null; } } - if (!$hotelAddress) { - $shopAddress = $this->shop->getAddress(); - if ($shopAddress instanceof Address) { - $hotelAddress = AddressFormat::generateAddress($shopAddress, array(), '
', ' '); + $hotelAddress = ''; + $paymentPolicy = ''; + $cancellationPolicy = ''; + + if ($objHotel) { + $policies = is_array($objHotel->policies) ? '' : (string)$objHotel->policies; + if ($policies) { + $policyText = html_entity_decode($policies, ENT_QUOTES, 'UTF-8'); + $policyText = preg_replace('//i', "\n", $policyText); + $policyText = strip_tags($policyText); + $policyText = preg_replace("/[\r\n]+/", "\n", $policyText); + $paymentPolicy = nl2br(trim($policyText)); + } + + $objBranchRefundRules = new HotelBranchRefundRules(); + $refundRules = $objBranchRefundRules->getHotelRefundRules( + (int)$objHotel->id, 0, 1, (int)$this->order->id_lang, 1 + ); + if (is_array($refundRules) && !empty($refundRules)) { + $policyBlocks = array(); + foreach ($refundRules as $rule) { + $ruleName = isset($rule['name']) ? trim(strip_tags($rule['name'])) : ''; + $ruleDescription = isset($rule['description']) ? trim($rule['description']) : ''; + if ($ruleName === '' && $ruleDescription === '') { + continue; + } + $block = $ruleName !== '' ? ''.Tools::safeOutput($ruleName).'' : ''; + if ($ruleDescription !== '') { + $block .= ($block !== '' ? ': ' : '').$ruleDescription; + } + $policyBlocks[] = $block; + } + if (!empty($policyBlocks)) { + $cancellationPolicy = implode('

', $policyBlocks); + } + } + + if ($idHotelAddress = $objHotel->getHotelIdAddress()) { + $objHotelAddress = new Address((int)$idHotelAddress); + if (Validate::isLoadedObject($objHotelAddress)) { + $objHotelAddress->firstname = $objHotel->hotel_name; + $hotelAddress = AddressFormat::generateAddress( + $objHotelAddress, + array('avoid' => array('lastname')), + '
', + ' ' + ); + } } } // --- Rooms, services, occupancy --- $totalRooms = 0; - $serviceRows = array(); - $roomTypeRows = array(); $totalRoomNights = 0; $totalGuests = 0; + $serviceGroups = array(); + $roomTypeRows = array(); foreach ($bookings as $booking) { $nights = (int)HotelHelper::getNumberOfDays($booking['date_from'], $booking['date_to']); @@ -170,20 +147,17 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $nights = 1; } - $roomReference = !empty($booking['room_num']) ? $booking['room_num'] : 'BK-'.(int)$booking['id']; - $adults = (int)$booking['adults']; - $children = (int)$booking['children']; - $totalGuests += $adults + $children; + $totalGuests += (int)$booking['adults'] + (int)$booking['children']; $totalRoomNights += $nights; + $totalRooms++; $dateFrom = ($booking['date_from'] && $booking['date_from'] !== '0000-00-00 00:00:00') ? Tools::displayDate($booking['date_from'], null, false) : '--'; $dateTo = ($booking['date_to'] && $booking['date_to'] !== '0000-00-00 00:00:00') ? Tools::displayDate($booking['date_to'], null, false) : '--'; - // Extra demands for this room - $autoAddedWithRoomPriceTaxExcl = 0; - $roomServiceRows = array(); + // Services for this booking + $bookingServices = array(); $objBookingDemand = new HotelBookingDemands(); $extraDemands = $objBookingDemand->getRoomTypeBookingExtraDemands( @@ -192,17 +166,11 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate ); if (is_array($extraDemands)) { foreach ($extraDemands as $demand) { - $roomServiceRows[] = array( - 'room_ref' => $roomReference, - 'check_in_date' => $dateFrom, - 'check_out_date' => $dateTo, - 'name' => $demand['name'], - 'quantity' => 1, - ); + $bookingServices[] = array('name' => $demand['name'], 'quantity' => 1); } } - // Auto-added services bundled with room price + // Auto-added services bundled with room price (for cost calculation only) $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $autoAddedWithRoomPriceTaxExcl = (float)$objServiceProductOrderDetail->getRoomTypeServiceProducts( (int)$this->order->id, 0, 0, @@ -219,20 +187,21 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate ); if (isset($additionalServices[(int)$booking['id']]['additional_services'])) { foreach ($additionalServices[(int)$booking['id']]['additional_services'] as $service) { - $roomServiceRows[] = array( - 'room_ref' => $roomReference, - 'check_in_date' => $dateFrom, - 'check_out_date' => $dateTo, - 'name' => $service['name'], - 'quantity' => (int)$service['quantity'], - ); + $bookingServices[] = array('name' => $service['name'], 'quantity' => (int)$service['quantity']); } } - $serviceRows = array_merge($serviceRows, $roomServiceRows); + if (!empty($bookingServices)) { + $serviceGroups[] = array( + 'room_type_name' => isset($booking['room_type_name']) ? $booking['room_type_name'] : '', + 'check_in_date' => $dateFrom, + 'check_out_date' => $dateTo, + 'room_count' => $totalRooms, + 'services' => $bookingServices, + ); + } - $roomTotalTaxExcl = (float)$booking['total_price_tax_excl']; - $roomTotalWithAutoServicesTaxExcl = $roomTotalTaxExcl + $autoAddedWithRoomPriceTaxExcl; + $roomTotalWithAutoServicesTaxExcl = (float)$booking['total_price_tax_excl'] + $autoAddedWithRoomPriceTaxExcl; // Aggregate per room type + date range $roomTypeRowKey = implode('|', array( @@ -270,10 +239,9 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } $roomTypeRows[$roomTypeRowKey]['rooms'] += 1; - $roomTypeRows[$roomTypeRowKey]['adults'] += $adults; - $roomTypeRows[$roomTypeRowKey]['children'] += $children; + $roomTypeRows[$roomTypeRowKey]['adults'] += (int)$booking['adults']; + $roomTypeRows[$roomTypeRowKey]['children'] += (int)$booking['children']; $roomTypeRows[$roomTypeRowKey]['total_price_tax_excl'] += $roomTotalWithAutoServicesTaxExcl; - $totalRooms++; } foreach ($roomTypeRows as &$roomTypeRow) { @@ -288,40 +256,81 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate } unset($roomTypeRow); - // --- Guest details --- - $guestName = ''; - $guestEmail = ''; - $guestPhone = ''; $guestAddress = ''; + $guest = new Customer((int)$this->order->id_customer); - $customer = new Customer((int)$this->order->id_customer); - if (Validate::isLoadedObject($customer)) { - $guestName = trim($customer->firstname.' '.$customer->lastname); - $guestEmail = $customer->email; - $guestPhone = $customer->phone; - } $addressId = (int)$this->order->id_address_invoice ?: (int)$this->order->id_address_delivery; if ($addressId) { $address = new Address($addressId); if (Validate::isLoadedObject($address)) { - $guestPhone = $address->phone_mobile ? $address->phone_mobile : $address->phone; $guestAddress = AddressFormat::generateAddress($address, array(), '
', ' '); } } - // Override with primary guest if this is a guest booking + if ($idCustomerGuestDetail = OrderCustomerGuestDetail::isCustomerGuestBooking((int)$this->order->id)) { - $traveler = new OrderCustomerGuestDetail((int)$idCustomerGuestDetail); - if (Validate::isLoadedObject($traveler)) { - $guestName = trim($traveler->firstname.' '.$traveler->lastname); - $guestEmail = $traveler->email; - $guestPhone = $traveler->phone; + $objGuest = new OrderCustomerGuestDetail((int)$idCustomerGuestDetail); + if (Validate::isLoadedObject($objGuest)) { + $guest = $objGuest; } } - // --- Totals --- - $footer = $this->getTotalsData($totalRooms, $totalRoomNights, $totalGuests); + $objBookingDemand = new HotelBookingDemands(); + $totalDemandsPriceTE = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, 0, 0, 0, 0, 1, 1, 0 + ); + $totalDemandsPriceTI = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( + (int)$this->order->id, 0, 0, 0, 0, 1, 1, 1 + ); + + $orderDetails = OrderDetail::getList((int)$this->order->id); + $idsOrderDetail = is_array($orderDetails) + ? array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail'))) + : array(); + + $footer = array( + 'room_price_tax_excl' => 0, + 'service_products_price_tax_excl' => 0, + 'additional_service_price_tax_excl' => 0, + 'total_convenience_fee_te' => 0, + ); + $roomsCostTaxIncl = 0; + $serviceProductsCostTaxIncl = 0; + $additionalServicesCostTaxIncl = 0; + $convenienceFeeTaxIncl = 0; + + if (!empty($idsOrderDetail)) { + $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); + $roomsCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); + $footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail); + $serviceProductsCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail); + $footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTE; + $additionalServicesCostTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTI; + $footer['total_convenience_fee_te'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); + $convenienceFeeTaxIncl = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); + } + + $productDiscountsTaxIncl = (float)$this->order->total_discounts_tax_incl; + foreach ($this->order->getCartRules() as $cartRule) { + if (!empty($cartRule['free_shipping'])) { + $productDiscountsTaxIncl -= (float)$this->order->total_shipping_tax_incl; + } + } + if ($productDiscountsTaxIncl < 0) { + $productDiscountsTaxIncl = 0; + } + + $footer['total_without_discount_te'] = $footer['room_price_tax_excl'] + $footer['total_convenience_fee_te'] + $footer['additional_service_price_tax_excl'] + $footer['service_products_price_tax_excl']; + $totalWithoutDiscountTaxIncl = $roomsCostTaxIncl + $serviceProductsCostTaxIncl + $additionalServicesCostTaxIncl + $convenienceFeeTaxIncl; + $footer['total_tax_without_discount'] = max(0, $totalWithoutDiscountTaxIncl - $footer['total_without_discount_te']); + $grandTotal = max(0.0, $totalWithoutDiscountTaxIncl - $productDiscountsTaxIncl); + $footer['product_discounts_tax_incl'] = $productDiscountsTaxIncl; + $footer['total_paid_tax_incl'] = $grandTotal; + $footer['amount_due'] = Tools::ps_round( + max(0, $grandTotal - (float)$this->order->getTotalPaid()), + _PS_PRICE_COMPUTE_PRECISION_, + $this->order->round_mode + ); - // --- Payment --- $paymentMethods = array(); $payments = $this->order->getOrderPaymentDetail(); if (is_array($payments) && $payments) { @@ -336,48 +345,29 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate $idCurrency = isset($paymentDetail['id_currency']) ? (int)$paymentDetail['id_currency'] : (int)$this->order->id_currency; - $paymentMethods[] = $method.' - '.Tools::displayPrice($amount, $idCurrency); + $paymentMethods[] = $method.': '.Tools::displayPrice($amount, $idCurrency); } } $paymentMethod = $paymentMethods ? implode('

', $paymentMethods) : $this->order->payment; $data = array( 'order' => $this->order, - 'order_status' => $orderState['name'], + 'order_state' => $orderState, 'booking_date' => Tools::displayDate($this->order->date_add, null, false), 'issue_date' => Tools::displayDate(date('Y-m-d'), null, false), - // hotel / property - 'hotel_name' => $hotelName, - 'hotel_phone' => $hotelPhone, - 'hotel_email' => $hotelEmail, + 'hotel' => $objHotel, 'hotel_address' => $hotelAddress, - // guest - 'guest_name' => $guestName, - 'guest_email' => $guestEmail, - 'guest_phone' => $guestPhone, + 'guest' => $guest, 'guest_address' => $guestAddress, 'total_guests' => (int)$totalGuests, - // booking summary 'total_rooms' => (int)$totalRooms, 'total_room_nights' => (int)$totalRoomNights, - // room and service tables 'room_type_rows' => array_values($roomTypeRows), - 'service_rows' => $serviceRows, - // payment + 'service_groups' => $serviceGroups, 'payment_method' => $paymentMethod, - 'payment_status' => $orderState['name'], - // totals — key named $footer to match invoice convention 'footer' => $footer, - // policies - 'check_in_time' => ($checkInTime && $checkInTime !== '--') - ? date('h:i a', strtotime($checkInTime)) : '--', - 'check_out_time' => ($checkOutTime && $checkOutTime !== '--') - ? date('h:i a', strtotime($checkOutTime)) : '--', - 'payment_policy' => $paymentPolicy - ? $paymentPolicy - : self::l('Please contact the property for policy details.'), + 'payment_policy' => $paymentPolicy, 'cancellation_policy' => $cancellationPolicy, - 'has_cancellation_policy' => (bool)trim(strip_tags($cancellationPolicy)), ); if (Tools::getValue('debug')) { @@ -388,120 +378,6 @@ class HTMLTemplateBookingVoucherCore extends HTMLTemplate return $this->smarty->fetch($this->getTemplate('booking-voucher')); } - /** - * Computes all cost totals using Order's own methods. - * Mirrors the $footer calculation in HTMLTemplateInvoice::getContent(). - * Extracted because it is 100+ lines of calculation that would obscure the data assembly above. - * - * @param int $totalRooms - * @param int $totalRoomNights - * @param int $totalGuests - * @return array - */ - protected function getTotalsData($totalRooms, $totalRoomNights, $totalGuests) - { - $objBookingDemand = new HotelBookingDemands(); - $totalDemandsPriceTE = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( - (int)$this->order->id, 0, 0, 0, 0, 1, 1, 0 - ); - $totalDemandsPriceTI = (float)$objBookingDemand->getRoomTypeBookingExtraDemands( - (int)$this->order->id, 0, 0, 0, 0, 1, 1, 1 - ); - - $orderDetails = OrderDetail::getList((int)$this->order->id); - $idsOrderDetail = is_array($orderDetails) - ? array_unique(array_map('intval', array_column($orderDetails, 'id_order_detail'))) - : array(); - - $roomsCost = 0; - $roomsCostTaxIncl = 0; - $serviceProductsCost = 0; - $serviceProductsCostTaxIncl = 0; - $additionalServicesCost = 0; - $additionalServicesCostTaxIncl = 0; - $convenienceFee = 0; - $convenienceFeeTaxIncl = 0; - $productDiscountsTaxIncl = (float)$this->order->total_discounts_tax_incl; - - foreach ($this->order->getCartRules() as $cartRule) { - if (!empty($cartRule['free_shipping'])) { - $productDiscountsTaxIncl -= (float)$this->order->total_shipping_tax_incl; - } - } - - if ($productDiscountsTaxIncl < 0) { - $productDiscountsTaxIncl = 0; - } - - if (!empty($idsOrderDetail)) { - $roomsCost = (float)$this->order->getTotalProductsWithoutTaxes( - false, true, null, null, null, $idsOrderDetail - ) + (float)$this->order->getTotalProductsWithoutTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail - ); - $roomsCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( - false, true, null, null, null, $idsOrderDetail - ) + (float)$this->order->getTotalProductsWithTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail - ); - - $serviceProductsCost = (float)$this->order->getTotalProductsWithoutTaxes( - false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail - ) + (float)$this->order->getTotalProductsWithoutTaxes( - false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail - ); - $serviceProductsCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( - false, false, Product::SELLING_PREFERENCE_STANDALONE, false, false, $idsOrderDetail - ) + (float)$this->order->getTotalProductsWithTaxes( - false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE, false, false, $idsOrderDetail - ); - - $additionalServicesCost = (float)$this->order->getTotalProductsWithoutTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail - ) + $totalDemandsPriceTE; - $additionalServicesCostTaxIncl = (float)$this->order->getTotalProductsWithTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0, null, $idsOrderDetail - ) + $totalDemandsPriceTI; - - $convenienceFee = (float)$this->order->getTotalProductsWithoutTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail - ); - $convenienceFeeTaxIncl = (float)$this->order->getTotalProductsWithTaxes( - false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail - ); - } - - $grandTotal = (float)$this->order->total_paid_tax_incl; - $totalPaidReal = (float)$this->order->getTotalPaid(); - $totalWithoutDiscountTaxExcl = $roomsCost + $serviceProductsCost + $additionalServicesCost + $convenienceFee; - $totalWithoutDiscountTaxIncl = $roomsCostTaxIncl + $serviceProductsCostTaxIncl + $additionalServicesCostTaxIncl + $convenienceFeeTaxIncl; - $totalTaxes = $totalWithoutDiscountTaxIncl - $totalWithoutDiscountTaxExcl; - if ($totalTaxes < 0) { - $totalTaxes = 0; - } - - $amountDue = $grandTotal - $totalPaidReal; - if ($amountDue < 0) { - $amountDue = 0; - } - - return array( - 'room_price_tax_excl' => $roomsCost, - 'service_products_price_tax_excl' => $serviceProductsCost, - 'additional_service_price_tax_excl' => $additionalServicesCost, - 'total_convenience_fee_te' => $convenienceFee, - 'total_without_discount_te' => $totalWithoutDiscountTaxExcl, - 'total_tax_without_discount' => $totalTaxes, - 'product_discounts_tax_incl' => $productDiscountsTaxIncl, - 'total_paid_tax_incl' => $grandTotal, - 'amount_due' => Tools::ps_round($amountDue, _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode), - ); - } - /** * @return string */ diff --git a/pdf/booking-voucher.tpl b/pdf/booking-voucher.tpl index 68aab5051..cf6d0b966 100644 --- a/pdf/booking-voucher.tpl +++ b/pdf/booking-voucher.tpl @@ -23,362 +23,273 @@ {assign var=pdf_style_template value=$smarty.const._PS_PDF_DIR_|cat:'invoice.style-tab.tpl'} {include file=$pdf_style_template} -
{l s='PAYMENT INFORMATION' pdf='true'} {l s='TOTAL AMOUNT' pdf='true'}
- +
+ + + + + + + + + + + + {* *} + + + + + + + + + + + + {if $service_groups} - - - - - - - - - - - + - - - - - - + - + {/if} +
+ + + + + + + + + + + + + + + + + + + + + + +
{l s='BOOKING INFORMATION' pdf='true'}
{l s='Booking Reference' pdf='true'}{$order->reference|escape:'html':'UTF-8'}{l s='Booking Date' pdf='true'}{$booking_date|escape:'html':'UTF-8'}{l s='Voucher Issue Date' pdf='true'}{$issue_date|escape:'html':'UTF-8'}
{l s='Status' pdf='true'}{if $order_state && isset($order_state.name)}{$order_state.name|escape:'html':'UTF-8'}{/if}{l s='Total Rooms' pdf='true'}{$total_rooms|intval}{l s='Total Nights' pdf='true'}{$total_room_nights|intval}
+
 
+ + + + + + + + + + + + + + + + + + + + + + +
{l s='PROPERTY DETAILS' pdf='true'}
{l s='Property' pdf='true'}{if $hotel}{$hotel->hotel_name|escape:'html':'UTF-8'}{/if}
{l s='Email' pdf='true'}{if $hotel}{$hotel->email|escape:'html':'UTF-8'}{/if}
{l s='Phone' pdf='true'}{if $hotel}{$hotel->phone|escape:'html':'UTF-8'}{/if}
{l s='Address' pdf='true'}{if $hotel_address}{$hotel_address nofilter}{else}--{/if}
+
  + + + + + + + + + + + + + + + + + + + + + + + + + + +
{l s='GUEST INFORMATION' pdf='true'}
{l s='Primary Guest' pdf='true'}{$guest->firstname|escape:'html':'UTF-8'} {$guest->lastname|escape:'html':'UTF-8'}
{l s='Email' pdf='true'}{$guest->email|escape:'html':'UTF-8'}
{l s='Phone' pdf='true'}{$guest->phone|escape:'html':'UTF-8'}
{l s='Address' pdf='true'}{if $guest_address|strip_tags|trim}{$guest_address nofilter}{else}--{/if}
{l s='Total Guests' pdf='true'}{$total_guests|intval}
+
 
+ + + + + + + + + + + + + + + + + {if $room_type_rows} + {foreach from=$room_type_rows item=room_type_row} + {cycle values="color_line_even,color_line_odd" assign=bgcolor_class} + + + + + + + + + + {/foreach} + {else} + + + + {/if} + +
{l s='ROOM DETAILS' pdf='true'}
{l s='Room Description' pdf='true'}{l s='Tax Rate(s)' pdf='true'}{l s='Unit Price' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{l s='Rooms' pdf='true'}{l s='Check-in Date' pdf='true'}{l s='Check-out Date' pdf='true'}{l s='Total' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{$room_type_row.room_type_name|escape:'html':'UTF-8'}{$room_type_row.order_detail_tax_label}{displayPrice currency=$order->id_currency price=$room_type_row.unit_price_tax_excl} + {if $room_type_row.adults <= 9}0{/if}{$room_type_row.adults|intval} {if $room_type_row.adults > 1}{l s='Adults' pdf='true'}{else}{l s='Adult' pdf='true'}{/if}{if $room_type_row.children}, {if $room_type_row.children <= 9}0{/if}{$room_type_row.children|intval} {if $room_type_row.children > 1}{l s='Children' pdf='true'}{else}{l s='Child' pdf='true'}{/if}{/if}
{if $room_type_row.rooms <= 9}0{/if}{$room_type_row.rooms|intval} {if $room_type_row.rooms > 1}{l s='Rooms' pdf='true'}{else}{l s='Room' pdf='true'}{/if} +
{$room_type_row.check_in_date|escape:'html':'UTF-8'}{$room_type_row.check_out_date|escape:'html':'UTF-8'}{displayPrice currency=$order->id_currency price=$room_type_row.total_price_tax_excl}
{l s='No room details available.' pdf='true'}
+
{l s='BOOKING INFORMATION' pdf='true'}
{l s='Booking Reference' pdf='true'}{$order->reference|escape:'html':'UTF-8'}{l s='Booking Date' pdf='true'}{$booking_date|escape:'html':'UTF-8'}{l s='Voucher Issue Date' pdf='true'}{$issue_date|escape:'html':'UTF-8'} 
{l s='Status' pdf='true'}{$order_status|escape:'html':'UTF-8'}{l s='Total Rooms' pdf='true'}{$total_rooms|intval}{l s='Total Nights' pdf='true'}{$total_room_nights|intval} + + + + + + + + + + + {foreach from=$service_groups item=group} + {foreach from=$group.services item=service name=service_loop} + + {if $smarty.foreach.service_loop.first} + + {/if} + + + + {/foreach} + {/foreach} + +
{l s='SERVICES DETAILS' pdf='true'}
{l s='Room Type' pdf='true'}{l s='Service Name' pdf='true'}{l s='Qty' pdf='true'}
{$group.room_type_name|escape:'html':'UTF-8'}
+ {$group.check_in_date|escape:'html':'UTF-8'} - {$group.check_out_date|escape:'html':'UTF-8'}
+ {l s='Room' pdf='true'} - {$group.room_count|intval} +
{$service.name|escape:'html':'UTF-8'}{$service.quantity|intval}
+
- +
 
+ + - + +
+ + + + + + + + + + + + + + +
{l s='PAYMENT INFORMATION' pdf='true'}
{l s='Payment Method' pdf='true'}{$payment_method nofilter}
{l s='Payment Status' pdf='true'}{if $order_state && isset($order_state.name)}{$order_state.name|escape:'html':'UTF-8'}{/if}
+
+ + + + + + {if isset($footer.room_price_tax_excl) && $footer.room_price_tax_excl} + + + + + {/if} + {if isset($footer.service_products_price_tax_excl) && $footer.service_products_price_tax_excl} + + + + + {/if} + {if isset($footer.additional_service_price_tax_excl) && $footer.additional_service_price_tax_excl} + + + + + {/if} + {if isset($footer.total_convenience_fee_te) && $footer.total_convenience_fee_te} + + + + + {/if} + + + + + {if $footer.total_tax_without_discount > 0} + + + + + {/if} + {if isset($footer.product_discounts_tax_incl) && $footer.product_discounts_tax_incl > 0} + + + + + {/if} + + + + + {if $footer.amount_due > 0} + + + + + {/if} + +
{l s='TOTAL AMOUNT' pdf='true'}
{l s='Total Rooms Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.room_price_tax_excl}
{l s='Total Products cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.service_products_price_tax_excl}
{l s='Extra Services Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.additional_service_price_tax_excl}
{l s='Convenience Fee (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_convenience_fee_te}
{l s='Total (Tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_without_discount_te}
{l s='Total Tax' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_tax_without_discount}
{l s='Total Discounts' pdf='true'}- {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_incl}
{l s='Final Booking Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_paid_tax_incl}
{l s='Due Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.amount_due}
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{l s='PROPERTY DETAILS' pdf='true'}{l s='GUEST INFORMATION' pdf='true'}
{l s='Property' pdf='true'}{$hotel_name|escape:'html':'UTF-8'}{l s='Primary Guest' pdf='true'}{$guest_name|escape:'html':'UTF-8'}
{l s='Email' pdf='true'}{$hotel_email|escape:'html':'UTF-8'}{l s='Email' pdf='true'}{$guest_email|escape:'html':'UTF-8'}
{l s='Phone' pdf='true'}{$hotel_phone|escape:'html':'UTF-8'}{l s='Phone' pdf='true'}{$guest_phone|escape:'html':'UTF-8'}
{l s='Address' pdf='true'}{if $hotel_address}{$hotel_address nofilter}{else}--{/if}{l s='Address' pdf='true'}{if $guest_address|strip_tags|trim}{$guest_address nofilter}{else}--{/if}
{l s='Total Guests' pdf='true'}{$total_guests|intval}
- - - - - -
- - - - - - - - - - - - - - - - - - {if $room_type_rows} - {foreach from=$room_type_rows item=room_type_row} - {cycle values="color_line_even,color_line_odd" assign=bgcolor_class} - - - - - - - - - - {/foreach} - {else} - - - - {/if} - -
{l s='ROOM DETAILS' pdf='true'}
{l s='Room Description' pdf='true'}{l s='Tax Rate(s)' pdf='true'}{l s='Unit Price' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{l s='Rooms' pdf='true'}{l s='Check-in Date' pdf='true'}{l s='Check-out Date' pdf='true'}{l s='Total' pdf='true'}
{l s='(Tax excl.)' pdf='true'}
{$room_type_row.room_type_name|escape:'html':'UTF-8'}{$room_type_row.order_detail_tax_label}{displayPrice currency=$order->id_currency price=$room_type_row.unit_price_tax_excl} - {if $room_type_row.adults <= 9}0{/if}{$room_type_row.adults|intval} {if $room_type_row.adults > 1}{l s='Adults' pdf='true'}{else}{l s='Adult' pdf='true'}{/if}{if $room_type_row.children}, {if $room_type_row.children <= 9}0{/if}{$room_type_row.children|intval} {if $room_type_row.children > 1}{l s='Children' pdf='true'}{else}{l s='Child' pdf='true'}{/if}{/if}
{if $room_type_row.rooms <= 9}0{/if}{$room_type_row.rooms|intval} {if $room_type_row.rooms > 1}{l s='Rooms' pdf='true'}{else}{l s='Room' pdf='true'}{/if} -
{$room_type_row.check_in_date|escape:'html':'UTF-8'}{$room_type_row.check_out_date|escape:'html':'UTF-8'}{displayPrice currency=$order->id_currency price=$room_type_row.total_price_tax_excl}
{l s='No room details available.' pdf='true'}
- -{if $service_rows} - - - - -
- +{if $cancellation_policy} +
 
- - - - - - - - - - - - {foreach from=$service_rows item=service} - {cycle values="color_line_even,color_line_odd" assign=bgcolor_class} - - - - - - - {/foreach} - -
{l s='SERVICES DETAILS' pdf='true'}
{l s='Room Ref' pdf='true'}{l s='Check-in / Check-out' pdf='true'}{l s='Service Name' pdf='true'}{l s='Qty' pdf='true'}
{$service.room_ref|escape:'html':'UTF-8'}{$service.check_in_date|escape:'html':'UTF-8'} - {$service.check_out_date|escape:'html':'UTF-8'}{$service.name|escape:'html':'UTF-8'}{$service.quantity|intval}
-{/if} - - - - - -
- -{assign var=payment_method_rendered value=false} -{assign var=payment_status_rendered value=false} - - - - - - - - {if isset($footer.room_price_tax_excl) && $footer.room_price_tax_excl} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - {if isset($footer.service_products_price_tax_excl) && $footer.service_products_price_tax_excl} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - {if isset($footer.additional_service_price_tax_excl) && $footer.additional_service_price_tax_excl} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - {if isset($footer.total_convenience_fee_te) && $footer.total_convenience_fee_te} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {if $footer.total_tax_without_discount > 0} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - {if isset($footer.product_discounts_tax_incl) && $footer.product_discounts_tax_incl > 0} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {if $footer.amount_due > 0} - - {if !$payment_method_rendered} - - - {assign var=payment_method_rendered value=true} - {elseif !$payment_status_rendered} - - - {assign var=payment_status_rendered value=true} - {else} - - - {/if} - - - - - {/if} - -
{l s='PAYMENT INFORMATION' pdf='true'}{l s='TOTAL AMOUNT' pdf='true'}
{l s='Payment Method' pdf='true'}{$payment_method nofilter}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Rooms Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.room_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Products cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.service_products_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Extra Services Cost (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.additional_service_price_tax_excl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Convenience Fee (tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_convenience_fee_te}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total (Tax excl.)' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_without_discount_te}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Tax' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_tax_without_discount}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Total Discounts' pdf='true'}- {displayPrice currency=$order->id_currency price=$footer.product_discounts_tax_incl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Final Booking Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.total_paid_tax_incl}
{l s='Payment Method' pdf='true'}{$payment_method|escape:'html':'UTF-8'}{l s='Payment Status' pdf='true'}{$payment_status|escape:'html':'UTF-8'}{l s='Due Amount' pdf='true'}{displayPrice currency=$order->id_currency price=$footer.amount_due}
- -{if $has_cancellation_policy} - - - - -
- - - - - @@ -386,26 +297,20 @@
{l s='CANCELLATION POLICY' pdf='true'}
{$cancellation_policy nofilter}
{/if} - - - - -
+
 
- + - - - + - + @@ -414,11 +319,9 @@
{l s='PROPERTY POLICIES' pdf='true'}
{l s='Check-in time' pdf='true'}{$check_in_time|escape:'html':'UTF-8'}{if $hotel && $hotel->check_in}{$hotel->check_in|escape:'html':'UTF-8'}{/if}
{l s='Check-out time' pdf='true'}{$check_out_time|escape:'html':'UTF-8'}{if $hotel && $hotel->check_out}{$hotel->check_out|escape:'html':'UTF-8'}{/if}
{l s='Policies' pdf='true'}
-{if isset($HOOK_DISPLAY_PDF) && $HOOK_DISPLAY_PDF} - - - - +{if isset($HOOK_DISPLAY_PDF) && $HOOK_DISPLAY_PDF|strip_tags|trim} +
 
+ From 65cd0ff1edb22fb15f479ecf1697029c09340289 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Wed, 3 Jun 2026 19:38:26 +0530 Subject: [PATCH 06/14] fix: resolve invalid price display on product page for catalog rule base price --- classes/Cart.php | 2 +- classes/SpecificPrice.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index ad5ee4302..f12f41249 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1833,7 +1833,7 @@ class CartCore extends ObjectModel $this->id, [], 0, - isset($product['id_hotel_cart_booking']) ? $product['id_hotel_cart_booking'] : null, + null, null, (int)$product['id_product'], null, diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 1dd3829a2..79c63995e 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -367,12 +367,12 @@ class SpecificPriceCore extends ObjectModel `id_shop` '.self::formatIntInQuery(0, $id_shop).' AND `id_currency` '.self::formatIntInQuery(0, $id_currency).' AND `id_country` '.self::formatIntInQuery(0, $id_country). - ' AND `id_htl_cart_booking`='.(int)$id_htl_cart_booking.' '. + ' AND `id_htl_cart_booking` '.self::formatIntInQuery(0, $id_htl_cart_booking).' '. (Group::isFeatureActive() ? ' AND `id_group` '.self::formatIntInQuery(0, $id_group) : '').' '.$query_extra.' AND IF(`from_quantity` > 1, `from_quantity`, 0) <= '; $query .= (Configuration::get('PS_QTY_DISCOUNT_ON_COMBINATION') || !$id_cart || !$real_quantity) ? (int)$quantity : max(1, (int)$real_quantity); - $query .= ' ORDER BY `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC, `to` DESC, `from` DESC'; + $query .= ' ORDER BY `id_htl_cart_booking` DESC, `id_product_attribute` DESC, `from_quantity` DESC, `score` DESC, `to` DESC, `from` DESC'; SpecificPrice::$_specificPriceCache[$key] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); } From 2bd11e0e99427a5836728b41c6030000cf9cfa0a Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 4 Jun 2026 16:23:01 +0530 Subject: [PATCH 07/14] Fixed: advance payment was added for the number of rooms added in cart in for loop which lead to Incorrect Total Amount Calculation Co-authored-by: Name --- classes/Cart.php | 90 +++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index ad5ee4302..9cf5a1caf 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1862,53 +1862,55 @@ class CartCore extends ObjectModel // by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices.... $totalPriceByProduct = 0; $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id); - foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { - $occupancy = array( - array( - 'adults' => $cartRoomInfo['adults'], - 'children' => $cartRoomInfo['children'], - 'child_ages' => json_decode($cartRoomInfo['child_ages']) - ) + + if ($type == Cart::ADVANCE_PAYMENT || $type == Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS) { + // getProductMinAdvPaymentAmountByIdCart already aggregates all rooms for this product internally, + // so call it once and add once — not inside the per-room loop. + $advProductPrice = $objAdvPayment->getProductMinAdvPaymentAmountByIdCart( + $this->id, + $product['id_product'], + 0, + 0, + $with_taxes ); - // get the real price of the room type - $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( - $cartRoomInfo['id_product'], - $cartRoomInfo['date_from'], - $cartRoomInfo['date_to'], - $occupancy, - Group::getCurrent()->id, - $cartRoomInfo['id_cart'], - $cartRoomInfo['id_guest'], - $cartRoomInfo['id_room'], - 0 - ); - if ($with_taxes) { - $totalPriceByProduct = $roomTotalPrice['total_price_tax_incl']; - } else { - $totalPriceByProduct = $roomTotalPrice['total_price_tax_excl']; - } - - // If customer has selected advance payment of the cart - if ($type == Cart::ADVANCE_PAYMENT || $type == Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS) { - $advProductPrice = $objAdvPayment->getProductMinAdvPaymentAmountByIdCart( - $this->id, - $cartRoomInfo['id_product'], - 0, - 0, - $with_taxes - ); - - // set advance payment price only if it is greater than real price - if ($advProductPrice < $totalPriceByProduct) { - $totalPriceByProduct = $advProductPrice; - } - } - - // Rounding as per configurations if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($totalPriceByProduct); + $products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($advProductPrice); } else { - $products_total[$id_tax_rules_group] += Tools::processPriceRounding($totalPriceByProduct); + $products_total[$id_tax_rules_group] += Tools::processPriceRounding($advProductPrice); + } + } else { + foreach ($roomTypesByIdProduct as $key => $cartRoomInfo) { + $occupancy = array( + array( + 'adults' => $cartRoomInfo['adults'], + 'children' => $cartRoomInfo['children'], + 'child_ages' => json_decode($cartRoomInfo['child_ages']) + ) + ); + // get the real price of the room type + $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( + $cartRoomInfo['id_product'], + $cartRoomInfo['date_from'], + $cartRoomInfo['date_to'], + $occupancy, + Group::getCurrent()->id, + $cartRoomInfo['id_cart'], + $cartRoomInfo['id_guest'], + $cartRoomInfo['id_room'], + 0 + ); + if ($with_taxes) { + $totalPriceByProduct = $roomTotalPrice['total_price_tax_incl']; + } else { + $totalPriceByProduct = $roomTotalPrice['total_price_tax_excl']; + } + + // Rounding as per configurations + if ($ps_round_type == Order::ROUND_TOTAL) { + $products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($totalPriceByProduct); + } else { + $products_total[$id_tax_rules_group] += Tools::processPriceRounding($totalPriceByProduct); + } } } } From 0dc272fbff950b51f40f4b2db087d478290ac5e0 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Thu, 4 Jun 2026 17:00:19 +0530 Subject: [PATCH 08/14] fix: preserve service product price in cart total after occupancy update --- controllers/admin/AdminCartsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f76331422..8252c7fa7 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1121,7 +1121,7 @@ class AdminCartsControllerCore extends AdminController if ($bookingInfo['id'] == $idBookingData) { $amtWithQty = $bookingInfo['amt_with_qty']; $bookingInfo['amt_with_qty'] = Tools::displayPrice($amtWithQty); - $bookingInfo['total_price'] = Tools::displayPrice($amtWithQty + $bookingInfo['demand_price']); + $bookingInfo['total_price'] = Tools::displayPrice($amtWithQty + $bookingInfo['demand_price'] + $bookingInfo['additional_service_price'] + $bookingInfo['additional_services_auto_add_price']); $response = array( 'curr_booking_info' => $bookingInfo, 'cart_info' => $this->ajaxReturnVars(), From 041fa626b0a9460401e698871f0f642f0905f1b8 Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 4 Jun 2026 17:25:14 +0530 Subject: [PATCH 09/14] Fixed: show serial wise room number in Room Extra Services Detail in invoice pdf Co-authored-by: Name --- pdf/invoice.extra-demands-tab.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf/invoice.extra-demands-tab.tpl b/pdf/invoice.extra-demands-tab.tpl index e7edf7fa4..cba5a8aed 100644 --- a/pdf/invoice.extra-demands-tab.tpl +++ b/pdf/invoice.extra-demands-tab.tpl @@ -114,8 +114,8 @@ {/foreach} {/if} + {assign var=roomCount value=$roomCount+1} {/foreach} - {assign var=roomCount value=$roomCount+1}
{$HOOK_DISPLAY_PDF}
From bdb4cd1c597900b68571776653d0bcacff944acc Mon Sep 17 00:00:00 2001 From: varun kewlani Date: Thu, 11 Jun 2026 19:35:48 +0530 Subject: [PATCH 10/14] Fixed: Show booking voucher PDF button in the Payment details section under the Order detail page in the front office Co-authored-by: Name --- .../front/PdfBookingVoucherController.php | 70 +++++++++++++++++++ pdf/booking-voucher.tpl | 28 +++++--- .../hotel-reservation-theme/order-detail.tpl | 20 ++++++ 3 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 controllers/front/PdfBookingVoucherController.php diff --git a/controllers/front/PdfBookingVoucherController.php b/controllers/front/PdfBookingVoucherController.php new file mode 100644 index 000000000..0ba3302c9 --- /dev/null +++ b/controllers/front/PdfBookingVoucherController.php @@ -0,0 +1,70 @@ +context->customer->isLogged() && !Tools::getValue('secure_key')) { + Tools::redirect('index.php?controller=authentication&back=pdf-booking-voucher'); + } + + $idOrder = (int)Tools::getValue('id_order'); + if (!Validate::isUnsignedId($idOrder)) { + die(Tools::displayError('The booking voucher was not found.')); + } + + $order = new Order($idOrder); + if (!Validate::isLoadedObject($order)) { + die(Tools::displayError('The booking voucher was not found.')); + } + + $secureKey = Tools::getValue('secure_key'); + if ($secureKey) { + if ($order->secure_key !== $secureKey) { + die(Tools::displayError('The booking voucher was not found.')); + } + } elseif ($order->id_customer != (int)$this->context->customer->id) { + die(Tools::displayError('The booking voucher was not found.')); + } + + $this->order = $order; + } + + public function display() + { + $pdf = new PDF($this->order, PDF::TEMPLATE_BOOKING_VOUCHER, $this->context->smarty); + $pdf->render(); + } +} diff --git a/pdf/booking-voucher.tpl b/pdf/booking-voucher.tpl index cf6d0b966..15cfe229e 100644 --- a/pdf/booking-voucher.tpl +++ b/pdf/booking-voucher.tpl @@ -302,19 +302,29 @@ - + - - + - - - - - - +
{l s='PROPERTY POLICIES' pdf='true'}{l s='PROPERTY POLICIES' pdf='true'}
{l s='Check-in time' pdf='true'}{if $hotel && $hotel->check_in}{$hotel->check_in|escape:'html':'UTF-8'}{/if} + {l s='Check-in Time:' pdf='true'} + {if $hotel && $hotel->check_in && $hotel->check_in != '00:00:00'}{$hotel->check_in|escape:'html':'UTF-8'}{else}__________{/if} +            + {l s='Check-out Time:' pdf='true'} + {if $hotel && $hotel->check_out && $hotel->check_out != '00:00:00'}{$hotel->check_out|escape:'html':'UTF-8'}{else}__________{/if} +
{l s='Check-out time' pdf='true'}{if $hotel && $hotel->check_out}{$hotel->check_out|escape:'html':'UTF-8'}{/if}
{l s='Policies' pdf='true'}{$payment_policy nofilter} + {l s='Hotel Policies:' pdf='true'}
+
+ {if isset($payment_policy) && $payment_policy|strip_tags|trim} + {$payment_policy nofilter} + {else} + ______________________________
+ ______________________________
+ ______________________________ + {/if} +
diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 9402a240d..efa462dc0 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -148,6 +148,16 @@ +
+
{l s='Booking Voucher'}
+ +
+
{l s='Status'}
@@ -647,6 +657,16 @@
+
+
{l s='Booking Voucher'}
+ +
+
{l s='Status'}
From 1df415e822b37fbcd6ba8ca5f0e7001fc83dda65 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Fri, 12 Jun 2026 12:24:08 +0530 Subject: [PATCH 11/14] fix: correct price aggregation for grouped rooms in OrderConfirmationController --- controllers/front/OrderConfirmationController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index f83b1fd7e..f00addd43 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -201,8 +201,8 @@ class OrderConfirmationControllerCore extends FrontController //// By webkul New way to calculate product prices with feature Prices $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; $cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']*$var_quant; - $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']*$var_quant; + $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; + $cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; $cart_htl_data[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; if ($data_v['is_back_order']) { $any_back_order = 1; From 2933be21e2fc8ac1395f446e173c90f8df624b55 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 16 Jun 2026 12:36:09 +0530 Subject: [PATCH 12/14] fix: replace deprecated tags with CSS styling in .tpl, .html, and .txt files --- .../languages/helpers/form/form.tpl | 4 +-- mails/en/account.html | 16 ++++----- mails/en/awaiting_payment.html | 16 ++++----- mails/en/backoffice_order.html | 8 ++--- mails/en/booking_extra_demands.tpl | 28 +++++++-------- mails/en/booking_extra_demands.txt | 12 +++---- mails/en/contact.html | 8 ++--- mails/en/contact_form.html | 12 +++---- mails/en/credit_slip.html | 12 +++---- mails/en/credit_slip_voucher.html | 8 ++--- mails/en/download_product.html | 16 ++++----- mails/en/employee_password.html | 8 ++--- mails/en/forward_msg.html | 8 ++--- mails/en/guest_to_customer.html | 16 ++++----- mails/en/in_transit.html | 16 ++++----- mails/en/log_alert.html | 8 ++--- mails/en/order_canceled.html | 20 +++++------ mails/en/order_changed.html | 16 ++++----- mails/en/order_conf.html | 16 ++++----- mails/en/order_conf_admin.html | 12 +++---- mails/en/order_conf_cart_rules.tpl | 8 ++--- mails/en/order_conf_product_list.tpl | 36 +++++++++---------- mails/en/order_customer_comment.html | 8 ++--- mails/en/order_hotel_detail.tpl | 4 +-- mails/en/order_merchant_comment.html | 8 ++--- mails/en/order_refund_completed_admin.html | 12 +++---- mails/en/order_refund_completed_customer.html | 12 +++---- mails/en/order_refund_denied_admin.html | 12 +++---- mails/en/order_refund_denied_customer.html | 12 +++---- mails/en/order_refund_pending_admin.html | 12 +++---- mails/en/order_refund_pending_customer.html | 12 +++---- mails/en/order_return_state.html | 12 +++---- mails/en/overbooking.html | 16 ++++----- mails/en/overbooking_admin.html | 12 +++---- mails/en/partial_payment_accepted.html | 16 ++++----- mails/en/password.html | 16 ++++----- mails/en/password_query.html | 8 ++--- mails/en/payment_accepted.html | 16 ++++----- mails/en/payment_error.html | 16 ++++----- mails/en/processing.html | 16 ++++----- mails/en/refund.html | 16 ++++----- mails/en/reply_msg.html | 2 +- mails/en/shipped.html | 8 ++--- mails/en/voucher.html | 8 ++--- mails/en/voucher_new.html | 8 ++--- .../templates/mail/mail_template_html.tpl | 4 +-- .../mails/en/newsletter_conf.html | 8 ++--- .../mails/en/newsletter_verif.html | 8 ++--- .../mails/en/newsletter_voucher.html | 8 ++--- .../templates/mail/mail_template_html.tpl | 4 +-- .../mails/en/review_approve.html | 16 ++++----- .../mails/en/review_reply_with_link.html | 16 ++++----- .../mails/en/review_reply_without_link.html | 16 ++++----- .../mails/en/review_request.html | 16 ++++----- themes/debug.tpl | 6 +++- 55 files changed, 336 insertions(+), 332 deletions(-) diff --git a/admin/themes/default/template/controllers/languages/helpers/form/form.tpl b/admin/themes/default/template/controllers/languages/helpers/form/form.tpl index 8d1dc403e..77baa0e70 100644 --- a/admin/themes/default/template/controllers/languages/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/languages/helpers/form/form.tpl @@ -69,11 +69,11 @@
{foreach $list.files as $key => $file} {if !file_exists($key)} - + {/if} {$key} {if !file_exists($key)} - + {/if}
{/foreach} diff --git a/mails/en/account.html b/mails/en/account.html index c80631219..d5e047532 100644 --- a/mails/en/account.html +++ b/mails/en/account.html @@ -68,10 +68,10 @@ - + Hi {firstname} {lastname},
Thank you for creating a customer account at {shop_name}. -
+ @@ -83,14 +83,14 @@   - +

Your {shop_name} login details

Here are your login details:
E-mail address: {email}
-
+   @@ -106,7 +106,7 @@   - +

Important Security Tips:

  1. Always keep your account details safe.
  2. @@ -114,7 +114,7 @@
  3. Change your password regularly.
  4. Should you suspect someone is using your account illegally, please notify us immediately.
-
+   @@ -126,9 +126,9 @@ - + You can now place orders on our website: {shop_name} - + diff --git a/mails/en/awaiting_payment.html b/mails/en/awaiting_payment.html index c6bc613c6..d83fbe902 100644 --- a/mails/en/awaiting_payment.html +++ b/mails/en/awaiting_payment.html @@ -69,10 +69,10 @@ - + Hi {firstname} {lastname},
{order_header_line_html} -
+ @@ -84,13 +84,13 @@   - +

Order {order_name} - Awaiting payment

Order reference: {order_name}
Payment method: {payment_method}
-
+   @@ -103,18 +103,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/backoffice_order.html b/mails/en/backoffice_order.html index 0b40f8b35..f779ea6ef 100644 --- a/mails/en/backoffice_order.html +++ b/mails/en/backoffice_order.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

A new order has been generated on your behalf.

Please go on {order_link} to finalize the payment. -
+   diff --git a/mails/en/booking_extra_demands.tpl b/mails/en/booking_extra_demands.tpl index b43ac4bed..fe38cdadd 100644 --- a/mails/en/booking_extra_demands.tpl +++ b/mails/en/booking_extra_demands.tpl @@ -23,22 +23,22 @@ {if $smarty.foreach.demandRow.first} - + {$data_v['name']}
{$rm_v['data_form']|date_format:"%d-%m-%Y"} {l s='to'} {$rm_v['data_to']|date_format:"%d-%m-%Y"}
{l s='Room'} - {$roomCount} -
+ {/if} - + {$demand['name']} - + - + {convertPrice price=$demand['total_price_tax_excl']} - + {/foreach} @@ -81,31 +81,31 @@ {if $smarty.foreach.serviceRow.first} - + {$data_v['name']}
{$rm_v['data_form']|date_format:"%d-%m-%Y"} {l s='to'} {$rm_v['data_to']|date_format:"%d-%m-%Y"}
{l s='Room'} - {$roomCount} -
+ {/if} - + {$service['name']} - + - + {if $service['allow_multiple_quantity']} {$service['quantity']} {else} {l s='--'} {/if} - + - + {convertPrice price=$service['total_price_tax_excl']} - + {/foreach} diff --git a/mails/en/booking_extra_demands.txt b/mails/en/booking_extra_demands.txt index 3139f8ce3..21f96098b 100644 --- a/mails/en/booking_extra_demands.txt +++ b/mails/en/booking_extra_demands.txt @@ -13,22 +13,22 @@ {foreach name=demandRow from=$roomDemand['extra_demands'] item=demand} {if $smarty.foreach.demandRow.first} - + {$data_v['name']}
{$rm_v['data_form']|date_format:"%d-%m-%Y"} {l s='to'} {$rm_v['data_to']|date_format:"%d-%m-%Y"}
{l s='Room'} - {$roomCount} -
+ {/if} - + {$demand['name']} - + - + {convertPrice price=$demand['total_price_tax_excl']} - + {/foreach} diff --git a/mails/en/contact.html b/mails/en/contact.html index 5c5aa9d53..210b11f5d 100644 --- a/mails/en/contact.html +++ b/mails/en/contact.html @@ -68,9 +68,9 @@ - + Message from a {shop_name} customer - + @@ -82,11 +82,11 @@   - + {contact_content_html} - +   diff --git a/mails/en/contact_form.html b/mails/en/contact_form.html index 73a8a7143..2a6cc0301 100644 --- a/mails/en/contact_form.html +++ b/mails/en/contact_form.html @@ -69,9 +69,9 @@ - + Your message to {shop_name} Customer Service - + @@ -83,7 +83,7 @@   - + Your message has been sent successfully.

Message: {message}

@@ -91,7 +91,7 @@ Product: {product_name}
Attached file: {attached_file}
-
+   @@ -103,10 +103,10 @@ - + We will answer as soon as possible. - + diff --git a/mails/en/credit_slip.html b/mails/en/credit_slip.html index 6aee0c304..40928b0e2 100644 --- a/mails/en/credit_slip.html +++ b/mails/en/credit_slip.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

Order {order_name} - Credit slip created

We have generated a credit slip in your name for order with the reference {order_name}. -
+   @@ -100,10 +100,10 @@ - + You can review this credit slip and download your invoice from the "My credit slips" section of your account by clicking "My account" on our website. - + diff --git a/mails/en/credit_slip_voucher.html b/mails/en/credit_slip_voucher.html index e864fd62b..6f5ba20a6 100644 --- a/mails/en/credit_slip_voucher.html +++ b/mails/en/credit_slip_voucher.html @@ -71,9 +71,9 @@ - + Hi {firstname} {lastname},
-
+ @@ -85,7 +85,7 @@   - +

VOUCHER GENERATED

@@ -95,7 +95,7 @@ Voucher Code: {voucher_code} for an amount of {voucher_amount}.

To use this voucher just copy and paste this code during payment process for your next order.
-
+   diff --git a/mails/en/download_product.html b/mails/en/download_product.html index a9d6b6e9a..a42775e85 100644 --- a/mails/en/download_product.html +++ b/mails/en/download_product.html @@ -69,10 +69,10 @@ - + Hi {firstname} {lastname},
Thank you for your order with the reference {order_name} from {shop_name} -
+ @@ -84,14 +84,14 @@   - +

Product(s) now available for download

You have {nbProducts} product(s) now available for download using the following link(s):

{virtualProducts}
-
+   @@ -103,18 +103,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/employee_password.html b/mails/en/employee_password.html index 7b1b059c9..d17759824 100644 --- a/mails/en/employee_password.html +++ b/mails/en/employee_password.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,7 +83,7 @@   - +

Your {shop_name} login information

@@ -93,7 +93,7 @@ Password: {passwd}
E-mail address: {email}
-
+   diff --git a/mails/en/forward_msg.html b/mails/en/forward_msg.html index 07728db09..f9d56a845 100644 --- a/mails/en/forward_msg.html +++ b/mails/en/forward_msg.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,7 +83,7 @@   - +

Customer service - Forwarded discussion

@@ -91,7 +91,7 @@ Discussion history: {messages}

{employee} added "{comment}"
-
+   diff --git a/mails/en/guest_to_customer.html b/mails/en/guest_to_customer.html index 0dc1e5c9a..fbed53b8a 100644 --- a/mails/en/guest_to_customer.html +++ b/mails/en/guest_to_customer.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,7 +83,7 @@   - +

Your customer account creation

@@ -91,7 +91,7 @@ E-mail address: {email}

Password: {passwd}
-
+   @@ -103,19 +103,19 @@ - + Please be careful when sharing these login details with others. - + - + You can access your customer account on our website: {shop_url} - + diff --git a/mails/en/in_transit.html b/mails/en/in_transit.html index 6c5318515..56b82dd3e 100644 --- a/mails/en/in_transit.html +++ b/mails/en/in_transit.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,14 +83,14 @@   - +

Order {order_name} - In transit

Your order with the reference {order_name} is currently in transit.

You can track your package using the following link: {followup}
-
+   @@ -102,18 +102,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/log_alert.html b/mails/en/log_alert.html index 13766029f..66299ede6 100644 --- a/mails/en/log_alert.html +++ b/mails/en/log_alert.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,13 +83,13 @@   - +

You have received a new log alert

Warning: you have received a new log alert in your Back Office.

You can check for it in the "Tools" > "Logs" section of your Back Office.
-
+   diff --git a/mails/en/order_canceled.html b/mails/en/order_canceled.html index 5271ab209..52f2eb3f4 100644 --- a/mails/en/order_canceled.html +++ b/mails/en/order_canceled.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

Order canceled - {order_name}

Your order with the reference {order_name} has been canceled. -
+   @@ -104,7 +104,7 @@   - +

Here are your order details:

@@ -112,7 +112,7 @@ Order reference: {order_name}
Order total: {total_paid}

-
+
{order_hotel_detail_html} @@ -127,18 +127,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/order_changed.html b/mails/en/order_changed.html index c224bc3ff..4e700defb 100644 --- a/mails/en/order_changed.html +++ b/mails/en/order_changed.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

Order {order_name} - Order changed

Your order with the reference {order_name} from {hotel_hotel_name} has been changed by the merchant. -
+   @@ -100,18 +100,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/order_conf.html b/mails/en/order_conf.html index 5e58397d2..dc29689fd 100755 --- a/mails/en/order_conf.html +++ b/mails/en/order_conf.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
{order_header_line_html} -
+ @@ -86,14 +86,14 @@   - +

Order details

Order: {order_name} Placed on {date}

Payment: {payment}
-
+   @@ -123,18 +123,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/order_conf_admin.html b/mails/en/order_conf_admin.html index 28729c428..a5117aa9e 100755 --- a/mails/en/order_conf_admin.html +++ b/mails/en/order_conf_admin.html @@ -70,10 +70,10 @@ - + Hi {firstname} {lastname},
{order_header_line_html} -
+ @@ -85,14 +85,14 @@   - +

Customer details

Name: {customer_name}

Email: {customer_email}
-
+   @@ -108,14 +108,14 @@   - +

Order details

Order: {order_name} Placed on {date}

Payment: {payment}
-
+   diff --git a/mails/en/order_conf_cart_rules.tpl b/mails/en/order_conf_cart_rules.tpl index 7a1a683b0..bf4468f07 100644 --- a/mails/en/order_conf_cart_rules.tpl +++ b/mails/en/order_conf_cart_rules.tpl @@ -5,9 +5,9 @@ - + {$cart_rule['voucher_name']} - + @@ -18,9 +18,9 @@ - + {$cart_rule['voucher_reduction']} - + diff --git a/mails/en/order_conf_product_list.tpl b/mails/en/order_conf_product_list.tpl index 525e38b70..ba0127f33 100644 --- a/mails/en/order_conf_product_list.tpl +++ b/mails/en/order_conf_product_list.tpl @@ -5,9 +5,9 @@   - + {$product['reference']} - +   @@ -18,9 +18,9 @@   - + {$product['name']} - +   @@ -31,9 +31,9 @@   - + {$product['unit_price']} - +   @@ -44,9 +44,9 @@   - + {$product['quantity']} - +   @@ -57,9 +57,9 @@   - + {$product['price']} - +   @@ -73,10 +73,10 @@   - + {$product['name']}
{$customization['customization_text']} -
+   @@ -87,9 +87,9 @@   - + {$product['unit_price']} - +   @@ -100,9 +100,9 @@   - + {$customization['customization_quantity']} - +   @@ -113,9 +113,9 @@   - + {$customization['quantity']} - +   diff --git a/mails/en/order_customer_comment.html b/mails/en/order_customer_comment.html index 6dd6fedcf..c9c18b7f1 100644 --- a/mails/en/order_customer_comment.html +++ b/mails/en/order_customer_comment.html @@ -68,9 +68,9 @@ - + Message from a customer - + @@ -82,14 +82,14 @@   - + You have received a new message regarding booking with the reference {order_name}.

Name: {firstname} {lastname}

E-mail: {email}

Customer message:
{message}

-
+   diff --git a/mails/en/order_hotel_detail.tpl b/mails/en/order_hotel_detail.tpl index 710025127..a6d98eb90 100644 --- a/mails/en/order_hotel_detail.tpl +++ b/mails/en/order_hotel_detail.tpl @@ -1,5 +1,5 @@ {if isset($list['hotel_name']) && $list['hotel_name']} - +

{l s='Hotel details'}:

@@ -9,5 +9,5 @@ {l s='Hotel Email'}: {$list['hotel_email']}
{l s='Total Rooms'}: {$list['num_rooms']}

-
+
{/if} \ No newline at end of file diff --git a/mails/en/order_merchant_comment.html b/mails/en/order_merchant_comment.html index 4cbc9d7b8..e57e34375 100644 --- a/mails/en/order_merchant_comment.html +++ b/mails/en/order_merchant_comment.html @@ -68,9 +68,9 @@ - + Hi {firstname} {lastname}, - + @@ -82,7 +82,7 @@   - +

Message from {shop_name}

@@ -90,7 +90,7 @@ You have received a new message from {shop_name} regarding booking with the reference {order_name}.

Message:
{message}
-
+   diff --git a/mails/en/order_refund_completed_admin.html b/mails/en/order_refund_completed_admin.html index 0c1baf06c..d1647d8fc 100755 --- a/mails/en/order_refund_completed_admin.html +++ b/mails/en/order_refund_completed_admin.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
A request has been completed for the {refund_for_txt} cancellation. -
+ @@ -87,7 +87,7 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

@@ -96,7 +96,7 @@ Payment Mode: {payment_mode}

Transaction Id: {id_transaction}

-
+   @@ -119,12 +119,12 @@   - +

Customer details

Customer name: {customer_name}

Customer email: {customer_email}

-
+   diff --git a/mails/en/order_refund_completed_customer.html b/mails/en/order_refund_completed_customer.html index 211a19f11..0cb997673 100755 --- a/mails/en/order_refund_completed_customer.html +++ b/mails/en/order_refund_completed_customer.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
Your request for {refund_for_txt} cancellation has been completed. -
+ @@ -86,7 +86,7 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

@@ -95,7 +95,7 @@ Payment Mode: {payment_mode}

Transaction Id: {id_transaction}

-
+   @@ -117,10 +117,10 @@ - + You can review your booking cancelation requests from the "Booking Refund Requests" section of your customer account by clicking "My account". - + diff --git a/mails/en/order_refund_denied_admin.html b/mails/en/order_refund_denied_admin.html index 2a1ef1624..ddb75a8d2 100755 --- a/mails/en/order_refund_denied_admin.html +++ b/mails/en/order_refund_denied_admin.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
A request has been denied for the {refund_for_txt} cancellation. -
+ @@ -87,13 +87,13 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

Refund Status: {status_name}

-
+   @@ -116,12 +116,12 @@   - +

Customer details

Customer name: {customer_name}

Customer email: {customer_email}

-
+   diff --git a/mails/en/order_refund_denied_customer.html b/mails/en/order_refund_denied_customer.html index c997eb0a3..67ea54f76 100755 --- a/mails/en/order_refund_denied_customer.html +++ b/mails/en/order_refund_denied_customer.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
Your request for {refund_for_txt} cancellation has been denied. -
+ @@ -86,13 +86,13 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

Refund Status: {status_name}

-
+   @@ -114,10 +114,10 @@ - + You can review your booking cancelation requests from the "Booking Refund Requests" section of your customer account by clicking "My account". - + diff --git a/mails/en/order_refund_pending_admin.html b/mails/en/order_refund_pending_admin.html index 36d245469..e85a274c7 100755 --- a/mails/en/order_refund_pending_admin.html +++ b/mails/en/order_refund_pending_admin.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
A request has been generated for {refund_for_txt} cancellations. -
+ @@ -87,14 +87,14 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

Refund Status: {status_name}

Cancelation Reason: {cancelation_reason}

-
+   @@ -117,12 +117,12 @@   - +

Customer details

Customer name: {customer_name}

Customer email: {customer_email}

-
+   diff --git a/mails/en/order_refund_pending_customer.html b/mails/en/order_refund_pending_customer.html index 2b439d093..6e885fa96 100755 --- a/mails/en/order_refund_pending_customer.html +++ b/mails/en/order_refund_pending_customer.html @@ -71,10 +71,10 @@ - + Hi {firstname} {lastname},
Your request for {refund_for_txt} cancellation has been submitted successfully. -
+ @@ -86,13 +86,13 @@   - +

Order details

Order: {order_reference} Placed on {order_date}

Refund Status: {status_name}

-
+   @@ -114,10 +114,10 @@ - + You can review your booking cancelation requests from the "Booking Refund Requests" section of your customer account by clicking "My account". - + diff --git a/mails/en/order_return_state.html b/mails/en/order_return_state.html index fd3de585a..104104849 100644 --- a/mails/en/order_return_state.html +++ b/mails/en/order_return_state.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,13 +83,13 @@   - +

Return #{id_order_return} - update

We have updated the progress on your return #{id_order_return}, the new status is: "{state_order_return}"
-
+   @@ -102,10 +102,10 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + diff --git a/mails/en/overbooking.html b/mails/en/overbooking.html index b58f70c8b..8ca343851 100755 --- a/mails/en/overbooking.html +++ b/mails/en/overbooking.html @@ -71,12 +71,12 @@ - + Hi {firstname} {lastname},

Thank you for booking with {hotel_hotel_name}!

Bookings in this order are Not Confirmed yet !!
We are sorry for your inconvenience. Please contact hotel to get final confirmation for your bookings. -
+ @@ -88,14 +88,14 @@   - +

Order details

Order: {order_name} Placed on {date}

Payment: {payment}

Status: {order_status}
-
+   @@ -127,18 +127,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our shop. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our shop. - + diff --git a/mails/en/overbooking_admin.html b/mails/en/overbooking_admin.html index a19795a02..c64acd1ec 100755 --- a/mails/en/overbooking_admin.html +++ b/mails/en/overbooking_admin.html @@ -70,12 +70,12 @@ - + Hi {firstname} {lastname},

New bookings are created on {hotel_hotel_name}!

Bookings in this order have Overbookings !!
This order is not confirmed yet. Please check the order details to resolve overbookings. -
+ @@ -87,14 +87,14 @@   - +

Customer details

Name: {customer_name}

Email: {customer_email}
-
+   @@ -110,7 +110,7 @@   - +

Order details

@@ -118,7 +118,7 @@ Payment: {payment}

Status: {order_status}
-
+   diff --git a/mails/en/partial_payment_accepted.html b/mails/en/partial_payment_accepted.html index 61b578477..953846164 100644 --- a/mails/en/partial_payment_accepted.html +++ b/mails/en/partial_payment_accepted.html @@ -69,10 +69,10 @@ - + Hi {firstname} {lastname},
{order_header_line_html} -
+ @@ -84,7 +84,7 @@   - +

Order {order_name} - Payment processed

@@ -93,7 +93,7 @@ Total Booking Amount: {total_paid}

Partial Payment Amount: {advance_paid_amount}

Total Paid Amount: {total_paid_real}

-
+   @@ -106,18 +106,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/password.html b/mails/en/password.html index e6fd5726b..803a94c72 100644 --- a/mails/en/password.html +++ b/mails/en/password.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,14 +83,14 @@   - +

Your new {shop_name} login details

E-mail address: {email}
Password: {passwd}
-
+   @@ -102,18 +102,18 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/password_query.html b/mails/en/password_query.html index 3a9071826..3825facc8 100644 --- a/mails/en/password_query.html +++ b/mails/en/password_query.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,7 +83,7 @@   - +

Password reset request for {shop_name}

@@ -91,7 +91,7 @@ Please note that this will change your current password.

To confirm this action, please use the following link:
{url}
-
+   diff --git a/mails/en/payment_accepted.html b/mails/en/payment_accepted.html index 97d84f255..b99974481 100644 --- a/mails/en/payment_accepted.html +++ b/mails/en/payment_accepted.html @@ -69,10 +69,10 @@ - + Hi {firstname} {lastname},
{order_header_line_html} -
+ @@ -84,12 +84,12 @@   - +

Order {order_name} - Payment processed

Your payment for order with the reference {order_name} was successfully processed. -
+   @@ -102,18 +102,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/payment_error.html b/mails/en/payment_error.html index ba3a129d7..af3d28bb5 100644 --- a/mails/en/payment_error.html +++ b/mails/en/payment_error.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,13 +83,13 @@   - +

Order {order_name} - Payment processing error

There is a problem with your payment for {shop_name} order with the reference {order_name}. Please contact us at your earliest convenience.
-
+   @@ -102,18 +102,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/processing.html b/mails/en/processing.html index de01bd0ab..cc1fabbe7 100644 --- a/mails/en/processing.html +++ b/mails/en/processing.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

Order {order_name} - Processing

We are currently processing your {shop_name} order with the reference {order_name}. -
+   @@ -101,18 +101,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/refund.html b/mails/en/refund.html index 5004f8183..b0f59304a 100644 --- a/mails/en/refund.html +++ b/mails/en/refund.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,12 +83,12 @@   - +

Order {order_name} - Refund processed

We have processed your {shop_name} refund for order with the reference {order_name}. -
+   @@ -101,18 +101,18 @@ {extra_mail_content_html} - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/mails/en/reply_msg.html b/mails/en/reply_msg.html index 7eafe00e4..de24a620d 100644 --- a/mails/en/reply_msg.html +++ b/mails/en/reply_msg.html @@ -80,7 +80,7 @@   - +

Message from {contact_name}


Title: {subject}


diff --git a/mails/en/shipped.html b/mails/en/shipped.html index f0e3c9a5e..815ce0a3b 100644 --- a/mails/en/shipped.html +++ b/mails/en/shipped.html @@ -69,10 +69,10 @@ - + Hi {firstname} {lastname},
Your order has been shipped -
+ @@ -84,13 +84,13 @@   - +

Order {order_name} - Shipped

Your order with the reference {order_name} has been shipped.
Thank you for booking with {shop_name}!
-
+   diff --git a/mails/en/voucher.html b/mails/en/voucher.html index 5be2a4031..471eebe48 100644 --- a/mails/en/voucher.html +++ b/mails/en/voucher.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,14 +83,14 @@   - +

Order {order_name} - Voucher created

A voucher has been created in your name as a result of your order with the reference {order_name}.

Voucher code: {voucher_num} in the amount of {voucher_amount}

Simply copy/paste this code during the payment process for your next order.
-
+   diff --git a/mails/en/voucher_new.html b/mails/en/voucher_new.html index 634666db7..6bc02205d 100644 --- a/mails/en/voucher_new.html +++ b/mails/en/voucher_new.html @@ -69,9 +69,9 @@ - + Hi {firstname} {lastname}, - + @@ -83,13 +83,13 @@   - +

This is to inform you about the creation of a voucher.

Here is the code of your voucher: {voucher_num}

Simply copy/paste this code during the payment process for your next order.
-
+   diff --git a/modules/bankwire/views/templates/mail/mail_template_html.tpl b/modules/bankwire/views/templates/mail/mail_template_html.tpl index 7d1634d33..012591c35 100644 --- a/modules/bankwire/views/templates/mail/mail_template_html.tpl +++ b/modules/bankwire/views/templates/mail/mail_template_html.tpl @@ -25,7 +25,7 @@   - +

{l s='Here are the bank details for your transfer:' mod='bankwire' lang=$lang}

@@ -35,7 +35,7 @@ {l s='Account details:' mod='bankwire' lang=$lang} {$bankwire_details}
{l s='Bank address:' mod='bankwire' lang=$lang} {$bankwire_address} -
+
  diff --git a/modules/blocknewsletter/mails/en/newsletter_conf.html b/modules/blocknewsletter/mails/en/newsletter_conf.html index cff837649..2c5f51f75 100644 --- a/modules/blocknewsletter/mails/en/newsletter_conf.html +++ b/modules/blocknewsletter/mails/en/newsletter_conf.html @@ -68,9 +68,9 @@ - + Hi, - + @@ -82,13 +82,13 @@   - + Thank you for subscribing to our newsletter! If you wish to unsubscribe, please click here. - +   diff --git a/modules/blocknewsletter/mails/en/newsletter_verif.html b/modules/blocknewsletter/mails/en/newsletter_verif.html index 1c55f012e..9ec521952 100644 --- a/modules/blocknewsletter/mails/en/newsletter_verif.html +++ b/modules/blocknewsletter/mails/en/newsletter_verif.html @@ -68,9 +68,9 @@ - + Hi, - + @@ -82,11 +82,11 @@   - + Thank you for subscribing to our newsletter, please confirm your request by clicking here. - +   diff --git a/modules/blocknewsletter/mails/en/newsletter_voucher.html b/modules/blocknewsletter/mails/en/newsletter_voucher.html index 457b8a35e..89cbaa5e7 100644 --- a/modules/blocknewsletter/mails/en/newsletter_voucher.html +++ b/modules/blocknewsletter/mails/en/newsletter_voucher.html @@ -69,9 +69,9 @@ - + Hi, - + @@ -83,7 +83,7 @@   - +

Newsletter subscription

@@ -94,7 +94,7 @@ Please note that the voucher will be valid on your first order. -
+   diff --git a/modules/cheque/views/templates/mail/mail_template_html.tpl b/modules/cheque/views/templates/mail/mail_template_html.tpl index 8b33da90c..607e4fe81 100644 --- a/modules/cheque/views/templates/mail/mail_template_html.tpl +++ b/modules/cheque/views/templates/mail/mail_template_html.tpl @@ -25,7 +25,7 @@   - +

{l s='Here are the bank details for your check:' mod='cheque' lang=$lang}

@@ -34,7 +34,7 @@ {l s='Payable to the order of:' mod='cheque' lang=$lang} {$cheque_name}
{l s='Please mail your check to:' mod='cheque' lang=$lang} {$cheque_address_html} -
+
  diff --git a/modules/qlohotelreview/mails/en/review_approve.html b/modules/qlohotelreview/mails/en/review_approve.html index eff0f4fa4..582dc6d3f 100644 --- a/modules/qlohotelreview/mails/en/review_approve.html +++ b/modules/qlohotelreview/mails/en/review_approve.html @@ -194,7 +194,7 @@ - + Dear {firstname} {lastname}, @@ -202,7 +202,7 @@ Your review has been approved - + @@ -214,7 +214,7 @@   - +

Review approved

@@ -237,7 +237,7 @@ You can view your review from here. -
+   @@ -249,20 +249,20 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/modules/qlohotelreview/mails/en/review_reply_with_link.html b/modules/qlohotelreview/mails/en/review_reply_with_link.html index 56de1edbc..634157f71 100644 --- a/modules/qlohotelreview/mails/en/review_reply_with_link.html +++ b/modules/qlohotelreview/mails/en/review_reply_with_link.html @@ -194,7 +194,7 @@ - + Dear {firstname} {lastname}, @@ -202,7 +202,7 @@ Hotel management has replied to your review - + @@ -214,7 +214,7 @@   - +

Management reply

@@ -244,7 +244,7 @@ You can view your review from here. -
+   @@ -256,20 +256,20 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/modules/qlohotelreview/mails/en/review_reply_without_link.html b/modules/qlohotelreview/mails/en/review_reply_without_link.html index 5c3b9a84a..7011057a9 100644 --- a/modules/qlohotelreview/mails/en/review_reply_without_link.html +++ b/modules/qlohotelreview/mails/en/review_reply_without_link.html @@ -194,7 +194,7 @@ - + Dear {firstname} {lastname}, @@ -202,7 +202,7 @@ Hotel management has replied to your review - + @@ -214,7 +214,7 @@   - +

Management reply

@@ -238,7 +238,7 @@ Management reply: {management_reply}
-
+   @@ -250,20 +250,20 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/modules/qlohotelreview/mails/en/review_request.html b/modules/qlohotelreview/mails/en/review_request.html index 60d1c5269..cfb573262 100644 --- a/modules/qlohotelreview/mails/en/review_request.html +++ b/modules/qlohotelreview/mails/en/review_request.html @@ -194,7 +194,7 @@ - + Dear {firstname} {lastname}, @@ -202,7 +202,7 @@ Thank you for choosing our hotel for your recent stay! - + @@ -214,7 +214,7 @@   - +

Please review us!

@@ -222,7 +222,7 @@ Could you please take a moment to review us? Please review your stay at {hotel_name} by clicking here. We would love to hear your feedback and use it to improve our services!
-
+   @@ -234,20 +234,20 @@ - + You can review your order and download your invoice from the "Order history" section of your customer account by clicking "My account" on our website. - + - + If you have a guest account, you can follow your order via the "Guest Tracking" section on our website. - + diff --git a/themes/debug.tpl b/themes/debug.tpl index 87fef347d..ebe7b79f4 100644 --- a/themes/debug.tpl +++ b/themes/debug.tpl @@ -103,6 +103,10 @@ font-style: italic; } + .template-name { + color: brown; + } + #table_assigned_vars th { color: blue; } @@ -123,7 +127,7 @@

included templates & config files (load time in seconds)

{foreach $template_data as $template} - {$template.name} + {$template.name} (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"} ) From 70b08b23e7dc3b42bdca2198b13efaf60d255af4 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Wed, 17 Jun 2026 15:39:41 +0530 Subject: [PATCH 13/14] Fixed: correct KPI implementation on AdminCartController view page Co-authored-by: Name --- .../controllers/carts/helpers/view/view.tpl | 4 +- controllers/admin/AdminCartsController.php | 144 +++++++++--------- 2 files changed, 77 insertions(+), 71 deletions(-) diff --git a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl index a57ed0a63..b26103a19 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -26,9 +26,7 @@ {extends file="helpers/view/view.tpl"} {block name="override_tpl"} -
- {$kpi} -
+
diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f76331422..002cd6be2 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -181,69 +181,85 @@ class AdminCartsControllerCore extends AdminController public function renderKpis() { - $time = time(); - $kpis = array(); + $objCart = new Cart(Tools::getValue('id_cart')); + if (Validate::isLoadedObject($objCart)) { + $currency = new Currency($objCart->id_currency); + $summary = $objCart->getSummaryDetails(); + $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id); + $total_price = ($tax_calculation_method == PS_TAX_EXC) + ? $summary['total_price_without_tax'] + : $summary['total_price']; - $daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS'); - - $helper = new HelperKpi(); - $helper->id = 'box-conversion-rate'; - $helper->icon = 'icon-sort-by-attributes-alt'; - //$helper->chart = true; - $helper->color = 'color1'; - $helper->title = $this->l('Conversion Rate', null, null, false); - if ($daysForConversionRate == 1) { - $helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false); + $helper = new HelperKpi(); + $helper->id = 'box-kpi-cart'; + $helper->icon = 'icon-shopping-cart'; + $helper->color = 'color1'; + $helper->title = $this->l('Total Cart', null, null, false); + $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $objCart->id); + $helper->value = Tools::displayPrice($total_price, $currency); + $this->kpis[] = $helper; } else { - $helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false); - } - if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) { - $helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART'); - } - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate'; - $this->kpis[] = $helper; + $daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS'); - $helper = new HelperKpi(); - $helper->id = 'box-carts'; - $helper->icon = 'icon-shopping-cart'; - $helper->color = 'color2'; - $helper->title = $this->l('Abandoned Carts', null, null, false); - $date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day')); - $date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day')); - $helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to); - $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day')); - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart'; - $this->kpis[] = $helper; + $helper = new HelperKpi(); + $helper->id = 'box-conversion-rate'; + $helper->icon = 'icon-sort-by-attributes-alt'; + //$helper->chart = true; + $helper->color = 'color1'; + $helper->title = $this->l('Conversion Rate', null, null, false); + if ($daysForConversionRate == 1) { + $helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false); + } else { + $helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false); + } + if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) { + $helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART'); + } + $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate'; + $this->kpis[] = $helper; - $daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS'); - $helper = new HelperKpi(); - $helper->id = 'box-average-order'; - $helper->icon = 'icon-money'; - $helper->color = 'color3'; - $helper->title = $this->l('Average Order Value', null, null, false); - if ($daysForAvgOrderVal == 1) { - $helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false); - } else { - $helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false); + $helper = new HelperKpi(); + $helper->id = 'box-carts'; + $helper->icon = 'icon-shopping-cart'; + $helper->color = 'color2'; + $helper->title = $this->l('Abandoned Carts', null, null, false); + $date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day')); + $date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day')); + $helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to); + $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.date('Y-m-d', strtotime('-2 day')).'&date_to='.date('Y-m-d', strtotime('-1 day')); + $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart'; + $this->kpis[] = $helper; + + $daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS'); + $helper = new HelperKpi(); + $helper->id = 'box-average-order'; + $helper->icon = 'icon-money'; + $helper->color = 'color3'; + $helper->title = $this->l('Average Order Value', null, null, false); + if ($daysForAvgOrderVal == 1) { + $helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false); + } else { + $helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false); + } + + $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value'; + $this->kpis[] = $helper; + + $daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS'); + $helper = new HelperKpi(); + $helper->id = 'box-net-profit-visitor'; + $helper->icon = 'icon-user'; + $helper->color = 'color4'; + $helper->title = $this->l('Net Profit per Visitor', null, null, false); + if ($daysForProfitPerVisitor == 1) { + $helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('day', null, null, false); + } else { + $helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false); + } + $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit'; + $this->kpis[] = $helper; } - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value'; - $this->kpis[] = $helper; - - $daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS'); - $helper = new HelperKpi(); - $helper->id = 'box-net-profit-visitor'; - $helper->icon = 'icon-user'; - $helper->color = 'color4'; - $helper->title = $this->l('Net Profit per Visitor', null, null, false); - if ($daysForProfitPerVisitor == 1) { - $helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('day', null, null, false); - } else { - $helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false); - } - $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit'; - $this->kpis[] = $helper; - return parent::renderKpis(); } @@ -254,6 +270,9 @@ class AdminCartsControllerCore extends AdminController if (!($cart = $this->loadObject(true))) { return; } + if ($this->tabAccess['kpi'] === 1) { + $this->content .= $this->renderKpis(); + } $customer = new Customer($cart->id_customer); $currency = new Currency($cart->id_currency); $this->context->cart = $cart; @@ -340,16 +359,6 @@ class AdminCartsControllerCore extends AdminController $cartHtlData = array(); } - $helper = new HelperKpi(); - $helper->id = 'box-kpi-cart'; - $helper->icon = 'icon-shopping-cart'; - $helper->color = 'color1'; - $helper->title = $this->l('Total Cart', null, null, false); - $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id); - $helper->value = Tools::displayPrice($total_price, $currency); - $kpi = $helper->generate(); - //end - // get standalone products in cart $objServiceProductCartDetail = new ServiceProductCartDetail(); $hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( @@ -381,7 +390,6 @@ class AdminCartsControllerCore extends AdminController 'cart_htl_data' => $cartHtlData,//by webkul hotel rooms in order data 'standalone_products' => $standaloneProducts, 'hotel_products' => $hotelProducts, - 'kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), 'cart_orders' => $cartOrders, From c9a56fab418da7122f56adf25a9deac8c0195765 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Tue, 23 Jun 2026 19:35:12 +0530 Subject: [PATCH 14/14] Fixed:Selected service price not included in total when no service mapping exists --- .../template/controllers/orders/_current_cart_details_data.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index e3405fa99..300bb29d0 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -130,7 +130,7 @@ {* {displayPrice price=$data.amt_with_qty} *} - {if (isset($data.extra_demands) && $data.extra_demands) || (isset($data.additional_service) && $data.additional_service)} + {if (isset($data.extra_demands) && $data.extra_demands) || (isset($data.additional_service) && $data.additional_service) || (isset($data.selected_services) && $data.selected_services)} {displayPrice price=($data.amt_with_qty + $data.additional_services_auto_add_price + $data.demand_price + $data.additional_service_price)|escape:'html':'UTF-8'} {else} {displayPrice price=$data.amt_with_qty|escape:'html':'UTF-8'}