From 4199e40098c33c37326376986817d171128ee4bd Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Thu, 26 Feb 2026 12:13:20 +0530 Subject: [PATCH 01/76] Added functionality for selecting the selling type in a single product with multiple types. --- .../normal_products/informations.tpl | 82 ++++++- .../controllers/orders/helpers/view/view.tpl | 36 ++- classes/Cart.php | 133 +++++++---- classes/PaymentModule.php | 212 ++++++++++++++++-- classes/Product.php | 77 ++++++- classes/order/Order.php | 81 ++++++- classes/order/OrderDetail.php | 2 +- classes/order/OrderInvoice.php | 23 +- classes/pdf/HTMLTemplateInvoice.php | 59 ++++- controllers/admin/AdminCartsController.php | 32 ++- .../admin/AdminNormalProductsController.php | 158 +++++-------- controllers/admin/AdminOrdersController.php | 198 ++++++++++++---- controllers/front/CartController.php | 122 +++++----- .../front/OrderConfirmationController.php | 92 ++++---- controllers/front/OrderDetailController.php | 87 ++++--- controllers/front/ParentOrderController.php | 35 ++- controllers/front/ProductController.php | 14 +- modules/blockcart/blockcart.php | 55 ++--- .../classes/HotelCartBookingData.php | 84 +++---- .../js/modules/blockcart/ajax-cart.js | 157 ++++++++----- .../modules/blockcart/blockcart.tpl | 20 +- .../modules/blockcart/cartrow.tpl | 16 +- .../hotel-reservation-theme/order-detail.tpl | 49 +++- 23 files changed, 1256 insertions(+), 568 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 2000a8f8c..ad77a39b0 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -230,7 +230,7 @@ {* Code For Standard product working *} - {*
+
-
*} -
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)}style="display:none;"{/if}> +
+
selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
-
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
{/block} {block name='blockcart_shopping_cart_hotel_name'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel}
{$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
@@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {else if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,10 +53,10 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {$hotel_wise_data.total_qty} - {elseif $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} - {$product.cart_quantity} + {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {$product.standalone_total_qty|intval} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {assign var='options' value=$hotel_wise_data.options} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {else} {assign var='options' value=$product.options} {/if}
@@ -155,4 +155,4 @@ {if !isset($product.attributes_small)}{/if} {/if} -{if isset($product.attributes_small)}{/if} \ No newline at end of file +{if isset($product.attributes_small)}{/if} diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 9402a240d..81fa7f340 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -317,14 +317,27 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - - {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} - {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} + {assign var=room_services_price_tax_excl value=( + $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_te + )} + {assign var=room_services_price_tax_incl value=( + $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_ti + )} + {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} + {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} + {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl ))} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=( + $all_services_price_tax_incl - $room_linked_services_price_tax_incl + )} + {assign var=total_standard_products_tax_excl value=( + $all_services_price_tax_excl - $room_linked_services_price_tax_excl + )} {if isset($cart_htl_data) && $cart_htl_data} {l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if} @@ -350,7 +363,7 @@ {/if} - {if $total_convenience_fee_te || $total_convenience_fee_te} + {if $total_convenience_fee_te || $total_convenience_fee_ti} {l s='Total Convenience Fees'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if}{/if} @@ -726,11 +739,25 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} - {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} + {assign var=room_services_price_tax_excl value=( + $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_te + )} + {assign var=room_services_price_tax_incl value=( + $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) + + $total_demands_price_ti + )} + {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} + {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} + {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=( + $all_services_price_tax_incl - $room_linked_services_price_tax_incl + )} + {assign var=total_standard_products_tax_excl value=( + $all_services_price_tax_excl - $room_linked_services_price_tax_excl + )} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} @@ -759,7 +786,7 @@ {/if} - {if $total_convenience_fee_te || $total_convenience_fee_te} + {if $total_convenience_fee_te || $total_convenience_fee_ti} {l s='Total Convenience Fees'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if}{/if} From 2a86378bae57b62b39aff58d532fc178989f8479 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 27 Feb 2026 10:14:09 +0530 Subject: [PATCH 02/76] Fix price calculation in order confirmation email --- classes/Cart.php | 81 +++++---- classes/PaymentModule.php | 60 +++++-- classes/pdf/HTMLTemplateInvoice.php | 80 ++++++++- classes/pdf/HTMLTemplateOrderSlip.php | 14 +- .../WebserviceSpecificManagementBookings.php | 10 +- controllers/admin/AdminImportController.php | 6 +- controllers/front/GuestTrackingController.php | 35 ++-- modules/blockcart/ajax-cart.js | 157 +++++++++++------- modules/blockcart/blockcart.tpl | 21 ++- modules/blockcart/cartrow.tpl | 12 +- .../AdminHotelRoomsBookingController.php | 4 +- 11 files changed, 321 insertions(+), 159 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index cc5d94173..e936c663c 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1791,42 +1791,59 @@ class CartCore extends ObjectModel } } else if ($canSellWithHotel) { - if ($type == Cart::ONLY_ROOM_SERVICES - || $type == Cart::ONLY_CONVENIENCE_FEE - || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD - || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE - || $type == Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE - ) { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - 0, - null, - null, - (int)$product['id_product'] - ); - } elseif ($type == Cart::ONLY_STANDALONE_PRODUCTS) { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - null, - 0, - null, - (int)$product['id_product'] - ); - } else { - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - 0, - null, - null, - (int)$product['id_product'] - ); + $isRoomServiceTotalType = in_array($type, array( + Cart::ONLY_ROOM_SERVICES, + Cart::ONLY_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, + Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, + )); + $id_hotel = null; + $id_hotel_cart_booking = null; + if ($param_product) { + if (isset($product['id_hotel']) && (int)$product['id_hotel']) { + $id_hotel = (int)$product['id_hotel']; + } + if (isset($product['id_hotel_cart_booking']) && (int)$product['id_hotel_cart_booking']) { + $id_hotel_cart_booking = (int)$product['id_hotel_cart_booking']; + } } + $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + null, + null, + null, + (int)$product['id_product'] + ); + if ($servicePorducts) { foreach ($servicePorducts as $servicePorduct) { + if ($param_product) { + if ($id_hotel_cart_booking !== null + && (int)$servicePorduct['id_hotel_cart_booking'] !== $id_hotel_cart_booking + ) { + continue; + } + if ($id_hotel_cart_booking === null + && $id_hotel !== null + && ( + !empty($servicePorduct['id_hotel_cart_booking']) + || (int)$servicePorduct['id_hotel'] !== $id_hotel + ) + ) { + continue; + } + } + if ($isRoomServiceTotalType && empty($servicePorduct['id_hotel_cart_booking'])) { + continue; + } + if ($type == Cart::ONLY_STANDALONE_PRODUCTS + && !empty($servicePorduct['id_hotel_cart_booking']) + ) { + continue; + } if ($with_taxes) { $priceAdd = $servicePorduct['total_price_tax_incl']; } else { diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 3af3b70dc..e39aa34b6 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -541,6 +541,7 @@ abstract class PaymentModuleCore extends Module $product_var_tpl_list = array(); $orderServiceProducts = array(); + $processedServiceProductCartIds = array(); $objProduct = new Product(); foreach ($order->product_list as $product) { @@ -591,11 +592,11 @@ abstract class PaymentModuleCore extends Module } if ( - !$product['booking_product'] + !$product['booking_product'] && !$product['id_hotel_cart_booking'] && ( Product::isSellableAsStandalone($product['selling_preference_type']) || Product::isSellableWithHotel($product['selling_preference_type']) - ) + ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -613,7 +614,8 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] ); - + $standaloneServiceProducts = array(); + $hotelServiceProducts = array(); foreach ($serviceProducts as $serviceProduct) { $orderServiceProducts[] = array_merge($product_var_tpl, $serviceProduct); } @@ -1402,28 +1404,52 @@ abstract class PaymentModuleCore extends Module $normal_products_data_txt = $this->getEmailTemplateContent('service_product_data_text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); // get order total information html/txt files + // room-related selling types: + // 1: with room type, 3: hotel+room, 6: standalone+room, 7: hotel+room+standalone + $roomRelatedSellingTypes = array( + Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ); + // total room price - $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_auto_with_room_tax_excl = 0; + $room_auto_with_room_tax_incl = 0; + foreach ($roomRelatedSellingTypes as $sellingType) { + $room_auto_with_room_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_auto_with_room_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + } + $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $room_auto_with_room_tax_excl; + $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $room_auto_with_room_tax_incl; $room_tax = ($room_price_tax_incl - $room_price_tax_excl); // extra services - $additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_te']); - $additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_ti']); + $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; + $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; + foreach ($roomRelatedSellingTypes as $sellingType) { + $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + } $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price - $total_convenience_fee_ti = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $total_convenience_fee_te = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_ti = 0; + $total_convenience_fee_te = 0; + foreach ($roomRelatedSellingTypes as $sellingType) { + $total_convenience_fee_ti += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_te += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + } $total_convenience_fee_tax = $total_convenience_fee_ti - $total_convenience_fee_te; // service products - $standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); - $standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); - $hotel_standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); - $hotel_standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); - - $service_products_tax = ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl) - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl); + $all_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false); + $all_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false); + $room_linked_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $room_linked_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $total_standard_products_tax_incl = $all_services_price_tax_incl - $room_linked_services_price_tax_incl; + $total_standard_products_tax_excl = $all_services_price_tax_excl - $room_linked_services_price_tax_excl; + $service_products_tax = $total_standard_products_tax_incl - $total_standard_products_tax_excl; $total_order_tax = $room_tax + $additional_service_tax + $total_convenience_fee_tax + $service_products_tax; @@ -1440,12 +1466,12 @@ abstract class PaymentModuleCore extends Module 'total_convenience_fee_te' => Tools::displayPrice($total_convenience_fee_te, $this->context->currency, false), 'total_convenience_fee_tax' => Tools::displayPrice($total_convenience_fee_tax, $this->context->currency, false), 'service_products_price_tax_excl' => Tools::displayPrice( - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl), + $total_standard_products_tax_excl, $this->context->currency, false ), 'service_products_price_tax_incl' => Tools::displayPrice( - ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl), + $total_standard_products_tax_incl, $this->context->currency, false ), diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 4b4754ca8..23839e4e8 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -679,17 +679,81 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail); foreach ($roomTypeSellingPreferenceTypes as $sellingPreferenceType) { - $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); - $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail); - $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 0, null, $idsOrderDetail); - $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 0, null, $idsOrderDetail); - $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); - $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); + $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 0, + null, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 0, + null, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); + $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + 1, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); } foreach ($serviceSellingPreferenceTypes as $sellingPreferenceType) { - $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes(false, false, $sellingPreferenceType, false, false, $idsOrderDetail); - $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes(false, false, $sellingPreferenceType, false, false, $idsOrderDetail); + $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( + false, + false, + $sellingPreferenceType, + false, + false, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM + ); + $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( + false, + false, + $sellingPreferenceType, + false, + false, + $idsOrderDetail, + Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM + ); } $footer['additional_service_price_tax_excl'] += $totalDemandsPriceTE; diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php index 16396243f..0c2a50c86 100644 --- a/classes/pdf/HTMLTemplateOrderSlip.php +++ b/classes/pdf/HTMLTemplateOrderSlip.php @@ -286,7 +286,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice $order_detail = array_filter($this->order->products, function($v) { return ((isset($v['is_booking_product']) && $v['is_booking_product']) || ((isset($v['product_auto_add']) && $v['product_auto_add']) - && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE + && Product::isSellableWithRoomType($v['selling_preference_type']) && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -347,10 +347,14 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice // - 'total_amount' $breakdown = array(); $order_detail = array_filter($this->order->products, function($v) { - return (!$v['is_booking_product'] && ( - $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE - || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE - )); + return ( + !$v['is_booking_product'] + && empty($v['id_htl_booking']) + && ( + Product::isSellableAsStandalone($v['selling_preference_type']) + || Product::isSellableWithHotel($v['selling_preference_type']) + ) + ); }); $details = $this->order->getProductTaxesDetails($order_detail, false); diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 10e52dab0..bb9e3be7d 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1015,7 +1015,15 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We } } - $serviceProductPrice = $objOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); + $serviceProductPrice = $objOrder->getTotalProductsWithTaxes( + false, + false, + null, + null, + null, + [], + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ); if ($demands = $objHotelBookingDemands->getExtraDemandsTaxesDetails($objOrder->id)) { $demandsPrice = array_sum(array_column($demands, 'total_price_tax_excl')); // Adding the tax diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index d2819efca..cf130c6e3 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1901,7 +1901,7 @@ class AdminImportControllerCore extends AdminController } $objServiceProduct = new Product($idServiceProduct); - if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $objServiceProduct->selling_preference_type) { + if (Product::isSellableWithRoomType($objServiceProduct->selling_preference_type)) { $objRoomTypeServiceProduct->addRoomProductLink( $objServiceProduct->id, $product->id, @@ -2329,12 +2329,12 @@ class AdminImportControllerCore extends AdminController $info['shop'] = explode($this->multiple_value_separator, $info['shop']); RoomTypeServiceProduct::deleteRoomProductLink($product->id); - if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $product->selling_preference_type) { + if (Product::isSellableWithRoomType($product->selling_preference_type)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if (isset($info['id_room_types']) && $info['id_room_types']) { $objRoomTypeServiceProduct->addRoomProductLink( $product->id, - $product->id_room_types, + $info['id_room_types'], RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE ); } diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 596d54185..fd684953b 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -497,7 +497,7 @@ class GuestTrackingControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } elseif ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { + } elseif (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, @@ -524,7 +524,10 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { + } else if ( + Product::isSellableWithHotel($type_value['selling_preference_type']) + || Product::isSellableAsStandalone($type_value['selling_preference_type']) + ) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -532,21 +535,21 @@ class GuestTrackingControllerCore extends FrontController } else { $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); - foreach ($hotelProducts as $hotelProduct) { - $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); - } - } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { - $cover_image_arr = $product->getCover($type_value['product_id']); - if (!empty($cover_image_arr)) { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); - } else { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); - } - $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); - foreach ($standaloneProducts as $standaloneProduct) { - $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); + $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( + $idOrder, + $type_value['id_order_detail'], + $type_value['product_id'] + ); + foreach ($serviceProducts as $serviceProduct) { + $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); + $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); + + if ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) { + $hotelServiceProducts[] = array_merge($type_value, $serviceProduct); + } elseif ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $standaloneServiceProducts[] = array_merge($type_value, $serviceProduct); + } } } } diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index ca2ad2695..85c34b47e 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -127,6 +127,51 @@ var ajaxCart = { dateFormat: 'DD-MM-YYYY', dateFormatFull: 'DD-MM-YYYY HH:mm:ss', nb_total_products: 0, + getSellingPreferenceChannels: function(sellingPreferenceType) { + var channels = { + with_room_type: false, + with_hotel: false, + standalone: false + }; + switch (parseInt(sellingPreferenceType)) { + case SELLING_PREFERENCE_WITH_ROOM_TYPE: + channels.with_room_type = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE: + channels.with_hotel = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + channels.with_room_type = true; + channels.with_hotel = true; + break; + case SELLING_PREFERENCE_STANDALONE: + channels.standalone = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + channels.with_hotel = true; + channels.standalone = true; + break; + case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + channels.with_room_type = true; + channels.standalone = true; + break; + case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + channels.with_room_type = true; + channels.with_hotel = true; + channels.standalone = true; + break; + } + return channels; + }, + isSellableWithRoomType: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).with_room_type; + }, + isSellableWithHotel: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).with_hotel; + }, + isSellableAsStandalone: function(sellingPreferenceType) { + return this.getSellingPreferenceChannels(sellingPreferenceType).standalone; + }, _overrideButtonsInThePage: function () { //for every 'add' buttons... $(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function (e) { @@ -703,15 +748,13 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); for (aProduct in jsonData.products) { //we've called the variable aProduct because IE6 bug if this variable is called product //if product has attributes - if ((parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(jsonData.products[aProduct]['selling_preference_type']) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) - && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length) - ) { + if (isHotelRow && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { $.each(jsonData.products[aProduct]['hotel_wise_data'], function() { - if (!ids[3] || (ids[3] == this.id_hotel)) { + if (ids[3] == this.id_hotel) { stayInTheCart = true; } }); @@ -835,25 +878,37 @@ var ajaxCart = { $(jsonData.products).each(function(key, value) { //fix ie6 bug (one more item 'undefined' in IE6) if (this.id != undefined) { - if (!this.booking_product && parseInt(this.selling_preference_type) == SELLING_PREFERENCE_WITH_ROOM_TYPE) { - return; - } - //create a container for listing the products and hide the 'no product in the cart' message (only if the cart was empty) - if ($('.cart_block:first dl.products').length == 0) { - $('.cart_block_no_products').before('
'); - $('.cart_block_no_products').hide(); - } - - if (parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(this.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + if ( + this.booking_product + || ajaxCart.isSellableWithHotel(parseInt(this.selling_preference_type)) + || ajaxCart.isSellableAsStandalone(parseInt(this.selling_preference_type)) ) { - if (typeof value.hotel_wise_data != 'undefined') { - $(value.hotel_wise_data).each(function(i, val) { - ajaxCart.addProductRow(value, val); - }); + if ($('.cart_block:first dl.products').length == 0) { + $('.cart_block_no_products').before('
'); + $('.cart_block_no_products').hide(); + } + + var hasHotelRows = (typeof value.hotel_wise_data != 'undefined' && value.hotel_wise_data.length); + if (hasHotelRows) { + if (typeof value.hotel_wise_data != 'undefined') { + $(value.hotel_wise_data).each(function(i, val) { + ajaxCart.addProductRow(value, val); + }); + } + } + + var shouldShowStandaloneRow = this.booking_product + || ( + !ajaxCart.isSellableWithHotel(parseInt(this.selling_preference_type)) + && !ajaxCart.isSellableWithRoomType(parseInt(this.selling_preference_type)) + ) + || ( + ajaxCart.isSellableAsStandalone(parseInt(this.selling_preference_type)) + && parseInt(value.standalone_total_qty || 0, 10) > 0 + ); + if (shouldShowStandaloneRow) { + ajaxCart.addProductRow(value); } - } else { - ajaxCart.addProductRow(value); } } }); @@ -876,10 +931,7 @@ var ajaxCart = { content += '
'; content += '' + name + ''; content += '
'; - if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) - && (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined') - ) { + if ((typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.hotel_name) != 'undefined')) { content += '
' + hotel_wise_data.hotel_name + '
'; } @@ -893,10 +945,7 @@ var ajaxCart = { if (product.booking_product) { content += formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank); - }else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) - && (typeof(hotel_wise_data) != 'undefined') - ) { + } else if (typeof(hotel_wise_data) != 'undefined') { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { content += formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank); @@ -916,7 +965,7 @@ var ajaxCart = { if (typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty) { content += hotel_wise_data.total_qty; } else { - content += product.cart_quantity; + content += (typeof product.standalone_total_qty != 'undefined' ? product.standalone_total_qty : product.cart_quantity); } } content += ''; @@ -976,16 +1025,11 @@ var ajaxCart = { content += '' + price_txt + ''; content += ' '; content += ''; - if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - ) { - if (hotel_wise_data.options !== 'undefined') { - var options = hotel_wise_data.options; - } - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_STANDALONE) { - if (product.options !== 'undefined') { - var options = product.options; - } + var options = []; + if (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.options) != 'undefined') { + options = hotel_wise_data.options; + } else if (typeof(product.options) != 'undefined') { + options = product.options; } if (options !== 'undefined') { $.each(options, function(data_k, data_v) { @@ -1043,16 +1087,11 @@ var ajaxCart = { } else if (product.hasOptions) { $('dt[data-id="cart_block_product_' + productDomId + '"] .cart_prod_cont tr.product_option_row').remove(); var product_options_content = ''; - if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - ) { - if (hotel_wise_data.options !== 'undefined') { - var options = hotel_wise_data.options; - } - } else if (parseInt(product.selling_preference_type) == SELLING_PREFERENCE_STANDALONE) { - if (product.options !== 'undefined') { - var options = product.options; - } + var options = []; + if (typeof(hotel_wise_data) != 'undefined' && typeof(hotel_wise_data.options) != 'undefined') { + options = hotel_wise_data.options; + } else if (typeof(product.options) != 'undefined') { + options = product.options; } if (options !== 'undefined') { $.each(options, function(data_k, data_v) { @@ -1077,10 +1116,7 @@ var ajaxCart = { if (!product.is_gift) { if (product.booking_product) { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank)); - } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) - && typeof(hotel_wise_data) != 'undefined' - ) { + } else if (typeof(hotel_wise_data) != 'undefined') { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank)); } else { $('dt[data-id="cart_block_product_' + productDomId + '"] .price').text(formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank)); @@ -1091,15 +1127,16 @@ var ajaxCart = { //cart_booking_data[key].total_num_rooms argument sent to update num of rooms instead of quantity if (product.booking_product) { ajaxCart.updateProductQuantity(jsonProduct, product.bookingData.total_num_rooms); - } else if ((parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE - || parseInt(product.selling_preference_type) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - ) - && typeof(hotel_wise_data) != 'undefined' + } else if ( + typeof(hotel_wise_data) != 'undefined' && hotel_wise_data.total_qty ) { ajaxCart.updateProductQuantity(jsonProduct, hotel_wise_data.total_qty, hotel_wise_data); } else { - ajaxCart.updateProductQuantity(jsonProduct, jsonProduct.cart_quantity); + ajaxCart.updateProductQuantity( + jsonProduct, + (typeof jsonProduct.standalone_total_qty != 'undefined' ? jsonProduct.standalone_total_qty : jsonProduct.cart_quantity) + ); } // Customized product diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index af73ec530..ec29d14f4 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -63,14 +63,15 @@
{foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || ($product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE)|| ($product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) || ($product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE)} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {if isset($product.hotel_wise_data) && $product.hotel_wise_data} - {foreach $product.hotel_wise_data as $hotel_wise_data} - {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} - {/foreach} - {/if} - {else} + {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} + {if isset($product.hotel_wise_data) && $product.hotel_wise_data} + {foreach $product.hotel_wise_data as $hotel_wise_data} + {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} + {/foreach} + {/if} + {if $product.booking_product + || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) + || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} @@ -401,11 +402,13 @@ {addJsDef img_dir=$img_dir|escape:'quotes':'UTF-8'} {addJsDef generated_date=$smarty.now|intval} {addJsDef ajax_allowed=$ajax_allowed|boolval} - {addJsDef hasDeliveryAddress=(isset($cart->id_address_delivery) && $cart->id_address_delivery)} {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} diff --git a/modules/blockcart/cartrow.tpl b/modules/blockcart/cartrow.tpl index e909aaacf..68d0cbc96 100644 --- a/modules/blockcart/cartrow.tpl +++ b/modules/blockcart/cartrow.tpl @@ -11,7 +11,7 @@
{/block} {block name='blockcart_shopping_cart_hotel_name'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)}
{$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
@@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {else if Product::isSellableWithHotel($product.selling_preference_type)} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,9 +53,9 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)} {$hotel_wise_data.total_qty} - {elseif $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {elseif Product::isSellableAsStandalone($product.selling_preference_type)} {$product.cart_quantity} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE || $product.selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} + {if Product::isSellableWithHotel($product.selling_preference_type)} {assign var='options' value=$hotel_wise_data.options} - {else if $product.selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE} + {else if Product::isSellableAsStandalone($product.selling_preference_type)} {assign var='options' value=$product.options} {/if}
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index fac60d468..b86558c85 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -625,9 +625,9 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (!$product->id || !$product->active) { $this->errors[] = $this->l('This product is no longer available.'); } - if ($product->booking_product || ($product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE)) { + if ($product->booking_product || !Product::isSellableAsStandalone($product->selling_preference_type)) { // cannot be added without room type or is a booking product. - $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added thorugh this method.'); + $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added through this method.'); } elseif (!$product->allow_multiple_quantity) { // check if product already exists in cart. if ($id_cart) { From 3dc7b7b1880cffe9fb62087376fd95a0f531ce52 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 27 Feb 2026 13:23:16 +0530 Subject: [PATCH 03/76] Fix update price calculation method --- .../controllers/normal_products/prices.tpl | 29 +++++---- .../_add_order_extra_services_tab_content.tpl | 15 ++++- ..._services_service_products_tab_content.tpl | 35 ++++++++--- classes/Product.php | 63 ++++++++++++++++--- .../WebserviceSpecificManagementBookings.php | 55 +++++++++------- controllers/admin/AdminCartsController.php | 10 +-- .../admin/AdminNormalProductsController.php | 11 +++- controllers/admin/AdminOrdersController.php | 36 ++++++----- .../classes/HotelHelper.php | 10 +-- .../classes/ServiceProductCartDetail.php | 39 ++++++------ .../_partials/cart_booking_demands.tpl | 17 +++-- .../_partials/service-products-list-row.tpl | 9 ++- 12 files changed, 222 insertions(+), 107 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/prices.tpl b/admin/themes/default/template/controllers/normal_products/prices.tpl index bae5d1211..6d315a307 100644 --- a/admin/themes/default/template/controllers/normal_products/prices.tpl +++ b/admin/themes/default/template/controllers/normal_products/prices.tpl @@ -206,19 +206,24 @@ $(document).ready(function () {
{if isset($pack) && $pack->isPack($product->id)}

{l s='The sum of prices of the products in the pack is %s%s%s' sprintf=[$currency->prefix,{toolsConvertPrice price=$pack->noPackPrice($product->id)|string_format:$priceDisplayPrecisionFormat},$currency->suffix]}

{/if}
*} -
- -
- +
+ +
+ +
-
{* As no use in QloApps currently so commented *} {*
{include file="controllers/products/multishop/checkbox.tpl" field="unit_price" type="unit_price"}
diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 048757a04..3dc6241f0 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -91,7 +91,11 @@ {$cartCurrency->sign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']} + {if Product::getPriceCalculationApplicableDays( + $product['price_calculation_method'], + $selectedRoomServiceProduct['date_from'], + $selectedRoomServiceProduct['date_to'] + ) > 1} {l s='/ night'} {/if}
@@ -132,8 +136,13 @@
diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 8fb331302..4f6ce1c58 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -82,7 +82,11 @@
{$currencySign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $service.price_calculation_method} + {if Product::getPriceCalculationApplicableDays( + $service.price_calculation_method, + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} {l s='/ night'} {/if}
@@ -152,9 +156,13 @@
{$currencySign} - {if Product::PRICE_CALCULATION_METHOD_PER_DAY == $product['price_calculation_method']} - {l s='/ night'} - {/if} + {if Product::getPriceCalculationApplicableDays( + $product['price_calculation_method'], + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} + {l s='/ night'} + {/if}
@@ -191,8 +199,13 @@
@@ -286,9 +299,13 @@ {displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency} - {if $service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY} - {l s='/ night'} - {/if} + {if Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $additionalServices['date_from'], + $additionalServices['date_to'] + ) > 1} + {l s='/ night'} + {/if} {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/Product.php b/classes/Product.php index fc962d3c0..cfb27c0ad 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -566,8 +566,15 @@ class ProductCore extends ObjectModel const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_PER_BOOKING = 1; - const PRICE_CALCULATION_METHOD_PER_DAY = 2; + const PRICE_CALCULATION_METHOD_PER_DAY = 1; + + const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; + const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; + const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 3; + const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 4; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; + const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2; @@ -6865,12 +6872,54 @@ class ProductCore extends ObjectModel ) ); - if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY - && $dateFrom && $dateTo - ) { - $price = $price * HotelHelper::getNumberOfDays($dateFrom, $dateTo); - } + $numdays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($idProduct), + $dateFrom, + $dateTo + ); + $price = $price * $numdays; return $price * (int)$quantity; } + + + public static function getPriceCalculationApplicableDays( + $priceCalculationMethod, + $dateFrom, + $dateTo, + $defaultDays = 1 + ) { + if (empty($dateFrom) || empty($dateTo)) { + return (int) $defaultDays; + } + + $numNights = (int) HotelHelper::getNumberOfDays($dateFrom, $dateTo); + if ($numNights <= 0) { + return (int) $defaultDays; + } + + switch ((int) $priceCalculationMethod) { + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: + return 1; + + case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: + return max($numNights - 1, 1); + + case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: + return 2; + + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: + return $numNights; + + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: + return $numNights + 1; + + default: + return $numNights; + } + } + } + diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index 10e52dab0..cc67e3351 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -2297,10 +2297,13 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We ))) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to); - } + + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objBookingDetail->date_from, + $objBookingDetail->date_to + ); + $totalPriceTaxExcl = Product::getServiceProductPrice( $service['id_product'], 0, @@ -2653,9 +2656,12 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($selectedAdditonalServices[$idHotelBooking]['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $cart_quantity = $cart_quantity * $quantity; - } + $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $dateFrom, + $dateTo + ); + $cart_quantity = $cart_quantity * $serviceApplicableDays; if ($cart_quantity >= $serviceOrderDetail->product_quantity) { $serviceOrderDetail->delete(); @@ -3169,10 +3175,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $priceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; $priceTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl; $objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $quantity = $objOrderDetail->product_quantity * $numDays; if ($objServiceProductOrderDetail->delete()) { @@ -3264,10 +3271,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $insertedServiceProductIdOrderDetail = $objHotelBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); $objOrderDetail = new OrderDetail($insertedServiceProductIdOrderDetail); - $numDays = 1; - if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($product['id_product']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $quantity = $objServiceProductCartDetail->quantity * $numDays; @@ -3687,17 +3695,18 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $services['id_service'] = (int) $service['id_product']; $services['name'] = $service['name']; $services['quantity'] = (int) $service['quantity']; - $services['unit_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl'] / $services['quantity']), _PS_PRICE_COMPUTE_PRECISION_); + $applicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $additionalService['date_from'], + $additionalService['date_to'] + ); + $unitDivisor = max(1, ((int) $services['quantity'] * (int) $applicableDays)); + $services['unit_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl'] / $unitDivisor), _PS_PRICE_COMPUTE_PRECISION_); $services['total_price_without_tax'] = Tools::ps_round(($service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_); $services['total_tax'] = Tools::ps_round(($service['total_price_tax_incl'] - $service['total_price_tax_excl']), _PS_PRICE_COMPUTE_PRECISION_); - $objProduct = new Product($service['id_product']); - $services['per_night'] = 0; - if ($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $services['per_night'] = 1; - } - - $services['price_mode'] = (int) $objProduct->price_calculation_method; + $services['per_night'] = ((int) $applicableDays > 1) ? 1 : 0; + $services['price_mode'] = (int) $service['price_calculation_method']; $roomInfo['services'][] = $services; } } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index f76331422..626185f1f 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1205,10 +1205,12 @@ class AdminCartsControllerCore extends AdminController if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { - $numDays = 1; - if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $servProduct['price_calculation_method']) { - $numDays = HotelHelper::getNumberOfDays($dateFrom, $dateTo); - } + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( $servProduct['id_product'], 0, diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 43838ccc8..6827d5811 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,8 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_PER_BOOKING => $this->l('Add price once for the booking range'), - Product::PRICE_CALCULATION_METHOD_PER_DAY => $this->l('Add price for each day of booking') + Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY => $this->l('Only check-in day'), + Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY => $this->l('Only check-out day'), + Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY => $this->l('Only during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY => $this->l('Check-in | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY => $this->l('Check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY => $this->l('Check-in | check-out | during-stay days'), ); $this->_join .= ' @@ -222,7 +227,7 @@ class AdminNormalProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.') '.HotelBranchInformation::addHotelRestriction(false, 'hrt'); - $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, IF(a.`price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', "'.$this->l('Per Day').'", "'.$this->l('Per Booking').'") as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; + $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, CASE a.`price_calculation_method` WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.' THEN "'.$this->l('Only check-in day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.' THEN "'.$this->l('Only check-out day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN "'.$this->l('Only during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN "'.$this->l('Check-in and check-out days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-out | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | check-out | during-stay days').'" ELSE "'.$this->l('Only check-in day').'" END as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 30026bcca..e9f5be74f 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5342,10 +5342,11 @@ class AdminOrdersControllerCore extends AdminController )) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($order->id, $service['id_product']); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id_product']), + $objBookingDetail->date_from, + $objBookingDetail->date_to + ); $totalPriceTaxExcl = Product::getServiceProductPrice( (int) $service['id_product'], @@ -6519,9 +6520,12 @@ class AdminOrdersControllerCore extends AdminController $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - if ($service['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $cart_quantity = $cart_quantity * $product_quantity; - } + $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $service['price_calculation_method'], + $selectedAdditonalServices[$idHotelBooking]['date_from'], + $selectedAdditonalServices[$idHotelBooking]['date_to'] + ); + $cart_quantity = $cart_quantity * $serviceApplicableDays; if ($cart_quantity >= $serviceOrderDetail->product_quantity) { $serviceOrderDetail->delete(); } else { @@ -7702,10 +7706,11 @@ class AdminOrdersControllerCore extends AdminController $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); - $numDays = 1; - if (Product::getProductPriceCalculation($service['id']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service['id']), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $initialServicePrice = Product::getServiceProductPrice( @@ -8013,10 +8018,11 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $cartProductProcessed = 1; - $numDays = 1; - if (Product::getProductPriceCalculation($objServiceProduct->id) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to); - } + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($objServiceProduct->id), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); foreach ($productList as &$product) { // This is used to get the actual quanity of the service as it is calculated incorrectly if the service is per night if ($idRoomTypeServProductCart = $objServiceProductCartDetail->alreadyExists( diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index a196694f5..709a9b23a 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2155,7 +2155,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Room Maintenance Fees', @@ -2220,7 +2220,7 @@ class HotelHelper 'price' => '50', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Airport Shuttle', @@ -2252,7 +2252,7 @@ class HotelHelper 'price' => '200', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Cab on Demand', @@ -2284,7 +2284,7 @@ class HotelHelper 'price' => '350', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Breakfast', @@ -2316,7 +2316,7 @@ class HotelHelper 'price' => '450', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Dinner', diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 25a1edfcb..1c93321d9 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -89,11 +89,13 @@ class ServiceProductCartDetail extends ObjectModel $objServiceProductCartDetail = new ServiceProductCartDetail($product['id_service_product_cart_detail']) )) { $updateQty = $product['quantity']; - if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); - $numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to); - $updateQty *= $numdays; - } + $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); + $numdays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($product['id_product']), + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + $updateQty *= $numdays; if ($objServiceProductCartDetail->delete()) { $objCart = new Cart($product['id_cart']); if (isset(Context::getContext()->controller->controller_type)) { @@ -247,13 +249,11 @@ class ServiceProductCartDetail extends ObjectModel $product['htl_cart_booking_id'] ); } else { - $numDays = 1; - // If price type is per day but the dates are not valid. - if (($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) - && (!$numDays = HotelHelper::getNumberOfDays($product['date_from'], $product['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $product['date_from'], + $product['date_to'] + ); $priceTaxIncl = Product::getServiceProductPrice( $objProduct->id, @@ -455,14 +455,13 @@ class ServiceProductCartDetail extends ObjectModel } if ($objServiceProductCartDetail->save()) { - if ($objProduct->price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelCartBooking->date_from, - $objHotelCartBooking->date_to - ); - $quantity = $objServiceProductCartDetail->quantity * $numDays; - } + if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBooking->date_from, + $objHotelCartBooking->date_to + ); + $quantity = $objServiceProductCartDetail->quantity * $numDays; } $objCart = new Cart($idCart); diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index f74c3b628..5a3db8aaa 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -148,12 +148,19 @@
-
- {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} - {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if}{if $product.price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}{l s='/Night'}{/if} +
+ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + + {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} + {if Product::getPriceCalculationApplicableDays( + $product.price_calculation_method, + $cartRoom.date_from|default:'', + $cartRoom.date_to|default:'' + ) > 1}{l s='/Night'}{/if} + - {/if} -
+ {/if} +
{/foreach} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 19ac25070..5a8896426 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -53,7 +53,14 @@ {if !$PS_CATALOG_MODE && !$order_date_restrict && ($service_product.show_price && !isset($restricted_country_mode))}
{block name='service_product_price'} - {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if}{if $service_product.price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY}{l s='/Night'}{/if} + {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if} + {if Product::getPriceCalculationApplicableDays( + $service_product.price_calculation_method, + $service_product.date_from|default:$date_from|default:'', + $service_product.date_to|default:$date_to|default:'' + ) > 1} + {l s='/Night'} + {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0}
From 37ff12c22aa0f63732753b0221da8b9b4c1ad73d Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 2 Mar 2026 12:40:00 +0530 Subject: [PATCH 04/76] Fix the issue related to price calculation on the invoice. --- .../controllers/orders/helpers/view/view.tpl | 3 ++- classes/PaymentModule.php | 6 ++---- classes/order/Order.php | 15 ++------------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 9d83f4482..0053d2631 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -902,7 +902,8 @@
- {* Assign order price *} + + {* Assign order price *} {if ($order->getTaxCalculationMethod() == $smarty.const.PS_TAX_EXC)} {assign var=order_product_price value=($order->total_products)} {assign var=order_discount_price value=$order->total_discounts_tax_excl} diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index e39aa34b6..6745a0e2d 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -1427,10 +1427,8 @@ abstract class PaymentModuleCore extends Module // extra services $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; - foreach ($roomRelatedSellingTypes as $sellingType) { - $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - } + $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT,null,Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price diff --git a/classes/order/Order.php b/classes/order/Order.php index 5ccfe9cba..ca9ef9327 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -635,21 +635,10 @@ class OrderCore extends ObjectModel if (!$is_booking && $selling_preference_type !== null) { $sql .= ' AND od.`selling_preference_type` = '. (int)$selling_preference_type; } - if ( - !$is_booking - && $selling_preference_type !== null - && Product::isSellableWithRoomType($selling_preference_type) - && $product_auto_add !== null - ) { + if (!$is_booking && $product_auto_add !== null) { $sql .= ' AND od.`product_auto_add` = '. (int)$product_auto_add; } - if ( - !$is_booking - && $selling_preference_type !== null - && Product::isSellableWithRoomType($selling_preference_type) - && $product_auto_add == 1 - && $product_price_addition_type !== null - ) { + if (!$is_booking && $product_auto_add == 1 && $product_price_addition_type !== null) { $sql .= ' AND od.`product_price_addition_type` = '. (int)$product_price_addition_type; } From cd047d34d3a1f3780937f4b51ac0ca120fdeda18 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 2 Mar 2026 18:44:24 +0530 Subject: [PATCH 05/76] Fix service product option display based on selling type. --- .../normal_products/informations.tpl | 62 ---------- classes/Cart.php | 38 +++--- js/admin/normal_products.js | 113 ++++++++++-------- 3 files changed, 88 insertions(+), 125 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index ad77a39b0..3bf54bd1b 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -614,66 +614,4 @@ var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE|intval}; var SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE|intval}; - - function toggleAssociationFieldNames(containerSelector, shouldShow) - { - var $container = $(containerSelector); - if (shouldShow) { - $container.show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - } else { - $container.hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - } - } - - function applySellingPreferenceUIState() - { - var sellingPreference = parseInt($('#selling_preference_type').val(), 10); - var showHotelTree = $.inArray(sellingPreference, [ - SELLING_PREFERENCE_HOTEL_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showRoomTypeTree = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showAutoAddToCart = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - - toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); - toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); - if (showAutoAddToCart) { - $('#auto_add_to_cart_container').show('fast'); - } else { - $('#auto_add_to_cart_container').hide('fast'); - $('input[name="auto_add_to_cart"]').trigger('change'); - } - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } - - $(document).on('change.sellingPreferenceExtended', '#selling_preference_type', function() { - applySellingPreferenceUIState(); - }); - - $(function() { - setTimeout(function() { - applySellingPreferenceUIState(); - }, 0); - }); diff --git a/classes/Cart.php b/classes/Cart.php index e936c663c..0b2d86500 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2483,6 +2483,9 @@ class CartCore extends ObjectModel )) { $array = array(); foreach($selectedServiceProducts as $selectedProduct) { + if (empty($selectedProduct['id_hotel_cart_booking'])) { + continue; + } if (isset($array[$selectedProduct['id_room_type_hotel']])) { $array[$selectedProduct['id_room_type_hotel']]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl']; $array[$selectedProduct['id_room_type_hotel']]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl']; @@ -2507,7 +2510,7 @@ class CartCore extends ObjectModel } } - + if ($array) { foreach($array as $selectedProduct) { $product['cart_quantity'] = $selectedProduct['quantity']; @@ -2544,19 +2547,27 @@ class CartCore extends ObjectModel } } } - if (Product::isSellableAsStandalone($product['selling_preference_type']) && !Product::isSellableWithRoomType($product['selling_preference_type'])) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + 0, + 0, + null, + (int)$product['id_product'] + )) { + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $product; + $standaloneProduct[$id_address]['product_list'][] = $product; } - $productinfo = $product; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; - $standaloneProduct[$id_address]['product_list'][] = $product; } if (Product::isSellableWithHotel($product['selling_preference_type'])) { @@ -2600,7 +2611,6 @@ class CartCore extends ObjectModel // if (!empty($hotelProducts['products'])) { // foreach($hotelProducts['products'] as $hotelProduct) { $productinfo = $serviceProduct; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; $orderPackage[$id_address][$hotelProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'] = $hotelProduct['id_hotel']; diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 2e1bf00a6..9826b146f 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -547,57 +547,72 @@ product_tabs['Informations'] = new function(){ }; this.switchProductType = function(){ + function toggleAssociationFieldNames(containerSelector, shouldShow) + { + var $container = $(containerSelector); + if (shouldShow) { + $container.show('fast').find('input').each(function() { + $(this).attr('name', $(this).attr('data-name')); + $(this).removeAttr('data-name'); + }); + } else { + $container.hide('fast').find('input').each(function() { + $(this).attr('data-name', $(this).attr('name')); + $(this).removeAttr('name'); + }); + } + } + + function applySellingPreferenceUIState() + { + var sellingPreference = parseInt($('#selling_preference_type').val(), 10); + var showHotelTree = $.inArray(sellingPreference, [ + SELLING_PREFERENCE_HOTEL_STANDALONE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var showRoomTypeTree = $.inArray(sellingPreference, [ + 0, + SELLING_PREFERENCE_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var showAutoAddToCart = $.inArray(sellingPreference, [ + 0, + SELLING_PREFERENCE_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE + ]) !== -1; + var $autoAddOff = $('#auto_add_to_cart_off'); + var $autoAddCheckedInput; + + toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); + toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); + + if (showAutoAddToCart) { + $('#auto_add_to_cart_container').show('fast'); + $autoAddCheckedInput = $('input[name="auto_add_to_cart"]:checked'); + if (!$autoAddCheckedInput.length) { + $autoAddOff.prop('checked', true); + $autoAddCheckedInput = $autoAddOff; + } + } else { + $autoAddOff.prop('checked', true); + $('#auto_add_to_cart_container').hide('fast'); + $autoAddCheckedInput = $autoAddOff; + } + + $autoAddCheckedInput.trigger('change'); + $('#product_options').show('fast'); + } $('#selling_preference_type').on('change',function(){ - if (parseInt($(this).val()) == SELLING_PREFERENCE_WITH_ROOM_TYPE) { - $('#associated_hotel_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_rooms_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').show('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_HOTEL_STANDALONE) { - $('#associated_hotel_rooms_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) { - $('#associated_hotel_rooms_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#associated_hotel_tree').show('fast').find('input').each(function() { - $(this).attr('name', $(this).attr('data-name')); - $(this).removeAttr('data-name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } else if (parseInt($(this).val()) == SELLING_PREFERENCE_STANDALONE) { - $('#associated_hotel_rooms_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#associated_hotel_tree').hide('fast').find('input').each(function() { - $(this).attr('data-name', $(this).attr('name')); - $(this).removeAttr('name'); - }); - $('#auto_add_to_cart_container').hide('fast'); - $('#show_at_front_container').show('fast'); - $('#product_options').show('fast'); - } + setTimeout(function() { + applySellingPreferenceUIState(); + }, 0); }); $('#selling_preference_type').trigger('change'); $('#simple_product').attr('checked', true); From e5dd7e67a5bc53fb43407074e9cefb394fc6dc45 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 10:27:45 +0530 Subject: [PATCH 06/76] Fix display service product total and unit price using quantity --- modules/blockcart/blockcart.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index eb364c6e6..2c2ea59ac 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -358,8 +358,11 @@ class Blockcart extends Module $addedProduct['option_name'] = $productOption->name; } } - $addedProduct['price'] = Tools::displayPrice($addedProduct['unit_price'] * $addedProduct['qty']); - $addedProduct['unit_price'] = Tools::displayPrice($addedProduct['unit_price']); + $quantity = $addedProduct['qty']; + $totalPrice = (float) $addedProduct['unit_price']; + $unitPrice = $totalPrice / $quantity; + $addedProduct['price'] = Tools::displayPrice($totalPrice); + $addedProduct['unit_price'] = Tools::displayPrice($unitPrice); } unset($this->context->cookie->currentAddedProduct); } From 7aaa29e07bec662eea479ca44beb28fcbcbb2bd5 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 16:20:58 +0530 Subject: [PATCH 07/76] Fix: correct invoice price calculation and fix standalone service product not being added when another product exists --- classes/Cart.php | 35 ++++-- classes/PaymentModule.php | 104 ------------------ classes/order/OrderInvoice.php | 18 +-- controllers/admin/AdminCartsController.php | 2 +- controllers/admin/AdminOrdersController.php | 2 +- controllers/front/CartController.php | 4 +- .../classes/ServiceProductCartDetail.php | 4 +- 7 files changed, 41 insertions(+), 128 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 0b2d86500..4f7d24e46 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2556,17 +2556,32 @@ class CartCore extends ObjectModel null, (int)$product['id_product'] )) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + $hasStandaloneService = false; + foreach ($selectedServiceProducts as $selectedServiceProduct) { + if ((int) $selectedServiceProduct['id_hotel'] === 0 + && (int) $selectedServiceProduct['id_hotel_cart_booking'] === 0 + ) { + $hasStandaloneService = true; + break; + } + } + + if ($hasStandaloneService) { + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $product; + $productinfo['id_hotel'] = 0; + $productinfo['id_hotel_cart_booking'] = 0; + $productinfo['id_room_type'] = 0; + $standaloneProduct[$id_address]['product_list'][] = $productinfo; } - $productinfo = $product; - $standaloneProduct[$id_address]['product_list'][] = $product; } } diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 6745a0e2d..4a38a14c7 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -974,110 +974,6 @@ abstract class PaymentModuleCore extends Module $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); - if ($canSellWithRoomType || $canSellWithHotel || $canSellAsStandalone) { - $idProductRoomType = null; - $idProductHotel = null; - if (isset($product['id_room_type']) && $product['id_room_type']) { - $idProductRoomType = $product['id_room_type']; - } elseif (isset($product['id_hotel']) && $product['id_hotel']) { - $idProductHotel = $product['id_hotel']; - } - - if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->context->cart->id, - [], - $idProductHotel, - null, - $idProductRoomType, - $product['id_product'] - )) { - foreach ($serviceProducts as $serviceProduct) { - $isRoomTypeService = !empty($serviceProduct['id_hotel_cart_booking']); - $isHotelService = !$isRoomTypeService && !empty($serviceProduct['id_hotel']); - - if ($isRoomTypeService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - ); - } elseif ($isHotelService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE - ); - } else { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_STANDALONE - ); - } - - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); - } - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id - ); - } - if (!$idOrderDetail) { - continue; - } - - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $objServiceProductOrderDetail->id_product = $idProduct; - $objServiceProductOrderDetail->id_order = $order->id; - $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; - $objServiceProductOrderDetail->id_cart = $this->context->cart->id; - $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; - $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; - $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; - $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; - $objServiceProductOrderDetail->name = $product['name']; - $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; - $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; - $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; - if ($isHotelService) { - $objServiceProductOrderDetail->id_hotel = $serviceProduct['id_hotel']; - if (Validate::isLoadedObject( - $objHotelBranch = new HotelBranchInformation($serviceProduct['id_hotel'], $this->context->cart->id_lang) - )) { - $objServiceProductOrderDetail->hotel_name = $objHotelBranch->hotel_name; - } - } elseif ($isRoomTypeService) { - if (!Validate::isDate($serviceProduct['date_from']) - || !Validate::isDate($serviceProduct['date_to']) - || !(int) $serviceProduct['id_room_type'] - ) { - continue; - } - $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( - $order->id, - $serviceProduct['id_room_type'], - $serviceProduct['date_from'], - $serviceProduct['date_to'], - $serviceProduct['id_room'] - ); - if (empty($roomBookingDetail['id'])) { - continue; - } - $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; - $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; - } - $objServiceProductOrderDetail->save(); - } - } - continue; - } - if ($canSellWithRoomType && !$canSellWithHotel && !$canSellAsStandalone) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index dc74a2105..911951c59 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,14 +478,16 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts(); - $order_detail = array_filter($order_detail, function($v) { - return ( - !$v['is_booking_product'] - && !$v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) - ); - }); + $order_detail = $this->getProducts( + $order->getProductsDetail( + false, + null, + 0, + Product::PRICE_ADDITION_TYPE_INDEPENDENT, + array(), + Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED + ) + ); $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index d7bda66aa..03b07ba0e 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1670,7 +1670,7 @@ class AdminCartsControllerCore extends AdminController $idServiceProduct, $operator, $quantity, - 0, + false, $idCartBooking ))) { $originalPrice = Product::getPriceStatic($idServiceProduct, false); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 7be742582..9cafbb2be 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -5644,7 +5644,7 @@ class AdminOrdersControllerCore extends AdminController $idProduct, 'up', $productInformations['product_quantity'], - isset($addressTax->id_hotel) ? $addressTax->id_hotel : 0, + isset($addressTax->id_hotel) ? $addressTax->id_hotel : false, false, isset($productInformations['product_option']) ? $productInformations['product_option'] : null )) { diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index c22b5f0b5..98fb6eaac 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -665,8 +665,8 @@ class CartControllerCore extends FrontController $this->id_product, $operator, $this->qty, - false, - false, + 0, + 0, isset($idProductOption) ? $idProductOption : null ); if ($operator == 'up') { diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 25a1edfcb..8f9a908ec 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -58,10 +58,10 @@ class ServiceProductCartDetail extends ObjectModel if ($idProduct) { $sql .= ' AND `id_product` = '.(int)$idProduct; } - if ($idHotel) { + if ($idHotel !== false && $idHotel !== null) { $sql .= ' AND `id_hotel` = '.(int)$idHotel; } - if ($idHtlCartData) { + if ($idHtlCartData !== false && $idHtlCartData !== null) { $sql .= ' AND `htl_cart_booking_id` = '.(int)$idHtlCartData; } if ($idProductOption) { From 14aa332f3ee81b55deb4a15c1ef93b1280aa0c40 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 3 Mar 2026 18:50:39 +0530 Subject: [PATCH 08/76] fix: resolve tax breakdown for multi selling-type products --- classes/order/OrderInvoice.php | 68 +++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 911951c59..cc9e95339 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,16 +478,32 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts( - $order->getProductsDetail( - false, - null, - 0, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - array(), - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ) - ); + $order_detail = array(); + $products = $this->getProducts(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + foreach ($products as $product) { + if ($product['is_booking_product'] + || $product['product_auto_add'] + || !Product::isSellableWithRoomType($product['selling_preference_type']) + ) { + continue; + } + + $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( + $product['id_order'], + $product['id_order_detail'] + ); + if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { + continue; + } + + foreach ($serviceProductDetail as $serviceProduct) { + if (!empty($serviceProduct['id_htl_booking_detail'])) { + $order_detail[] = $product; + break; + } + } + } $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { @@ -614,14 +630,32 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = $this->getProducts(); - $order_detail = array_filter($order_detail, function($v) { - return ( - !$v['is_booking_product'] - && (Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type'])) + $order_detail = array(); + $products = $this->getProducts(); + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + foreach ($products as $product) { + if ($product['is_booking_product'] + || !Product::isSellableAsStandalone($product['selling_preference_type']) + || !Product::isSellableWithHotel($product['selling_preference_type']) + ) { + continue; + } + + $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( + $product['id_order'], + $product['id_order_detail'] ); - }); + if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { + continue; + } + + foreach ($serviceProductDetail as $serviceProduct) { + if (empty($serviceProduct['id_htl_booking_detail'])) { + $order_detail[] = $product; + break; + } + } + } $details = $order->getProductTaxesDetails($order_detail, false); From 4a644cb4521646d6f68607e896e7e1d1c0ddd9a0 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 10 Mar 2026 19:18:36 +0530 Subject: [PATCH 09/76] Fixed:Fix incorrect mapping between order detail and service product order detail when product selling type hotel + room type --- .../controllers/orders/helpers/view/view.tpl | 36 +--- classes/Cart.php | 71 +++++--- classes/PaymentModule.php | 165 +++--------------- classes/order/Order.php | 38 +--- classes/order/OrderInvoice.php | 61 ++----- classes/pdf/HTMLTemplateInvoice.php | 106 +---------- .../classes/ServiceProductCartDetail.php | 2 +- .../hotel-reservation-theme/order-detail.tpl | 45 +---- 8 files changed, 108 insertions(+), 416 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index 0053d2631..13e3fcb22 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -923,42 +923,18 @@ {* Get total rooms prices *} {assign var=total_rooms_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=total_rooms_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} {* Get total extra services including convenience fees prices *} - {assign var=total_products_price_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} - {assign var=total_products_price_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} + {assign var=total_products_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE))} + {assign var=total_products_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE))} {* Get total of extra services and extra demands prices(excluding convenience fee) *} - {assign var=total_room_services_and_demands_tax_excl value=( - $room_linked_services_price_tax_excl - + $totalDemandsPriceTE - )} - {assign var=total_room_services_and_demands_tax_incl value=( - $room_linked_services_price_tax_incl - + $totalDemandsPriceTI - )} + {assign var=total_room_services_and_demands_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $totalDemandsPriceTE)} + {assign var=total_room_services_and_demands_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $totalDemandsPriceTI)} {* Get total of only convenience fees prices *} - {assign var=total_convenience_fee_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - )} - {assign var=total_convenience_fee_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT) - )} + {assign var=total_convenience_fee_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} + {assign var=total_convenience_fee_tax_incl value=$order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT)} {assign var=order_total_price_tax_excl value=($total_rooms_price_tax_excl + $total_room_services_and_demands_tax_excl + $total_products_price_tax_excl)} {assign var=order_total_price_tax_incl value=($total_rooms_price_tax_incl + $total_room_services_and_demands_tax_incl + $total_products_price_tax_incl)} diff --git a/classes/Cart.php b/classes/Cart.php index 4f7d24e46..ced44ff2d 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1761,13 +1761,9 @@ class CartCore extends ObjectModel && (!$canSellWithHotel && !$canSellWithRoomType || ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellWithHotel)) ) { - $idHotelCartBooking = null; - $idHotel = null; - if ($type == Cart::ONLY_STANDALONE_PRODUCTS && $canSellWithRoomType) { - // For room+standalone products, standalone totals must exclude room-linked rows. - $idHotelCartBooking = 0; - $idHotel = 0; - } + $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; + $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; + if ($servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -2522,7 +2518,7 @@ class CartCore extends ObjectModel $product['id_room_type'] = $selectedProduct['id_room_type']; $product['id_hotel_cart_booking'] = $selectedProduct['id_hotel_cart_booking']; $productinfo = $product; - // $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; + $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; $orderPackage[$id_address][$selectedProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'] = $selectedProduct['id_hotel']; @@ -2556,31 +2552,51 @@ class CartCore extends ObjectModel null, (int)$product['id_product'] )) { - $hasStandaloneService = false; + $array = array(); foreach ($selectedServiceProducts as $selectedServiceProduct) { if ((int) $selectedServiceProduct['id_hotel'] === 0 && (int) $selectedServiceProduct['id_hotel_cart_booking'] === 0 ) { - $hasStandaloneService = true; - break; + if (isset($array[$selectedServiceProduct['id_product']])) { + $array[$selectedServiceProduct['id_product']]['total_price_tax_excl'] += $selectedServiceProduct['total_price_tax_excl']; + $array[$selectedServiceProduct['id_product']]['total_price_tax_incl'] += $selectedServiceProduct['total_price_tax_incl']; + $array[$selectedServiceProduct['id_product']]['quantity'] += $selectedServiceProduct['quantity']; + } else { + $array[$selectedServiceProduct['id_product']] = array( + 'quantity' => $selectedServiceProduct['quantity'], + 'total_price_tax_excl' => $selectedServiceProduct['total_price_tax_excl'], + 'total_price_tax_incl' => $selectedServiceProduct['total_price_tax_incl'], + ); + } + } } - if ($hasStandaloneService) { - if (!isset($standaloneProduct[$id_address])) { - $standaloneProduct[$id_address] = array( - 'product_list' => array(), - 'warehouse_list' => $package['warehouse_list'], - 'carrier_list' => $product['carrier_list'], - 'id_warehouse' => $package['id_warehouse'], - 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 - ); + if ($array) { + foreach ($array as $standaloneProductData) { + $serviceProduct = $product; + $serviceProduct['cart_quantity'] = $standaloneProductData['quantity']; + $serviceProduct['total'] = $standaloneProductData['total_price_tax_excl']; + $serviceProduct['total_wt'] = $standaloneProductData['total_price_tax_incl']; + $serviceProduct['price'] = $standaloneProductData['total_price_tax_excl'] / $standaloneProductData['quantity']; + $serviceProduct['price_wt'] = $standaloneProductData['total_price_tax_incl'] / $standaloneProductData['quantity']; + $serviceProduct['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; + $serviceProduct['id_hotel'] = 0; + $serviceProduct['id_hotel_cart_booking'] = 0; + $serviceProduct['id_room_type'] = 0; + if (!isset($standaloneProduct[$id_address])) { + $standaloneProduct[$id_address] = array( + 'product_list' => array(), + 'warehouse_list' => $package['warehouse_list'], + 'carrier_list' => $product['carrier_list'], + 'id_warehouse' => $package['id_warehouse'], + 'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0 + ); + } + $productinfo = $serviceProduct; + + $standaloneProduct[$id_address]['product_list'][] = $productinfo; } - $productinfo = $product; - $productinfo['id_hotel'] = 0; - $productinfo['id_hotel_cart_booking'] = 0; - $productinfo['id_room_type'] = 0; - $standaloneProduct[$id_address]['product_list'][] = $productinfo; } } } @@ -2596,6 +2612,9 @@ class CartCore extends ObjectModel )) { $array = array(); foreach($selectedServiceProducts as $hotelProduct) { + if (!isset($hotelProduct['id_hotel']) || !$hotelProduct['id_hotel']) { + continue; + } if (isset($array[$hotelProduct['id_hotel']])) { $array[$hotelProduct['id_hotel']]['total_price_tax_excl'] += $hotelProduct['total_price_tax_excl']; $array[$hotelProduct['id_hotel']]['total_price_tax_incl'] += $hotelProduct['total_price_tax_incl']; @@ -2626,6 +2645,8 @@ class CartCore extends ObjectModel // if (!empty($hotelProducts['products'])) { // foreach($hotelProducts['products'] as $hotelProduct) { $productinfo = $serviceProduct; + $productinfo['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; + $orderPackage[$id_address][$hotelProduct['id_hotel']]['product_list'][] = $productinfo; if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'])) { $orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'] = $hotelProduct['id_hotel']; diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 4a38a14c7..a022f3484 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -606,16 +606,16 @@ abstract class PaymentModuleCore extends Module $cover_img = $this->context->link->getImageLink($product['link_rewrite'], $this->context->language->iso_code."-default", 'small_default'); } $product_var_tpl['cover_img'] = $cover_img; + $idHotel = isset($product['id_hotel']) ? $product['id_hotel'] : 0; $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $order->id_cart, [], - null, + $idHotel, 0, null, $product['id_product'] ); - $standaloneServiceProducts = array(); - $hotelServiceProducts = array(); + foreach ($serviceProducts as $serviceProduct) { $orderServiceProducts[] = array_merge($product_var_tpl, $serviceProduct); } @@ -1061,9 +1061,9 @@ abstract class PaymentModuleCore extends Module } elseif ($canSellAsStandalone && !$canSellWithRoomType && !$canSellWithHotel) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, - [Product::SELLING_PREFERENCE_STANDALONE], - null, - null, + [], + 0, + 0, null, $product['id_product'] )) { @@ -1089,108 +1089,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif ($canSellWithRoomType || $canSellWithHotel || $canSellAsStandalone) { - $idProductRoomType = null; - $idProductHotel = null; - if (isset($product['id_room_type']) && $product['id_room_type']) { - $idProductRoomType = $product['id_room_type']; - } elseif (isset($product['id_hotel']) && $product['id_hotel']) { - $idProductHotel = $product['id_hotel']; - } - - if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->context->cart->id, - [], - $idProductHotel, - null, - $idProductRoomType, - $product['id_product'] - )) { - foreach ($serviceProducts as $serviceProduct) { - $isRoomTypeService = !empty($serviceProduct['id_hotel_cart_booking']); - $isHotelService = !$isRoomTypeService && !empty($serviceProduct['id_hotel']); - - if ($isRoomTypeService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE - ); - } elseif ($isHotelService) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE - ); - } else { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - Product::SELLING_PREFERENCE_STANDALONE - ); - } - - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); - } - if (!$idOrderDetail) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id - ); - } - if (!$idOrderDetail) { - continue; - } - - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $objServiceProductOrderDetail->id_product = $idProduct; - $objServiceProductOrderDetail->id_order = $order->id; - $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; - $objServiceProductOrderDetail->id_cart = $this->context->cart->id; - $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; - $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; - $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; - $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; - $objServiceProductOrderDetail->name = $product['name']; - $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; - $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; - $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; - if ($isHotelService) { - $objServiceProductOrderDetail->id_hotel = $serviceProduct['id_hotel']; - if (Validate::isLoadedObject( - $objHotelBranch = new HotelBranchInformation($serviceProduct['id_hotel'], $this->context->cart->id_lang) - )) { - $objServiceProductOrderDetail->hotel_name = $objHotelBranch->hotel_name; - } - } elseif ($isRoomTypeService) { - if (!Validate::isDate($serviceProduct['date_from']) - || !Validate::isDate($serviceProduct['date_to']) - || !(int) $serviceProduct['id_room_type'] - ) { - continue; - } - $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( - $order->id, - $serviceProduct['id_room_type'], - $serviceProduct['date_from'], - $serviceProduct['date_to'], - $serviceProduct['id_room'] - ); - if (empty($roomBookingDetail['id'])) { - continue; - } - $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; - $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; - } - $objServiceProductOrderDetail->save(); - } - } - } + } } } @@ -1300,50 +1199,28 @@ abstract class PaymentModuleCore extends Module $normal_products_data_txt = $this->getEmailTemplateContent('service_product_data_text.tpl', Mail::TYPE_TEXT, $orderServiceProducts); // get order total information html/txt files - // room-related selling types: - // 1: with room type, 3: hotel+room, 6: standalone+room, 7: hotel+room+standalone - $roomRelatedSellingTypes = array( - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - // total room price - $room_auto_with_room_tax_excl = 0; - $room_auto_with_room_tax_incl = 0; - foreach ($roomRelatedSellingTypes as $sellingType) { - $room_auto_with_room_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - $room_auto_with_room_tax_incl += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); - } - $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $room_auto_with_room_tax_excl; - $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $room_auto_with_room_tax_incl; + $room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); $room_tax = ($room_price_tax_incl - $room_price_tax_excl); // extra services - $additional_service_price_tax_excl = (float) $cart_booking_data['total_extra_demands_te']; - $additional_service_price_tax_incl = (float) $cart_booking_data['total_extra_demands_ti']; - $additional_service_price_tax_excl += $order->getTotalProductsWithoutTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $additional_service_price_tax_incl += $order->getTotalProductsWithTaxes(false, false, null, 0, Product::PRICE_ADDITION_TYPE_INDEPENDENT,null,Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); + $additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_te']); + $additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0) + $cart_booking_data['total_extra_demands_ti']); $additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl); // convenience fee price - $total_convenience_fee_ti = 0; - $total_convenience_fee_te = 0; - foreach ($roomRelatedSellingTypes as $sellingType) { - $total_convenience_fee_ti += $order->getTotalProductsWithTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - $total_convenience_fee_te += $order->getTotalProductsWithoutTaxes(false, false, $sellingType, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); - } + $total_convenience_fee_ti = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $total_convenience_fee_te = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); $total_convenience_fee_tax = $total_convenience_fee_ti - $total_convenience_fee_te; // service products - $all_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false); - $all_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false); - $room_linked_services_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $room_linked_services_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED); - $total_standard_products_tax_incl = $all_services_price_tax_incl - $room_linked_services_price_tax_incl; - $total_standard_products_tax_excl = $all_services_price_tax_excl - $room_linked_services_price_tax_excl; - $service_products_tax = $total_standard_products_tax_incl - $total_standard_products_tax_excl; + $standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); + $standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE); + $hotel_standalone_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $hotel_standalone_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + + $service_products_tax = ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl) - ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl); $total_order_tax = $room_tax + $additional_service_tax + $total_convenience_fee_tax + $service_products_tax; @@ -1360,12 +1237,12 @@ abstract class PaymentModuleCore extends Module 'total_convenience_fee_te' => Tools::displayPrice($total_convenience_fee_te, $this->context->currency, false), 'total_convenience_fee_tax' => Tools::displayPrice($total_convenience_fee_tax, $this->context->currency, false), 'service_products_price_tax_excl' => Tools::displayPrice( - $total_standard_products_tax_excl, + ($standalone_products_price_tax_excl + $hotel_standalone_products_price_tax_excl), $this->context->currency, false ), 'service_products_price_tax_incl' => Tools::displayPrice( - $total_standard_products_tax_incl, + ($standalone_products_price_tax_incl + $hotel_standalone_products_price_tax_incl), $this->context->currency, false ), diff --git a/classes/order/Order.php b/classes/order/Order.php index ca9ef9327..0ed9581a3 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -617,8 +617,7 @@ class OrderCore extends ObjectModel $selling_preference_type = null, $product_auto_add = null, $product_price_addition_type = null, - $ids_order_detail = [], - $service_product_context = null + $ids_order_detail = [] ) { $sql = 'SELECT *, od.`selling_preference_type` as selling_preference_type FROM `'._DB_PREFIX_.'order_detail` od @@ -635,37 +634,12 @@ class OrderCore extends ObjectModel if (!$is_booking && $selling_preference_type !== null) { $sql .= ' AND od.`selling_preference_type` = '. (int)$selling_preference_type; } - if (!$is_booking && $product_auto_add !== null) { + if (!$is_booking && $selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product_auto_add !== null) { $sql .= ' AND od.`product_auto_add` = '. (int)$product_auto_add; } - if (!$is_booking && $product_auto_add == 1 && $product_price_addition_type !== null) { + if (!$is_booking && $selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product_auto_add == 1 && $product_price_addition_type !== null) { $sql .= ' AND od.`product_price_addition_type` = '. (int)$product_price_addition_type; } - - if (!$is_booking && $service_product_context !== null) { - if ((int) $service_product_context === self::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) { - - $sql .= ' - AND EXISTS ( - SELECT 1 - FROM ' . _DB_PREFIX_ . 'service_product_order_detail spod - WHERE spod.id_order = od.id_order - AND spod.id_order_detail = od.id_order_detail - AND spod.id_htl_booking_detail > 0 - )'; - - } elseif ((int) $service_product_context === self::SERVICE_PRODUCT_CONTEXT_NON_ROOM) { - - $sql .= ' - AND EXISTS ( - SELECT 1 - FROM ' . _DB_PREFIX_ . 'service_product_order_detail spod - WHERE spod.id_order = od.id_order - AND spod.id_order_detail = od.id_order_detail - AND spod.id_htl_booking_detail = 0 - )'; - } - } } return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } @@ -1154,11 +1128,10 @@ class OrderCore extends ObjectModel $product_auto_add = null, $product_price_addition_type = null, $ids_order_detail = [], - $service_product_context = null ) { // update if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail, $service_product_context); + $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail); } $return = 0; @@ -1181,11 +1154,10 @@ class OrderCore extends ObjectModel $product_auto_add = null, $product_price_addition_type = null, $ids_order_detail = [], - $service_product_context = null ) { /* Retro-compatibility (now set directly on the validateOrder() method) */ if (!$products) { - $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail, $service_product_context); + $products = $this->getProductsDetail($bookingProducts, $selling_preference_type, $product_auto_add, $product_price_addition_type, $ids_order_detail); } $return = 0; diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index cc9e95339..f97c589fc 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -478,32 +478,11 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = array(); - $products = $this->getProducts(); - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - foreach ($products as $product) { - if ($product['is_booking_product'] - || $product['product_auto_add'] - || !Product::isSellableWithRoomType($product['selling_preference_type']) - ) { - continue; - } + $order_detail = $this->getProducts(); + $order_detail = array_filter($order_detail, function($v) { + return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); + }); - $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( - $product['id_order'], - $product['id_order_detail'] - ); - if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { - continue; - } - - foreach ($serviceProductDetail as $serviceProduct) { - if (!empty($serviceProduct['id_htl_booking_detail'])) { - $order_detail[] = $product; - break; - } - } - } $details = $order->getProductTaxesDetails($order_detail, false); if ($sum_composite_taxes) { @@ -632,30 +611,14 @@ class OrderInvoiceCore extends ObjectModel $breakdown = array(); $order_detail = array(); $products = $this->getProducts(); - $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - foreach ($products as $product) { - if ($product['is_booking_product'] - || !Product::isSellableAsStandalone($product['selling_preference_type']) - || !Product::isSellableWithHotel($product['selling_preference_type']) - ) { - continue; - } - - $serviceProductDetail = $objServiceProductOrderDetail->getServiceProductsInOrder( - $product['id_order'], - $product['id_order_detail'] - ); - if (!is_array($serviceProductDetail) || empty($serviceProductDetail)) { - continue; - } - - foreach ($serviceProductDetail as $serviceProduct) { - if (empty($serviceProduct['id_htl_booking_detail'])) { - $order_detail[] = $product; - break; - } - } - } + $order_detail = $this->getProducts(); + $order_detail = array_filter($order_detail, function($v) { + return (!$v['is_booking_product'] && ( + Product::isSellableAsStandalone($v['selling_preference_type']) + || Product::isSellableWithHotel($v['selling_preference_type']) + )); + }); + $details = $order->getProductTaxesDetails($order_detail, false); diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 23839e4e8..37b895353 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -660,104 +660,14 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $footer['service_products_price_tax_excl'] = 0; $footer['service_products_price_tax_incl'] = 0; if ($idsOrderDetail = array_column($order_details, 'id_order_detail')) { - $roomTypeSellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - $serviceSellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - - $footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail); - $footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail); - - foreach ($roomTypeSellingPreferenceTypes as $sellingPreferenceType) { - $footer['room_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['room_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['additional_service_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 0, - null, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['additional_service_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 0, - null, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['total_convenience_fee_te'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - $footer['total_convenience_fee_ti'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - 1, - Product::PRICE_ADDITION_TYPE_INDEPENDENT, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); - } - - foreach ($serviceSellingPreferenceTypes as $sellingPreferenceType) { - $footer['service_products_price_tax_excl'] += $this->order->getTotalProductsWithoutTaxes( - false, - false, - $sellingPreferenceType, - false, - false, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM - ); - $footer['service_products_price_tax_incl'] += $this->order->getTotalProductsWithTaxes( - false, - false, - $sellingPreferenceType, - false, - false, - $idsOrderDetail, - Order::SERVICE_PRODUCT_CONTEXT_NON_ROOM - ); - } - - $footer['additional_service_price_tax_excl'] += $totalDemandsPriceTE; - $footer['additional_service_price_tax_incl'] += $totalDemandsPriceTI; + $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); + $footer['room_price_tax_incl'] = $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); + $footer['service_products_price_tax_incl'] = $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; + $footer['additional_service_price_tax_incl'] = $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); + $footer['total_convenience_fee_ti'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail); } $footer['total_paid_real'] = $this->order_invoice->getTotalPaid(); diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 8f9a908ec..cbb03bf63 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -348,7 +348,7 @@ class ServiceProductCartDetail extends ObjectModel $productInfo['id_room'] = 0; } - if ($detailedInfo) { + if ($detailedInfo && $product['id_hotel']) { $objHotelBranchInformation = new HotelBranchInformation(); $hotelInfo = $objHotelBranchInformation->hotelBranchesInfo($language->id, 2, 1, $product['id_hotel']); $hotelInfo['location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 81fa7f340..d1682db6a 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -317,27 +317,14 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_te - )} - {assign var=room_services_price_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_ti - )} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + + {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} + {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl ))} - {assign var=total_standard_products_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} - {assign var=total_standard_products_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} {if isset($cart_htl_data) && $cart_htl_data} @@ -739,25 +726,11 @@ {assign var=room_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, true)} {assign var=room_price_tax_incl value=$order->getTotalProductsWithTaxes(false, true)} - {assign var=room_services_price_tax_excl value=( - $order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_te - )} - {assign var=room_services_price_tax_incl value=( - $order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED) - + $total_demands_price_ti - )} - {assign var=all_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false)} - {assign var=all_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false)} - {assign var=room_linked_services_price_tax_incl value=$order->getTotalProductsWithTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} - {assign var=room_linked_services_price_tax_excl value=$order->getTotalProductsWithoutTaxes(false, false, null, null, null, null, Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED)} + {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} + {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} - {assign var=total_standard_products_tax_incl value=( - $all_services_price_tax_incl - $room_linked_services_price_tax_incl - )} - {assign var=total_standard_products_tax_excl value=( - $all_services_price_tax_excl - $room_linked_services_price_tax_excl - )} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} From 0da72aefc9d4cbaec53c27558a6bb2741b90a99d Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 20 Mar 2026 18:59:04 +0530 Subject: [PATCH 10/76] Fixed: support per-room booking methods, update selling object type across order pages, and add default property & room type values --- .../orders/_current_cart_details_data.tpl | 14 +- .../controllers/products/configuration.tpl | 37 ++-- .../controllers/products/informations.tpl | 39 +++- classes/Product.php | 26 +++ classes/module/ModuleGraph.php | 3 + controllers/admin/AdminCartsController.php | 5 - controllers/admin/AdminOrdersController.php | 10 +- .../admin/AdminPPreferencesController.php | 8 - controllers/admin/AdminProductsController.php | 31 +++- controllers/front/CartController.php | 3 +- controllers/front/CategoryController.php | 8 + .../front/OrderConfirmationController.php | 1 + controllers/front/OrderDetailController.php | 5 + controllers/front/ProductController.php | 23 ++- install/data/db_structure.sql | 2 + js/admin/ppreferences.js | 6 +- modules/blockcart/ajax-cart.js | 49 ++++- modules/blockcart/blockcart.php | 6 + modules/blockcart/blockcart.tpl | 10 +- .../classes/HotelBookingDetail.php | 1 + .../classes/HotelBranchInformation.php | 32 ++++ .../classes/HotelCartBookingData.php | 15 +- .../classes/HotelHelper.php | 41 +++++ .../classes/HotelReservationSystemDb.php | 19 ++ .../classes/HotelRoomType.php | 13 +- .../classes/HotelRoomTypeSellingType.php | 102 +++++++++++ .../admin/AdminAddHotelController.php | 13 ++ ...minHotelRoomTypeSellingTypesController.php | 168 ++++++++++++++++++ .../AdminHotelRoomsBookingController.php | 21 ++- .../AdminOrderRefundRequestsController.php | 2 +- modules/hotelreservationsystem/define.php | 1 + .../hotelreservationsystem.php | 2 + .../views/js/admin/hotel_rooms_booking.js | 23 ++- .../admin/add_hotel/helpers/form/form.tpl | 37 ++-- .../helpers/view/_partials/booking-rooms.tpl | 36 ++-- .../helpers/view/view.tpl | 2 +- .../views/templates/hook/searchForm.tpl | 4 +- .../_partials/booking-form.tpl | 26 +-- .../_partials/occupancy_field.tpl | 18 +- .../_partials/order-room-detail.tpl | 30 ++-- .../_partials/room_type_list.tpl | 8 +- .../cart-total-block.tpl | 2 +- .../js/modules/blockcart/ajax-cart.js | 53 +++++- .../hotel-reservation-theme/js/occupancy.js | 42 ++++- themes/hotel-reservation-theme/js/product.js | 17 +- .../modules/blockcart/blockcart.tpl | 10 +- .../order-confirmation.tpl | 11 +- .../hotel-reservation-theme/order-detail.tpl | 33 ++-- .../hotel-reservation-theme/order-return.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 16 +- .../shopping-cart-detail.tpl | 11 +- 51 files changed, 895 insertions(+), 202 deletions(-) create mode 100644 modules/hotelreservationsystem/classes/HotelRoomTypeSellingType.php create mode 100644 modules/hotelreservationsystem/controllers/admin/AdminHotelRoomTypeSellingTypesController.php 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..9566bbfe1 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 @@ -37,9 +37,7 @@ - {if $occupancy_required_for_booking} - - {/if} + {* *} @@ -58,7 +56,11 @@ {assign var="is_full_date" value=($show_full_date && ($data['date_from']|date_format:'%D' == $data['date_to']|date_format:'%D'))} - {if $occupancy_required_for_booking} + {assign var=room_occ_required value=false} + {if isset($data.occupancy_required_for_booking)} + {assign var=room_occ_required value=$data.occupancy_required_for_booking} + {/if} + {if $room_occ_required} + {else} + {/if} @@ -55,14 +62,14 @@
{l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if}{l s='Room Image'} {l s='Room Type'} {l s='Duration'}{l s='Occupancy'}{l s='Occupancy / Quantity'} {l s='Unit Price (tax excl)'} {l s='Extra Services / Fees (tax excl)'}{l s='Total Rooms Price (tax excl)'}{dateFormat date=$data.date_from full=$is_full_date} - {dateFormat date=$data.date_to full=$is_full_date} + 1 + {assign var=shown_room_type_price value=$data.feature_price_tax_excl} diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index 7f0bc0f60..5e78cb1dc 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -21,9 +21,16 @@ *} {if isset($product->id)} + {if isset($htl_room_type['room_type_selling_type_name']) && $htl_room_type['room_type_selling_type_name']} + {assign var=attribute_type value=$htl_room_type['room_type_selling_type_name']} + {assign var=attribute_types value=$htl_room_type['room_type_selling_type_name']|cat:'s'} + {else} + {assign var=attribute_type value={l s='Room'}} + {assign var=attribute_types value={l s='Rooms'}} + {/if}
-

{l s='Rooms'}

+

{$attribute_types}

@@ -35,7 +42,7 @@
@@ -201,14 +208,14 @@
  • -  {l s='Create Rooms'} +  {l s='Create %s' sprintf=$attribute_types}
  • @@ -253,7 +260,7 @@
      -
    • {l s='Please save this room first to add dates.'}
    • +
    • {l s='Please save this %s first to add dates.' sprintf=$attribute_types}
    @@ -325,7 +332,7 @@ - +
    diff --git a/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl b/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl index fded1812c..6977cff00 100644 --- a/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl +++ b/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl @@ -14,7 +14,7 @@
    - +
    @@ -26,7 +26,7 @@
    {if isset($product_rules) && $product_rules|@count} {foreach from=$product_rules item='product_rule'} 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..381e81bec 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -81,11 +81,11 @@ - + - + @@ -104,7 +104,7 @@ @@ -134,10 +134,10 @@
    diff --git a/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl b/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl index d11710c85..32d0bc9a0 100644 --- a/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl +++ b/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl @@ -55,7 +55,7 @@   - {dateFormat date=$message.date_add full=0} - {$message.date_add|substr:11:5} {if $message.private}{l s='Private'}{/if} {if isset($message.file_name)}   {l s="Attachment"}{/if} - {if isset($message.product_name)}   {if isset($message.booking_product) && $message.booking_product}{l s="Room type:"}{else}{l s="Product:"}{/if} {$message.product_name|escape:'html':'UTF-8'} {/if} + {if isset($message.product_name)}   {if isset($message.booking_product) && $message.booking_product}{l s="Stay type:"}{else}{l s="Product:"}{/if} {$message.product_name|escape:'html':'UTF-8'} {/if}

    {$message.message|escape:'html':'UTF-8'|nl2br}

    diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 4f52451c7..1ecd5b9f5 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -358,7 +358,7 @@ {if $products AND count($products)}
    - {l s='Room types and services'} {count($products)} + {l s='Stay types and services'} {count($products)}
    {l s='Image'}{l s='Room Type'}{l s='Stay Type'} {l s='Hotel'} {l s='Duration'} {l s='occupancy'}{l s='Room price'}{l s='Stay price'} {l s='Extra services'} {l s='Total'}
    {dateFormat date=$room['date_from'] full=$is_full_date} - {dateFormat date=$room['date_to'] full=$is_full_date} - {if $room['adults']}{$room['adults']}{/if} {if $room['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$room['children']}}, {$room['children']} {if $room['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} + {if $stay['adults']}{$stay['adults']}{/if} {if $stay['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if {$stay['children']}}, {$stay['children']} {if $stay['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if} {displayWtPriceWithCurrency price=$room['feature_price_tax_excl'] currency=$currency}
    diff --git a/admin/themes/default/template/controllers/import/helpers/form/form.tpl b/admin/themes/default/template/controllers/import/helpers/form/form.tpl index 5d74f7313..a077ec3a2 100644 --- a/admin/themes/default/template/controllers/import/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/import/helpers/form/form.tpl @@ -315,10 +315,10 @@ {l s='Sample Hotels file'} - {l s='Sample Room Types file'} + {l s='Sample Stay Types file'} - {l s='Sample Rooms file'} + {l s='Sample Stays file'} {l s='Sample Service Products file'} diff --git a/admin/themes/default/template/controllers/normal_products/associations.tpl b/admin/themes/default/template/controllers/normal_products/associations.tpl index 52708b6f8..ddbaff453 100644 --- a/admin/themes/default/template/controllers/normal_products/associations.tpl +++ b/admin/themes/default/template/controllers/normal_products/associations.tpl @@ -46,13 +46,13 @@
    - {l s='Associations are used to display service product category wise on room type page when'} {l s='Category filter'} {l s='is enabled'} + {l s='Associations are used to display service product category wise on stay type page when'} {l s='Category filter'} {l s='is enabled'}
    {include file="controllers/products/multishop/checkbox.tpl" field="id_category_default" type="default"}
    diff --git a/admin/themes/default/template/controllers/normal_products/features.tpl b/admin/themes/default/template/controllers/normal_products/features.tpl index dc02a8aa8..04baf3c36 100644 --- a/admin/themes/default/template/controllers/normal_products/features.tpl +++ b/admin/themes/default/template/controllers/normal_products/features.tpl @@ -23,10 +23,10 @@ {if isset($product->id)}
    -

    {l s='Assign features to this room type'}

    +

    {l s='Assign features to this stay type'}

    - {l s='You can specify a value for each relevant feature regarding this room type. Empty fields will not be displayed.'}
    + {l s='You can specify a value for each relevant feature regarding this stay type. Empty fields will not be displayed.'}
    {l s='You can either create a specific value, or select among the existing pre-defined values you\'ve previously added.'}
    @@ -50,7 +50,7 @@
    {/foreach} + + AdminRoomTypeSellingObjects + diff --git a/install/langs/en/data/tab.xml b/install/langs/en/data/tab.xml index ab5391a0f..403df2844 100644 --- a/install/langs/en/data/tab.xml +++ b/install/langs/en/data/tab.xml @@ -22,6 +22,7 @@ + diff --git a/js/admin.js b/js/admin.js index 48507c79a..55ec83c73 100644 --- a/js/admin.js +++ b/js/admin.js @@ -576,6 +576,18 @@ function redirectSelectChange() showRedirectProductSelectOptions(true); } +function showBookingMehtodOption(show) +{ + if (show) { + $('.booking_method_product_options').fadeIn(); + $('#booking_method_select').show(); + $('#booking_method').prop('disabled', false); + } else { + $('.booking_method_product_options').fadeOut(); + $('#booking_method').prop('disabled', true); + } +} + function addRelatedProduct(id_product_to_add, product_name) { if (!id_product_to_add || id_product == id_product_to_add) diff --git a/mails/en/booking_extra_demands.tpl b/mails/en/booking_extra_demands.tpl index b43ac4bed..cc89a656e 100644 --- a/mails/en/booking_extra_demands.tpl +++ b/mails/en/booking_extra_demands.tpl @@ -2,10 +2,10 @@
    {$available_feature.name} - +
    - + - + @@ -26,7 +26,7 @@ {$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} + {l s='Stay'} - {$roomCount}
    {/if} @@ -50,7 +50,7 @@ {if !isset($room_demand_exists)} - + {/if} @@ -59,10 +59,10 @@
    {l s='Room Extra Demands Detail'}{l s='Stay Extra Demands Detail'}
    {l s='Room Type'}{l s='Stay Type'} {l s='Name'} {l s='Total'}
    {l s='(Tax excl.)'}
    {l s='No room extra demands added.'}{l s='No stay extra demands added.'}
    - + - + @@ -84,7 +84,7 @@ {$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} + {l s='Stay'} - {$roomCount}
    {/if} @@ -117,7 +117,7 @@ {if !isset($room_additinal_services_exists)} - + {/if} diff --git a/mails/en/booking_extra_demands.txt b/mails/en/booking_extra_demands.txt index 3139f8ce3..b81fc7bc4 100644 --- a/mails/en/booking_extra_demands.txt +++ b/mails/en/booking_extra_demands.txt @@ -1,6 +1,6 @@ {if isset($list)} {l s='Extra Demands Details'} - {l s='Room Type'} + {l s='Stay Type'} {l s='Extra demand name'} {l s='Total'} {l s='(Tax excl.)'} @@ -16,7 +16,7 @@ {$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} + {l s='Stay'} - {$roomCount}
    {/if} diff --git a/mails/en/booking_extra_demands_text.tpl b/mails/en/booking_extra_demands_text.tpl index 38d5b7320..e8ee4b5dc 100644 --- a/mails/en/booking_extra_demands_text.tpl +++ b/mails/en/booking_extra_demands_text.tpl @@ -1,8 +1,8 @@ {if isset($list) && $list} -{l s='Room Extra Demands Detail'} +{l s='Stay Extra Demands Detail'} -{l s='Room Type'} +{l s='Stay Type'} {l s='Name'} {l s='Total'} {l s='(Tax excl.)'} @@ -23,7 +23,7 @@ {$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} +{l s='Stay'} - {$roomCount} {/if} @@ -39,13 +39,13 @@ {/foreach} {if !isset($room_demand_exists)} -{l s='No room extra demands added.'} +{l s='No stay extra demands added.'} {/if} -{l s='Rooms Services Detail'} +{l s='Stays Services Detail'} -{l s='Room Type'} +{l s='Stay Type'} {l s='Name'} {l s='Qty'} {l s='Total'} @@ -66,7 +66,7 @@ {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} +{l s='Stay'} - {$roomCount} {/if} {$service['name']} @@ -87,6 +87,6 @@ {/foreach} {if !isset($room_additinal_services_exists)} -{l s='No room services added.'} +{l s='No stay services added.'} {/if} {/if} diff --git a/mails/en/bookings_refund_request_detail_admin.tpl b/mails/en/bookings_refund_request_detail_admin.tpl index 657124172..bdd382c89 100644 --- a/mails/en/bookings_refund_request_detail_admin.tpl +++ b/mails/en/bookings_refund_request_detail_admin.tpl @@ -2,11 +2,11 @@
    {l s='Rooms Services Detail'}{l s='Stays Services Detail'}
    {l s='Room Type'}{l s='Stay Type'} {l s='Name'} {l s='Qty'} {l s='Total'}
    {l s='No room services added.'}{l s='No stay services added.'}
    - + - - + + diff --git a/mails/en/bookings_refund_request_detail_admin_text.tpl b/mails/en/bookings_refund_request_detail_admin_text.tpl index 236cfacad..e5d75108f 100644 --- a/mails/en/bookings_refund_request_detail_admin_text.tpl +++ b/mails/en/bookings_refund_request_detail_admin_text.tpl @@ -1,8 +1,8 @@ {if isset($list) && $list} -{l s="Room Num"} +{l s="Stay Num"} -{l s="Room Type"} +{l s="Stay Type"} {l s="Hotel"} diff --git a/mails/en/bookings_refund_request_detail_customer.tpl b/mails/en/bookings_refund_request_detail_customer.tpl index 07be275d5..52d33a0f8 100644 --- a/mails/en/bookings_refund_request_detail_customer.tpl +++ b/mails/en/bookings_refund_request_detail_customer.tpl @@ -2,12 +2,12 @@
    {l s='Rooms Bookings Detail'}{l s='Stays Bookings Detail'}
    {l s="Room Num"}{l s="Room Type"}{l s="Stay Num"}{l s="Stay Type"} {l s="Hotel"} {l s="Duration"}
    - + - + - + diff --git a/mails/en/bookings_refund_request_detail_customer_text.tpl b/mails/en/bookings_refund_request_detail_customer_text.tpl index 51d0d3ea7..536982d28 100644 --- a/mails/en/bookings_refund_request_detail_customer_text.tpl +++ b/mails/en/bookings_refund_request_detail_customer_text.tpl @@ -1,13 +1,13 @@ {if isset($list) && $list} -{l s='Rooms Bookings Detail'} +{l s='Stays Bookings Detail'} -{l s="Room Type"} +{l s="Stay Type"} {l s="Hotel"} -{l s="Rooms Qty"} +{l s="Stays Qty"} {l s="Duration"} diff --git a/mails/en/hotel_booking_cart_data.tpl b/mails/en/hotel_booking_cart_data.tpl index 7f1d3eb67..f4e533aab 100644 --- a/mails/en/hotel_booking_cart_data.tpl +++ b/mails/en/hotel_booking_cart_data.tpl @@ -2,14 +2,14 @@
    {l s='Rooms Bookings Detail'}{l s='Stays Bookings Detail'}
    {l s="Room Type"}{l s="Stay Type"} {l s="Hotel"}{l s="Rooms Qty"}{l s="Stays Qty"} {l s="Duration"}
    - + - - - + + + - + diff --git a/mails/en/order_canceled.txt b/mails/en/order_canceled.txt index ac4074023..2cb8c69a7 100644 --- a/mails/en/order_canceled.txt +++ b/mails/en/order_canceled.txt @@ -9,7 +9,7 @@ been canceled. Here are your order details: Order reference: {order_name} Order total: {total_paid} -Total Rooms: {num_rooms} +Total Stays: {num_rooms} Hotel details: Hotel Name: {hotel_hotel_name} diff --git a/mails/en/order_conf_total_info.tpl b/mails/en/order_conf_total_info.tpl index 7c094a1aa..b25e22d69 100644 --- a/mails/en/order_conf_total_info.tpl +++ b/mails/en/order_conf_total_info.tpl @@ -2,7 +2,7 @@ {if isset($list['has_room_bookings']) && $list['has_room_bookings']} - + {/foreach} diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index d630c926a..243b6db3e 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -327,7 +327,7 @@ class DashGuestCycle extends Module 'order_id' => array('title' => $this->l('Order ID'), 'class' => 'text-center'), 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), - 'total' => array('title' => $this->l('Total Rooms'), 'class' => 'text-center'), + 'total' => array('title' => $this->l('Total Stays'), 'class' => 'text-center'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'order_total' => array('title' => $this->l('Order Total'), 'class' => 'text-right'), 'order_status' => array('title' => $this->l('Order Status'), 'class' => 'text-left'), diff --git a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl index 5d0ab4dfa..cf2f74964 100644 --- a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl @@ -73,7 +73,7 @@
    -
    +

    {l s='Revenue Per Available Room' mod='dashperformance'}

    diff --git a/modules/dashproducts/dashproducts.php b/modules/dashproducts/dashproducts.php index 3603141b8..d26b71a68 100644 --- a/modules/dashproducts/dashproducts.php +++ b/modules/dashproducts/dashproducts.php @@ -144,7 +144,7 @@ class DashProducts extends Module { $header = array( array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - array('title' => $this->l('Total Rooms'), 'class' => 'text-left'), + array('title' => $this->l('Total Stays'), 'class' => 'text-left'), array('title' => $this->l('Order'), 'class' => 'text-left'), array('title' => $this->l('Hotel'), 'class' => 'text-left'), array('title' => $this->l('Total').' '.$this->l('Tax excl.'), 'class' => 'text-left'), diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index ba300e3da..ba0046321 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -579,36 +579,6 @@ class HotelBranchInformation extends ObjectModel return Db::getInstance()->getRow($sql); } - public function getHotelPropertyTypeName($id_hotel = null, $idLang = null) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - if (!$id_hotel) { - $id_hotel = (int) $this->id; - } - - if (!$id_hotel) { - return false; - } - - $cache_key = 'HotelBranchInformation::getHotelPropertyTypeName'.(int)$id_hotel; - if(!Cache::isStored($cache_key)){ - $sql = 'SELECT hrtstl.`name` - FROM `'._DB_PREFIX_.'htl_branch_info` hbi - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_selling_type_lang` hrtstl - ON (hbi.`id_property_type` = hrtstl.`id_htl_room_type_selling_type` - AND hrtstl.`id_lang` = '.(int) $idLang.') - WHERE hbi.`id` = '.(int) $id_hotel; - - $res = Db::getInstance()->getValue($sql); - }else{ - $res = Cache::retrieve($cache_key); - } - return $res; - } - /** * [getHotelCategoryTree : Select category info by name of the category] * @param [string] $searchData [description] diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 3d896d0cf..0088d69eb 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -459,8 +459,8 @@ class HotelCartBookingData extends ObjectModel $chkQty = 0; $num_days = HotelHelper::getNumberOfDays($date_from, $date_to); $objServiceProductCartDetail = new ServiceProductCartDetail(); - $PS_ROOM_UNIT_SELECTION_TYPE = Product::getRoomTypeBookingMethod($id_product); - if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + $isOccupancyBooking = Product::isOccupancyBookingMethod($id_product); + if ($isOccupancyBooking) { $roomsRequired = count($occupancy); } else { $objRoomType = new HotelRoomType(); @@ -486,7 +486,7 @@ class HotelCartBookingData extends ObjectModel $obj_htl_cart_booking_data->date_to = $date_to; $obj_htl_cart_booking_data->booking_type = $booking_type; $obj_htl_cart_booking_data->comment = $comment; - if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if ($isOccupancyBooking) { $room_occupancy = array_shift($occupancy); $obj_htl_cart_booking_data->adults = $room_occupancy['adults']; $obj_htl_cart_booking_data->children = $room_occupancy['children']; @@ -590,8 +590,8 @@ class HotelCartBookingData extends ObjectModel 'id_cart' => $id_cart, 'id_guest' => $id_guest, ); - $PS_ROOM_UNIT_SELECTION_TYPE = Product::getRoomTypeBookingMethod($id_product); - if ($PS_ROOM_UNIT_SELECTION_TYPE == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + $isOccupancyBooking = Product::isOccupancyBookingMethod($id_product); + if ($isOccupancyBooking) { $roomsRequired = count($occupancy); } else { $roomsRequired = $occupancy; @@ -1171,7 +1171,7 @@ class HotelCartBookingData extends ObjectModel $cart_detail_data[$key]['date_from'] = $value['date_from']; $cart_detail_data[$key]['date_to'] = $value['date_to']; $cart_detail_data[$key]['occupancy_required_for_booking'] = - (Product::getRoomTypeBookingMethod($value['id_product']) == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY); + Product::isOccupancyBookingMethod($value['id_product']); $cart_detail_data[$key]['child_ages'] = json_decode($value['child_ages']); $occupancy = array( @@ -1557,7 +1557,9 @@ class HotelCartBookingData extends ObjectModel $cartHotelData[$prodKey]['total_num_rooms'] = 0; $cartHotelData[$prodKey]['id_product'] = $product['id_product']; $cartHotelData[$prodKey]['name'] = $objProduct->name; - $cartHotelData[$prodKey]['room_type_selling_type_name'] = $roomDetail['room_type_selling_type_name']; + $cartHotelData[$prodKey]['room_type_selling_object'] = $roomDetail['room_type_selling_object']; + $cartHotelData[$prodKey]['multiple_room_type_selling_object'] = $roomDetail['multiple_room_type_selling_object']; + $cartHotelData[$prodKey]['isOccupancyType'] = Product::isOccupancyBookingMethod($product['id_product']);; $cartHotelData[$prodKey]['unit_price'] = $unitPrice; $cartHotelData[$prodKey]['unit_price_without_reduction'] = $unitPriceWithoutReduction; $cartHotelData[$prodKey]['total_room_type_amount'] = 0; diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 6bdded18c..8d50d7086 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1368,25 +1368,26 @@ class HotelHelper return true; } - public function createHotelDefaultRoomTypeSellingTypes() + public function createHotelDefaultPropertyTypes() { $propertyTypes = array( 'Hotel', 'Motel', - ); - - $sellingTypes = array( - 'Room', + 'Resort', + 'Hostel', + 'Guest House', + 'Lodge', 'Apartment', - 'Villa', - 'Cottage', - 'Bungalow', + 'Vacation Rental', + 'Homestay', + 'Co-Living', + 'Camping', + 'Bed & Breakfast', ); $languages = Language::getLanguages(true); foreach ($propertyTypes as $typeName) { - $objType = new HotelRoomTypeSellingType(); - $objType->type = HotelRoomTypeSellingType::HOTEL_PROPERTY_TYPE; + $objType = new HotelPropertyType(); $objType->active = 1; foreach ($languages as $lang) { $objType->name[$lang['id_lang']] = $typeName; @@ -1394,9 +1395,31 @@ class HotelHelper $objType->save(); } - foreach ($sellingTypes as $typeName) { - $objType = new HotelRoomTypeSellingType(); - $objType->type = HotelRoomTypeSellingType::ROOM_TYPE_OBJECT_SELLING_TYPE; + return true; + } + + public function createHotelDefaultRoomSellingTypes() + { + $sellingObjects = array( + 'Room', + 'Apartment', + 'Villa', + 'Cottage', + 'Bungalow', + 'House', + 'Chalet', + 'Cabin', + 'Studio', + 'Penthouse', + 'Camping Pitch', + 'Overwater Bungalow', + 'Heritage Room', + 'Houseboat', + ); + + $languages = Language::getLanguages(true); + foreach ($sellingObjects as $typeName) { + $objType = new RoomTypeSellingObject(); $objType->active = 1; foreach ($languages as $lang) { $objType->name[$lang['id_lang']] = $typeName; @@ -2029,7 +2052,7 @@ class HotelHelper $product->show_at_front = 1; $product->is_virtual = 1; $product->indexed = 1; - $product->id_room_type_selling_object_type = 3; // assign default selling type as 'Per Room' + $product->id_room_type_selling_object= 1; $product->save(); $product_id = $product->id; @@ -2518,6 +2541,8 @@ class HotelHelper $this->saveDummyHotelFeatures($htl_id); $this->saveDummyProductsAndRelatedInfo($htl_id); $this->saveDummyServiceProductsAndRelatedInfo(); + $this->createHotelDefaultPropertyTypes(); + $this->createHotelDefaultRoomSellingTypes(); return true; } diff --git a/modules/hotelreservationsystem/classes/HotelPropertyType.php b/modules/hotelreservationsystem/classes/HotelPropertyType.php new file mode 100644 index 000000000..9d75dc6d9 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelPropertyType.php @@ -0,0 +1,112 @@ + 'htl_property_type', + 'primary' => 'id_htl_property_type', + 'multilang' => true, + 'fields' => array( + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true), + ), + ); + + public function delete() + { + Db::getInstance()->update( + 'htl_branch_info', + array('id_property_type' => 0), + '`id_property_type` = '.(int)$this->id + ); + + return parent::delete(); + } + + /** + * Get the property type name of a hotel in the requested language. + * + * @param int|null $idHotel + * @param int|null $idLang + * + * @return string + */ + public static function getPropertyType($idHotel = null, $idLang = null) + { + $idHotel = (int) $idHotel; + $idLang = $idLang ? (int) $idLang : (int) Context::getContext()->language->id; + $cacheKey = 'HotelPropertyType::getPropertyType'.$idHotel.'_'.$idLang; + + if (!Cache::isStored($cacheKey)) { + $sql = 'SELECT hptl.`name` + FROM `'._DB_PREFIX_.'htl_branch_info` hbi + LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl + ON (hbi.`id_property_type` = hptl.`id_htl_property_type` + AND hptl.`id_lang` = '.$idLang.') + WHERE hbi.`id` = '.$idHotel; + + Cache::store($cacheKey, Db::getInstance()->getValue($sql)); + } + + $propertyType = Cache::retrieve($cacheKey); + + return $propertyType ? $propertyType : Translate::getModuleTranslation('hotelreservationsystem', 'Hotel', 'HotelPropertyType'); + } + + /** + * Get the list of property types in the requested language. + * + * @param int|null $idLang + * @param bool $active + * + * @return array + */ + public static function getPropertyTypes($idLang = null, $active = true) + { + $idLang = $idLang ? (int) $idLang : (int) Context::getContext()->language->id; + $active = (bool) $active; + $cacheKey = 'HotelPropertyType::getPropertyTypes'.$idLang.'_'.(int) $active; + + if (!Cache::isStored($cacheKey)) { + $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hptl.`name` + FROM `'._DB_PREFIX_.'htl_property_type` hpt + LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl + ON (hpt.`id_htl_property_type` = hptl.`id_htl_property_type` + AND hptl.`id_lang` = '.$idLang.')'. + ($active ? ' WHERE hpt.`active` = 1' : ''). + ' ORDER BY hptl.`name` ASC'; + + Cache::store($cacheKey, Db::getInstance()->executeS($sql)); + } + + return Cache::retrieve($cacheKey); + } +} diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 06e9ee61d..5d754acad 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -118,20 +118,19 @@ class HotelReservationSystemDb PRIMARY KEY (`id`, `id_lang`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_selling_type` ( - `id_htl_room_type_selling_type` int(10) unsigned NOT NULL AUTO_INCREMENT, - `type` tinyint(2) unsigned NOT NULL, + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_property_type` ( + `id_htl_property_type` int(10) unsigned NOT NULL AUTO_INCREMENT, `active` tinyint(1) unsigned NOT NULL DEFAULT '1', `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, - PRIMARY KEY (`id_htl_room_type_selling_type`) + PRIMARY KEY (`id_htl_property_type`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_selling_type_lang` ( - `id_htl_room_type_selling_type` int(10) unsigned NOT NULL, + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_property_type_lang` ( + `id_htl_property_type` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `name` varchar(255) NOT NULL, - PRIMARY KEY (`id_htl_room_type_selling_type`, `id_lang`) + PRIMARY KEY (`id_htl_property_type`, `id_lang`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_cart_booking_data` ( @@ -630,8 +629,8 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_bed_type`, `'._DB_PREFIX_.'htl_bed_type_lang`, `'._DB_PREFIX_.'htl_room_type_bed_type`, - `'._DB_PREFIX_.'htl_room_type_selling_type`, - `'._DB_PREFIX_.'htl_room_type_selling_type_lang`, + `'._DB_PREFIX_.'htl_property_type`, + `'._DB_PREFIX_.'htl_property_type_lang`, `'._DB_PREFIX_.'htl_access`, `'._DB_PREFIX_.'htl_settings_link`, `'._DB_PREFIX_.'htl_settings_link_lang`' diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 3f345bc03..1f6e5fd6b 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -234,18 +234,29 @@ class HotelRoomType extends ObjectModel if (!$idLang) { $idLang = Context::getContext()->language->id; } - $sql = 'SELECT hrt.*, hbl.`hotel_name`, hrtstl.`name` AS `room_type_selling_type_name` + + $sql = 'SELECT hrt.*, hbl.`hotel_name`, + hrtstl.`name` AS `room_type_selling_object`, + CONCAT(hrtstl.`name`, "s") AS `multiple_room_type_selling_object` FROM `'._DB_PREFIX_.'htl_room_type` AS hrt INNER JOIN `'._DB_PREFIX_.'htl_branch_info_lang` AS hbl - ON (hbl.`id` = hrt.`id_hotel` AND hbl.`id_lang` = '.(int)$idLang.') + ON (hbl.`id` = hrt.`id_hotel` + AND hbl.`id_lang` = '.(int)$idLang.') LEFT JOIN `'._DB_PREFIX_.'product` AS p - ON (p.`id_product` = hrt.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_selling_type_lang` AS hrtstl - ON (hrtstl.`id_htl_room_type_selling_type` = p.`id_room_type_selling_object_type` - AND hrtstl.`id_lang` = '.(int)$idLang.') + ON (p.`id_product` = hrt.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object_lang` AS hrtstl + ON (hrtstl.`id_room_type_selling_object` = p.`id_room_type_selling_object` + AND hrtstl.`id_lang` = '.(int)$idLang.') WHERE hrt.`id_product` = '.(int)$id_product; - return Db::getInstance()->getRow($sql); + $result = Db::getInstance()->getRow($sql); + + if ($result && !$result['room_type_selling_object']) { + $result['room_type_selling_object'] = Translate::getModuleTranslation('hotelreservationsystem', 'Room', 'HotelRoomType'); + $result['multiple_room_type_selling_object'] = Translate::getModuleTranslation('hotelreservationsystem', 'Rooms', 'HotelRoomType'); + } + + return $result; } /** @@ -303,15 +314,15 @@ class HotelRoomType extends ObjectModel $idLang = Context::getContext()->language->id; } - $sql = 'SELECT pl.`name`, COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests`, hrtstl.`name` AS `room_type_selling_type_name` + $sql = 'SELECT pl.`name`, COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests`, hrtstl.`name` AS `room_type_selling_object`, CONCAT(hrtstl.`name`, "s") AS `multiple_room_type_selling_object` '.($position ? ', cp.`position`' : '').' '.($fullDetail ? ', pl.`link_rewrite`, pl.`description_short`' : '').' FROM `'._DB_PREFIX_.'htl_room_type` AS `hrt` INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS `hri` ON (hri.`id_product` = hrt.`id_product`)'; $sql .= ' INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (hrt.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.')'; $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product` AS p ON (p.`id_product` = hrt.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_selling_type_lang` AS hrtstl - ON (hrtstl.`id_htl_room_type_selling_type` = p.`id_room_type_selling_object_type` + LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object_lang` AS hrtstl + ON (hrtstl.`id_room_type_selling_object` = p.`id_room_type_selling_object` AND hrtstl.`id_lang` = '.(int)$idLang.')'; if ($position) { @@ -323,7 +334,17 @@ class HotelRoomType extends ObjectModel GROUP BY hrt.`id_product`'. ($position ? ' ORDER BY cp.`position`' : ''); - return Db::getInstance()->executeS($sql); + $results = Db::getInstance()->executeS($sql); + + foreach ($results as &$row) { + if (!$row['room_type_selling_object']) { + $row['room_type_selling_object'] = Translate::getModuleTranslation('hotelreservationsystem', 'Room', 'HotelRoomType'); + $row['multiple_room_type_selling_object'] = Translate::getModuleTranslation('hotelreservationsystem', 'Rooms', 'HotelRoomType'); + } + } + unset($row); + + return $results; } /** diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeSellingType.php b/modules/hotelreservationsystem/classes/HotelRoomTypeSellingType.php deleted file mode 100644 index 28ecf8503..000000000 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeSellingType.php +++ /dev/null @@ -1,102 +0,0 @@ - 'htl_room_type_selling_type', - 'primary' => 'id_htl_room_type_selling_type', - 'multilang' => true, - 'fields' => array( - 'type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true), - 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true), - ), - ); - - public static function getRoomTypeSellingObjectTypes($idLang = null, $active = true) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - $cache_key = 'HotelRoomTypeSellingType::getRoomTypeSellingObjectTypes'.$idLang.'_'.$active; - if(!Cache::isStored($cache_key)){ - $sql = 'SELECT hrtst.`id_htl_room_type_selling_type` AS `id_room_type_selling_object_type`, hrtstl.`name` - FROM `'._DB_PREFIX_.'htl_room_type_selling_type` hrtst - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_selling_type_lang` hrtstl - ON (hrtst.`id_htl_room_type_selling_type` = hrtstl.`id_htl_room_type_selling_type` - AND hrtstl.`id_lang` = '.(int) $idLang.') - WHERE hrtst.`type` = '.(int) self::ROOM_TYPE_OBJECT_SELLING_TYPE. - ($active ? ' AND hrtst.`active` = 1' : '').' - ORDER BY hrtstl.`name` ASC'; - - $res = Db::getInstance()->executeS($sql); - }else { - $res = Cache::retrieve($cache_key); - } - - return $res; - - } - - public static function getHotelPropertyTypes($idLang = null, $active = true) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - $cache_key = 'HotelRoomTypeSellingType::getHotelPropertyTypes'.$idLang.'_'.$active; - if(!Cache::isStored($cache_key)){ - - $sql = 'SELECT hrtst.`id_htl_room_type_selling_type` AS `id_property_type`, hrtstl.`name` - FROM `'._DB_PREFIX_.'htl_room_type_selling_type` hrtst - LEFT JOIN `'._DB_PREFIX_.'htl_room_type_selling_type_lang` hrtstl - ON (hrtst.`id_htl_room_type_selling_type` = hrtstl.`id_htl_room_type_selling_type` - AND hrtstl.`id_lang` = '.(int) $idLang.') - WHERE hrtst.`type` = '.(int) self::HOTEL_PROPERTY_TYPE. - ($active ? ' AND hrtst.`active` = 1' : '').' - ORDER BY hrtstl.`name` ASC'; - - $res = Db::getInstance()->executeS($sql); - - }else{ - $res = Cache::retrieve($cache_key); - } - - return $res; - - } - -} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 1a3ddceec..dc457008f 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -45,16 +45,24 @@ class AdminAddHotelController extends ModuleAdminController $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = aa.`id_state`)'; $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = aa.`id_country` AND cl.`id_lang` = '.(int) $this->context->language->id.')'; - - $this->_select = ' hbl.`hotel_name`, aa.`city`, s.`name` as `state_name`, cl.`name` as country_name'; + $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hrtsl + ON (hrtsl.`id_htl_property_type` = a.`id_property_type` AND hrtsl.`id_lang` = '.(int) $this->context->language->id.')'; + $this->_select = ' hrtsl.`name` as `property_type` , hbl.`hotel_name`, aa.`city`, s.`name` as `state_name`, cl.`name` as `country_name`'; $this->fields_list = array( 'id' => array( 'title' => $this->l('ID'), 'align' => 'center', ), + 'property_type' => array( + 'title' => $this->l('Property type'), + 'align' => 'center', + 'optional' => false, + 'filter_key' => 'hrtsl!name', + 'order_key' => 'hrtsl!name', + ), 'hotel_name' => array( - 'title' => $this->l('Hotel Name'), + 'title' => $this->l('Name'), 'align' => 'center', ), 'city' => array( @@ -222,7 +230,7 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['PS_MAX_CHECKOUT_OFFSET'] = (int) Configuration::get('PS_MAX_CHECKOUT_OFFSET'); $smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET'); $smartyVars['WK_ORDER_REFUND_ALLOWED'] = Configuration::get('WK_ORDER_REFUND_ALLOWED'); - $hotelPropertyTypes = HotelRoomTypeSellingType::getHotelPropertyTypes($this->context->language->id); + $hotelPropertyTypes = HotelPropertyType::getPropertyTypes($this->context->language->id); $smartyVars['hotel_property_types_info'] = $hotelPropertyTypes; $selectedHotelPropertyType = Tools::getValue('id_property_type'); if (!$selectedHotelPropertyType && isset($hotelBranchInfo)) { @@ -296,10 +304,6 @@ class AdminAddHotelController extends ModuleAdminController } } - if ($idHotelPropertyType == '' && $idHotelPropertyType == null && !Validate::isUnsignedId($idHotelPropertyType)) { - $this->errors[] = $this->l('Invalid property type.'); - } - foreach ($languages as $lang) { if ($shortDescription = html_entity_decode(Tools::getValue('short_description_'.$lang['id_lang']))) { if (!Validate::isCleanHtml($shortDescription)) { diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php new file mode 100644 index 000000000..b63cbb5e8 --- /dev/null +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php @@ -0,0 +1,127 @@ +bootstrap = true; + $this->table = 'htl_property_type'; + $this->className = 'HotelPropertyType'; + $this->identifier = 'id_htl_property_type'; + $this->lang = true; + $this->context = Context::getContext(); + $this->toolbar_title = $this->l('Property Types'); + + parent::__construct(); + + $this->fields_list = array( + 'id_htl_property_type' => array( + 'title' => $this->l('ID'), + 'align' => 'center', + 'class' => 'fixed-width-xs', + ), + 'name' => array( + 'title' => $this->l('Name'), + 'align' => 'left', + ), + 'active' => array( + 'title' => $this->l('Status'), + 'align' => 'center', + 'active' => 'status', + 'type' => 'bool', + 'orderby' => false, + ), + ); + + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array( + 'delete' => array( + 'text' => $this->l('Delete selected'), + 'confirm' => $this->l('Delete selected items?'), + 'icon' => 'icon-trash', + ), + ); + } + + public function initPageHeaderToolbar() + { + if (!$this->display || $this->display == 'list') { + $this->page_header_toolbar_btn['new_property_type'] = array( + 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, + 'desc' => $this->l('Add New Property', null, null, false), + 'icon' => 'process-icon-new', + ); + } + + parent::initPageHeaderToolbar(); + } + + public function renderForm() + { + if (!$this->loadObject(true)) { + return; + } + + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Property Type'), + 'icon' => 'icon-building', + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('Name'), + 'name' => 'name', + 'lang' => true, + 'required' => true, + 'hint' => $this->l('Displayed name for this property type.'), + ), + array( + 'type' => 'switch', + 'label' => $this->l('Status'), + 'name' => 'active', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled'), + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled'), + ), + ), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ); + + return parent::renderForm(); + } +} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index fd1b887da..d684fcf5f 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -375,7 +375,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController } $booking_data['rm_data'][$roomKey]['occupancy_required_for_booking'] = - (int) (Product::getRoomTypeBookingMethod($roomData['id_product']) == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY); + (int) Product::isOccupancyBookingMethod($roomData['id_product']); } $this->context->smarty->assign(array( @@ -576,13 +576,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if ($bookingData = $objBookingDetail->getBookingData($bookingParams)) { if ($bookingData['stats']['num_avail']) { $eventColor = '#7EC77B'; - $title = sprintf($this->l('Available Rooms : %s'), $bookingData['stats']['num_avail']); + $title = sprintf($this->l('Available Stays : %s'), $bookingData['stats']['num_avail']); } elseif ($bookingData['stats']['num_part_avai']) { $eventColor = '#FFC224'; - $title = sprintf($this->l('Partially Available Rooms : %s'), $bookingData['stats']['num_part_avai']); + $title = sprintf($this->l('Partially Available Stays : %s'), $bookingData['stats']['num_part_avai']); } else { $eventColor = '#FF3838'; - $title = sprintf($this->l('Available Rooms : %s'), $bookingData['stats']['num_avail']); + $title = sprintf($this->l('Available Stays : %s'), $bookingData['stats']['num_avail']); } $bookingData['date_from_format'] = Tools::displayDate($searchDateFrom); $bookingData['date_to_format'] = Tools::displayDate($searchDateTo); @@ -688,7 +688,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); $occupancy = Tools::getValue('occupancy'); - if (Product::getRoomTypeBookingMethod($id_product) == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + if (Product::isOccupancyBookingMethod($id_product)) { if (!Validate::isOccupancy($occupancy)) { $occupancy = array(); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 28268cf10..c25c6af0a 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -93,7 +93,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController if ($refundReqBookings) { $this->fields_list['num_rooms'] = array( - 'title' => $this->l('Total Rooms'), + 'title' => $this->l('Total Stays'), 'align' => 'center', 'havingFilter' => true, ); @@ -304,7 +304,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $objCustomer = new Customer($objOrderReturn->id_customer); $objOrder = new Order($objOrderReturn->id_order); $orderCurrency = new Currency($objOrder->id_currency); - + $objRoomType = new HotelRoomType(); $objRefundRules = new HotelOrderRefundRules(); if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrderReturn->id_order, $objOrderReturn->id)){ foreach ($refundReqBookings as &$booking) { @@ -313,6 +313,9 @@ class AdminOrderRefundRequestsController extends ModuleAdminController $objOrderReturn->id, $booking['id'] ); + + $roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($booking['id_product']); + $booking['room_type_info'] = $roomTypeInfo; $booking = array_merge($booking, array_shift($bookingCharges)); } } diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index aa436407f..c5e7b3df7 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -49,7 +49,7 @@ require_once 'classes/HotelRoomDisableDates.php'; require_once 'classes/HotelBranchRefundRules.php'; require_once 'classes/HotelBedType.php'; require_once 'classes/HotelRoomTypeBedType.php'; -require_once 'classes/HotelRoomTypeSellingType.php'; +require_once 'classes/HotelPropertyType.php'; // linked products require_once 'classes/RoomTypeServiceProduct.php'; diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index c361346b1..bf808b6a2 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -555,7 +555,7 @@ class HotelReservationSystem extends Module $this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelFeatures', 'Manage Hotel Features', 'AdminHotelReservationSystemManagement'); - $this->installTab('AdminHotelRoomTypeSellingTypes', 'Property & Room Types', 'AdminHotelReservationSystemManagement'); + $this->installTab('AdminHotelPropertyTypes', 'Manage Property Types', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminOrderRefundRules', 'Manage Order Refund Rules', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminOrderRefundRequests', 'Manage Order Refund Requests', 'AdminHotelReservationSystemManagement'); @@ -611,7 +611,6 @@ class HotelReservationSystem extends Module || !$objHtlHelper->insertDefaultHotelEntries() || !$objHtlHelper->createHotelRoomDefaultFeatures() || !$objHtlHelper->createHotelDefaultBedTypes() - || !$objHtlHelper->createHotelDefaultRoomTypeSellingTypes() || !$objHtlHelper->insertHotelCommonFeatures() ) { return false; diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index 2081956a3..5b865a0be 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -123,23 +123,25 @@
    -
    - -
    - + {if isset($hotel_property_types_info) && $hotel_property_types_info} +
    + +
    + +
    -
    + {/if}
    {l s='Rooms Booking Detail'}{l s='Stays Booking Detail'}
    {l s="Room Image"}{l s="Room Description"}{l s="Room Capcity"}{l s="Stay Image"}{l s="Stay Description"}{l s="Stay Capcity"} {l s="Unit Price"}{l s="Rooms Qty"}{l s="Stays Qty"} {l s="Check-in Date"} {l s="Check-out Date"} {l s="Total"}
    - {l s="Total Rooms Cost"} + {l s="Total Stays Cost"} {$list['room_price_tax_excl']} diff --git a/mails/en/order_conf_total_info_text.tpl b/mails/en/order_conf_total_info_text.tpl index ca048b8d0..f8917505b 100644 --- a/mails/en/order_conf_total_info_text.tpl +++ b/mails/en/order_conf_total_info_text.tpl @@ -1,5 +1,5 @@ {if isset($list['has_room_bookings']) && $list['has_room_bookings']} -{l s="Total Rooms Cost"} {$list['room_price_tax_excl']} +{l s="Total Stays Cost"} {$list['room_price_tax_excl']} {/if} {if isset($list['has_standalone_products']) && $list['has_standalone_products']} diff --git a/mails/en/order_hotel_detail.tpl b/mails/en/order_hotel_detail.tpl index 710025127..97c314cca 100644 --- a/mails/en/order_hotel_detail.tpl +++ b/mails/en/order_hotel_detail.tpl @@ -7,7 +7,7 @@ {l s='Hotel Name'}: {$list['hotel_name']}
    {l s='Hotel Phone'}: {$list['hotel_phone']}
    {l s='Hotel Email'}: {$list['hotel_email']}
    - {l s='Total Rooms'}: {$list['num_rooms']}
    + {l s='Total Stays'}: {$list['num_rooms']}

    {/if} \ No newline at end of file diff --git a/mails/en/order_hotel_detail_text.tpl b/mails/en/order_hotel_detail_text.tpl index e80d3bb4b..b44866e10 100644 --- a/mails/en/order_hotel_detail_text.tpl +++ b/mails/en/order_hotel_detail_text.tpl @@ -4,6 +4,6 @@ {l s='Hotel Name'}: {$list['hotel_name']} {l s='Hotel Phone'}: {$list['hotel_phone']} {l s='Hotel Email'}: {$list['hotel_email']} -{l s='Total Rooms'}: {$list['num_rooms']} +{l s='Total Stays'}: {$list['num_rooms']} {/if} \ No newline at end of file diff --git a/mails/en/order_refund_completed_admin.txt b/mails/en/order_refund_completed_admin.txt index 5ab3942c1..13e4ceedd 100755 --- a/mails/en/order_refund_completed_admin.txt +++ b/mails/en/order_refund_completed_admin.txt @@ -12,8 +12,8 @@ Transaction Id: {id_transaction} Booking details -Room Num -Room Type +Stay Num +Stay Type Hotel Duration {refundBookingHtml} diff --git a/mails/en/order_refund_completed_customer.txt b/mails/en/order_refund_completed_customer.txt index c063d7c0e..ee20a0bf9 100755 --- a/mails/en/order_refund_completed_customer.txt +++ b/mails/en/order_refund_completed_customer.txt @@ -12,9 +12,9 @@ Payment Mode: {payment_mode} Transaction Id: {id_transaction} Booking details -Room Type +Stay Type Hotel -Num. Rooms +Num. Stays Duration {refundBookingHtml} diff --git a/mails/en/order_refund_denied_admin.txt b/mails/en/order_refund_denied_admin.txt index 722b43415..b4bf0dc27 100755 --- a/mails/en/order_refund_denied_admin.txt +++ b/mails/en/order_refund_denied_admin.txt @@ -10,8 +10,8 @@ Refund Status: {status_name} Booking details -Room Num -Room Type +Stay Num +Stay Type Hotel Duration diff --git a/mails/en/order_refund_denied_customer.txt b/mails/en/order_refund_denied_customer.txt index cbd4410fe..b6c9b4318 100755 --- a/mails/en/order_refund_denied_customer.txt +++ b/mails/en/order_refund_denied_customer.txt @@ -11,9 +11,9 @@ Refund Status: {status_name} Booking details -Room Type +Stay Type Hotel -Num. Rooms +Num. Stays Duration {refundBookingHtml} diff --git a/mails/en/order_refund_pending_admin.txt b/mails/en/order_refund_pending_admin.txt index f520f617c..24b12dfe0 100755 --- a/mails/en/order_refund_pending_admin.txt +++ b/mails/en/order_refund_pending_admin.txt @@ -11,8 +11,8 @@ Cancelation Reason: {cancelation_reason} Requested Booking Cancellations -Room Num -Room Type +Stay Num +Stay Type Hotel Duration diff --git a/mails/en/order_refund_pending_customer.txt b/mails/en/order_refund_pending_customer.txt index 012c6e64e..fc93e00c1 100755 --- a/mails/en/order_refund_pending_customer.txt +++ b/mails/en/order_refund_pending_customer.txt @@ -10,9 +10,9 @@ Refund Status: {status_name} Booking details -Room Type +Stay Type Hotel -Num. Rooms +Num. Stays Duration {refundBookingHtml} diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index cd98e1d01..568aaf46b 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -136,6 +136,7 @@ var ajaxCart = { var dateFrom = $(this).attr('cat_rm_check_in'); var dateTo = $(this).attr('cat_rm_check_out'); + occupancy_required_for_booking = $(this).closest('.booking_room_fields').data('occupancy-required'); var occupancy = getBookingOccupancyDetails($(this).closest('.booking_room_fields'), true); /* By Webkul * Note : In our case minimalQuantity is taken from Qty. field @@ -378,9 +379,6 @@ var ajaxCart = { if ($('.cart_block_list').hasClass('collapsed')) this.expand(); - var isOccupancyBooking = getOccupancyRequiredForBooking($(callerElement).closest('.booking_room_fields')); - ajaxCart.lastOccupancyRequiredForBooking = isOccupancyBooking; - // create from data in order to manage adding different type of products var req = new FormData(); req.append('controller', 'cart'); @@ -401,7 +399,7 @@ var ajaxCart = { if (typeof dateTo != 'undefined') req.append('dateTo', dateTo); - if (isOccupancyBooking) { + if (occupancy_required_for_booking) { req.append('occupancy', JSON.stringify(occupancy)); } else { req.append('qty', ((occupancy && occupancy != null) ? occupancy : '1')); @@ -1206,28 +1204,22 @@ var ajaxCart = { $('#layer_cart_product_quantity').parent().show(); var product_quantity_text = ''; if(parseInt(product.booking_product)) { - var roomLabel = product.attribute_type || (typeof room_txt !== 'undefined' ? room_txt : 'Room'); - var roomsLabel = product.attribute_types || (typeof rooms_txt !== 'undefined' ? rooms_txt : roomLabel); - applyRoomLabelsToLayer(roomLabel, roomsLabel); let rooms = 0; let adults = 0; let children = 0; - var isOccupancyBooking = (typeof ajaxCart.lastOccupancyRequiredForBooking !== 'undefined') ? ajaxCart.lastOccupancyRequiredForBooking : occupancy_required_for_booking; - var $roomLabel = $('#layer_cart .layer_cart_room_txt .layer_cart_attribute_type'); - if ($roomLabel.length) { - var $labelContainer = $roomLabel.closest('.layer_cart_room_txt'); - var label = isOccupancyBooking ? $labelContainer.data('label-occupancy') : $labelContainer.data('label-quantity'); - if (label) { - $roomLabel.text(label); - } + if (typeof product.layer_cart_attribute_label !== 'undefined') { + $('#layer_cart .layer_cart_attribute_type').text(product.layer_cart_attribute_label); } - if (isOccupancyBooking) { + if(typeof product.layer_cart_room_success_msg !== 'undefined'){ + $('#layer_cart .layer_cart_room_success_msg').text(product.layer_cart_room_success_msg); + } + if (occupancy_required_for_booking) { $.each(product.occupancy, function(index, val) { rooms++; adults += parseInt(val.adults); children += parseInt(val.children); }); - product_quantity_text = getRoomTypeGuestOccupancyFormated(adults, children, rooms); + product_quantity_text = getRoomTypeGuestOccupancyFormated(adults, children, rooms,product.room_info.room_type_selling_object, product.room_info.multiple_room_type_selling_object); } else { product_quantity_text = product.occupancy; } @@ -1469,8 +1461,7 @@ function getBookingOccupancyDetails(bookingform, booking_product) { let occupancy; if (booking_product) { - var isOccupancyBooking = getOccupancyRequiredForBooking(bookingform); - if (isOccupancyBooking) { + if (occupancy_required_for_booking) { $('.booking_guest_occupancy_conatiner .dropdown').removeClass('open'); let selected_occupancy = $(bookingform).find(".occupancy_info_block.selected") if (selected_occupancy.length) { @@ -1513,29 +1504,3 @@ function getBookingOccupancyDetails(bookingform, booking_product) return occupancy; } -function applyRoomLabelsToLayer(roomLabel, roomsLabel) -{ - var $layer = $('#layer_cart'); - $layer.find('[data-room-msg-template]').each(function() { - var template = $(this).attr('data-room-msg-template'); - if (!template) { - return; - } - var text = template.replace(/__ROOMS__/g, roomsLabel).replace(/__ROOM__/g, roomLabel); - $(this).text(text); - }); -} - -function getOccupancyRequiredForBooking(bookingform) { - var value = occupancy_required_for_booking; - var $form = bookingform ? $(bookingform) : $('#booking-form').closest('.booking_room_fields'); - - if ($form.length) { - var dataVal = $form.data('occupancy-required'); - if (dataVal !== undefined) { - value = parseInt(dataVal) === 1; - } - } - - return value; -} diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 7cf3c7325..e2e975b2e 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -305,18 +305,20 @@ class Blockcart extends Module 'cart_default' ); $addedProduct['booking_product'] = $objProduct->booking_product; - $roomLabel = $objRoomType->getRoomTypeInfoByIdProduct($objProduct->id, $this->context->language->id); - if ($roomLabel) { - $addedProduct['attribute_type'] = $roomLabel['room_type_selling_type_name']; - $addedProduct['attribute_types'] = $roomLabel['room_type_selling_type_name'].'s'; - } + $room_info = $objRoomType->getRoomTypeInfoByIdProduct($objProduct->id, $this->context->language->id); + $addedProduct['room_info'] = $room_info; if ($objProduct->booking_product) { + $addedProduct['occupancy_required_for_booking'] = (bool) Product::isOccupancyBookingMethod($objProduct->id); + $addedProduct['layer_cart_attribute_label'] = $addedProduct['occupancy_required_for_booking'] + ? sprintf($this->l('%s occupancy'), $room_info['room_type_selling_object']) + : sprintf($this->l('%s quantity added'), $room_info['multiple_room_type_selling_object']); $price = $addedProduct['price'] = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $objProduct->id, $addedProduct['date_from'], $addedProduct['date_to'], $addedProduct['occupancy'] ); + $addedProduct['layer_cart_room_success_msg'] = sprintf($this->l('%s successfully added to your cart'), $room_info['room_type_selling_object']); if ($priceDisplayMethod == PS_TAX_EXC) { $addedProduct['price'] = Tools::displayPrice($price['total_price_tax_excl']); } else { @@ -473,6 +475,8 @@ class Blockcart extends Module $res = $this->getContentVars($params); if (is_array($res) && ($id_product = Tools::getValue('id_product')) && Configuration::get('PS_BLOCK_CART_SHOW_CROSSSELLING')) { + $isOccupancyType = Product::isOccupancyBookingMethod($id_product); + $this->context->smarty->assign('occupancy_required_for_booking', $isOccupancyType); $this->smarty->assign('orderProducts', OrderDetail::getCrossSells($id_product, $this->context->language->id, Configuration::get('PS_BLOCK_CART_XSELL_LIMIT'))); $res['crossSelling'] = $this->display(__FILE__, 'crossselling.tpl'); } diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 534e111ac..5e90552ea 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -33,8 +33,8 @@ {$total_products_in_cart} - - + + {if $cart_qties > 0} {if $priceDisplay == 1} @@ -196,7 +196,7 @@ {block name='blockcart_layer_cart_left_heading'}

    - {l s='Room successfully added to your cart' mod='blockcart'} + {l s='Stay successfully added to your cart' mod='blockcart'}

    {l s='Product successfully added to your cart' mod='blockcart'} @@ -223,14 +223,12 @@
    - - {if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}{l s='Room occupancy' mod='blockcart'}{else}{l s='Rooms quantity added' mod='blockcart'}{/if}  -  - + {if isset($occupancy_required_for_booking) && $occupancy_required_for_booking}{l s='Stay occupancy' mod='blockcart'}{else}{l s='Stays quantity added' mod='blockcart'}{/if}  -  {l s='Quantity' mod='blockcart'}  - 
    - {l s='Room type cost' mod='blockcart'}  -  + {l s='Stay type cost' mod='blockcart'}  -  {l s='Total' mod='blockcart'}  - 
    @@ -434,7 +432,7 @@ {addJsDefL name=qty_txt}{l s='Qty' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=duration_txt}{l s='Duration' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=capacity_txt}{l s='Capacity' mod='blockcart' js=1}{/addJsDefL} - {addJsDefL name=remove_rm_title}{l s='Remove this room from my cart' mod='blockcart' js=1}{/addJsDefL} + {addJsDefL name=remove_rm_title}{l s='Remove this stay from my cart' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=no_internet_txt}{l s='No internet. Please check your internet connection.' mod='blockcart' js=1}{/addJsDefL} {addJsDef rm_avail_process_lnk = $link->getModuleLink('blockcart', 'checkroomavailabilityajaxprocess')} diff --git a/modules/blockcart/cartrow.tpl b/modules/blockcart/cartrow.tpl index e909aaacf..47d370f90 100644 --- a/modules/blockcart/cartrow.tpl +++ b/modules/blockcart/cartrow.tpl @@ -89,7 +89,7 @@

    {$data_v['num_rm']} {convertPrice price=($data_v['amount'] + $data_v['demand_price'])}
    - - + + @@ -70,7 +70,7 @@
    {l s='Room No.' mod='hotelreservationsystem'}{l s='Room Type' mod='hotelreservationsystem'}{l s='Stay No.' mod='hotelreservationsystem'}{l s='Stay Type' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Amount (Tax excl.)' mod='hotelreservationsystem'}
    - + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index b8cc6ceee..a236ed232 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -16,10 +16,10 @@
    @@ -27,7 +27,7 @@
    {l s='Rooms Amount (Tax excl.):' mod='hotelreservationsystem'}{l s='Stays Amount (Tax excl.):' mod='hotelreservationsystem'} {if isset($cart_rooms_amount)}{convertPrice price=$cart_rooms_amount}{else}{convertPrice price=0}{/if}
    - + @@ -59,13 +59,13 @@ - - + {if $book_v.occupancy_required_for_booking} @@ -148,7 +148,7 @@ -
    {l s='%s No.' sprintf=$book_v['room_type_selling_type_name'] mod='hotelreservationsystem'}{l s='%s No.' sprintf=$book_v['room_type_selling_object'] mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Message' mod='hotelreservationsystem'} {l s='Allotment Type' mod='hotelreservationsystem'}
    {l s='Duration' mod='hotelreservationsystem'}{l s='%s No.' sprintf=$book_v['room_type_selling_type_name'] mod='hotelreservationsystem'}{l s='%s No.' sprintf=$book_v['room_type_selling_object'] mod='hotelreservationsystem'} {l s='Allotment Type' mod='hotelreservationsystem'}{l s='Guests' mod='hotelreservationsystem'}
    - + @@ -246,7 +246,7 @@
    {l s='%s No.' sprintf=$book_v['room_type_selling_type_name'] mod='hotelreservationsystem'}{l s='%s No.' sprintf=$book_v['room_type_selling_object'] mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Order' mod='hotelreservationsystem'} {l s='Message' mod='hotelreservationsystem'}
    - + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl index 11690bc24..f929dd4ff 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/search-stats.tpl @@ -1,12 +1,12 @@
    -
    +
    -

    {l s='Total Rooms' mod='hotelreservationsystem'}

    +

    {l s='Total Stays' mod='hotelreservationsystem'}

    {if isset($booking_data) && $booking_data}{$booking_data['stats']['total_rooms']|escape:'htmlall':'UTF-8'}{else}00{/if}

    @@ -15,7 +15,7 @@
    -

    {l s='Available Rooms' mod='hotelreservationsystem'}

    +

    {l s='Available Stays' mod='hotelreservationsystem'}

    {if isset($booking_data) && $booking_data}{$booking_data['stats']['num_avail']|escape:'htmlall':'UTF-8'}{else}00{/if}

    @@ -35,7 +35,7 @@
    -

    {l s='Booked Rooms' mod='hotelreservationsystem'}

    +

    {l s='Booked Stays' mod='hotelreservationsystem'}

    {if isset($booking_data) && $booking_data}{$booking_data['stats']['num_booked']|escape:'htmlall':'UTF-8'}{else}00{/if}

    @@ -47,7 +47,7 @@
    -

    {l s='Unavailable Rooms' mod='hotelreservationsystem'}

    +

    {l s='Unavailable Stays' mod='hotelreservationsystem'}

    {if isset($booking_data) && $booking_data}{$booking_data['stats']['num_unavail']|escape:'htmlall':'UTF-8'}{else}00{/if}

    @@ -56,7 +56,7 @@
    -

    {l s='In-Cart Rooms' mod='hotelreservationsystem'}

    +

    {l s='In-Cart Stays' mod='hotelreservationsystem'}

    {if isset($booking_data) && $booking_data}{$booking_data['stats']['num_cart']|escape:'htmlall':'UTF-8'}{else}00{/if}

    @@ -67,7 +67,7 @@
    - {l s='Available Rooms' mod='hotelreservationsystem'} + {l s='Available Stays' mod='hotelreservationsystem'}
    @@ -75,11 +75,11 @@
    - {l s='Unavailable Rooms' mod='hotelreservationsystem'} + {l s='Unavailable Stays' mod='hotelreservationsystem'}
    - {l s='Booked Rooms' mod='hotelreservationsystem'} + {l s='Booked Stays' mod='hotelreservationsystem'}
    \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl index 6dfd81da5..5d8cc6a22 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl @@ -231,7 +231,7 @@
    -
    {l s='Total Rooms' mod='hotelreservationsystem'}
    +
    {l s='Total Stays' mod='hotelreservationsystem'}
    @@ -239,15 +239,15 @@
    -
    {l s='Booked Rooms' mod='hotelreservationsystem'}
    +
    {l s='Booked Stays' mod='hotelreservationsystem'}
    -
    {l s='Unavailable Rooms' mod='hotelreservationsystem'}
    +
    {l s='Unavailable Stays' mod='hotelreservationsystem'}
    -
    {l s='Partially Available Rooms' mod='hotelreservationsystem'}
    +
    {l s='Partially Available Stays' mod='hotelreservationsystem'}
    diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index 6a2ee54fa..c5069eb3e 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -84,7 +84,7 @@ {if isset($refundReqBookings) && $refundReqBookings}
    - {l s='Total rooms' mod='hotelreservationsystem'} : + {l s='Total stays' mod='hotelreservationsystem'} :
    {$refundReqBookings|count} @@ -142,14 +142,14 @@ {if !$isRefundCompleted}
    {/if} - - + + {if !$isRefundCompleted} - + {/if} {if $hasOrderDiscountOrPayment || $isRefundCompleted} @@ -176,7 +176,7 @@ - + '.(!$this->id_hotel ? '' : '').' @@ -415,7 +415,7 @@ class StatsCheckUp extends Module $hotelsHtml .= ' - + '.(!$this->id_hotel ? '' : '').' diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index 4307437f9..1b601a5c8 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -308,7 +308,7 @@ class StatsProduct extends ModuleGraph '.$this->l('Room type name').' diff --git a/pdf/invoice.extra-demands-tab.tpl b/pdf/invoice.extra-demands-tab.tpl index e7edf7fa4..d89bfdcfb 100644 --- a/pdf/invoice.extra-demands-tab.tpl +++ b/pdf/invoice.extra-demands-tab.tpl @@ -27,10 +27,10 @@
    {l s='%s No.' sprintf=$book_v['room_type_selling_type_name'] mod='hotelreservationsystem'}{l s='%s No.' sprintf=$book_v['room_type_selling_object'] mod='hotelreservationsystem'} {l s='Status' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Message' mod='hotelreservationsystem'}{l s='Room num' mod='hotelreservationsystem'}{l s='Room type' mod='hotelreservationsystem'}{l s='Stay num' mod='hotelreservationsystem'}{l s='Stay type' mod='hotelreservationsystem'} {l s='Property' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Total cost (tax incl.)' mod='hotelreservationsystem'} {l s='Total paid amount (tax incl.)' mod='hotelreservationsystem'}{l s='Rooms cancelation charges' mod='hotelreservationsystem'}{l s='Stays cancelation charges' mod='hotelreservationsystem'}{l s='Refund amount' mod='hotelreservationsystem'} '.$this->l('Images').' '.$this->l('Orders').''.$this->l('Total rooms').''.$this->l('Total stays').' '.$this->l('Overall status').''.$this->l('Action').'
    '.$this->l('Images').' '.$this->l('Orders').''.$this->l('Total rooms').''.$this->l('Total stays').' '.$this->l('Overall status').'
    - '.$this->l('Total rooms').' + '.$this->l('Total stays').' '.$this->l('Action').' @@ -400,7 +400,7 @@ class StatsProduct extends ModuleGraph case 42: $this->_titles['main'][0] = $this->l('ID'); $this->_titles['main'][1] = $this->l('Room type name'); - $this->_titles['main'][2] = $this->l('Total Rooms'); + $this->_titles['main'][2] = $this->l('Total Stays'); break; } } diff --git a/modules/wkroomsearchblock/views/templates/hook/categoryPageSearch.tpl b/modules/wkroomsearchblock/views/templates/hook/categoryPageSearch.tpl index e0a1037a5..36f5f6ec9 100644 --- a/modules/wkroomsearchblock/views/templates/hook/categoryPageSearch.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/categoryPageSearch.tpl @@ -24,7 +24,7 @@ {if isset($hotels_info) && count($hotels_info)}
    -

    {l s='Search Rooms' mod='wkroomsearchblock'}

    +

    {l s='Search Stays' mod='wkroomsearchblock'}


    {block name='search_form'} diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index 26f90c9e8..6be773d60 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -164,7 +164,7 @@ {/foreach} {else}
    -
    {l s='Room - 1' mod='wkroomsearchblock'}
    +
    {l s='Stay - 1' mod='wkroomsearchblock'}
    @@ -226,7 +226,7 @@
    - {l s='Add Room' mod='wkroomsearchblock'} + {l s='Add Stay' mod='wkroomsearchblock'} @@ -240,7 +240,7 @@ {block name='search_form_submit'}
    {/block} diff --git a/pdf/invoice.addresses-tab.tpl b/pdf/invoice.addresses-tab.tpl index df5e70de0..67de4a81f 100644 --- a/pdf/invoice.addresses-tab.tpl +++ b/pdf/invoice.addresses-tab.tpl @@ -33,7 +33,7 @@ -->
    {if !empty($hotel_address)} - {l s='Hotel Detail' pdf='true'}

    + {l s='%s Detail' sprintf=$property_type pdf='true'}

    {$hotel_address} {/if}
    - + - + @@ -45,7 +45,7 @@ {/if}
    {l s='Room Additional Facilities Detail' pdf='true'}{l s='Stay Additional Facilities Detail' pdf='true'}
    {l s='Room Type' pdf='true'}{l s='Stay Type' pdf='true'} {l s='Name' pdf='true'} {l s='Tax rate(s)' pdf='true'} {l s='Total' pdf='true'}
    {l s='(Tax excl.)' pdf='true'}
    {$roomDemand['room_type_name']}
    {dateFormat date=$roomDemand['date_from']} {l s='to' pdf='true'} {dateFormat date=$roomDemand['date_to']}
    - {l s='Room' pdf='true'} - {$roomCount} + {l s='Stay' pdf='true'} - {$roomCount}
    @@ -72,10 +72,10 @@ - + - + @@ -92,7 +92,7 @@ {/if}
    {l s='Room Extra Services Detail' pdf='true'}{l s='Stay Extra Services Detail' pdf='true'}
    {l s='Room Type' pdf='true'}{l s='Stay Type' pdf='true'} {l s='Name' pdf='true'} {l s='Tax rate(s)' pdf='true'} {l s='Qty' pdf='true'} {$htlBookingServices['room_type_name']}
    {dateFormat date=$htlBookingServices['date_from']} {l s='to' pdf='true'} {dateFormat date=$htlBookingServices['date_to']}
    - {l s='Room' pdf='true'} - {$roomCount} + {l s='Stay' pdf='true'} - {$roomCount}
    diff --git a/pdf/invoice.product-tab.tpl b/pdf/invoice.product-tab.tpl index d31799c1f..8fb02e16e 100644 --- a/pdf/invoice.product-tab.tpl +++ b/pdf/invoice.product-tab.tpl @@ -27,20 +27,20 @@ - + {if $display_product_images} - + {/if} - + {* {if isset($layout.before_discount)} {/if} *} - + @@ -71,7 +71,7 @@
    {l s='Rooms Details' pdf='true'}{l s='Stays Details' pdf='true'}
    {l s='Room Image' pdf='true'}{l s='Stay Image' pdf='true'}{l s='Room Description' pdf='true'}{l s='Stay Description' pdf='true'} {l s='Tax Rate(s)' pdf='true'}{l s='Base price' pdf='true'}
    {l s='(Tax excl.)' pdf='true'}
    {l s='Unit Price' pdf='true'}
    {l s='(Tax excl.)' pdf='true'}
    {l s='Rooms' pdf='true'}{l s='Stays' 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'}

    - {if $rm_v['adults'] <= 9}0{$rm_v['adults']}{else}{$rm_v['adults']}{/if} {if $rm_v['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $rm_v['children']}, {if $rm_v['children'] <= 9}0{$rm_v['children']}{else} {$rm_v['children']}{/if} {if $rm_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
    {if $rm_v['num_rm'] <= 9}0{/if}{$rm_v['num_rm']} {if $rm_v['num_rm'] > 1}{l s='Rooms'}{else}{l s='Room'}{/if} + {if $rm_v['adults'] <= 9}0{$rm_v['adults']}{else}{$rm_v['adults']}{/if} {if $rm_v['adults'] > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $rm_v['children']}, {if $rm_v['children'] <= 9}0{$rm_v['children']}{else} {$rm_v['children']}{/if} {if $rm_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}
    {if $rm_v['num_rm'] <= 9}0{/if}{$rm_v['num_rm']} {if $rm_v['num_rm'] > 1}{l s='Stays'}{else}{l s='Stay'}{/if}

    diff --git a/pdf/invoice.tax-tab.tpl b/pdf/invoice.tax-tab.tpl index 511d8fe54..87d391bd6 100644 --- a/pdf/invoice.tax-tab.tpl +++ b/pdf/invoice.tax-tab.tpl @@ -68,7 +68,7 @@ {if $label == 'additional_services_tax'} {l s='Services' pdf='true'} {elseif $label == 'room_tax'} - {l s='Rooms' pdf='true'} + {l s='Stays' pdf='true'} {elseif $label == 'extra_demands_tax'} {l s='Facilities' pdf='true'} {elseif $label == 'convenience_fee_tax'} diff --git a/pdf/invoice.total-tab.tpl b/pdf/invoice.total-tab.tpl index b0a42eac7..6ce211442 100644 --- a/pdf/invoice.total-tab.tpl +++ b/pdf/invoice.total-tab.tpl @@ -27,7 +27,7 @@ {if isset($footer.room_price_tax_excl) && $footer.room_price_tax_excl}
    - {l s='Total Rooms Cost (tax excl.)' pdf='true'} + {l s='Total Stays Cost (tax excl.)' pdf='true'} {displayPrice currency=$order->id_currency price=$footer.room_price_tax_excl} @@ -67,7 +67,7 @@ {* {if isset($footer.product_taxes) && $footer.product_taxes}
    - {l s='Rooms Tax' pdf='true'} + {l s='Stays Tax' pdf='true'} {displayPrice currency=$order->id_currency price=($footer.room_price_tax_incl - $footer.room_price_tax_excl)} diff --git a/pdf/order-slip.product-tab.tpl b/pdf/order-slip.product-tab.tpl index 6ba4979dc..fb0b3b445 100644 --- a/pdf/order-slip.product-tab.tpl +++ b/pdf/order-slip.product-tab.tpl @@ -27,13 +27,13 @@ - + - + - + diff --git a/themes/hotel-reservation-theme/$tpl_dir./shopping-cart.tpl b/themes/hotel-reservation-theme/$tpl_dir./shopping-cart.tpl new file mode 100644 index 000000000..e69de29bb diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index 23dd74bc6..896a21643 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -19,15 +19,9 @@ * @copyright Since 2010 Webkul * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{if isset($room_type_info['room_type_selling_type_name']) && $room_type_info['room_type_selling_type_name']} - {assign var=attribute_types value=$room_type_info['room_type_selling_type_name']|cat:'s'} - {assign var=attribute_type value=$room_type_info['room_type_selling_type_name']} -{else} - {assign var=attribute_types value={l s='Rooms'}} - {assign var=attribute_type value={l s='Room'}} -{/if} +
    -
    +
    {block name='booking_form_content'} {block name='product_hidden_fields'} @@ -72,7 +66,7 @@ {include file="./occupancy_field.tpl"} {/block} {else} - + {block name='quantity_field'} {include file="./quantity_field.tpl"} {/block} @@ -85,7 +79,7 @@
    - +

    {convertPrice price=$rooms_price|floatval} + @@ -106,7 +100,7 @@

    {if isset($selected_service_product) && $selected_service_product}
    -

    {l s='Selected services'} {l s='(Per %s)' sprintf=$attribute_type}

    +

    {l s='Selected services'} {l s='(Per %s)' sprintf=$room_type_info['room_type_selling_object']}

    {foreach $selected_service_product as $product}
    @@ -127,7 +121,7 @@ {/if} {if isset($selected_demands) && $selected_demands}
    -

    {l s='Selected facilities'} {l s='(Per room)'}

    +

    {l s='Selected facilities'} {l s='(Per stay)'}

    {foreach $selected_demands as $product}
    @@ -149,7 +143,7 @@
    -
    {l s='Total price per %s' sprintf=$attribute_type}
    +
    {l s='Total price per %s' sprintf=$room_type_info['room_type_selling_object']}

    {displayPrice price=$demands_price_per_room}

    @@ -187,7 +181,7 @@ {$total_available_rooms|escape:'html':'UTF-8'} - {if $total_available_rooms > 1} {l s='%s left!' sprintf=$attribute_types} {else} {l s='%s left!' sprintf=$attribute_type} {/if} + {if $total_available_rooms > 1} {l s='%s left!' sprintf=$room_type_info['multiple_room_type_selling_object']} {else} {l s='%s left!' sprintf=$room_type_info['room_type_selling_object']} {/if}
    {/if} {/block} @@ -218,7 +212,7 @@ {/block} {else}
    - {l s='All %s sold out!' sprintf=$attribute_types} + {l s='All %s sold out!' sprintf=$room_type_info['multiple_room_type_selling_object']}
    {/if} {/if} @@ -346,7 +340,7 @@ {/if} {* {if $order_date_restrict}
    - {l s='You can\'t book rooms after %s.' sprintf=[{dateFormat date=$max_order_date full=0}]} + {l s='You can\'t book stays after %s.' sprintf=[{dateFormat date=$max_order_date full=0}]}
    {/if} *} diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index f74c3b628..4af332b9e 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -39,7 +39,7 @@ {if isset($selectedRoomDemands) && $selectedRoomDemands}
    -

    {l s='Add below facilities to the rooms for better hotel experience'}

    +

    {l s='Add below facilities to the %s for better hotel experience' sprintf=$room_type_info['room_type_selling_object']}

    {assign var=roomCount value=1} {foreach $selectedRoomDemands as $key => $roomDemand} @@ -47,7 +47,7 @@
    @@ -101,7 +101,7 @@ {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts}
    -

    {l s='Add below services to the rooms for better hotel experience'}

    +

    {l s='Add below services to the %s for better hotel experience' sprintf=$room_type_info['room_type_selling_object']}

    {assign var=roomCount value=1} {foreach $cartRooms as $key => $cartRoom} @@ -109,7 +109,7 @@
    diff --git a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl index 004f64a96..dd77bde6f 100644 --- a/themes/hotel-reservation-theme/_partials/occupancy_field.tpl +++ b/themes/hotel-reservation-theme/_partials/occupancy_field.tpl @@ -20,20 +20,12 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{if isset($room_type_info['room_type_selling_type_name']) && $room_type_info['room_type_selling_type_name']} - {assign var=attribute_type value=$room_type_info['room_type_selling_type_name']} - {assign var=attribute_types value=$room_type_info['room_type_selling_type_name']|cat:'s'} -{else} - {assign var=attribute_type value={l s='Room'}} - {assign var=attribute_types value={l s='Rooms'}} -{/if} -
    - + {/foreach} diff --git a/themes/hotel-reservation-theme/order-confirmation.tpl b/themes/hotel-reservation-theme/order-confirmation.tpl index 9ead821bb..89da2e402 100644 --- a/themes/hotel-reservation-theme/order-confirmation.tpl +++ b/themes/hotel-reservation-theme/order-confirmation.tpl @@ -64,7 +64,7 @@ {if $any_back_order} {if $shw_bo_msg}
    -

    *{l s='Some of your rooms are on back order. Please read the following message for rooms with status on backorder'}

    +

    *{l s='Some of your stays are on back order. Please read the following message for stays with status on backorder'}

    -  {$back_ord_msg}

    @@ -76,7 +76,7 @@
    {if isset($cart_htl_data)}
    -
    {l s='Room Details'}
    +
    {l s='Stay Details'}
    {foreach from=$cart_htl_data key=data_k item=data_v} {foreach from=$data_v['date_diff'] key=rm_k item=rm_v} @@ -100,13 +100,6 @@
    {assign var="is_full_date" value=($show_full_date && ($rm_v['data_form']|date_format:'%D' == $rm_v['data_to']|date_format:'%D'))} - {if isset($data_v['room_type_selling_type_name']) && $data_v['room_type_selling_type_name']} - {assign var=attribute_type value=$data_v['room_type_selling_type_name']} - {assign var=attribute_types value=$data_v['room_type_selling_type_name']|cat:'s'} - {else} - {assign var=attribute_type value={l s='Room'}} - {assign var=attribute_types value={l s='Rooms'}} - {/if}
    {l s='Check-in'}
    @@ -124,7 +117,7 @@
    -
    {if $rm_v.num_rm > 1}{$attribute_types|escape:'html':'UTF-8'}{else}{$attribute_type|escape:'html':'UTF-8'}{/if}
    +
    {if $rm_v.num_rm > 1}{$data_v['multiple_room_type_selling_object']|escape:'html':'UTF-8'}{else}{$data_v['room_type_selling_object']|escape:'html':'UTF-8'}{/if}
    {$rm_v.num_rm|string_format:'%02d'}
    @@ -173,7 +166,7 @@
    -

    {l s='Room cost'} :

    +

    {l s='%s cost' sprintf=$data_v['multiple_room_type_selling_object']} :

    diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index c6f5c2351..2e2489853 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -78,7 +78,7 @@ {if isset($obj_hotel_branch_information) && $obj_hotel_branch_information}

    - {l s='%s Details' sprintf=$property_name} + {l s='%s Details' sprintf=[$property_name|default:'Hotel']}
    @@ -102,7 +102,7 @@
    -
    {l s='%s Name' sprintf=$property_name}
    +
    {l s='%s Name' sprintf=[$property_name|default:'Hotel']}
    {$obj_hotel_branch_information->hotel_name}
    {l s='Phone Number'}
    @@ -176,7 +176,7 @@ {if isset($obj_hotel_branch_information)} @@ -1064,7 +1057,7 @@
    {if isset($hasRoomRefunds) && $hasRoomRefunds} - + {/if} {if isset($hasProductRefunds) && $hasProductRefunds} diff --git a/themes/hotel-reservation-theme/order-opc.tpl b/themes/hotel-reservation-theme/order-opc.tpl index 81115a208..8ccbfd473 100644 --- a/themes/hotel-reservation-theme/order-opc.tpl +++ b/themes/hotel-reservation-theme/order-opc.tpl @@ -62,7 +62,7 @@
    {block name='order_opc_rooms_summary_heading'}
    - {l s='Rooms & Price Summary'} + {l s='Stays & Price Summary'}
    {/block} @@ -340,7 +340,7 @@ {include file="$tpl_dir./errors.tpl"} {/block} -

    {l s='You have not added any rooms or products to your cart yet.'}

    +

    {l s='You have not added any stays or products to your cart yet.'}

    {/if} {block name='order_opc_js_vars'} {strip} diff --git a/themes/hotel-reservation-theme/order-return.tpl b/themes/hotel-reservation-theme/order-return.tpl index 6b14106e1..382a94dee 100644 --- a/themes/hotel-reservation-theme/order-return.tpl +++ b/themes/hotel-reservation-theme/order-return.tpl @@ -54,16 +54,16 @@ {block name='order_return_detail'} {if $refundReqBookings} {if isset($refundReqProducts) && $refundReqProducts} -

    {l s='Rooms refund requests'}

    +

    {l s='Stays refund requests'}

    {/if}
    {l s='Room Bookings Detail' pdf='true'}{l s='Stay Bookings Detail' pdf='true'}
    {l s='Room Type / Reference' pdf='true'}{l s='Stay Type / Reference' pdf='true'} {l s='Hotel' pdf='true'} {l s='Duration' pdf='true'}{l s='Num rooms' pdf='true'}{l s='Num stays' pdf='true'} {l s='Total Price' pdf='true'}
    {if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}
    {$data_v['num_rm']} {convertPrice price=($data_v['amount'] + $data_v['demand_price'])}
    {l s='Order'}{l s='Total rooms'}{l s='Total stays'}{l s='Total products'}
    - - + + - + {if $isRefundCompleted} @@ -72,7 +72,7 @@ {foreach from=$refundReqBookings item=$booking name=refundRequest} - + {assign var="is_full_date" value=($show_full_date && ($booking['date_from']|date_format:'%D' == $booking['date_to']|date_format:'%D'))} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index d7d9f8dc6..2afc79a4e 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -49,7 +49,7 @@ {/if} --> {if isset($adminActionDisplay) && $adminActionDisplay}
    -

    {l s='This room type is not visible to your customers.'} +

    {l s='This stay type is not visible to your customers.'} {l s='Publish'} @@ -205,18 +205,13 @@ {/block} {/if}

    - {if isset($room_type_info['room_type_selling_type_name']) && $room_type_info['room_type_selling_type_name']} - {assign var=attribute_type value=$room_type_info['room_type_selling_type_name']} - {else} - {assign var=attribute_type value={l s='Room'}} - {/if}
    {block name='product_tabs'}
    {l s='Rooms'}{l s='Room type'}{l s='Stays'}{l s='Stay type'} {l s='Property Name'} {l s='Duration'}{l s='Total rooms price (tax incl.)'}{l s='Total stays price (tax incl.)'} {l s='Extra services price (tax incl.)'}{l s='Refund amount'}
    {l s='Room'} - {$smarty.foreach.refundRequest.iteration|string_format:'%02d'}{l s='Stay'} - {$smarty.foreach.refundRequest.iteration|string_format:'%02d'} {$booking['room_type_name']|escape:'htmlall':'UTF-8'} {$booking['hotel_name']|escape:'htmlall':'UTF-8'}
    - {l s='Stay Type selection'} + {l s='Room Type selection'} diff --git a/admin/themes/default/template/controllers/cart_rules/product_rule.tpl b/admin/themes/default/template/controllers/cart_rules/product_rule.tpl index 3e0214739..10afca5a0 100644 --- a/admin/themes/default/template/controllers/cart_rules/product_rule.tpl +++ b/admin/themes/default/template/controllers/cart_rules/product_rule.tpl @@ -3,7 +3,7 @@ {* Everything is on a single line in order to avoid a empty space between the [ ] and the word *} - [{if $product_rule_type == 'products'}{l s='Stay types:'}{elseif $product_rule_type == 'categories'}{l s='Categories:'}{elseif $product_rule_type == 'manufacturers'}{l s='Manufacturers:'}{elseif $product_rule_type == 'suppliers'}{l s='Suppliers'}{elseif $product_rule_type == 'attributes'}{l s='Attributes'}{/if}] + [{if $product_rule_type == 'products'}{l s='Room types:'}{elseif $product_rule_type == 'categories'}{l s='Categories:'}{elseif $product_rule_type == 'manufacturers'}{l s='Manufacturers:'}{elseif $product_rule_type == 'suppliers'}{l s='Suppliers'}{elseif $product_rule_type == 'attributes'}{l s='Attributes'}{/if}]
    diff --git a/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl b/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl index 6977cff00..fded1812c 100644 --- a/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl +++ b/admin/themes/default/template/controllers/cart_rules/product_rule_group.tpl @@ -14,7 +14,7 @@
    - +
    @@ -26,7 +26,7 @@
    {if isset($product_rules) && $product_rules|@count} {foreach from=$product_rules item='product_rule'} 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 381e81bec..7a09fc693 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -81,7 +81,7 @@ - + diff --git a/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl b/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl index 32d0bc9a0..d11710c85 100644 --- a/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl +++ b/admin/themes/default/template/controllers/customer_threads/helpers/view/message.tpl @@ -55,7 +55,7 @@   - {dateFormat date=$message.date_add full=0} - {$message.date_add|substr:11:5} {if $message.private}{l s='Private'}{/if} {if isset($message.file_name)}   {l s="Attachment"}{/if} - {if isset($message.product_name)}   {if isset($message.booking_product) && $message.booking_product}{l s="Stay type:"}{else}{l s="Product:"}{/if} {$message.product_name|escape:'html':'UTF-8'} {/if} + {if isset($message.product_name)}   {if isset($message.booking_product) && $message.booking_product}{l s="Room type:"}{else}{l s="Product:"}{/if} {$message.product_name|escape:'html':'UTF-8'} {/if}

    {$message.message|escape:'html':'UTF-8'|nl2br}

    diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 1ecd5b9f5..4f52451c7 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -358,7 +358,7 @@ {if $products AND count($products)}
    - {l s='Stay types and services'} {count($products)} + {l s='Room types and services'} {count($products)}
    {l s='Image'}{l s='Stay Type'}{l s='Room Type'} {l s='Hotel'} {l s='Duration'} {l s='occupancy'}
    diff --git a/admin/themes/default/template/controllers/import/helpers/form/form.tpl b/admin/themes/default/template/controllers/import/helpers/form/form.tpl index a077ec3a2..61870cf91 100644 --- a/admin/themes/default/template/controllers/import/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/import/helpers/form/form.tpl @@ -315,7 +315,7 @@ {l s='Sample Hotels file'} - {l s='Sample Stay Types file'} + {l s='Sample Room Types file'} {l s='Sample Stays file'} diff --git a/admin/themes/default/template/controllers/normal_products/associations.tpl b/admin/themes/default/template/controllers/normal_products/associations.tpl index ddbaff453..52708b6f8 100644 --- a/admin/themes/default/template/controllers/normal_products/associations.tpl +++ b/admin/themes/default/template/controllers/normal_products/associations.tpl @@ -46,13 +46,13 @@
    - {l s='Associations are used to display service product category wise on stay type page when'} {l s='Category filter'} {l s='is enabled'} + {l s='Associations are used to display service product category wise on room type page when'} {l s='Category filter'} {l s='is enabled'}
    {include file="controllers/products/multishop/checkbox.tpl" field="id_category_default" type="default"}
    diff --git a/admin/themes/default/template/controllers/normal_products/features.tpl b/admin/themes/default/template/controllers/normal_products/features.tpl index 04baf3c36..7c3cf710d 100644 --- a/admin/themes/default/template/controllers/normal_products/features.tpl +++ b/admin/themes/default/template/controllers/normal_products/features.tpl @@ -23,10 +23,10 @@ {if isset($product->id)}
    -

    {l s='Assign features to this stay type'}

    +

    {l s='Assign features to this room type'}

    - {l s='You can specify a value for each relevant feature regarding this stay type. Empty fields will not be displayed.'}
    + {l s='You can specify a value for each relevant feature regarding this room type. Empty fields will not be displayed.'}
    {l s='You can either create a specific value, or select among the existing pre-defined values you\'ve previously added.'}
    diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 870e8e26c..1a008c063 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -30,8 +30,8 @@

    {l s='Information'}

    {if isset($display_common_field) && $display_common_field} -
    {l s='Warning, if you change the value of fields with an orange bullet %s, the value will be changed for all other shops for this stay type' sprintf=$bullet_common_field}
    +
    {l s='Warning, if you change the value of fields with an orange bullet %s, the value will be changed for all other shops for this room type' sprintf=$bullet_common_field}
    {/if} {include file="controllers/products/multishop/check_fields.tpl" product_tab="Informations"} @@ -103,7 +103,7 @@
    {include file="controllers/products/multishop/checkbox.tpl" field="name" type="default" multilang="true"}
    @@ -155,7 +155,7 @@
    - + @@ -62,7 +62,7 @@ - + diff --git a/mails/en/booking_extra_demands.txt b/mails/en/booking_extra_demands.txt index b81fc7bc4..a73cdf3ea 100644 --- a/mails/en/booking_extra_demands.txt +++ b/mails/en/booking_extra_demands.txt @@ -1,6 +1,6 @@ {if isset($list)} {l s='Extra Demands Details'} - {l s='Stay Type'} + {l s='Room Type'} {l s='Extra demand name'} {l s='Total'} {l s='(Tax excl.)'} diff --git a/mails/en/booking_extra_demands_text.tpl b/mails/en/booking_extra_demands_text.tpl index e8ee4b5dc..a9912e849 100644 --- a/mails/en/booking_extra_demands_text.tpl +++ b/mails/en/booking_extra_demands_text.tpl @@ -2,7 +2,7 @@ {l s='Stay Extra Demands Detail'} -{l s='Stay Type'} +{l s='Room Type'} {l s='Name'} {l s='Total'} {l s='(Tax excl.)'} @@ -45,7 +45,7 @@ {l s='Stays Services Detail'} -{l s='Stay Type'} +{l s='Room Type'} {l s='Name'} {l s='Qty'} {l s='Total'} diff --git a/mails/en/bookings_refund_request_detail_admin.tpl b/mails/en/bookings_refund_request_detail_admin.tpl index bdd382c89..15746d490 100644 --- a/mails/en/bookings_refund_request_detail_admin.tpl +++ b/mails/en/bookings_refund_request_detail_admin.tpl @@ -6,7 +6,7 @@ - + diff --git a/mails/en/bookings_refund_request_detail_admin_text.tpl b/mails/en/bookings_refund_request_detail_admin_text.tpl index e5d75108f..aeee78e27 100644 --- a/mails/en/bookings_refund_request_detail_admin_text.tpl +++ b/mails/en/bookings_refund_request_detail_admin_text.tpl @@ -2,7 +2,7 @@ {l s="Stay Num"} -{l s="Stay Type"} +{l s="Room Type"} {l s="Hotel"} diff --git a/mails/en/bookings_refund_request_detail_customer.tpl b/mails/en/bookings_refund_request_detail_customer.tpl index 52d33a0f8..52a0fa435 100644 --- a/mails/en/bookings_refund_request_detail_customer.tpl +++ b/mails/en/bookings_refund_request_detail_customer.tpl @@ -5,7 +5,7 @@ - + diff --git a/mails/en/bookings_refund_request_detail_customer_text.tpl b/mails/en/bookings_refund_request_detail_customer_text.tpl index 536982d28..6dd5f585e 100644 --- a/mails/en/bookings_refund_request_detail_customer_text.tpl +++ b/mails/en/bookings_refund_request_detail_customer_text.tpl @@ -3,7 +3,7 @@ {l s='Stays Bookings Detail'} -{l s="Stay Type"} +{l s="Room Type"} {l s="Hotel"} diff --git a/mails/en/order_refund_completed_admin.txt b/mails/en/order_refund_completed_admin.txt index 13e4ceedd..0962d1344 100755 --- a/mails/en/order_refund_completed_admin.txt +++ b/mails/en/order_refund_completed_admin.txt @@ -13,7 +13,7 @@ Transaction Id: {id_transaction} Booking details Stay Num -Stay Type +Room Type Hotel Duration {refundBookingHtml} diff --git a/mails/en/order_refund_completed_customer.txt b/mails/en/order_refund_completed_customer.txt index ee20a0bf9..ae0f5ecd3 100755 --- a/mails/en/order_refund_completed_customer.txt +++ b/mails/en/order_refund_completed_customer.txt @@ -12,7 +12,7 @@ Payment Mode: {payment_mode} Transaction Id: {id_transaction} Booking details -Stay Type +Room Type Hotel Num. Stays Duration diff --git a/mails/en/order_refund_denied_admin.txt b/mails/en/order_refund_denied_admin.txt index b4bf0dc27..402c08def 100755 --- a/mails/en/order_refund_denied_admin.txt +++ b/mails/en/order_refund_denied_admin.txt @@ -11,7 +11,7 @@ Refund Status: {status_name} Booking details Stay Num -Stay Type +Room Type Hotel Duration diff --git a/mails/en/order_refund_denied_customer.txt b/mails/en/order_refund_denied_customer.txt index b6c9b4318..a5d520607 100755 --- a/mails/en/order_refund_denied_customer.txt +++ b/mails/en/order_refund_denied_customer.txt @@ -11,7 +11,7 @@ Refund Status: {status_name} Booking details -Stay Type +Room Type Hotel Num. Stays Duration diff --git a/mails/en/order_refund_pending_admin.txt b/mails/en/order_refund_pending_admin.txt index 24b12dfe0..d3cfb2814 100755 --- a/mails/en/order_refund_pending_admin.txt +++ b/mails/en/order_refund_pending_admin.txt @@ -12,7 +12,7 @@ Cancelation Reason: {cancelation_reason} Requested Booking Cancellations Stay Num -Stay Type +Room Type Hotel Duration diff --git a/mails/en/order_refund_pending_customer.txt b/mails/en/order_refund_pending_customer.txt index fc93e00c1..c50c62b34 100755 --- a/mails/en/order_refund_pending_customer.txt +++ b/mails/en/order_refund_pending_customer.txt @@ -10,7 +10,7 @@ Refund Status: {status_name} Booking details -Stay Type +Room Type Hotel Num. Stays Duration diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 5e90552ea..fa9a8051b 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -228,7 +228,7 @@
    - {l s='Stay type cost' mod='blockcart'}  -  + {l s='Room type cost' mod='blockcart'}  -  {l s='Total' mod='blockcart'}  - 
    diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index 243b6db3e..b12d17126 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -140,9 +140,9 @@ class DashGuestCycle extends Module { $header = array( 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - 'room_num' => array('title' => $this->l('Room No.'), 'class' => 'text-center'), + 'room_num' => array('title' => $this->l('Stay No.'), 'class' => 'text-center'), 'room_type' => array('title' => $this->l('Room Type'), 'class' => 'text-left'), - 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), + 'hotel' => array('title' => $this->l('Property'), 'class' => 'text-left'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'check_out' => array('title' => $this->l('Check-out (LOS)'), 'class' => 'text-left'), 'order_id' => array('title' => $this->l('Order ID'), 'class' => 'text-center'), @@ -200,9 +200,9 @@ class DashGuestCycle extends Module { $header = array( 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - 'room_num' => array('title' => $this->l('Room No.'), 'class' => 'text-center'), + 'room_num' => array('title' => $this->l('Stay No.'), 'class' => 'text-center'), 'room_type' => array('title' => $this->l('Room Type'), 'class' => 'text-left'), - 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), + 'hotel' => array('title' => $this->l('Property'), 'class' => 'text-left'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'check_in' => array('title' => $this->l('Check-in (LOS)'), 'class' => 'text-left'), 'order_id' => array('title' => $this->l('Order ID'), 'class' => 'text-center'), @@ -260,9 +260,9 @@ class DashGuestCycle extends Module { $header = array( 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - 'room_num' => array('title' => $this->l('Room No.'), 'class' => 'text-center'), + 'room_num' => array('title' => $this->l('Stay No.'), 'class' => 'text-center'), 'room_type' => array('title' => $this->l('Room Type'), 'class' => 'text-left'), - 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), + 'hotel' => array('title' => $this->l('Property'), 'class' => 'text-left'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'check_in' => array('title' => $this->l('Check-in'), 'class' => 'text-left'), 'check_out' => array('title' => $this->l('Check-out (LOS)'), 'class' => 'text-left'), @@ -326,7 +326,7 @@ class DashGuestCycle extends Module $header = array( 'order_id' => array('title' => $this->l('Order ID'), 'class' => 'text-center'), 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), + 'hotel' => array('title' => $this->l('Property'), 'class' => 'text-left'), 'total' => array('title' => $this->l('Total Stays'), 'class' => 'text-center'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'order_total' => array('title' => $this->l('Order Total'), 'class' => 'text-right'), @@ -388,9 +388,9 @@ class DashGuestCycle extends Module $header = array( 'request_id' => array('title' => $this->l('Request ID'), 'class' => 'text-center'), 'name' => array('title' => $this->l('Customer Name'), 'class' => 'text-left'), - 'room_num' => array('title' => $this->l('Room No.'), 'class' => 'text-center'), + 'room_num' => array('title' => $this->l('Stay No.'), 'class' => 'text-center'), 'room_type' => array('title' => $this->l('Room Type'), 'class' => 'text-left'), - 'hotel' => array('title' => $this->l('Hotel'), 'class' => 'text-left'), + 'hotel' => array('title' => $this->l('Property'), 'class' => 'text-left'), 'guests' => array('title' => $this->l('Guests'), 'class' => 'text-center'), 'check_in' => array('title' => $this->l('Check-in'), 'class' => 'text-left'), 'check_out' => array('title' => $this->l('Check-out'), 'class' => 'text-left'), diff --git a/modules/dashinsights/dashinsights.php b/modules/dashinsights/dashinsights.php index 0b0676a5c..b15ea49c4 100644 --- a/modules/dashinsights/dashinsights.php +++ b/modules/dashinsights/dashinsights.php @@ -60,7 +60,7 @@ class DashInsights extends Module Media::addJsDef(array( 'hotel_txt' => $this->l('Hotel'), 'nights_booked_txt' => $this->l('Nights Booked'), - 'room_booked_txt' => $this->l('Rooms Booked'), + 'room_booked_txt' => $this->l('Stays Booked'), 'length_of_stay_txt' => $this->l('Length Of Stay'), 'total_nights_booked_txt' => $this->l('Total Nights Booked'), 'date_txt' => $this->l('Date'), @@ -127,7 +127,7 @@ class DashInsights extends Module $addressInfo = HotelBranchInformation::getAddress($idHotel, $this->context->language->id); $panelsLabel = sprintf('(%s, %s)', $objHotelBranchInformation->hotel_name, $addressInfo['city']); } else { - $panelsLabel = $this->l('(All Hotels)'); + $panelsLabel = $this->l('(All Properties)'); } $return = array( @@ -145,13 +145,13 @@ class DashInsights extends Module 'chart_type' => 'multibar_chart_dotw_dashinsights', 'data' => $daysOfTheWeekData, 'date_format' => $this->context->language->date_format_lite, - 'axis_labels' => array('y' => $this->l('Rooms occupied')), + 'axis_labels' => array('y' => $this->l('Stays occupied')), ), 'dashinsights_multibar_chart2' => array( 'chart_type' => 'multibar_chart_los_dashinsights', 'data' => $lengthOfStayData, 'date_format' => $this->context->language->date_format_lite, - 'axis_labels' => array('x' => $this->l('Length of stay'), 'y' => $this->l('Rooms occupied')), + 'axis_labels' => array('x' => $this->l('Length of stay'), 'y' => $this->l('Stays occupied')), ), ), ); @@ -164,10 +164,10 @@ class DashInsights extends Module $seriesWiseRoomNights = array(); if (Configuration::get('PS_DASHBOARD_SIMULATION')) { // set room nights demo data - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $allHotelSeriesInfo = array( 'data' => array(), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); foreach ($this->discreteDates as $discreteDate) { @@ -207,11 +207,11 @@ class DashInsights extends Module ); } } else { - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $idsHotel = $this->accessibleIdsHotel; $allHotelSeriesInfo = array( 'data' => AdminStatsController::getRoomNightsData($dateFrom, $dateTo, $idsHotel), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); $seriesWiseRoomNights[] = $allHotelSeriesInfo; @@ -271,10 +271,10 @@ class DashInsights extends Module $seriesWiseDaysOfTheWeek = array(); if (Configuration::get('PS_DASHBOARD_SIMULATION')) { // set room nights demo data - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $allHotelSeriesInfo = array( 'data' => array(), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); // 1 = SUN @@ -316,11 +316,11 @@ class DashInsights extends Module ); } } else { - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $idsHotel = $this->accessibleIdsHotel; $allHotelSeriesInfo = array( 'data' => AdminStatsController::getOccupiedRoomsForDaysOfTheWeek($dateFrom, $dateTo, $idsHotel), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); $seriesWiseDaysOfTheWeek[] = $allHotelSeriesInfo; @@ -348,7 +348,7 @@ class DashInsights extends Module $averageDaysOfTheWeekData = AdminStatsController::getOccupiedRoomsForDaysOfTheWeek($dateFrom, $dateTo, $idsHotel, true, true); $averageSeriesInfo = array( 'data' => $averageDaysOfTheWeekData, - 'label' => $this->l('Other Hotels Average'), + 'label' => $this->l('Other Properties Average'), ); $seriesWiseDaysOfTheWeek[] = $averageSeriesInfo; @@ -409,10 +409,10 @@ class DashInsights extends Module if (Configuration::get('PS_DASHBOARD_SIMULATION')) { // set room nights demo data - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $allHotelSeriesInfo = array( 'data' => array(), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); $roomsOccupied = array( @@ -486,11 +486,11 @@ class DashInsights extends Module ); } } else { - if ($idHotel == 0) { // if 'All Hotels' is selected + if ($idHotel == 0) { // if 'All Properties' is selected $idsHotel = $this->accessibleIdsHotel; $allHotelSeriesInfo = array( 'data' => AdminStatsController::getLengthOfStayInfo($day, $dateFrom, $dateTo, $idsHotel), - 'label' => $this->l('All Hotels'), + 'label' => $this->l('All Properties'), ); $seriesWiseLengthOfStay[] = $allHotelSeriesInfo; diff --git a/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl b/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl index d164c8393..27df76a44 100644 --- a/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl +++ b/modules/dashinsights/views/templates/hook/dashboard-zone-two.tpl @@ -35,7 +35,7 @@
    -

    {l s='Room Nights' mod='dashinsights'}

    +

    {l s='Stay Nights' mod='dashinsights'}

    diff --git a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl index cf2f74964..9beb30b62 100644 --- a/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashperformance/views/templates/hook/dashboard_zone_two.tpl @@ -75,7 +75,7 @@
    -

    {l s='Revenue Per Available Room' mod='dashperformance'}

    +

    {l s='Revenue Per Available Stay' mod='dashperformance'}

    -- @@ -85,7 +85,7 @@
    -

    {l s='Total Revenue Per Available Room' mod='dashperformance'}

    +

    {l s='Total Revenue Per Available Stay' mod='dashperformance'}

    -- diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 96c05607f..72e3e8198 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -86,8 +86,6 @@ class HotelBookingDetail extends ObjectModel const SEARCH_TYPE_OWS = 1; const SEARCH_TYPE_NORMAL = 2; - // - const PS_ROOM_UNIT_SELECTION_TYPE_DEFAULT = 0; const PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY = 1; const PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY = 2; diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php index b63cbb5e8..4992e4af0 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php @@ -100,9 +100,10 @@ class AdminHotelPropertyTypesController extends ModuleAdminController ), array( 'type' => 'switch', - 'label' => $this->l('Status'), + 'label' => $this->l('Enabled'), 'name' => 'active', 'is_bool' => true, + 'default_value' => 1, 'values' => array( array( 'id' => 'active_on', @@ -124,4 +125,38 @@ class AdminHotelPropertyTypesController extends ModuleAdminController return parent::renderForm(); } + + public function postProcess() + { + if (Tools::isSubmit('submitAdd'.$this->table)) { + $languages = Language::getLanguages(false); + $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); + $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); + $idPropertyType = Tools::getValue($this->identifier); + + if (!trim(Tools::getValue('name_'.$defaultLangId))) { + $this->errors[] = $this->l('Name is required at least in ').$objDefaultLanguage['name']; + } else { + foreach ($languages as $lang) { + if (trim(Tools::getValue('name_'.$lang['id_lang']))) { + if (!Validate::isGenericName(Tools::getValue('name_'.$lang['id_lang']))) { + $this->errors[] = $this->l('Invalid Name in ').$lang['name']; + } + } + } + } + + if ($idPropertyType) { + $this->display = 'edit'; + } else { + $this->display = 'add'; + } + + if (!$this->errors) { + parent::postProcess(); + } + } else { + parent::postProcess(); + } + } } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index d684fcf5f..78eb518db 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -41,8 +41,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController parent::__construct(); - $this->_conf[52] = $this->l('Room in the booking is successfully reallocated'); - $this->_conf[53] = $this->l('Room in the booking is successfully swapped'); + $this->_conf[52] = $this->l('Stay in the booking is successfully reallocated'); + $this->_conf[53] = $this->l('Stay in the booking is successfully swapped'); } public function init() @@ -946,7 +946,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $modal = array( 'modal_id' => 'room-reallocation-modal', 'modal_class' => 'modal-md order_detail_modal', - 'modal_title' => '  '.$this->l('Room Reallocation / Swap'), + 'modal_title' => '  '.$this->l('Stay Reallocation / Swap'), 'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_room_reallocation.tpl'), 'modal_actions' => null, ); @@ -994,14 +994,14 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'add_to_cart' => $this->l('Add To Cart', null, true), 'remove' => $this->l('Remove', null, true), 'noRoomTypeAvlTxt' => $this->l('No room type available.', null, true), - 'slct_rm_err' => $this->l('Please select a room first.', null, true), + 'slct_rm_err' => $this->l('Please select a stay first.', null, true), 'slct_rm_type_err' => $this->l('Please select a room type first.', null, true), 'product_added_cart_txt' => $this->l('Product added in cart', null, true), 'info_icon_path' => _MODULE_DIR_.$this->module->name.'/views/img/Slices/info-icon.svg', 'select_age_txt' => $this->l('Select age', null, true), 'under_1_age' => $this->l('Under 1', null, true), - 'room_txt' => $this->l('Room', null, true), - 'rooms_txt' => $this->l('Rooms', null, true), + 'room_txt' => $this->l('Stay', null, true), + 'rooms_txt' => $this->l('Stays', null, true), 'remove_txt' => $this->l('Remove', null, true), 'adult_txt' => $this->l('Adults', null, true), 'adults_txt' => $this->l('Adults', null, true), @@ -1010,7 +1010,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'below_txt' => $this->l('Below', null, true), 'years_txt' => $this->l('years', null, true), 'all_children_txt' => $this->l('All Children', null, true), - 'max_occupancy_reached_txt' => $this->l('Maximum room occupancy reached', null, true), + 'max_occupancy_reached_txt' => $this->l('Maximum stay occupancy reached', null, true), 'max_adults_txt' => $this->l('Maximum adult occupancy reached', null, true), 'max_children_txt' => $this->l('Maximum children occupancy reached', null, true), 'no_children_allowed_txt' => $this->l('Only adults can be accommodated', null, true), @@ -1018,13 +1018,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'PS_BACKDATE_ORDER_ALLOW' => $PS_BACKDATE_ORDER_ALLOW, // 'check_calender_var' => $check_calender_var, 'txtSomeErr' => $this->l('Some error occurred. Please try again.', null, true), - 'no_rm_avail_txt' => $this->l('No room available.', null, true), - 'no_realloc_rm_avail_txt' => $this->l('No room available for reallocation.', null, true), + 'no_rm_avail_txt' => $this->l('No stay available.', null, true), + 'no_realloc_rm_avail_txt' => $this->l('No stay available for reallocation.', null, true), 'no_realloc_rm_type_avail_txt' => $this->l('No room type available for reallocation.', null, true), - 'no_swap_rm_avail_txt' => $this->l('No room available for swap.', null, true), - 'select_room_txt' => $this->l('Select room', null, true), - 'added_room_success_txt' => $this->l('Room added to cart successfully', null, true), - 'removed_room_success_txt' => $this->l('Room removed from cart successfully', null, true), + 'no_swap_rm_avail_txt' => $this->l('No stay available for swap.', null, true), + 'select_room_txt' => $this->l('Select stay', null, true), + 'added_room_success_txt' => $this->l('Stay added to cart successfully', null, true), + 'removed_room_success_txt' => $this->l('Stay removed from cart successfully', null, true), ); if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS ) { $jsVars['is_occupancy_wise_search'] = true; diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl index 1c1b045d9..e562e5664 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-cart.tpl @@ -14,7 +14,7 @@
    - + diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index c5069eb3e..f8bef0905 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -143,7 +143,7 @@ {/if} - + diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 8c32d680a..073b5aae2 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -234,7 +234,7 @@ class StatsCheckUp extends Module 'DESCRIPTIONS' => array('name' => $this->l('Descriptions'), 'text' => $this->l('chars (without HTML)')), 'IMAGES' => array('name' => $this->l('Images'), 'text' => $this->l('images')), 'ORDERS' => array('name' => $this->l('Orders'), 'text' => $this->l('orders / month')), - 'TOTAL_ROOMS' => array('name' => $this->l('Total stays'), 'text' => $this->l('rooms')), + 'TOTAL_ROOMS' => array('name' => $this->l('Total stays'), 'text' => $this->l('stays')), ); $hotelsHtml = ' diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index 1b601a5c8..a8c634e12 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -356,9 +356,9 @@ class StatsProduct extends ModuleGraph if (Tools::getValue('export')) { $this->_titles['main'][] = $this->l('Date'); } - $this->_titles['main'][] = $this->l('Room nights'); + $this->_titles['main'][] = $this->l('Stay nights'); $this->_titles['main'][] = $this->l('Views (x100)'); - $this->_titles['y'] = $this->l('Room nights, Views (x100)'); + $this->_titles['y'] = $this->l('Stay nights, Views (x100)'); $this->_formats['y'] = 'd'; $this->query[0] = 'SELECT o.`date_add`, SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`)) AS total diff --git a/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php b/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php index 7d23d48e7..90528dfb1 100644 --- a/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php +++ b/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php @@ -223,7 +223,7 @@ class AdminHotelRoomModuleSettingController extends ModuleAdminController $this->fields_form = array( 'legend' => array( - 'title' => $this->l('Rooms Configuration'), + 'title' => $this->l('Stays Configuration'), 'icon' => 'icon-globe' ), 'input' => array( diff --git a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl index 6be773d60..1141721c3 100644 --- a/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl +++ b/modules/wkroomsearchblock/views/templates/hook/searchForm.tpl @@ -88,7 +88,7 @@ - + @@ -75,7 +75,7 @@ - + diff --git a/pdf/order-slip.product-tab.tpl b/pdf/order-slip.product-tab.tpl index fb0b3b445..67a02f0e0 100644 --- a/pdf/order-slip.product-tab.tpl +++ b/pdf/order-slip.product-tab.tpl @@ -30,7 +30,7 @@ - + diff --git a/themes/hotel-reservation-theme/_partials/room_type_list.tpl b/themes/hotel-reservation-theme/_partials/room_type_list.tpl index 528be5c56..1baf86f0a 100644 --- a/themes/hotel-reservation-theme/_partials/room_type_list.tpl +++ b/themes/hotel-reservation-theme/_partials/room_type_list.tpl @@ -152,7 +152,7 @@ {/foreach} {else}
    - {l s='No stay available for this hotel!'} + {l s='No stay available for this property!'}
    {/if} diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index 5e90552ea..fa9a8051b 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -228,7 +228,7 @@
    - {l s='Stay type cost' mod='blockcart'}  -  + {l s='Room type cost' mod='blockcart'}  -  {l s='Total' mod='blockcart'}  - 
    diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index 2e2489853..f7f03580a 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -577,12 +577,12 @@ {block name='order_detail_add_order_messages_form'}
    - +

    {if $service_products_formatted} - {l s='To add a comment about a stay type/product, please select one first.'} + {l s='To add a comment about a room type/product, please select one first.'} {else} - {l s='To add a comment about a stay type, please select one first.'} + {l s='To add a comment about a room type, please select one first.'} {/if}

    {l s='Stay Extra Demands Detail'}
    {l s='Stay Type'}{l s='Room Type'} {l s='Name'} {l s='Total'}
    {l s='(Tax excl.)'}
    {l s='Stays Services Detail'}
    {l s='Stay Type'}{l s='Room Type'} {l s='Name'} {l s='Qty'} {l s='Total'}
    {l s="Stay Num"}{l s="Stay Type"}{l s="Room Type"} {l s="Hotel"} {l s="Duration"}
    {l s='Stays Bookings Detail'}
    {l s="Stay Type"}{l s="Room Type"} {l s="Hotel"} {l s="Stays Qty"} {l s="Duration"}
    {l s='Stay No.' mod='hotelreservationsystem'}{l s='Stay Type' mod='hotelreservationsystem'}{l s='Room Type' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Amount (Tax excl.)' mod='hotelreservationsystem'} {l s='Stay num' mod='hotelreservationsystem'}{l s='Stay type' mod='hotelreservationsystem'}{l s='Room type' mod='hotelreservationsystem'} {l s='Property' mod='hotelreservationsystem'} {l s='Duration' mod='hotelreservationsystem'} {l s='Total cost (tax incl.)' mod='hotelreservationsystem'}{l s='Stay Additional Facilities Detail' pdf='true'}
    {l s='Stay Type' pdf='true'}{l s='Room Type' pdf='true'} {l s='Name' pdf='true'} {l s='Tax rate(s)' pdf='true'} {l s='Total' pdf='true'}
    {l s='(Tax excl.)' pdf='true'}
    {l s='Stay Extra Services Detail' pdf='true'}
    {l s='Stay Type' pdf='true'}{l s='Room Type' pdf='true'} {l s='Name' pdf='true'} {l s='Tax rate(s)' pdf='true'} {l s='Qty' pdf='true'}{l s='Stay Bookings Detail' pdf='true'}
    {l s='Stay Type / Reference' pdf='true'}{l s='Room Type / Reference' pdf='true'} {l s='Hotel' pdf='true'} {l s='Duration' pdf='true'} {l s='Num stays' pdf='true'}
    - + diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index 2afc79a4e..8453e6e82 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -49,7 +49,7 @@ {/if} --> {if isset($adminActionDisplay) && $adminActionDisplay} - {else} - {/if} diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index ce48b8773..917a164a0 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2283,6 +2283,7 @@ class AdminProductsControllerCore extends AdminController $_POST['description_short'] = strip_tags(Tools::getValue('description_short')); } $_POST['booking_method'] = Tools::getValue('booking_method_switch') ? (int)Tools::getValue('booking_method') : 0; + $_POST['id_room_type_selling_object'] = Tools::getValue('id_room_type_selling_object') ?? 0; // Check description short size without html $limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT'); From f98ad8ee82dfef25d58d5b315ebfc98de6f872cd Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Wed, 20 May 2026 14:57:42 +0530 Subject: [PATCH 14/76] replace hotel word to property --- .../controllers/access/helpers/form/form.tpl | 4 +-- .../orders/modals/_cancel_room_bookings.tpl | 2 +- controllers/admin/AdminImagesController.php | 6 ++-- controllers/admin/AdminImportController.php | 18 +++++----- .../admin/AdminOrderPreferencesController.php | 6 ++-- .../bookings_refund_request_detail_admin.tpl | 2 +- ...ookings_refund_request_detail_customer.tpl | 2 +- ...gs_refund_request_detail_customer_text.tpl | 2 +- mails/en/order_hotel_detail.tpl | 8 ++--- mails/en/order_hotel_detail_text.tpl | 8 ++--- modules/blockcart/blockcart.tpl | 2 +- modules/dashinsights/dashinsights.php | 2 +- modules/dashproducts/dashproducts.php | 8 ++--- ...minHotelConfigurationSettingController.php | 2 +- .../admin/AdminHotelFeaturePricesSettings.php | 2 +- .../AdminHotelGeneralSettingsController.php | 36 +++++++++---------- .../AdminHotelRoomsBookingController.php | 6 ++-- .../helpers/form/form.tpl | 8 ++--- .../helpers/view/view.tpl | 2 +- .../hotel_features/helpers/view/view.tpl | 2 +- .../hotel_rooms_booking/helpers/view/view.tpl | 6 ++-- .../admin/AdminHotelReviewHotelReview.php | 4 +-- .../statsbestcategories.php | 6 ++-- .../statsbestproducts/statsbestproducts.php | 2 +- modules/statscatalog/statscatalog.php | 4 +-- modules/statscheckup/statscheckup.php | 4 +-- .../AdminAboutHotelBlockSettingController.php | 8 ++--- .../AdminFeaturesModuleSettingController.php | 4 +-- .../wkhotelfeaturesblock.php | 4 +-- .../wkhotelfilterblock/wkhotelfilterblock.php | 2 +- .../AdminHotelRoomModuleSettingController.php | 20 +++++------ .../wkroomsearchblock/wkroomsearchblock.php | 6 ++-- ...minTestimonialsModuleSettingController.php | 4 +-- .../wktestimonialblock/wktestimonialblock.php | 4 +-- pdf/order-slip.product-tab.tpl | 2 +- .../modules/blockcart/blockcart.tpl | 2 +- .../hotel-reservation-theme/order-detail.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 2 +- 38 files changed, 107 insertions(+), 107 deletions(-) diff --git a/admin/themes/default/template/controllers/access/helpers/form/form.tpl b/admin/themes/default/template/controllers/access/helpers/form/form.tpl index d3f2a73f8..6d07fe6ee 100644 --- a/admin/themes/default/template/controllers/access/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/access/helpers/form/form.tpl @@ -261,11 +261,11 @@
    {if isset($hotels) && $hotels}
    -

    {l s='Hotel Permissions'}

    +

    {l s='Property Permissions'}

    {l s='Stays'}{l s='Stay type'}{l s='Room type'} {l s='Property Name'} {l s='Duration'} {l s='Total stays price (tax incl.)'}
    - + - + diff --git a/controllers/admin/AdminImagesController.php b/controllers/admin/AdminImagesController.php index 9298fa147..68631940d 100644 --- a/controllers/admin/AdminImagesController.php +++ b/controllers/admin/AdminImagesController.php @@ -86,7 +86,7 @@ class AdminImagesControllerCore extends AdminController 'orderby' => false ), 'hotels' => array( - 'title' => $this->l('Hotels'), + 'title' => $this->l('Properties'), 'align' => 'center', 'type' => 'bool', 'active' => 'hotels', @@ -301,7 +301,7 @@ class AdminImagesControllerCore extends AdminController ), array( 'type' => 'switch', - 'label' => $this->l('Hotels'), + 'label' => $this->l('Properties'), 'name' => 'hotels', 'required' => false, 'is_bool' => true, @@ -503,7 +503,7 @@ class AdminImagesControllerCore extends AdminController $types = array( 'categories' => $this->l('Categories'), 'products' => $this->l('Room Types/Products'), - 'hotels' => $this->l('Hotels'), + 'hotels' => $this->l('Properties'), // 'manufacturers' => $this->l('Manufacturers'), // 'suppliers' => $this->l('Suppliers'), // 'scenes' => $this->l('Scenes'), diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index fec2fd096..7345f0afe 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -78,7 +78,7 @@ class AdminImportControllerCore extends AdminController { $this->bootstrap = true; $this->entities = array( - $this->l('Hotels'), + $this->l('Properties'), $this->l('Room Types'), $this->l('Stays'), $this->l('Categories'), @@ -108,7 +108,7 @@ class AdminImportControllerCore extends AdminController 'parent' => Configuration::get('PS_HOME_CATEGORY'), ); break; - case $this->entities[$this->l('Hotels')]: + case $this->entities[$this->l('Properties')]: $this->required_fields = array( 'hotel_name', 'phone', @@ -132,7 +132,7 @@ class AdminImportControllerCore extends AdminController 'no' => array('label' => $this->l('Ignore this column')), 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active (0/1)')), - 'hotel_name' => array('label' => $this->l('Hotel Name *')), + 'hotel_name' => array('label' => $this->l('Property Name *')), 'short_description' => array('label' => $this->l('Short Description')), 'description' => array('label' => $this->l('Description')), 'phone' => array('label' => $this->l('Mobile phone *')), @@ -146,7 +146,7 @@ class AdminImportControllerCore extends AdminController 'city' => array('label' => $this->l('City *')), 'postcode' => array('label' => $this->l('Zip Code *')), 'fax' => array('label' => $this->l('Fax')), - 'policies' => array('label' => $this->l('Hotel Policies')), + 'policies' => array('label' => $this->l('Property Policies')), 'active_refund' => array('label' => $this->l('Allow Refund (0 = No, 1 = Yes)')), 'refund_ids' => array('label' => $this->l('Refund IDs (x,y,z...)')), 'max_checkout_offset' => array('label' => $this->l('Maximum checkout offset')), @@ -169,7 +169,7 @@ class AdminImportControllerCore extends AdminController 'id' => array('label' => $this->l('ID')), 'active' => array('label' => $this->l('Active (0/1)')), 'name' => array('label' => $this->l('Name *')), - 'id_hotel' => array('label' => $this->l('Hotel ID *')), + 'id_hotel' => array('label' => $this->l('Property ID *')), 'price' => array('label' => $this->l('Pre-tax retail price')), 'wholesale_price' => array('label' => $this->l('Pre-tax operating cost')), 'id_tax_rules_group' => array('label' => $this->l('Tax rule ID')), @@ -1479,8 +1479,8 @@ class AdminImportControllerCore extends AdminController } } } else { - $this->warnings[] = $this->l('Hotel creation for the ').$objCountry->name. - $this->l(' is currently unavailable. Kindly activate the country for hotel creation.'); + $this->warnings[] = $this->l('Property creation for the ').$objCountry->name. + $this->l(' is currently unavailable. Kindly activate the country for property creation.'); } } } @@ -3297,7 +3297,7 @@ class AdminImportControllerCore extends AdminController } } break; - case $this->entities[$this->l('Hotels')]: + case $this->entities[$this->l('Properties')]: Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_info_lang`'); Db::getInstance()->execute('DELETE c, cl FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.id_category = cl.id_category @@ -3494,7 +3494,7 @@ class AdminImportControllerCore extends AdminController $import_type = false; Db::getInstance()->disableCache(); switch ((int)Tools::getValue('entity')) { - case $this->entities[$import_type = $this->l('Hotels')]: + case $this->entities[$import_type = $this->l('Properties')]: $this->hotelImport(); $this->clearSmartyCache(); break; diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index d3000dea1..d16123ec9 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -330,7 +330,7 @@ class AdminOrderPreferencesControllerCore extends AdminController ), array( 'value' => Product::STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL, - 'name' => $this->l('Hotel Address') + 'name' => $this->l('Property Address') ), array( 'value' => Product::STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOM, @@ -374,8 +374,8 @@ class AdminOrderPreferencesControllerCore extends AdminController 'identifier' => 'value', 'js' => "changeStandardProductAddressType()", 'hint' => $this->l('Select address for standard product tax calculation, this will be used to calculate the tax for the standard product price.'), - 'desc' => $this->l('The selected address will be used to calculate tax for standard products. To change the hotel address, update the "Primary Hotel" in the'). - ' '.$this->l('Hotel General Configuration.').'' + 'desc' => $this->l('The selected address will be used to calculate tax for standard products. To change the property address, update the "Primary Property" in the'). + ' '.$this->l('Property General Configuration.').'' ), 'PS_STANDARD_PRODUCT_ORDER_ADDRESS' => array( 'title' => $this->l('Custom address for tax calculation'), diff --git a/mails/en/bookings_refund_request_detail_admin.tpl b/mails/en/bookings_refund_request_detail_admin.tpl index 15746d490..7c437554e 100644 --- a/mails/en/bookings_refund_request_detail_admin.tpl +++ b/mails/en/bookings_refund_request_detail_admin.tpl @@ -7,7 +7,7 @@ - + diff --git a/mails/en/bookings_refund_request_detail_customer.tpl b/mails/en/bookings_refund_request_detail_customer.tpl index 52a0fa435..6f6f70f03 100644 --- a/mails/en/bookings_refund_request_detail_customer.tpl +++ b/mails/en/bookings_refund_request_detail_customer.tpl @@ -6,7 +6,7 @@ - + diff --git a/mails/en/bookings_refund_request_detail_customer_text.tpl b/mails/en/bookings_refund_request_detail_customer_text.tpl index 6dd5f585e..0b81bbaea 100644 --- a/mails/en/bookings_refund_request_detail_customer_text.tpl +++ b/mails/en/bookings_refund_request_detail_customer_text.tpl @@ -5,7 +5,7 @@ {l s="Room Type"} -{l s="Hotel"} +{l s="Property Name"} {l s="Stays Qty"} diff --git a/mails/en/order_hotel_detail.tpl b/mails/en/order_hotel_detail.tpl index 97c314cca..7def2f0e4 100644 --- a/mails/en/order_hotel_detail.tpl +++ b/mails/en/order_hotel_detail.tpl @@ -1,12 +1,12 @@ {if isset($list['hotel_name']) && $list['hotel_name']}

    - {l s='Hotel details'}: + {l s='Property details'}:

    - {l s='Hotel Name'}: {$list['hotel_name']}
    - {l s='Hotel Phone'}: {$list['hotel_phone']}
    - {l s='Hotel Email'}: {$list['hotel_email']}
    + {l s='Property Name'}: {$list['hotel_name']}
    + {l s='Property Phone'}: {$list['hotel_phone']}
    + {l s='Property Email'}: {$list['hotel_email']}
    {l s='Total Stays'}: {$list['num_rooms']}

    diff --git a/mails/en/order_hotel_detail_text.tpl b/mails/en/order_hotel_detail_text.tpl index b44866e10..7dc951483 100644 --- a/mails/en/order_hotel_detail_text.tpl +++ b/mails/en/order_hotel_detail_text.tpl @@ -1,9 +1,9 @@ {if isset($list['hotel_name']) && $list['hotel_name']} -{l s='Hotel details'}: +{l s='Property details'}: -{l s='Hotel Name'}: {$list['hotel_name']} -{l s='Hotel Phone'}: {$list['hotel_phone']} -{l s='Hotel Email'}: {$list['hotel_email']} +{l s='Property Name'}: {$list['hotel_name']} +{l s='Property Phone'}: {$list['hotel_phone']} +{l s='Property Email'}: {$list['hotel_email']} {l s='Total Stays'}: {$list['num_rooms']} {/if} \ No newline at end of file diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index fa9a8051b..ca1901956 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -215,7 +215,7 @@
    - {l s='Hotel Name' mod='blockcart'}  -  + {l s='Property Name' mod='blockcart'}  - 
    diff --git a/modules/dashinsights/dashinsights.php b/modules/dashinsights/dashinsights.php index b15ea49c4..e9c99498c 100644 --- a/modules/dashinsights/dashinsights.php +++ b/modules/dashinsights/dashinsights.php @@ -58,7 +58,7 @@ class DashInsights extends Module { if (Tools::getValue('controller') == 'AdminDashboard') { Media::addJsDef(array( - 'hotel_txt' => $this->l('Hotel'), + 'hotel_txt' => $this->l('Property'), 'nights_booked_txt' => $this->l('Nights Booked'), 'room_booked_txt' => $this->l('Stays Booked'), 'length_of_stay_txt' => $this->l('Length Of Stay'), diff --git a/modules/dashproducts/dashproducts.php b/modules/dashproducts/dashproducts.php index d26b71a68..a72bcd91e 100644 --- a/modules/dashproducts/dashproducts.php +++ b/modules/dashproducts/dashproducts.php @@ -146,7 +146,7 @@ class DashProducts extends Module array('title' => $this->l('Customer Name'), 'class' => 'text-left'), array('title' => $this->l('Total Stays'), 'class' => 'text-left'), array('title' => $this->l('Order'), 'class' => 'text-left'), - array('title' => $this->l('Hotel'), 'class' => 'text-left'), + array('title' => $this->l('Property'), 'class' => 'text-left'), array('title' => $this->l('Total').' '.$this->l('Tax excl.'), 'class' => 'text-left'), array('title' => $this->l('Date'), 'class' => 'text-left'), array('title' => $this->l('Status'), 'class' => 'text-left'), @@ -235,7 +235,7 @@ class DashProducts extends Module ), array( 'id' => 'category', - 'title' => $this->l('Hotel'), + 'title' => $this->l('Property'), 'class' => 'text-center', ), array( @@ -339,7 +339,7 @@ class DashProducts extends Module ), array( 'id' => 'hotel', - 'title' => $this->l('Hotel'), + 'title' => $this->l('Property'), 'class' => 'text-center', ), array( @@ -448,7 +448,7 @@ class DashProducts extends Module ), array( 'id' => 'reference', - 'title' => $this->l('Hotel'), + 'title' => $this->l('Property'), 'class' => 'text-center' ), array( diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php index f44afd8f7..f235e6c8a 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelConfigurationSettingController.php @@ -122,7 +122,7 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController { parent::initToolbar(); if ($this->display == 'view') { - $this->toolbar_title = $this->l('Hotel Settings'); + $this->toolbar_title = $this->l('Property Settings'); $this->page_header_toolbar_btn['manage_links'] = array( 'icon' => 'process-icon-cogs', 'href' => self::$currentIndex.'&display=list&token='.$this->token, diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index d5731d87f..0f7bc7c40 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -113,7 +113,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController 'class' => 'chosen', ), 'hotel_name' => array( - 'title' => $this->l('Hotel'), + 'title' => $this->l('Property'), 'align' => 'center', 'type' => 'select', 'filter_key' => 'hrt!id_hotel', diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index e18ab1f4a..f11e57fc0 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -112,11 +112,11 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'hint' => $this->l('Enable if you want the next booking search field to be focused automatically after setting value for a field.'), ), 'WK_HOTEL_NAME_SEARCH_THRESHOLD' => array( - 'title' => $this->l('Hotel name search threshold'), + 'title' => $this->l('Property name search threshold'), 'type' => 'text', 'required' => true, 'validation' => 'isUnsignedInt', - 'hint' => $this->l('Enter the number of hotels after which user can search hotel by name.'), + 'hint' => $this->l('Enter the number of properties after which user can search property by name.'), 'desc' => $this->l('Set to 0 to always show the search box.'), 'class' => 'fixed-width-xxl', ), @@ -129,34 +129,34 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'title' => $this->l('Website Configuration'), 'fields' => array( 'WK_HTL_CHAIN_NAME' => array( - 'title' => $this->l('Hotel Name'), + 'title' => $this->l('Property Name'), 'type' => 'textLang', 'lang' => true, 'required' => true, 'validation' => 'isGenericName', - 'hint' => $this->l('Enter Hotel name in case of single hotel or enter your hotels chain name in case of multiple hotels.'), + 'hint' => $this->l('Enter Property name in case of single property or enter your properties chain name in case of multiple properties.'), ), 'WK_HTL_TAG_LINE' => array( - 'title' => $this->l('Hotel Tag Line'), + 'title' => $this->l('Property Tag Line'), 'type' => 'textareaLang', 'lang' => true, 'required' => true, 'validation' => 'isGenericName', - 'hint' => $this->l('This will display hotel tag line in hotel page.'), + 'hint' => $this->l('This will display property tag line in property page.'), ), 'WK_HTL_SHORT_DESC' => array( - 'title' => $this->l('Hotel Short Description'), + 'title' => $this->l('Property Short Description'), 'type' => 'textareaLang', 'lang' => true, 'required' => true, 'rows' => '4', 'cols' => '2', 'validation' => 'isGenericName', - 'hint' => $this->l('This will display hotel short description in footer. Note: number of letters must be less than 220.'), + 'hint' => $this->l('This will display property short description in footer. Note: number of letters must be less than 220.'), ), 'WK_PRIMARY_HOTEL' => array( - 'title' => $this->l('Primary hotel'), - 'hint' => $this->l('Primary hotel is used to default address for your business. The hotel address will be considered as your registered business address.'), + 'title' => $this->l('Primary property'), + 'hint' => $this->l('Primary property is used to default address for your business. The property address will be considered as your registered business address.'), 'type' => 'select', 'identifier' => 'id', 'list' => $hotelsInfo, @@ -541,41 +541,41 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController // End occupancy fields validation if (!$hotelNameSearchThreshold && $hotelNameSearchThreshold !== '0') { - $this->errors[] = $this->l('Hotel name search threshold field is required.'); + $this->errors[] = $this->l('Property name search threshold field is required.'); } elseif (!Validate::isUnsignedInt($hotelNameSearchThreshold)) { - $this->errors[] = $this->l('Hotel name search threshold field is invalid.'); + $this->errors[] = $this->l('Property name search threshold field is invalid.'); } if (!trim(Tools::getValue('WK_HTL_CHAIN_NAME_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel chain name is required at least in ').$objDefaultLanguage['name']; + $this->errors[] = $this->l('Property chain name is required at least in ').$objDefaultLanguage['name']; } else { foreach ($languages as $lang) { if (trim(Tools::getValue('WK_HTL_CHAIN_NAME_'.$lang['id_lang']))) { if (!Validate::isGenericName(Tools::getValue('WK_HTL_CHAIN_NAME_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid hotel chain name in ').$lang['name']; + $this->errors[] = $this->l('Invalid property chain name in ').$lang['name']; } } } } if (!trim(Tools::getValue('WK_HTL_TAG_LINE_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel tag line is required at least in ').$objDefaultLanguage['name']; + $this->errors[] = $this->l('Property tag line is required at least in ').$objDefaultLanguage['name']; } else { foreach ($languages as $lang) { if (trim(Tools::getValue('WK_HTL_TAG_LINE_'.$lang['id_lang']))) { if (!Validate::isGenericName(Tools::getValue('WK_HTL_TAG_LINE_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid Hotel tag line in ').$lang['name']; + $this->errors[] = $this->l('Invalid Property tag line in ').$lang['name']; } } } } if (!trim(Tools::getValue('WK_HTL_SHORT_DESC_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel short description is required at least in '). + $this->errors[] = $this->l('Property short description is required at least in '). $objDefaultLanguage['name']; } else { foreach ($languages as $lang) { if (trim(Tools::getValue('WK_HTL_SHORT_DESC_'.$lang['id_lang']))) { if (!Validate::isGenericName(Tools::getValue('WK_HTL_SHORT_DESC_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid hotel short description in ').$lang['name']; + $this->errors[] = $this->l('Invalid property short description in ').$lang['name']; } } } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 78eb518db..d3c728c63 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -644,7 +644,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (validate::isLoadedObject($objHotelBranch = new HotelBranchInformation($id_hotel))) { $hotelIdAddress = $objHotelBranch->getHotelIdAddress(); } else { - $this->errrors[] = $this->l('Hotel not found'); + $this->errrors[] = $this->l('Property not found'); } } @@ -985,11 +985,11 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'rooms_reallocation_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'), 'rooms_booking_url' => $this->context->link->getAdminLink('AdminHotelRoomsBooking'), 'opt_select_all' => $this->l('All Types', null, true), - 'slt_another_htl' => $this->l('Select Another Hotel', null, true), + 'slt_another_htl' => $this->l('Select Another Property', null, true), 'product_type_cond' => $this->l('Product type is required', null, true), 'from_date_cond' => $this->l('From date is required', null, true), 'to_date_cond' => $this->l('To date is required', null, true), - 'hotel_name_cond' => $this->l('Hotel Name is required', null, true), + 'hotel_name_cond' => $this->l('Property Name is required', null, true), 'num_rooms_cond' => $this->l('Number of Rooms is required', null, true), 'add_to_cart' => $this->l('Add To Cart', null, true), 'remove' => $this->l('Remove', null, true), diff --git a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl index c5b09363c..122b130cc 100644 --- a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl @@ -33,7 +33,7 @@
    {if isset($edit)} {else}
    @@ -51,7 +51,7 @@ {/foreach} {else} - {l s='No hotels available' mod='hotelreservationsystem'} + {l s='No properties available' mod='hotelreservationsystem'} {/if} @@ -209,7 +209,7 @@ {else}
    - {l s='No Hotels' mod='hotelreservationsystem'} + {l s='No Properties Available' mod='hotelreservationsystem'}
    diff --git a/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php b/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php index a8e7d9284..79fbb9058 100644 --- a/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php +++ b/modules/qlohotelreview/controllers/admin/AdminHotelReviewHotelReview.php @@ -72,8 +72,8 @@ class AdminHotelReviewHotelReviewController extends ModuleAdminController 'class' => 'fixed-width-xs', ), 'hotel_name' => array( - 'title' => $this->l('Hotel'), - 'hint' => $this->l('Name of the hotel for which this review has been added.'), + 'title' => $this->l('Property Name'), + 'hint' => $this->l('Name of the property for which this review has been added.'), 'align' => 'left', 'callback' => 'getHotelLink', ), diff --git a/modules/statsbestcategories/statsbestcategories.php b/modules/statsbestcategories/statsbestcategories.php index c3eb94abf..781e28908 100644 --- a/modules/statsbestcategories/statsbestcategories.php +++ b/modules/statsbestcategories/statsbestcategories.php @@ -56,7 +56,7 @@ class StatsBestCategories extends ModuleGrid $this->columns = array( array( 'id' => 'name', - 'header' => $this->l('Hotel name'), + 'header' => $this->l('Property Name'), 'dataIndex' => 'hotel_name', 'align' => 'center' ), @@ -65,14 +65,14 @@ class StatsBestCategories extends ModuleGrid 'header' => $this->l('Room nights booked'), 'dataIndex' => 'totalRoomsBooked', 'align' => 'center', - 'tooltip' => $this->l('The room nights booked for the hotel.'), + 'tooltip' => $this->l('The room nights booked for the property.'), ), array( 'id' => 'availableRooms', 'header' => $this->l('Available room nights'), 'dataIndex' => 'availableRooms', 'align' => 'center', - 'tooltip' => $this->l('The total room nights available for booking for the hotel.'), + 'tooltip' => $this->l('The total room nights available for booking for the property.'), ), array( 'id' => 'totalOrders', diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php index 74d0f8603..3128f5386 100644 --- a/modules/statsbestproducts/statsbestproducts.php +++ b/modules/statsbestproducts/statsbestproducts.php @@ -64,7 +64,7 @@ class StatsBestProducts extends ModuleGrid ), array( 'id' => 'hotelName', - 'header' => $this->l('Hotel name'), + 'header' => $this->l('Property Name'), 'dataIndex' => 'hotelName', 'align' => 'center', ), diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php index aeb179514..4244a2f7c 100644 --- a/modules/statscatalog/statscatalog.php +++ b/modules/statscatalog/statscatalog.php @@ -46,7 +46,7 @@ class StatsCatalog extends Module parent::__construct(); - $this->displayName = $this->l('Hotel statistics'); + $this->displayName = $this->l('Property statistics'); $this->description = $this->l('Adds a tab containing general statistics about your catalog to the Stats dashboard.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.7.0.99'); } @@ -278,7 +278,7 @@ class StatsCatalog extends Module
    • '.$this->returnLine($this->l('Available room types'), ''.(int)$total).'
    • '.$this->returnLine($this->l('Average base price'), ''.Tools::displayPrice($average_price, $this->context->currency)).'
    • -
    • '.$this->returnLine($this->l('Hotel page views'), ''.(int)$total_hotel_page_viewed).'
    • +
    • '.$this->returnLine($this->l('Property page views'), ''.(int)$total_hotel_page_viewed).'
    • '.$this->returnLine($this->l('Room type page views'), ''.(int)$total_room_type_page_viewed).'
    • '.$this->returnLine($this->l('Booked room nights'), ''.(int)$total_booked_rooms).'
    • '.$this->returnLine($this->l('Average number of page visits'), ''.number_format((float)$average_viewed, 2, '.', '')).'
    • diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 073b5aae2..f65446750 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -167,7 +167,7 @@ class StatsCheckUp extends Module
    - + '; foreach ($languages as $language) { $hotelsHtml .= ''; diff --git a/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php b/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php index 133fc0bac..351d9fc48 100644 --- a/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php +++ b/modules/wkabouthotelblock/controllers/admin/AdminAboutHotelBlockSettingController.php @@ -36,7 +36,7 @@ class AdminAboutHotelBlockSettingController extends ModuleAdminController $this->fields_options = array( 'global' => array( - 'title' => $this->l('Hotel Interior Description'), + 'title' => $this->l('Property Interior Description'), 'icon' => 'icon-cogs', 'fields' => array( 'HOTEL_INTERIOR_HEADING' => array( @@ -188,7 +188,7 @@ class AdminAboutHotelBlockSettingController extends ModuleAdminController $this->fields_form = array( 'legend' => array( - 'title' => $this->l('Add New Hotel Interior Image'), + 'title' => $this->l('Add New Property Interior Image'), 'icon' => 'icon-list-ul' ), 'input' => array( @@ -200,7 +200,7 @@ class AdminAboutHotelBlockSettingController extends ModuleAdminController ), array( 'type' => 'file', - 'label' => $this->l('Hotel Interior Image'), + 'label' => $this->l('Property Interior Image'), 'name' => 'interior_img', 'required' => true, 'display_image' => true, @@ -252,7 +252,7 @@ class AdminAboutHotelBlockSettingController extends ModuleAdminController } if (!(Tools::getValue("id_interior_image") && !$file['size'])) { if (!$file['size']) { - $this->errors[] = $this->l('Hotel Interior Image Required.'); + $this->errors[] = $this->l('Property Interior Image Required.'); } elseif ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize())) { $this->errors[] = $error; } diff --git a/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php b/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php index e4f6608a1..c53dc6fa5 100644 --- a/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php +++ b/modules/wkhotelfeaturesblock/controllers/admin/AdminFeaturesModuleSettingController.php @@ -42,7 +42,7 @@ class AdminFeaturesModuleSettingController extends ModuleAdminController // field options for global fields $this->fields_options = array( 'global' => array( - 'title' => $this->l('Hotel Amenity Setting'), + 'title' => $this->l('Property Amenity Setting'), 'icon' => 'icon-cogs', 'fields' => array( 'HOTEL_AMENITIES_HEADING' => array( @@ -278,7 +278,7 @@ class AdminFeaturesModuleSettingController extends ModuleAdminController } if (!$hotelAmenityId || $file['size']) { if (!$file['size']) { - $this->errors[] = $this->l('Hotel Amenity Image Required.'); + $this->errors[] = $this->l('Property Amenity Image Required.'); } elseif ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize())) { $this->errors[] = $error; } diff --git a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php index 5538dcc1e..7f02b3c0b 100644 --- a/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php +++ b/modules/wkhotelfeaturesblock/wkhotelfeaturesblock.php @@ -40,8 +40,8 @@ class WkHotelFeaturesBlock extends Module $this->bootstrap = true; parent::__construct(); - $this->displayName = $this->l('Hotel Features'); - $this->description = $this->l('Show Hotel Amenities on the home page using this module.'); + $this->displayName = $this->l('Property Features'); + $this->description = $this->l('Show Property Amenities on the home page using this module.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 17226b9a2..2acc75b23 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -41,7 +41,7 @@ class wkhotelfilterblock extends Module parent::__construct(); $this->displayName = $this->l('Layered filters and sorting block'); - $this->description = $this->l('Hotel filter and sorting block'); + $this->description = $this->l('Property filter and sorting block'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } diff --git a/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php b/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php index 90528dfb1..bbc4f5292 100644 --- a/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php +++ b/modules/wkhotelroom/controllers/admin/AdminHotelRoomModuleSettingController.php @@ -43,26 +43,26 @@ class AdminHotelRoomModuleSettingController extends ModuleAdminController $this->fields_options = array( 'global' => array( - 'title' => $this->l('Hotel Room Display Setting'), + 'title' => $this->l('Property Room Display Setting'), 'icon' => 'icon-cogs', 'fields' => array( 'HOTEL_ROOM_DISPLAY_HEADING' => array( - 'title' => $this->l('Hotel Room Block Title'), + 'title' => $this->l('Property Room Block Title'), 'type' => 'textLang', 'lang' => true, 'required' => true, 'validation' => 'isGenericName', - 'hint' => $this->l('Enter a title for the hotel rooms block.'), + 'hint' => $this->l('Enter a title for the property rooms block.'), ), 'HOTEL_ROOM_DISPLAY_DESCRIPTION' => array( - 'title' => $this->l('Hotel room block description'), + 'title' => $this->l('Property room block description'), 'type' => 'textareaLang', 'lang' => true, 'required' => true, 'validation' => 'isGenericName', 'rows' => '4', 'cols' => '2', - 'hint' => $this->l('Enter a description for the hotel rooms block.'), + 'hint' => $this->l('Enter a description for the property rooms block.'), ), ), 'submit' => array('title' => $this->l('Save')) @@ -91,7 +91,7 @@ class AdminHotelRoomModuleSettingController extends ModuleAdminController 'orderby' => false, ), 'hotel_name' => array( - 'title' => $this->l('Hotel'), + 'title' => $this->l('Property'), 'align' => 'center', 'orderby' => false, ), @@ -335,25 +335,25 @@ class AdminHotelRoomModuleSettingController extends ModuleAdminController $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); $languages = Language::getLanguages(false); if (!trim(Tools::getValue('HOTEL_ROOM_DISPLAY_HEADING_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel rooms block title is required at least in '). + $this->errors[] = $this->l('Property rooms block title is required at least in '). $objDefaultLanguage['name']; } else { foreach ($languages as $lang) { if (trim(Tools::getValue('HOTEL_ROOM_DISPLAY_HEADING_'.$lang['id_lang']))) { if (!Validate::isGenericName(Tools::getValue('HOTEL_ROOM_DISPLAY_HEADING_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid hotel rooms block title in ').$lang['name']; + $this->errors[] = $this->l('Invalid property rooms block title in ').$lang['name']; } } } } if (!trim(Tools::getValue('HOTEL_ROOM_DISPLAY_DESCRIPTION_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel rooms block description is required at least in '). + $this->errors[] = $this->l('Property rooms block description is required at least in '). $objDefaultLanguage['name']; } else { foreach ($languages as $lang) { if (trim(Tools::getValue('HOTEL_ROOM_DISPLAY_DESCRIPTION_'.$lang['id_lang']))) { if (!Validate::isGenericName(Tools::getValue('HOTEL_ROOM_DISPLAY_DESCRIPTION_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid hotel rooms block description in ').$lang['name']; + $this->errors[] = $this->l('Invalid property rooms block description in ').$lang['name']; } } } diff --git a/modules/wkroomsearchblock/wkroomsearchblock.php b/modules/wkroomsearchblock/wkroomsearchblock.php index 7629e3aac..a47a38ec2 100644 --- a/modules/wkroomsearchblock/wkroomsearchblock.php +++ b/modules/wkroomsearchblock/wkroomsearchblock.php @@ -71,13 +71,13 @@ class WkRoomSearchBlock extends Module 'autocompletesearch' ), 'no_results_found_cond' => $this->l('No results found for this search', false, true), - 'hotel_name_cond' => $this->l('Please select a hotel name', false, true), + 'hotel_name_cond' => $this->l('Please select a property name', false, true), 'check_in_time_cond' => $this->l('Please enter Check In time', false, true), 'check_out_time_cond' => $this->l('Please enter Check Out time', false, true), 'less_checkin_date' => $this->l('Check In date can not be before current date.', false, true), 'more_checkout_date' => $this->l('Check Out date must be greater than Check In date.', false, true), - 'hotel_location_txt' => $this->l('Hotel Location', false, true), - 'select_htl_txt' => $this->l('Select Hotel', false, true), + 'hotel_location_txt' => $this->l('Property Location', false, true), + 'select_htl_txt' => $this->l('Select Property', false, true), 'select_age_txt' => $this->l('Select age', false, true), 'under_1_age' => $this->l('Under 1', false, true), 'room_txt' => $this->l('Stay', false, true), diff --git a/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php b/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php index 7c3ad8a2c..2d4feac9d 100644 --- a/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php +++ b/modules/wktestimonialblock/controllers/admin/AdminTestimonialsModuleSettingController.php @@ -37,7 +37,7 @@ class AdminTestimonialsModuleSettingController extends ModuleAdminController $this->fields_options = array( 'modulesetting' => array( - 'title' => $this->l('Hotel Testimonials Setting'), + 'title' => $this->l('Property Testimonials Setting'), 'fields' => array( 'HOTEL_TESIMONIAL_BLOCK_HEADING' => array( 'title' => $this->l('Testimonial block title'), @@ -154,7 +154,7 @@ class AdminTestimonialsModuleSettingController extends ModuleAdminController $this->fields_form = array( 'legend' => array( - 'title' => $this->l('Hotel Testimonial Configuration'), + 'title' => $this->l('Property Testimonial Configuration'), 'icon' => 'icon-globe' ), 'input' => array( diff --git a/modules/wktestimonialblock/wktestimonialblock.php b/modules/wktestimonialblock/wktestimonialblock.php index bdf04f06c..8305910a9 100644 --- a/modules/wktestimonialblock/wktestimonialblock.php +++ b/modules/wktestimonialblock/wktestimonialblock.php @@ -42,8 +42,8 @@ class WkTestimonialBlock extends Module $this->bootstrap = true; parent::__construct(); - $this->displayName = $this->l('Hotel Testimonial'); - $this->description = $this->l('Show Hotel testimonials on home page using this module.'); + $this->displayName = $this->l('Property Testimonial'); + $this->description = $this->l('Show Property testimonials on home page using this module.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); } diff --git a/pdf/order-slip.product-tab.tpl b/pdf/order-slip.product-tab.tpl index 67a02f0e0..b0e382a29 100644 --- a/pdf/order-slip.product-tab.tpl +++ b/pdf/order-slip.product-tab.tpl @@ -31,7 +31,7 @@ - + diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index fa9a8051b..ca1901956 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -215,7 +215,7 @@
    - {l s='Hotel Name' mod='blockcart'}  -  + {l s='Property Name' mod='blockcart'}  - 
    diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index f7f03580a..682198561 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -121,7 +121,7 @@
    {else} -
    {l s='Hotel details not available.'}
    +
    {l s='Property details not available.'}
    {/if} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index 8453e6e82..364fe2c31 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -329,7 +329,7 @@
    - {l s='Hotel Images'} + {l s='Property Images'}
    From 5541f6761466e96526b81ab6572fb949853dbaff Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Wed, 20 May 2026 15:21:24 +0530 Subject: [PATCH 15/76] fix: issue get only active room type selling object --- .../hotelreservationsystem/classes/HotelRoomType.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 1f6e5fd6b..fb5cbaeea 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -244,8 +244,11 @@ class HotelRoomType extends ObjectModel AND hbl.`id_lang` = '.(int)$idLang.') LEFT JOIN `'._DB_PREFIX_.'product` AS p ON (p.`id_product` = hrt.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object` AS hrtso + ON (hrtso.`id_room_type_selling_object` = p.`id_room_type_selling_object` + AND hrtso.`active` = 1) LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object_lang` AS hrtstl - ON (hrtstl.`id_room_type_selling_object` = p.`id_room_type_selling_object` + ON (hrtstl.`id_room_type_selling_object` = hrtso.`id_room_type_selling_object` AND hrtstl.`id_lang` = '.(int)$idLang.') WHERE hrt.`id_product` = '.(int)$id_product; @@ -321,8 +324,11 @@ class HotelRoomType extends ObjectModel INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS `hri` ON (hri.`id_product` = hrt.`id_product`)'; $sql .= ' INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (hrt.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.')'; $sql .= ' LEFT JOIN `'._DB_PREFIX_.'product` AS p ON (p.`id_product` = hrt.`id_product`) + LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object` AS hrtso + ON (hrtso.`id_room_type_selling_object` = p.`id_room_type_selling_object` + AND hrtso.`active` = 1) LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object_lang` AS hrtstl - ON (hrtstl.`id_room_type_selling_object` = p.`id_room_type_selling_object` + ON (hrtstl.`id_room_type_selling_object` = hrtso.`id_room_type_selling_object` AND hrtstl.`id_lang` = '.(int)$idLang.')'; if ($position) { From b3240226005394f832a2073ca0ab8a2bb31519e4 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 25 May 2026 14:33:49 +0530 Subject: [PATCH 16/76] Fixed: Service product prices are incorrect when added to an order created in a different currency. --- .../normal_products/informations.tpl | 41 ++- .../controllers/normal_products/prices.tpl | 46 ++- .../normal_products/selected_option.tpl | 98 ++++++ .../orders/_cart_booking_demands.tpl | 2 +- .../_add_order_extra_services_tab_content.tpl | 32 +- ..._extra_services_facilities_tab_content.tpl | 6 +- ..._services_service_products_tab_content.tpl | 36 ++- classes/Cart.php | 216 ++++++------- classes/PaymentModule.php | 42 +-- classes/Product.php | 24 +- classes/order/Order.php | 25 +- classes/order/OrderDetail.php | 22 +- classes/order/OrderInvoice.php | 6 +- .../WebserviceSpecificManagementBookings.php | 21 +- controllers/admin/AdminCartsController.php | 126 ++++++-- .../admin/AdminNormalProductsController.php | 51 +-- controllers/admin/AdminOrdersController.php | 293 +++++++++++------- controllers/admin/AdminProductsController.php | 18 +- controllers/admin/AdminStatsController.php | 4 +- controllers/front/CartController.php | 52 +++- controllers/front/GuestTrackingController.php | 33 +- .../front/OrderConfirmationController.php | 93 +++--- controllers/front/OrderDetailController.php | 87 ++---- js/admin.js | 12 + js/admin/normal_products.js | 39 +-- modules/blockcart/ajax-cart.js | 20 +- .../classes/HotelCartBookingData.php | 19 ++ .../classes/HotelHelper.php | 2 +- .../classes/RoomTypeServiceProduct.php | 7 +- .../classes/ServiceProductCartDetail.php | 24 +- .../helpers/view/view.tpl | 2 +- .../qlostatsserviceproducts.php | 25 +- .../_partials/cart_booking_demands.tpl | 4 +- .../_partials/service-products-list-row.tpl | 2 +- .../js/modules/blockcart/ajax-cart.js | 22 +- .../modules/blockcart/blockcart.tpl | 6 +- .../order-confirmation.tpl | 16 +- .../hotel-reservation-theme/order-detail.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 2 +- 39 files changed, 940 insertions(+), 638 deletions(-) create mode 100644 admin/themes/default/template/controllers/normal_products/selected_option.tpl diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 3bf54bd1b..b1d0b9f72 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -231,21 +231,34 @@
    {* Code For Standard product working *}
    -
    diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index 3dc6241f0..d56daffe8 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -96,7 +96,7 @@ $selectedRoomServiceProduct['date_from'], $selectedRoomServiceProduct['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} {/if} @@ -134,16 +134,26 @@
    - - + + +
    + +
    +
    + +
    +
    + +
    diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl index 3537d8dd2..e4f40435a 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl @@ -51,7 +51,7 @@ {$currencySign} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if}
    @@ -122,7 +122,7 @@ {/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if}
    @@ -159,7 +159,7 @@ diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 4f6ce1c58..d8d3ef96d 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -87,7 +87,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} @@ -161,7 +161,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if} @@ -197,16 +197,26 @@
    - - + + +
    + +
    +
    + +
    +
    + +
    @@ -304,7 +314,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ night'} + {l s='/ day'} {/if}
    - + diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index da29873a8..bb77c1095 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -99,7 +99,7 @@ $selectedRoomServiceProduct['date_from'], $selectedRoomServiceProduct['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} {/if} diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl index e4f40435a..3537d8dd2 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_facilities_tab_content.tpl @@ -51,7 +51,7 @@ {$currencySign} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} @@ -122,7 +122,7 @@ {/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} @@ -159,7 +159,7 @@ diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index b322c7dde..de2af862f 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -89,7 +89,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -164,7 +164,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -320,7 +320,7 @@ $additionalServices['date_from'], $additionalServices['date_to'] ) > 1} - {l s='/ day'} + {l s='/ night'} {/if} @@ -729,8 +729,8 @@ {assign var=room_services_price_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_te)} {assign var=room_services_price_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + $total_demands_price_ti)} - {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} - {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE))} + {assign var=total_standard_products_tax_incl value=($order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_STANDALONE) + $order->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_HOTEL))} + {assign var=total_standard_products_tax_excl value=($order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_STANDALONE) + $order->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_HOTEL))} {assign var=total_tax_without_discount value=(($room_price_tax_incl - $room_price_tax_excl) + ($room_services_price_tax_incl - $room_services_price_tax_excl) + ($total_standard_products_tax_incl - $total_standard_products_tax_excl))} @@ -979,7 +979,7 @@ ({$hotel_booking_detail.adults|string_format:'%02d'} {if $hotel_booking_detail.adults > 1}{l s='Adults'}{else}{l s='Adult'}{/if}{if $hotel_booking_detail.children > 0}{l s=', '}{$hotel_booking_detail.children|string_format:'%02d'} {if $hotel_booking_detail.children > 1}{l s='Children'}{else}{l s='Child'}{/if}{/if}) - {if $hotel_booking_detail.is_cancelled}{l s='Cancelled'}{else if $hotel_booking_detail.is_refunded}{l s='Refunded'}{else if $hotel_booking_detail.refund_denied}{l s='Refund denied'}{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED}{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}{/if} + {if $hotel_booking_detail.is_cancelled}{l s='Cancelled'}{else if $hotel_booking_detail.is_refunded}{l s='Refunded'}{else if $hotel_booking_detail.refund_denied}{l s='Refund denied'} {include file='_partials/htl-tooltip.tpl' tooltip_content={l s='Refund for this booking is denied. Please contact admin for more detail.'}}{else if $hotel_booking_detail.id_status != $ROOM_STATUS_ALLOTED}{if $hotel_booking_detail.id_status == $ROOM_STATUS_CHECKED_OUT}{l s='Checked-Out'}{else}{l s='Checked-In'}{/if}{/if} @@ -1037,7 +1037,7 @@ {$product_option.name}{if isset($product_option.option_name) && $product_option.option_name} : {$product_option.option_name}{/if} - {if $product_option.is_cancelled}{l s='Cancelled'}{else if $product_option.is_refunded}{l s='Refunded'}{else if isset($product_option.refund_denied) && $product_option.refund_denied}{l s='Refund denied'}{/if} + {if $product_option.is_cancelled}{l s='Cancelled'}{else if $product_option.is_refunded}{l s='Refunded'}{else if isset($product_option.refund_denied) && $product_option.refund_denied}{l s='Refund denied'} {include file='_partials/htl-tooltip.tpl' tooltip_content={l s='Refund for this product is denied. Please contact admin for more detail.'}}{/if} {if $product_option.allow_multiple_quantity}
    diff --git a/themes/hotel-reservation-theme/shopping-cart-detail.tpl b/themes/hotel-reservation-theme/shopping-cart-detail.tpl index ccbb199e7..668006b40 100644 --- a/themes/hotel-reservation-theme/shopping-cart-detail.tpl +++ b/themes/hotel-reservation-theme/shopping-cart-detail.tpl @@ -120,22 +120,18 @@
    -

    - - {displayPrice price=($rm_v['amount'])} - +

    + {displayPrice price=($rm_v['amount'])} {if (($rm_v['amount'] - $rm_v['amount_without_auto_add']) > 0) && (in_array($data_v['id_product'], $discounted_products) || $PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN)} - - - -

    {l s='Total rooms price'} {if $display_tax_label}{if $priceDisplay} {l s='(Excl.'} {else}{l s='(Incl.)'}{/if} {l s='all taxes.)'}{/if}

    From b4a087be55f998bc38a685d83a43d5822b114bb9 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 1 Jun 2026 11:35:05 +0530 Subject: [PATCH 23/76] Fix price calculation issue labal --- .../_partials/cart_booking_demands.tpl | 4 ++-- .../_partials/service-products-list-row.tpl | 2 +- themes/hotel-reservation-theme/product.tpl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index a7c56b4b1..fe620e385 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -82,7 +82,7 @@

    - {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Day'}{/if} + {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}

    @@ -183,7 +183,7 @@ $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' - ) > 1}{l s='/Day'}{/if} + ) > 1}{l s='/Night'}{/if} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 8aba19cd4..ea97398e2 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -86,7 +86,7 @@ $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' ) > 1} - {l s='/Day'} + {l s='/Night'} {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index c6f23c5e2..f9836c246 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@
    {/if}
    -

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/day'}{/if}{/if}

    +

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/night'}{/if}{/if}

    {if isset($demand['adv_option']) && $demand['adv_option']}
    @@ -136,8 +165,34 @@ + {capture name='adm_pcm_tooltip_content'} + {assign var="priceCalcMethod" value=$product['price_calculation_method']|default:0} +
    +
    +
      + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-in day'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='During-stay days'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-out day'}
    • + {/if} +
    +
    + {/capture} + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.adm_pcm_tooltip_content allow_html=true} + + {capture name='room_type_service_pcm_tooltip_content'} + {assign var="priceCalcMethod" value=$service['price_calculation_method']|default:0} +
    +
    +
      + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-in day'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='During-stay days'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-out day'}
    • + {/if} +
    +
    + {/capture} + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_pcm_tooltip_content allow_html=true} {if !$isRefundCompleted} + + @@ -140,12 +142,26 @@ {l s='Auto'} {/if} + +
    {l s='Hotel'}{l s='Property'} {l s='All'} diff --git a/admin/themes/default/template/controllers/orders/modals/_cancel_room_bookings.tpl b/admin/themes/default/template/controllers/orders/modals/_cancel_room_bookings.tpl index 6335b7549..5cdf0462c 100644 --- a/admin/themes/default/template/controllers/orders/modals/_cancel_room_bookings.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_cancel_room_bookings.tpl @@ -45,7 +45,7 @@ {l s='Stay No.'} {l s='Room Type'}{l s='Hotel Name'}{l s='Property Name'} {l s='Duration'} {l s='Total Price (Tax incl.)'}
    {l s="Stay Num"} {l s="Room Type"}{l s="Hotel"}{l s="Property Name"} {l s="Duration"}
    {l s="Room Type"}{l s="Hotel"}{l s="Property Name"} {l s="Stays Qty"} {l s="Duration"}
    '.$this->l('ID').''.(!$this->id_hotel ? $this->l('Hotel') : $this->l('Room type')).''.(!$this->id_hotel ? $this->l('Property') : $this->l('Room type')).' '.$this->l('Active').''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).')
    {l s='Room Type / Reference' pdf='true'}{l s='Hotel' pdf='true'}{l s='Property Name' pdf='true'} {l s='Duration' pdf='true'} {l s='Num stays' pdf='true'} {l s='Total Price' pdf='true'}
    {if $tax_excluded_display}{l s='(Tax Excl.)' pdf='true'}{else}{l s='(Tax Incl.)' pdf='true'}{/if}
    {displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ night'} + {l s='/ day'} {/if} {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/Cart.php b/classes/Cart.php index ced44ff2d..d544f3cf9 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -827,7 +827,7 @@ class CartCore extends ObjectModel $serviceProducts = array(); $context = Context::getContext(); foreach ($productList as $key => $product) { - if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'] && !Product::isSellableWithRoomType($product['selling_preference_type']))) { if (Validate::isLoadedObject( $objProduct = new Product($product['id_product'], false, $this->id_lang) )) { @@ -1756,124 +1756,102 @@ class CartCore extends ObjectModel $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $isRoomServiceTotalType = in_array($type, array( + Cart::ONLY_ROOM_SERVICES, + Cart::ONLY_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, + Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, + Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, + )); - if ($canSellAsStandalone - && (!$canSellWithHotel && !$canSellWithRoomType - || ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellWithHotel)) - ) { + if ($canSellAsStandalone && !$isRoomServiceTotalType) { $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; - if ($servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( + if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], - $idHotel, - $idHotelCartBooking, + 0, + 0, null, (int)$product['id_product'] )) { - foreach ($servicePorducts as $servicePorduct) { + foreach ($serviceProducts as $serviceProduct) { if ($with_taxes) { - $priceAdd = $servicePorduct['unit_price_tax_incl']; + $priceAdd = $serviceProduct['unit_price_tax_incl']; } else { - $priceAdd = $servicePorduct['unit_price_tax_excl']; + $priceAdd = $serviceProduct['unit_price_tax_excl']; } if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd * (int)$servicePorduct['quantity']; + $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd * (int)$serviceProduct['quantity']; } else { - $products_total[$id_tax_rules_group] += $priceAdd * (int)$servicePorduct['quantity']; + $products_total[$id_tax_rules_group] += $priceAdd * (int)$serviceProduct['quantity']; } + } } - } else if ($canSellWithHotel) { - $isRoomServiceTotalType = in_array($type, array( - Cart::ONLY_ROOM_SERVICES, - Cart::ONLY_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, - Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, - )); - $id_hotel = null; - $id_hotel_cart_booking = null; - if ($param_product) { - if (isset($product['id_hotel']) && (int)$product['id_hotel']) { - $id_hotel = (int)$product['id_hotel']; - } - if (isset($product['id_hotel_cart_booking']) && (int)$product['id_hotel_cart_booking']) { - $id_hotel_cart_booking = (int)$product['id_hotel_cart_booking']; - } - } - - $servicePorducts = $objServiceProductCartDetail->getServiceProductsInCart( - $this->id, - [], - null, - null, - null, - (int)$product['id_product'] - ); - - if ($servicePorducts) { - foreach ($servicePorducts as $servicePorduct) { - if ($param_product) { - if ($id_hotel_cart_booking !== null - && (int)$servicePorduct['id_hotel_cart_booking'] !== $id_hotel_cart_booking - ) { - continue; - } - if ($id_hotel_cart_booking === null - && $id_hotel !== null - && ( - !empty($servicePorduct['id_hotel_cart_booking']) - || (int)$servicePorduct['id_hotel'] !== $id_hotel - ) - ) { - continue; - } - } - if ($isRoomServiceTotalType && empty($servicePorduct['id_hotel_cart_booking'])) { - continue; - } - if ($type == Cart::ONLY_STANDALONE_PRODUCTS - && !empty($servicePorduct['id_hotel_cart_booking']) - ) { - continue; - } - if ($with_taxes) { - $priceAdd = $servicePorduct['total_price_tax_incl']; - } else { - $priceAdd = $servicePorduct['total_price_tax_excl']; - } - - if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd; - } else { - $products_total[$id_tax_rules_group] += $priceAdd; - } - } - } - } else if ($canSellWithRoomType) { - $isRoomServiceTotalType = in_array($type, array( - Cart::ONLY_ROOM_SERVICES, - Cart::ONLY_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD, - Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE, - Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, - )); - - $idHotelCartBooking = null; - if ($param_product && isset($product['id_hotel_cart_booking'])) { - $idHotelCartBooking = (int)$product['id_hotel_cart_booking']; + } + if ($canSellWithHotel ) { + if ($type == Cart::ONLY_ROOM_SERVICES + || $type == Cart::ONLY_CONVENIENCE_FEE + || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD + || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE + || $type == Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE + ) { + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + 0, + null, + null, + (int)$product['id_product'] + ); } elseif ($type == Cart::ONLY_STANDALONE_PRODUCTS) { - $idHotelCartBooking = 0; + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + null, + 0, + null, + (int)$product['id_product'] + ); + } else { + $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->id, + [], + isset($product['id_hotel']) ? $product['id_hotel'] : null, + null, + null, + (int)$product['id_product'] + ); } + if ($serviceProducts) { + foreach ($serviceProducts as $serviceProduct) { + if(!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { + if ($with_taxes) { + $priceAdd = $serviceProduct['total_price_tax_incl']; + } else { + $priceAdd = $serviceProduct['total_price_tax_excl']; + } + + if ($ps_round_type == Order::ROUND_TOTAL) { + $products_total[$id_tax_rules_group.'_'.$id_address] += $priceAdd; + } else { + $products_total[$id_tax_rules_group] += $priceAdd; + } + } + } + } + } + if ($canSellWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { + if ($servicesWithRoom = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], 0, - $idHotelCartBooking, + null, null, (int)$product['id_product'], null, @@ -1883,27 +1861,19 @@ class CartCore extends ObjectModel (int)$product['price_addition_type'] )) { foreach ($servicesWithRoom as $service) { - if ($param_product && $idHotelCartBooking !== null) { - if (!$idHotelCartBooking && !empty($service['id_hotel_cart_booking'])) { - continue; + if(!empty($service['id_hotel_cart_booking']) && empty($service['id_hotel'])) { + if ($with_taxes) { + $servicePrice = $service['total_price_tax_incl']; + } else { + $servicePrice = $service['total_price_tax_excl']; } - if ($idHotelCartBooking && (int)$service['id_hotel_cart_booking'] !== $idHotelCartBooking) { - continue; - } - } elseif ($isRoomServiceTotalType && empty($service['id_hotel_cart_booking'])) { - continue; - } - if ($with_taxes) { - $servicePrice = $service['total_price_tax_incl']; - } else { - $servicePrice = $service['total_price_tax_excl']; - } - // Rounding as per configurations - if ($ps_round_type == Order::ROUND_TOTAL) { - $products_total[$id_tax_rules_group.'_'.$id_address] += $servicePrice; - } else { - $products_total[$id_tax_rules_group] += $servicePrice; + // Rounding as per configurations + if ($ps_round_type == Order::ROUND_TOTAL) { + $products_total[$id_tax_rules_group.'_'.$id_address] += $servicePrice; + } else { + $products_total[$id_tax_rules_group] += $servicePrice; + } } } } @@ -2495,16 +2465,12 @@ class CartCore extends ObjectModel 'id_hotel_cart_booking' => $selectedProduct['id_hotel_cart_booking'], ); } - if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $selectedProduct['price_calculation_method']) { - $numDays = HotelHelper::getNumberOfDays( - $selectedProduct['date_from'], - $selectedProduct['date_to'] - ); - $array[$selectedProduct['id_room_type_hotel']]['quantity'] += ($selectedProduct['quantity'] * $numDays); - } else { - $array[$selectedProduct['id_room_type_hotel']]['quantity'] += $selectedProduct['quantity']; - - } + $numDays = Product::getPriceCalculationApplicableDays( + $selectedProduct['price_calculation_method'], + $selectedProduct['date_from'], + $selectedProduct['date_to'] + ); + $array[$selectedProduct['id_room_type_hotel']]['quantity'] += ($selectedProduct['quantity'] * $numDays); } if ($array) { @@ -2512,8 +2478,8 @@ class CartCore extends ObjectModel $product['cart_quantity'] = $selectedProduct['quantity']; $product['total'] = $selectedProduct['total_price_tax_excl']; $product['total_wt'] = $selectedProduct['total_price_tax_incl']; - $product['price_wt'] = $selectedProduct['total_price_tax_incl'] / $selectedProduct['quantity']; - $product['price'] = $selectedProduct['total_price_tax_excl'] / $selectedProduct['quantity']; + $product['price_wt'] = $selectedProduct['total_price_tax_incl'] / max($selectedProduct['quantity'], 1); + $product['price'] = $selectedProduct['total_price_tax_excl'] / max($selectedProduct['quantity'], 1); $product['id_hotel'] = $selectedProduct['id_hotel']; $product['id_room_type'] = $selectedProduct['id_room_type']; $product['id_hotel_cart_booking'] = $selectedProduct['id_hotel_cart_booking']; diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index a022f3484..43158862f 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -505,7 +505,6 @@ abstract class PaymentModuleCore extends Module $objMail = new Mail(); $objServiceProductCartDetail = new ServiceProductCartDetail(); $cart_rules = $this->context->cart->getCartRules(); - foreach ($order_detail_list as $key => $order_detail) { /** @var OrderDetail $order_detail */ @@ -541,7 +540,6 @@ abstract class PaymentModuleCore extends Module $product_var_tpl_list = array(); $orderServiceProducts = array(); - $processedServiceProductCartIds = array(); $objProduct = new Product(); foreach ($order->product_list as $product) { @@ -970,11 +968,9 @@ abstract class PaymentModuleCore extends Module $objServiceProductCartDetail = new ServiceProductCartDetail(); foreach ($normalProducts as $product) { $idProduct = $product['id_product']; - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $productSellingType = $product['selling_preference_type']; - if ($canSellWithRoomType && !$canSellWithHotel && !$canSellAsStandalone) { + if (Product::isSellableWithRoomType($productSellingType)) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -983,16 +979,10 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($roomTypeServices as $roomTypeService) { - if (!Validate::isDate($roomTypeService['date_from']) - || !Validate::isDate($roomTypeService['date_to']) - || !(int) $roomTypeService['id_room_type'] - ) { + if (!$roomTypeService['id_hotel_cart_booking']) { continue; } $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( @@ -1002,9 +992,6 @@ abstract class PaymentModuleCore extends Module $roomTypeService['date_to'], $roomTypeService['id_room'] ); - if (empty($roomBookingDetail['id'])) { - continue; - } $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; $objServiceProductOrderDetail->id_order = $order->id; @@ -1021,7 +1008,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif ($canSellWithHotel && !$canSellWithRoomType && !$canSellAsStandalone) { + } elseif (Product::isSellableWithHotel($productSellingType)) { if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1030,11 +1017,7 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($hotelProducts as $hotelProduct) { $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; @@ -1056,9 +1039,10 @@ abstract class PaymentModuleCore extends Module } $objServiceProductOrderDetail->quantity = $hotelProduct['quantity']; $objServiceProductOrderDetail->save(); + } } - } elseif ($canSellAsStandalone && !$canSellWithRoomType && !$canSellWithHotel) { + } elseif (Product::isSellableAsStandalone($productSellingType)) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1067,11 +1051,7 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct( - $idProduct, - $order->id, - $product['selling_preference_type'] - ); + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($standaloneProducts as $standaloneProduct) { $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $idProduct; @@ -1089,7 +1069,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } + } } } diff --git a/classes/Product.php b/classes/Product.php index dcf55eb40..f88ec4917 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -569,12 +569,10 @@ class ProductCore extends ObjectModel const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_PER_DAY = 1; - const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; - const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 3; - const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 4; + const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 4; + const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 3; const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; @@ -6909,23 +6907,31 @@ class ProductCore extends ObjectModel return (int) $defaultDays; } + $checkin = 1; + $checkout = 1; + $duringStay = max($numNights - 1, 0); + switch ((int) $priceCalculationMethod) { case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: + return $checkin; + case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: - return 1; + return $checkout; case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: - return max($numNights - 1, 1); + return $duringStay; case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: - return 2; + return $checkin + $checkout; case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: + return $checkin + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: - return $numNights; + return $checkout + $duringStay; case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: - return $numNights + 1; + return $checkin + $checkout + $duringStay; default: return $numNights; diff --git a/classes/order/Order.php b/classes/order/Order.php index 0ed9581a3..26ee52823 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -47,9 +47,6 @@ class OrderCore extends ObjectModel const ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG = 3; - const SERVICE_PRODUCT_CONTEXT_ROOM_LINKED = 1; - const SERVICE_PRODUCT_CONTEXT_NON_ROOM = 2; - /** @var int Delivery address id */ public $id_address_delivery; @@ -2581,12 +2578,11 @@ class OrderCore extends ObjectModel )) { $totals = array_reduce($serviceProductDetail, function ($carry, $item) use ($order_detail) { $objHotelBookingDetail = new HotelBookingDetail((int) $item['id_htl_booking_detail']); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $order_detail['product_price_calculation_method']) - && (!$numDays = HotelHelper::getNumberOfDays($objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to)) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $order_detail['product_price_calculation_method'], + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); if (!empty($item['id_tax_rules_group'])) { $qty = isset($item['quantity']) ? $item['quantity'] : 0; @@ -2637,12 +2633,11 @@ class OrderCore extends ObjectModel // We are getting auto added service for specific room.There will be only on htl_booking_detail but can have multiple auto added service with room. // Note: All the auto added service with room have same id_tax_rule group $autoAddedServiceData = array_shift($autoAddedServiceData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $order_detail['product_price_calculation_method']) - && (!$numDays = HotelHelper::getNumberOfDays($autoAddedServiceData['date_from'], $autoAddedServiceData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $order_detail['product_price_calculation_method'], + $autoAddedServiceData['date_from'], + $autoAddedServiceData['date_to'] + ); $autoAddedServices = $autoAddedServiceData['additional_services']; // Calculate total quantity of auto-added services diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index 3f37eeb1d..4b28d23ff 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -450,12 +450,11 @@ class OrderDetailCore extends ObjectModel $taxGroupInfo['id_room_type'], )) { $serviceProductData = array_shift($serviceProductData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $this->product_price_calculation_method) - && (!$numDays = HotelHelper::getNumberOfDays($serviceProductData['date_from'], $serviceProductData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $this->product_price_calculation_method, + $serviceProductData['date_from'], + $serviceProductData['date_to'] + ); $unit_price_tax_excl = array_reduce($serviceProductData['additional_services'], function ($unitPriceTaxExcl, $item) { return $unitPriceTaxExcl + (isset($item['unit_price_tax_excl']) ? $item['unit_price_tax_excl'] : 0); @@ -488,12 +487,11 @@ class OrderDetailCore extends ObjectModel $serviceProductData = array_shift($serviceProductData); - $numDays = 1; - if ((Product::PRICE_CALCULATION_METHOD_PER_DAY == $this->product_price_calculation_method) - && (!$numDays = HotelHelper::getNumberOfDays($serviceProductData['date_from'], $serviceProductData['date_to'])) - ) { - $numDays = 1; - } + $numDays = Product::getPriceCalculationApplicableDays( + $this->product_price_calculation_method, + $serviceProductData['date_from'], + $serviceProductData['date_to'] + ); $quantity = $quantity * $numDays; } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index f97c589fc..457a0baa9 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -483,7 +483,7 @@ class OrderInvoiceCore extends ObjectModel return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); }); - $details = $order->getProductTaxesDetails($order_detail, false); + $details = $order->getProductTaxesDetails($order_detail, false,Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($sum_composite_taxes) { $grouped_details = array(); @@ -550,7 +550,7 @@ class OrderInvoiceCore extends ObjectModel ); }); - $details = $order->getProductTaxesDetails($order_detail, false); + $details = $order->getProductTaxesDetails($order_detail, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($sum_composite_taxes) { $grouped_details = array(); @@ -609,8 +609,6 @@ class OrderInvoiceCore extends ObjectModel // - 'total_price_tax_excl' // - 'total_amount' $breakdown = array(); - $order_detail = array(); - $products = $this->getProducts(); $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && ( diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index ad3586d3b..e234ef7fa 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1015,15 +1015,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We } } - $serviceProductPrice = $objOrder->getTotalProductsWithTaxes( - false, - false, - null, - null, - null, - [], - Order::SERVICE_PRODUCT_CONTEXT_ROOM_LINKED - ); + $serviceProductPrice = $objOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); if ($demands = $objHotelBookingDemands->getExtraDemandsTaxesDetails($objOrder->id)) { $demandsPrice = array_sum(array_column($demands, 'total_price_tax_excl')); // Adding the tax @@ -1187,12 +1179,11 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objOrderDetail = new OrderDetail($service['id_order_detail']); $objServiceProductOrderDetail = new ServiceProductOrderDetail($service['id_service_product_order_detail']); $quantity = $objServiceProductOrderDetail->quantity; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $quantity = $quantity * HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - } + $quantity *= Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); if (isset($this->wsRequestedRoomTypes[$dateRoomJoinKey]['services'][$service['id_product']])) { $oldPriceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index c38b6d896..2b8115761 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1211,33 +1211,39 @@ class AdminCartsControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo, + $idCart + ) / max($numDays, 1); + } + } + } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); } - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $numDays = Product::getPriceCalculationApplicableDays( - $servProduct['price_calculation_method'], - $dateFrom, - $dateTo - ); - - $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( - $servProduct['id_product'], - 0, - 0, - $idProduct, - false, - 1, - $dateFrom, - $dateTo, - $idCart - )/$numDays; - } - } - $objServiceProductCartDetail = new ServiceProductCartDetail(); if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( $idCart, @@ -1381,6 +1387,7 @@ class AdminCartsControllerCore extends AdminController $idHotelCartBooking = Tools::getValue('id_hotel_cart_booking'); // valiadate services being added if (Validate::isLoadedObject($objHtlCartBooking = new HotelCartBookingData($idHotelCartBooking))) { + $objCart = new Cart($objHtlCartBooking->id_cart); $name = trim(Tools::getValue('new_service_name')); $price = Tools::getValue('new_service_price'); $priceCalcMethod = Tools::getValue('new_service_price_calc_method'); @@ -1415,6 +1422,15 @@ class AdminCartsControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid service name'); } + + if (empty($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Please select at least one price calculation method.'); + } elseif ( + !Validate::isUnsignedInt($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Invalid price calculation method.'); + } if (!isset($price)) { $response['hasError'] = true; @@ -1427,6 +1443,12 @@ class AdminCartsControllerCore extends AdminController // if no validation errors then add service if (!$response['hasError']) { // ======= START: Create Service product ========= + if ($objCart->id_currency != (int)Configuration::get('PS_CURRENCY_DEFAULT')) { + $currency = Currency::getCurrencyInstance($objCart->id_currency); + $price = Tools::ps_round($price/$currency->conversion_rate, 6); + $this->context->currency = new Currency((int) $objCart->id_currency); + } + $objServiceProduct = new Product(); $objServiceProduct->price_calculation_method = $priceCalcMethod; $objServiceProduct->selling_preference_type = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; @@ -1466,7 +1488,6 @@ class AdminCartsControllerCore extends AdminController RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE ); // If service product is create successfully the start adding the product in cart and order - $objCart = new Cart($objHtlCartBooking->id_cart); $objServiceProduct = new Product($objServiceProduct->id, false, $objCart->id_lang); $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -1539,16 +1560,32 @@ class AdminCartsControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $objCartBookingData->date_from, + $objCartBookingData->date_to + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $objCartBookingData->id_product, + false, + 1, + $objCartBookingData->date_from, + $objCartBookingData->date_to, + $objCartBookingData->id_cart + )/$numDays; + } + } } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($objCartBookingData->id_product, 1, 0, false, 2, null); } - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - } - } $objServiceProductCartDetail = new ServiceProductCartDetail(); if ($selectedRoomServiceProduct = $objCartBookingData->getRoomRowByIdProductIdRoomInDateRange( @@ -1632,6 +1669,39 @@ class AdminCartsControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid unit price for service').': '.$objProduct->name; } + + if ($selected && $objProduct->allow_multiple_quantity + && isset($serviceQuantities[$idServiceProduct]) + && Validate::isUnsignedInt($serviceQuantities[$idServiceProduct]) + ) { + $cartTotalQty = Cart::getProductQtyInCart($objCart->id, $idServiceProduct); + + $qty = (int)$serviceQuantities[$idServiceProduct]; + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + + $existingQty = 0; + $objSpCartDetail = new ServiceProductCartDetail(); + if ($idExistingDetail = $objSpCartDetail->alreadyExists( + $objCart->id, + $idServiceProduct, + $idCartBooking + )) { + $existingQty = (int)(new ServiceProductCartDetail($idExistingDetail))->quantity * $numDays; + } + + $finalQty = (int)$cartTotalQty - $existingQty + ($qty * $numDays); + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError(sprintf('Cannot add more than %d quantity.', $objProduct->max_quantity)).': '.$objProduct->name; + } elseif (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$idServiceProduct)) && !$objProduct->checkQty($finalQty)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('There isn\'t enough product in stock.').': '.$objProduct->name; + } + } } else { $response['errors'][] = Tools::displayError('Some services not found. please try after refreshing the page'); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index ba3dbb220..7bea0215f 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -227,7 +227,7 @@ class AdminNormalProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.') '.HotelBranchInformation::addHotelRestriction(false, 'hrt'); - $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, CASE a.`price_calculation_method` WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.' THEN "'.$this->l('Only check-in day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.' THEN "'.$this->l('Only check-out day').'" WHEN '.Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN "'.$this->l('Only during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN "'.$this->l('Check-in and check-out days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-out | during-stay days').'" WHEN '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN "'.$this->l('Check-in | check-out | during-stay days').'" ELSE "'.$this->l('Only check-in day').'" END as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; + $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; $this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`'; @@ -302,13 +302,14 @@ class AdminNormalProductsControllerCore extends AdminController 'callback' => 'getPriceDisplayPreference', 'list' => $priceAdditionType, ); - $this->fields_list['price_calculation_method_txt'] = array( + $this->fields_list['price_calculation_method'] = array( 'title' => $this->l('Price calculation method'), 'filter_key' => 'a!price_calculation_method', 'type' => 'select', 'list' => $priceCalculationMethod, 'visible_default' => true, 'optional' => true, + 'callback' => 'getPriceCalculationMethod', ); $this->servicesCategory = array(); $idServiceCategory = Configuration::get('PS_SERVICE_CATEGORY'); @@ -432,23 +433,29 @@ class AdminNormalProductsControllerCore extends AdminController public function getBuyingOption($selling_preference_type, $row) { - if ($selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { - return $this->l('With room type'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE) { - return $this->l('With hotel|room type'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE) { - return $this->l('Standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { - return $this->l('With hotel'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE) { - return $this->l('With hotel|standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE) { - return $this->l('With room type|standalone'); - } else if ($selling_preference_type == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) { - return $this->l('With hotel|room type|standalone'); + $list = $this->fields_list['selling_preference_type']['list']; + + if (!isset($list[$selling_preference_type])) { + return '--'; } - return '--'; + $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$selling_preference_type]))); + + return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + } + + public function getPriceCalculationMethod($txt, $row) + { + $list = $this->fields_list['price_calculation_method']['list']; + $method = (int)$row['price_calculation_method']; + + if (!isset($list[$method])) { + return '--'; + } + + $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$method]))); + + return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); } public function getHotelName($hotelName, $row) @@ -480,7 +487,7 @@ class AdminNormalProductsControllerCore extends AdminController .'template')) { $bo_theme = 'default'; } - + $this->addJqueryUI('ui.tooltip', 'base', true); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js'); @@ -2360,6 +2367,14 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('This product must be in the default category.'); } + if (!Tools::getValue('selling_preference_type')) { + $this->errors[] = $this->l('Please select at least one buying option.'); + } + + if (!Tools::getValue('price_calculation_method')) { + $this->errors[] = $this->l('Please select at least one price calculation method.'); + } + // Tags foreach ($languages as $language) { if ($value = Tools::getValue('tags_'.$language['id_lang'])) { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 4739ab5d1..05c7a4f3c 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -996,25 +996,56 @@ class AdminOrdersControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); - } else { - $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); - } + ); + + if($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + if (!empty($additionalServices[$productLineData['id']]) + && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } else { - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - if (isset($additionalServices[$productLineData['id']]) - && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) - ) { - unset($serviceProducts[$key]); + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo + ) / max($numDays, 1); + } } } + } else { + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + if ($serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) { + foreach ($serviceProducts as $key => $servProduct) { + if (isset($additionalServices[$productLineData['id']]) + && in_array($servProduct['id_product'], array_column($additionalServices[$productLineData['id']]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } + } - $smartyVars['serviceProducts'] = $serviceProducts; + } } + + $smartyVars['serviceProducts'] = $serviceProducts; $objOrderReturn = new OrderReturn(); $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1); $smartyVars['refundReqBookings'] = $refundReqBookings; @@ -5469,7 +5500,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objBookingDetail->date_from, $objBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxExcl = Product::getServiceProductPrice( (int) $service['id_product'], 0, @@ -5479,7 +5510,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objBookingDetail->date_from, $objBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objServiceProductOrderDetail->id_product = $service['id_product']; @@ -6235,61 +6266,67 @@ class AdminOrdersControllerCore extends AdminController && count($orderServiceProduct['additional_services']) ) { foreach ($orderServiceProduct['additional_services'] as $serviceProduct) { - if ($serviceProduct['price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $newNumDays = HotelHelper::getNumberOfDays($new_date_from, $new_date_to); - $objServiceProductOrderDetail = new ServiceProductOrderDetail((int) $serviceProduct['id_service_product_order_detail']); - $unitPriceTaxExcl = $objServiceProductOrderDetail->unit_price_tax_excl; - $unitPriceTaxIncl = $objServiceProductOrderDetail->unit_price_tax_incl; + $newNumDays = Product::getPriceCalculationApplicableDays( + $serviceProduct['price_calculation_method'], + $new_date_from, + $new_date_to + ); + $oldNumDays = Product::getPriceCalculationApplicableDays( + $serviceProduct['price_calculation_method'], + $old_date_from, + $old_date_to + ); + $objServiceProductOrderDetail = new ServiceProductOrderDetail((int) $serviceProduct['id_service_product_order_detail']); + $unitPriceTaxExcl = $objServiceProductOrderDetail->unit_price_tax_excl; + $unitPriceTaxIncl = $objServiceProductOrderDetail->unit_price_tax_incl; - $newTotalPriceTaxExcl = Tools::processPriceRounding( - ($newNumDays * $unitPriceTaxExcl), - $objServiceProductOrderDetail->quantity, - $order->round_type, - $order->round_mode - ); - $newTotalPriceTaxIncl = Tools::processPriceRounding( - ($newNumDays * $unitPriceTaxIncl), - $objServiceProductOrderDetail->quantity, - $order->round_type, - $order->round_mode - ); + $newTotalPriceTaxExcl = Tools::processPriceRounding( + ($newNumDays * $unitPriceTaxExcl), + $objServiceProductOrderDetail->quantity, + $order->round_type, + $order->round_mode + ); + $newTotalPriceTaxIncl = Tools::processPriceRounding( + ($newNumDays * $unitPriceTaxIncl), + $objServiceProductOrderDetail->quantity, + $order->round_type, + $order->round_mode + ); - $order->total_products -= $objServiceProductOrderDetail->total_price_tax_excl; - $order->total_products_wt -= $objServiceProductOrderDetail->total_price_tax_incl; + $order->total_products -= $objServiceProductOrderDetail->total_price_tax_excl; + $order->total_products_wt -= $objServiceProductOrderDetail->total_price_tax_incl; - // change order total - $order->total_products += $newTotalPriceTaxExcl; - $order->total_products_wt += $newTotalPriceTaxIncl; + // change order total + $order->total_products += $newTotalPriceTaxExcl; + $order->total_products_wt += $newTotalPriceTaxIncl; - $objOrderDetail = new OrderDetail((int) $serviceProduct['id_order_detail']); - $objOrderDetail->total_price_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; - $objOrderDetail->total_price_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; + $objOrderDetail = new OrderDetail((int) $serviceProduct['id_order_detail']); + $objOrderDetail->total_price_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; + $objOrderDetail->total_price_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; - $objOrderDetail->total_price_tax_excl += $newTotalPriceTaxExcl; - $objOrderDetail->total_price_tax_incl += $newTotalPriceTaxIncl; + $objOrderDetail->total_price_tax_excl += $newTotalPriceTaxExcl; + $objOrderDetail->total_price_tax_incl += $newTotalPriceTaxIncl; - $oldNumDays = HotelHelper::getNumberOfDays($old_date_from, $old_date_to); - $oldProductQuantity = $objServiceProductOrderDetail->quantity * $oldNumDays; - $newProductQuantity = $objServiceProductOrderDetail->quantity * $newNumDays; - $objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity); + $oldProductQuantity = $objServiceProductOrderDetail->quantity * $oldNumDays; + $newProductQuantity = $objServiceProductOrderDetail->quantity * $newNumDays; + $objOrderDetail->product_quantity += ($newProductQuantity - $oldProductQuantity); - $objOrderDetail->save(); - $this->context->cart = new Cart($objServiceProductOrderDetail->id_cart); - $objOrderDetail->updateTaxAmount($order); + $objOrderDetail->save(); + $this->context->cart = new Cart($objServiceProductOrderDetail->id_cart); + $objOrderDetail->updateTaxAmount($order); - if (isset($order_invoice)) { - $order_invoice->total_paid_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; - $order_invoice->total_paid_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; + if (isset($order_invoice)) { + $order_invoice->total_paid_tax_excl -= $objServiceProductOrderDetail->total_price_tax_excl; + $order_invoice->total_paid_tax_incl -= $objServiceProductOrderDetail->total_price_tax_incl; - $order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl; - $order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl; - } - $objServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl; - $objServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl; - $objServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl; - $objServiceProductOrderDetail->total_price_tax_incl = $newTotalPriceTaxIncl; - $objServiceProductOrderDetail->save(); + $order_invoice->total_paid_tax_excl += (float)$newTotalPriceTaxExcl; + $order_invoice->total_paid_tax_incl += (float)$newTotalPriceTaxIncl; } + $objServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl; + $objServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl; + $objServiceProductOrderDetail->total_price_tax_excl = $newTotalPriceTaxExcl; + $objServiceProductOrderDetail->total_price_tax_incl = $newTotalPriceTaxIncl; + $objServiceProductOrderDetail->save(); } } } @@ -6766,15 +6803,6 @@ class AdminOrdersControllerCore extends AdminController $order_invoice->total_discount_tax_excl = 0; $res &= $order_invoice->update(); } - - // If no rooms left in the order, Update Order total and discounts to 0 - $order->total_discounts = 0; - $order->total_discounts_tax_incl = 0; - $order->total_discounts_tax_excl = 0; - $order->total_paid = 0; - $order->total_paid_tax_incl = 0; - $order->total_paid_tax_excl = 0; - $order->update(); } // Assign to smarty informations in order to show the new product line @@ -7479,17 +7507,48 @@ class AdminOrdersControllerCore extends AdminController $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) ); + if ($serviceProducts) { + foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + if (!empty($additionalServices[$idHtlBookingDetail]) + && in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product')) + ) { + unset($serviceProducts[$key]); + } else { + + $numDays = Product::getPriceCalculationApplicableDays( + $servProduct['price_calculation_method'], + $dateFrom, + $dateTo + ); + + $serviceProducts[$key]['price_tax_exc'] = Product::getServiceProductPrice( + $servProduct['id_product'], + 0, + 0, + $idProduct, + false, + 1, + $dateFrom, + $dateTo + ) / max($numDays, 1); + } + } + } + } else { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); - $serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null); - } - - if ($serviceProducts) { - foreach ($serviceProducts as $key => $servProduct) { - $serviceProducts[$key]['price_tax_exc'] = $servProduct['price']; - if (isset($additionalServices[$idHtlBookingDetail]) && $additionalServices[$idHtlBookingDetail]) { - if (in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product'))) { - unset($serviceProducts[$key]); + if ($serviceProducts = $objRoomTypeServiceProduct->getServiceProductsData($idProduct, 1, 0, false, 2, null)) { + foreach ($serviceProducts as $key => $servProduct) { + if (!empty($additionalServices[$idHtlBookingDetail])) { + if (in_array($servProduct['id_product'], array_column($additionalServices[$idHtlBookingDetail]['additional_services'], 'id_product'))) { + unset($serviceProducts[$key]); + } } } } @@ -7643,13 +7702,11 @@ class AdminOrdersControllerCore extends AdminController $objServiceProductOrderDetail->quantity = $quantity; $objServiceProductOrderDetail->unit_price_tax_excl = $unitPrice; $objServiceProductOrderDetail->unit_price_tax_incl = $unitPrice * $oldTaxMultiplier; - $numDays = 1; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - } + $numDays = Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); $objServiceProductOrderDetail->total_price_tax_excl = Tools::processPriceRounding( ($objServiceProductOrderDetail->unit_price_tax_excl * $numDays), $quantity, @@ -7667,22 +7724,14 @@ class AdminOrdersControllerCore extends AdminController $priceDiffTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl - $oldTotalPriceTaxExcl; $priceDiffTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl - $oldTotalPriceTaxIncl; - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - $quantityDiff = ($objServiceProductOrderDetail->quantity - $oldQuantity)*$numDays; - } else { - $quantityDiff = $objServiceProductOrderDetail->quantity - $oldQuantity; - } + $quantityDiff = ($objServiceProductOrderDetail->quantity - $oldQuantity) * $numDays; $objOrderDetail->product_quantity += $quantityDiff; $objOrderDetail->total_price_tax_excl += $priceDiffTaxExcl; $objOrderDetail->total_price_tax_incl += $priceDiffTaxIncl; - $objOrderDetail->unit_price_tax_excl = ($objOrderDetail->total_price_tax_excl / $objOrderDetail->product_quantity); - $objOrderDetail->unit_price_tax_incl = ($objOrderDetail->total_price_tax_incl / $objOrderDetail->product_quantity); + $objOrderDetail->unit_price_tax_excl = ($objOrderDetail->total_price_tax_excl / max($objOrderDetail->product_quantity, 1)); + $objOrderDetail->unit_price_tax_incl = ($objOrderDetail->total_price_tax_incl / max($objOrderDetail->product_quantity, 1)); $result &= $objOrderDetail->updateTaxAmount($objOrder); @@ -7770,6 +7819,25 @@ class AdminOrdersControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = sprintf($this->l('Invalid unit price for %s.'), $objProduct->name); } + + if ($objProduct->allow_multiple_quantity && Validate::isUnsignedInt($qty[$service])) { + $finalQty = (int)$qty[$service]; + $numDays = Product::getPriceCalculationApplicableDays( + Product::getProductPriceCalculation($service), + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); + $stockQty = $finalQty * $numDays; + + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $response['hasError'] = true; + $response['errors'][] = sprintf($this->l('Cannot add more than %d quantity.'), $objProduct->max_quantity).': '.$objProduct->name; + } elseif (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$service)) && !$objProduct->checkQty($stockQty)) { + $response['hasError'] = true; + $response['errors'][] = $this->l('There isn\'t enough product in stock.').': '.$objProduct->name; + } + } + $selectedServices[$key] = array( 'id' => $service, 'qty' => $qty[$service], @@ -7826,7 +7894,7 @@ class AdminOrdersControllerCore extends AdminController 1, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to - ) / $numDays; + ) / max($numDays, 1); if ($initialServicePrice != $service['price']) { $specific_price = new SpecificPrice(); @@ -7887,7 +7955,7 @@ class AdminOrdersControllerCore extends AdminController 1, null, $roomHtlCartInfo['id'] - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxIncl = Product::getServiceProductPrice( (int) $product['id_product'], 0, @@ -7902,7 +7970,7 @@ class AdminOrdersControllerCore extends AdminController 1, null, $roomHtlCartInfo['id'] - ) / $numDays; + ) / max($numDays, 1); $totalPriceChangeTaxExcl += $totalPriceTaxExcl = Tools::processPriceRounding( ($unitPriceTaxExcl * $numDays), @@ -8047,6 +8115,15 @@ class AdminOrdersControllerCore extends AdminController $response['errors'][] = Tools::displayError('Invalid service name'); } + if (empty($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Please select at least one price calculation method.'); + } elseif ( + !Validate::isUnsignedInt($priceCalcMethod)) { + $response['hasError'] = true; + $response['errors'][] = Tools::displayError('Invalid price calculation method.'); + } + if (!isset($price)) { $response['hasError'] = true; $response['errors'][] = Tools::displayError('Service price is required'); @@ -8054,7 +8131,6 @@ class AdminOrdersControllerCore extends AdminController $response['hasError'] = true; $response['errors'][] = Tools::displayError('Invalid service price'); } - // if no validation errors then add service if (!$response['hasError']) { // ======= START: Create Service product ========= @@ -8164,7 +8240,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objCart->id - ) / $numDays; + ) / max($numDays, 1); $unitPriceTaxIncl = Product::getServiceProductPrice( (int)$product['id_product'], 0, @@ -8175,7 +8251,7 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to, $objCart->id - ) / $numDays; + ) / max($numDays, 1); $totalPriceChangeTaxExcl += $totalPriceTaxExcl = Tools::processPriceRounding( ($unitPriceTaxExcl * $numDays), @@ -8358,13 +8434,12 @@ class AdminOrdersControllerCore extends AdminController if ($res &= $objServiceProductOrderDetail->delete()) { $order = new Order($objServiceProductOrderDetail->id_order); - if ($objOrderDetail->product_price_calculation_method == Product::PRICE_CALCULATION_METHOD_PER_DAY) { - $numDays = HotelHelper::getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); - $quantity = $quantity * $numDays; - } + $numDays = Product::getPriceCalculationApplicableDays( + $objOrderDetail->product_price_calculation_method, + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to + ); + $quantity = $quantity * $numDays; if ($quantity >= $objOrderDetail->product_quantity) { $objOrderDetail->delete(); } else { diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 0a7acb76f..7c8c20efc 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -415,9 +415,12 @@ class AdminProductsControllerCore extends AdminController ); $objProduct = new Product(); - $hotelServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE); - $roomTypeServiceProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); - $allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts); + $allServiceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + } + )); $serviceProducts = array(); foreach ($allServiceProducts as $serviceProduct) { $serviceProducts[$serviceProduct['id_product']] = $serviceProduct['name']; @@ -3152,9 +3155,12 @@ class AdminProductsControllerCore extends AdminController $objRoomType = new HotelRoomType(); if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) { - $hotelServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE); - $roomTypeServiceProducts = $obj->getServiceProducts(null, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); - $allServiceProducts = array_merge($roomTypeServiceProducts, $hotelServiceProducts); + $allServiceProducts = array_values(array_filter( + $obj->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + } + )); $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index ba6b3b371..95ee79919 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -2304,9 +2304,9 @@ class AdminStatsControllerCore extends AdminStatsTabController IFNULL(SUM( CASE WHEN od.`purchase_supplier_price` <> "0.000000" - THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) + THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) WHEN od.`purchase_supplier_price` = "0.000000" - THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_PER_BOOKING.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) + THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) END ), 0) FROM `'._DB_PREFIX_.'service_product_order_detail` rtspod diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 98fb6eaac..67ee06439 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -482,7 +482,11 @@ class CartControllerCore extends FrontController if ($product->allow_multiple_quantity) { $finalQuantity = $this->qty; if (isset($productCartDetail) && $productCartDetail) { - $finalQuantity += $productCartDetail['quantity']; + $quantityInCart = Cart::getProductQtyInCart( + $id_cart, + $this->id_product + ); + $finalQuantity += $quantityInCart; } if ($product->max_quantity && $finalQuantity > $product->max_quantity) { $this->errors[] = Tools::displayError(sprintf('You cannot add more than %d quantity for this product in the cart.', $product->max_quantity)); @@ -560,22 +564,24 @@ class CartControllerCore extends FrontController } } - // Check product quantity availability - if ($this->id_product_attribute) { - if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + // Check product quantity availability only when no earlier validation error exists + if (!$this->errors) { + if ($this->id_product_attribute) { + if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); + } + } elseif ($product->hasAttributes()) { + $minimumQuantity = ($product->out_of_stock == 2) ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock; + $this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity); + // @todo do something better than a redirect admin !! + if (!$this->id_product_attribute) { + Tools::redirectAdmin($this->context->link->getProductLink($product)); + } elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); + } + } elseif (!$product->checkQty($qty_to_check)) { $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } - } elseif ($product->hasAttributes()) { - $minimumQuantity = ($product->out_of_stock == 2) ? !Configuration::get('PS_ORDER_OUT_OF_STOCK') : !$product->out_of_stock; - $this->id_product_attribute = Product::getDefaultAttribute($product->id, $minimumQuantity); - // @todo do something better than a redirect admin !! - if (!$this->id_product_attribute) { - Tools::redirectAdmin($this->context->link->getProductLink($product)); - } elseif (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !ProductAttribute::checkAttributeQty($this->id_product_attribute, $qty_to_check)) { - $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); - } - } elseif (!$product->checkQty($qty_to_check)) { - $this->errors[] = Tools::displayError('There isn\'t enough product in stock.', !Tools::getValue('ajax')); } // If no errors, process product addition @@ -748,8 +754,20 @@ class CartControllerCore extends FrontController if ($objProduct->allow_multiple_quantity) { if (!Validate::isUnsignedInt($qty)) { $this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.'); - } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) { - $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } else { + $cartTotalQty = Cart::getProductQtyInCart((int)$this->context->cart->id,(int)$idServiceProduct); + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBookingData->date_from, + $objHotelCartBookingData->date_to + ); + $currentQty = $qty * $numDays; + $finalQty = (int)$cartTotalQty + $currentQty; + if ($objProduct->max_quantity && $finalQty > $objProduct->max_quantity) { + $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity)); + } else if (!Product::isAvailableWhenOutOfStock($objProduct->out_of_stock) && !$objProduct->checkQty($finalQty)) { + $this->errors[] = Tools::displayError('There isn\'t enough product in stock.'); + } } } else { $qty = 1; diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index fd684953b..3b6fd2b2b 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -524,10 +524,7 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if ( - Product::isSellableWithHotel($type_value['selling_preference_type']) - || Product::isSellableAsStandalone($type_value['selling_preference_type']) - ) { + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -535,21 +532,21 @@ class GuestTrackingControllerCore extends FrontController } else { $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($hotelProducts as $hotelProduct) { + $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $cover_image_arr = $product->getCover($type_value['product_id']); - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( - $idOrder, - $type_value['id_order_detail'], - $type_value['product_id'] - ); - foreach ($serviceProducts as $serviceProduct) { - $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - - if ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) { - $hotelServiceProducts[] = array_merge($type_value, $serviceProduct); - } elseif ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) { - $standaloneServiceProducts[] = array_merge($type_value, $serviceProduct); - } + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($standaloneProducts as $standaloneProduct) { + $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); } } } diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index 44940f97d..e40a7bec0 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -149,6 +149,7 @@ class OrderConfirmationControllerCore extends FrontController $cart_standalone_service_products = array(); $cart_hotel_service_products = array(); $cart_htl_data = array(); + foreach ($cartOrders as $cartOrder) { $idOrder = $cartOrder['id_order']; $objCartOrder = new Order($idOrder); @@ -298,7 +299,7 @@ class OrderConfirmationControllerCore extends FrontController if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; } - $additionalServicesPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $extraDemandPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -310,12 +311,10 @@ class OrderConfirmationControllerCore extends FrontController 1, 0 ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI; - $orderTotalInfo['total_services_ti'] += $additionalServicesPriceTI; if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; } - $additionalServicesPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $extraDemandPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -327,13 +326,11 @@ class OrderConfirmationControllerCore extends FrontController 0, 0 ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE; - $orderTotalInfo['total_services_te'] += $additionalServicesPriceTE; // get auto added price to be displayed with room price if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; } - $autoAddedServicesPriceTI = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -346,12 +343,10 @@ class OrderConfirmationControllerCore extends FrontController 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $autoAddedServicesPriceTI; - $orderTotalInfo['total_auto_add_services_ti'] += $autoAddedServicesPriceTI; if (empty($cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; } - $autoAddedServicesPriceTE = $objServiceProductOrderDetail->getRoomTypeServiceProducts( + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, 0, 0, @@ -364,16 +359,10 @@ class OrderConfirmationControllerCore extends FrontController 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM ); - $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $autoAddedServicesPriceTE; - $orderTotalInfo['total_auto_add_services_te'] += $autoAddedServicesPriceTE; $totalRoomsBooked += 1; } - } else { - $canSellWithRoomType = Product::isSellableWithRoomType($type_value['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($type_value['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($type_value['selling_preference_type']); - + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -383,43 +372,36 @@ class OrderConfirmationControllerCore extends FrontController } $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); foreach ($serviceProducts as $serviceProduct) { - $idHotel = (int)$serviceProduct['id_hotel']; - $isRoomLinked = !empty($serviceProduct['id_htl_booking_detail']); + $type_value['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; + $type_value['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; + $type_value['product_quantity'] = $serviceProduct['quantity']; + $type_value['option_name'] = $serviceProduct['option_name']; + $type_value['location'] = $serviceProduct['option_name']; - $serviceLine = $type_value; - $serviceLine['unit_price_tax_excl'] = $serviceProduct['unit_price_tax_excl']; - $serviceLine['unit_price_tax_incl'] = $serviceProduct['unit_price_tax_incl']; - $serviceLine['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; - $serviceLine['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; - $serviceLine['product_quantity'] = $serviceProduct['quantity']; - $serviceLine['option_name'] = $serviceProduct['option_name']; - - if ( - $canSellWithRoomType - && (int)$type_value['product_auto_add'] == 1 - && (int)$type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT - ) { - $orderTotalInfo['total_convenience_fee_ti'] += $serviceLine['total_price_tax_incl']; - $orderTotalInfo['total_convenience_fee_te'] += $serviceLine['total_price_tax_excl']; - continue; + if ($hotelInfo = $objHtlBranchInfo->hotelBranchesInfo($this->context->language->id, 2, 1, $serviceProduct['id_hotel'])) { + $type_value['hotel_location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. + ($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '. + $hotelInfo['country_name'].', '.$hotelInfo['postcode']; } + $cart_hotel_service_products[] = $type_value; + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $cover_image_arr = $product->getCover($type_value['product_id']); - if ($canSellWithHotel && $idHotel) { - $serviceLine['location'] = $serviceProduct['option_name']; - if ($hotelInfo = $objHtlBranchInfo->hotelBranchesInfo($this->context->language->id, 2, 1, $idHotel)) { - $serviceLine['hotel_location'] = $hotelInfo['hotel_name'].', '.$hotelInfo['city']. - ($hotelInfo['state_name']?', '.$hotelInfo['state_name']:'').', '. - $hotelInfo['country_name'].', '.$hotelInfo['postcode']; - } - $cart_hotel_service_products[] = $serviceLine; - } elseif ($canSellAsStandalone && !$idHotel && !$isRoomLinked) { - $cart_standalone_service_products[] = $serviceLine; - } else { - continue; - } - - $orderTotalInfo['total_standalone_products_ti'] += $serviceLine['total_price_tax_incl']; - $orderTotalInfo['total_standalone_products_te'] += $serviceLine['total_price_tax_excl']; + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($idOrder, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($serviceProducts as $serviceProduct) { + $type_value['unit_price_tax_excl'] = $serviceProduct['unit_price_tax_excl']; + $type_value['unit_price_tax_incl'] = $serviceProduct['unit_price_tax_incl']; + $type_value['total_price_tax_excl'] = $serviceProduct['total_price_tax_excl']; + $type_value['total_price_tax_incl'] = $serviceProduct['total_price_tax_incl']; + $type_value['product_quantity'] = $serviceProduct['quantity']; + $type_value['option_name'] = $serviceProduct['option_name']; + $cart_standalone_service_products[] = $type_value; } } } @@ -433,9 +415,17 @@ class OrderConfirmationControllerCore extends FrontController if (!$objCartOrder->hasInvoice()) { $orders_has_invoice = 0; } + $orderTotalInfo['total_standalone_products_ti'] += ($objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)+$objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE)); + $orderTotalInfo['total_standalone_products_te'] += ($objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)+$objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_STANDALONE)); $orderTotalInfo['total_wrapping'] += $objCartOrder->total_wrapping; $orderTotalInfo['total_rooms_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, true); $orderTotalInfo['total_rooms_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, true); + $orderTotalInfo['total_auto_add_services_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $orderTotalInfo['total_auto_add_services_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM); + $orderTotalInfo['total_services_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0); + $orderTotalInfo['total_services_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 0); + $orderTotalInfo['total_convenience_fee_te'] += $objCartOrder->getTotalProductsWithoutTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); + $orderTotalInfo['total_convenience_fee_ti'] += $objCartOrder->getTotalProductsWithTaxes(false, false, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT); $orderTotalInfo['total_discounts'] += $objCartOrder->total_discounts; $orderTotalInfo['total_discounts_te'] += $objCartOrder->total_discounts_tax_excl; @@ -481,6 +471,7 @@ class OrderConfirmationControllerCore extends FrontController $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl'); } + /** * Execute the hook displayPaymentReturn */ diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 98e979865..c71439dab 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -101,7 +101,6 @@ class OrderDetailControllerCore extends FrontController $total_convenience_fee_te = 0; $total_convenience_fee_ti = 0; $roomTypes = array(); - $processedConvenienceFeeProducts = array(); $objOrderReturn = new OrderReturn(); $refundedAmount = 0; $refundedAmount = $objOrderReturn->getRefundedAmount($order->id); @@ -359,17 +358,8 @@ class OrderDetailControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } else { - $canSellWithRoomType = Product::isSellableWithRoomType($type_value['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($type_value['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($type_value['selling_preference_type']); - - if ($canSellWithRoomType - && $type_value['product_auto_add'] - && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT - && !isset($processedConvenienceFeeProducts[$type_value['product_id']]) - ) { - $processedConvenienceFeeProducts[$type_value['product_id']] = true; + } else if (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $id_order, $type_value['product_id'], @@ -395,50 +385,37 @@ class OrderDetailControllerCore extends FrontController 1 ); } - - if ($canSellWithHotel || $canSellAsStandalone) { - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder( - $id_order, - $type_value['id_order_detail'], - $type_value['product_id'] - ); - - foreach ($serviceProducts as $serviceProduct) { - $idHotel = (int)$serviceProduct['id_hotel']; - $isRoomLinked = !empty($serviceProduct['id_htl_booking_detail']); - - // Room-linked rows are already included in room detail block. - if ($isRoomLinked) { - continue; - } - - if ($canSellWithHotel && $idHotel) { - $hotelProduct = array_merge($type_value, $serviceProduct); - $hotelServiceProducts[] = $hotelProduct; - $formattedProduct = $serviceProduct; - $formattedProduct['refund_denied'] = 0; - if (isset($serviceProduct['refund_info']) - && ($serviceProduct['refund_info']['refunded'] && !$serviceProduct['refund_info']['id_customization']) - ) { - $formattedProduct['refund_denied'] = 1; - } - } elseif ($canSellAsStandalone && !$idHotel) { - $standaloneProduct = array_merge($type_value, $serviceProduct); - $standaloneServiceProducts[] = $standaloneProduct; - $formattedProduct = $serviceProduct; - } else { - continue; - } - - if (!isset($serviceProductsFormatted[$serviceProduct['id_product']])) { - $serviceProductsFormatted[$serviceProduct['id_product']] = array( - 'id_product' => $serviceProduct['id_product'], - 'name' => $serviceProduct['name'], - 'options' => array() - ); - } - $serviceProductsFormatted[$serviceProduct['id_product']]['options'][] = $formattedProduct; + } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($hotelProducts as $hotelProduct) { + $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); + if (!isset($serviceProductsFormatted[$hotelProduct['id_product']])) { + $serviceProductsFormatted[$hotelProduct['id_product']] = array( + 'id_product' => $hotelProduct['id_product'], + 'name' => $hotelProduct['name'], + 'options' => array() + ); } + $hotelProduct['refund_denied'] = 0; + if (isset($hotelProduct['refund_info']) + && ($hotelProduct['refund_info']['refunded'] && !$hotelProduct['refund_info']['id_customization']) + ) { + $hotelProduct['refund_denied'] = 1; + } + $serviceProductsFormatted[$hotelProduct['id_product']]['options'][] = $hotelProduct; + } + } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); + foreach ($standaloneProducts as $standaloneProduct) { + $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); + if (!isset($serviceProductsFormatted[$standaloneProduct['id_product']])) { + $serviceProductsFormatted[$standaloneProduct['id_product']] = array( + 'id_product' => $standaloneProduct['id_product'], + 'name' => $standaloneProduct['name'], + 'options' => array() + ); + } + $serviceProductsFormatted[$standaloneProduct['id_product']]['options'][] = $standaloneProduct; } } $roomTypes[$type_value['id_product']] = $type_value; diff --git a/js/admin.js b/js/admin.js index 48507c79a..06665a2df 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1749,3 +1749,15 @@ function closeRecommendation() } }); } + +function applyPriceCalcMethodValue() +{ + var ci = $('#pcm_checkin').is(':checked') ? 1 : 0; + var co = $('#pcm_checkout').is(':checked') ? 2 : 0; + var ds = $('#pcm_duringstay').is(':checked') ? 4 : 0; + $('#price_calculation_method').val(ci + co + ds); +} +$(document).on('change','#pcm_checkin, #pcm_checkout, #pcm_duringstay', function() { + applyPriceCalcMethodValue(); +}); +applyPriceCalcMethodValue(); \ No newline at end of file diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 9826b146f..6b283d882 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -565,34 +565,21 @@ product_tabs['Informations'] = new function(){ function applySellingPreferenceUIState() { - var sellingPreference = parseInt($('#selling_preference_type').val(), 10); - var showHotelTree = $.inArray(sellingPreference, [ - SELLING_PREFERENCE_HOTEL_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showRoomTypeTree = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; - var showAutoAddToCart = $.inArray(sellingPreference, [ - 0, - SELLING_PREFERENCE_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ]) !== -1; + var withRoomType = $('#sp_with_room_type').is(':checked'); + var withHotel = $('#sp_with_hotel').is(':checked'); + var standalone = $('#sp_standalone').is(':checked'); + + // Bitmask: Room Type=1, Hotel=2, Standalone=4 + var sellingPreference = (withRoomType ? 1 : 0) + (withHotel ? 2 : 0) + (standalone ? 4 : 0); + $('#selling_preference_type').val(sellingPreference); + var $autoAddOff = $('#auto_add_to_cart_off'); var $autoAddCheckedInput; - toggleAssociationFieldNames('#associated_hotel_tree', showHotelTree); - toggleAssociationFieldNames('#associated_hotel_rooms_tree', showRoomTypeTree); + toggleAssociationFieldNames('#associated_hotel_tree', withHotel); + toggleAssociationFieldNames('#associated_hotel_rooms_tree', withRoomType); - if (showAutoAddToCart) { + if (withRoomType) { $('#auto_add_to_cart_container').show('fast'); $autoAddCheckedInput = $('input[name="auto_add_to_cart"]:checked'); if (!$autoAddCheckedInput.length) { @@ -609,12 +596,12 @@ product_tabs['Informations'] = new function(){ $('#product_options').show('fast'); } - $('#selling_preference_type').on('change',function(){ + $('#sp_with_room_type, #sp_with_hotel, #sp_standalone').on('change', function(){ setTimeout(function() { applySellingPreferenceUIState(); }, 0); }); - $('#selling_preference_type').trigger('change'); + applySellingPreferenceUIState(); $('#simple_product').attr('checked', true); $('input[name="type_product"]').on('click', function(e) diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index 85c34b47e..a7cdbe2e3 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -748,11 +748,12 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; - var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3]) > 0); for (aProduct in jsonData.products) { //we've called the variable aProduct because IE6 bug if this variable is called product //if product has attributes - if (isHotelRow && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { + if (isHotelRow && jsonData.products[aProduct]['id'] == ids[0] + && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { $.each(jsonData.products[aProduct]['hotel_wise_data'], function() { if (ids[3] == this.id_hotel) { stayInTheCart = true; @@ -760,7 +761,20 @@ var ajaxCart = { }); } else { if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) { - stayInTheCart = true; + var productType = parseInt(jsonData.products[aProduct]['selling_preference_type']); + var isStandaloneRow = (typeof ids[3] == 'undefined' || parseInt(ids[3]) === 0); + + if (!isStandaloneRow) { + } else if ( + ajaxCart.isSellableAsStandalone(productType) + && (ajaxCart.isSellableWithHotel(productType) || ajaxCart.isSellableWithRoomType(productType)) + ) { + if (parseInt(jsonData.products[aProduct]['standalone_total_qty']) > 0) { + stayInTheCart = true; + } + } else { + stayInTheCart = true; + } // update the product customization display (when the product is still in the cart) ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], productDomId); } diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 86b46ddd7..4a8565923 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1027,6 +1027,25 @@ class HotelCartBookingData extends ObjectModel } } } + + // Check available stock: remove if cart quantity exceeds what is in stock. + if (!$toRemoveService) { + $availableQty = Product::getQuantity((int)$service['id_product']); + $totalQty = Cart::getProductQtyInCart((int)$service['id_cart'],(int)$service['id_product']); + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$service['id_product'])) + && $availableQty !== false + && $availableQty < (int)$totalQty + ) { + $toRemoveService = 1; + } + } + + // Check max quantity: remove if cart quantity exceeds the product's configured maximum. + if (!$toRemoveService && $product->allow_multiple_quantity && (int)$product->max_quantity > 0) { + if ((int)$service['quantity'] > (int)$product->max_quantity) { + $toRemoveService = 1; + } + } } if ($toRemoveService) { diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 709a9b23a..afc2a0735 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2187,7 +2187,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_PER_BOOKING, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_INDEPENDENT, 'en' => array( 'name' => 'Internet Handling Charges', diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 9bac1f873..06bcd0079 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -200,7 +200,12 @@ class RoomTypeServiceProduct extends ObjectModel $subCategory )) { $serviceProducts = Product::getProductsProperties($idLang, $serviceProducts); - foreach($serviceProducts as &$serviceProduct) { + foreach($serviceProducts as $key => &$serviceProduct) { + if (!$serviceProduct['allow_oosp'] && $serviceProduct['quantity'] <= 0) { + unset($serviceProducts[$key]); + continue; + } + $serviceProduct['price_tax_exc'] = Product::getServiceProductPrice( (int)$serviceProduct['id_product'], 0, diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index f7456863e..512e12b6b 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -95,7 +95,9 @@ class ServiceProductCartDetail extends ObjectModel $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to ); - $updateQty *= $numdays; + if($numdays){ + $updateQty *= $numdays; + } if ($objServiceProductCartDetail->delete()) { $objCart = new Cart($product['id_cart']); if (isset(Context::getContext()->controller->controller_type)) { @@ -269,7 +271,7 @@ class ServiceProductCartDetail extends ObjectModel 1, null, $product['htl_cart_booking_id'] - )/$numDays; + ) / max($numDays, 1); $priceTaxExcl = Product::getServiceProductPrice( $objProduct->id, $product['id_product_option'], @@ -284,7 +286,7 @@ class ServiceProductCartDetail extends ObjectModel 1, null, $product['htl_cart_booking_id'] - )/$numDays; + ) / max($numDays, 1); $optionDetails = false; if (ServiceProductOption::productHasOptions($product['id_product'])) { @@ -461,9 +463,11 @@ class ServiceProductCartDetail extends ObjectModel $objHotelCartBooking->date_from, $objHotelCartBooking->date_to ); - $quantity = $objServiceProductCartDetail->quantity * $numDays; + if($numDays){ + $quantity = $quantity * $numDays; + } } - + $objCart = new Cart($idCart); return $objCart->updateQty($quantity, $idProduct); } @@ -514,6 +518,16 @@ class ServiceProductCartDetail extends ObjectModel $updateQunatity = $objServiceProductCartDetail->delete(); } if ($updateQunatity) { + if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($product['id_hotel_cart_booking']))) { + $objProduct = new Product((int) $product['id_product']); + $numDays = Product::getPriceCalculationApplicableDays( + $objProduct->price_calculation_method, + $objHotelCartBooking->date_from, + $objHotelCartBooking->date_to + ); + $removedQuantity = $removedQuantity * $numDays; + } + $objCart = new Cart($idCart); if (isset(Context::getContext()->controller->controller_type)) { $controllerType = Context::getContext()->controller->controller_type; diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index d8cadf9e9..3a181b149 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -372,7 +372,7 @@
    diff --git a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php index fd72eb7e3..684cf15f9 100644 --- a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php +++ b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php @@ -179,24 +179,25 @@ class QloStatsServiceProducts extends ModuleGrid public function setQueryForServices($dateBetween) { + $numNightsSql = 'IFNULL(DATEDIFF(hbd.`date_to`, hbd.`date_from`), 0)'; + $applicableDaysSql = 'CASE + WHEN spod.`id_htl_booking_detail` IS NULL OR spod.`id_htl_booking_detail` = 0 THEN 1 + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.') THEN 1 + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN 2 + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.') THEN GREATEST('.$numNightsSql.', 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) + ELSE GREATEST('.$numNightsSql.', 1) + END'; + $this->query = '(SELECT od.`product_name` as `display_name`, p.`active`, od.`product_auto_add` as auto_add_to_cart, od.`product_price_addition_type` as price_addition_type, ROUND(IFNULL(SUM(spod.`total_price_tax_excl` / o.`conversion_rate`), 0), 2) / SUM( - IF(od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', - (IF(spod.`id_htl_booking_detail`, - DATEDIFF(hbd.`date_to`, hbd.`date_from`), - 1)) * spod.`quantity`, - spod.`quantity` - ) + ('.$applicableDaysSql.') * spod.`quantity` ) AS avgPriceSold, IFNULL(SUM( - IF(od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', - (IF(spod.`id_htl_booking_detail`, - DATEDIFF(hbd.`date_to`, hbd.`date_from`), - 1)) * spod.`quantity`, - spod.`quantity` - ) + ('.$applicableDaysSql.') * spod.`quantity` ), 0) AS totalQuantitySold, ROUND(IFNULL(SUM(spod.`total_price_tax_excl` / o.`conversion_rate`), 0), 2) AS totalPriceSold FROM '._DB_PREFIX_.'service_product_order_detail spod diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 5a3db8aaa..b22722e4f 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -82,7 +82,7 @@

    - {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if} + {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price']|escape:'html':'UTF-8'}{else}{convertPrice price = $demand['price']|escape:'html':'UTF-8'}{/if}{if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Day'}{/if}

    @@ -156,7 +156,7 @@ $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' - ) > 1}{l s='/Night'}{/if} + ) > 1}{l s='/Day'}{/if} {/if} diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 5a8896426..fa04edfea 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -59,7 +59,7 @@ $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' ) > 1} - {l s='/Night'} + {l s='/Day'} {/if} {/block} {if $service_product.allow_multiple_quantity && $service_product.available_for_order && $service_product.max_quantity > 0} diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index 85c34b47e..a69ecd93f 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -748,11 +748,12 @@ var ajaxCart = { //try to know if the current product is still in the new list var stayInTheCart = false; - var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3], 10) > 0); + var isHotelRow = (typeof ids[3] != 'undefined' && parseInt(ids[3]) > 0); for (aProduct in jsonData.products) { //we've called the variable aProduct because IE6 bug if this variable is called product //if product has attributes - if (isHotelRow && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { + if (isHotelRow && jsonData.products[aProduct]['id'] == ids[0] + && (typeof jsonData.products[aProduct]['hotel_wise_data'] != 'undefined' && jsonData.products[aProduct]['hotel_wise_data'].length)) { $.each(jsonData.products[aProduct]['hotel_wise_data'], function() { if (ids[3] == this.id_hotel) { stayInTheCart = true; @@ -760,7 +761,20 @@ var ajaxCart = { }); } else { if (jsonData.products[aProduct]['id'] == ids[0] && (!ids[1] || jsonData.products[aProduct]['idCombination'] == ids[1])) { - stayInTheCart = true; + var productType = parseInt(jsonData.products[aProduct]['selling_preference_type']); + var isStandaloneRow = (typeof ids[3] == 'undefined' || parseInt(ids[3]) === 0); + + if (!isStandaloneRow) { + } else if ( + ajaxCart.isSellableAsStandalone(productType) + && (ajaxCart.isSellableWithHotel(productType) || ajaxCart.isSellableWithRoomType(productType)) + ) { + if (parseInt(jsonData.products[aProduct]['standalone_total_qty']) > 0) { + stayInTheCart = true; + } + } else { + stayInTheCart = true; + } // update the product customization display (when the product is still in the cart) ajaxCart.hideOldProductCustomizations(jsonData.products[aProduct], productDomId); } @@ -945,7 +959,7 @@ var ajaxCart = { if (product.booking_product) { content += formatCurrency(parseFloat(product.bookingData.total_room_type_amount), currency_format, currency_sign, currency_blank); - } else if (typeof(hotel_wise_data) != 'undefined') { + } else if (typeof(hotel_wise_data) != 'undefined' && ajaxCart.isSellableWithHotel(product.selling_preference_type)) { content += formatCurrency(parseFloat(hotel_wise_data.amount), currency_format, currency_sign, currency_blank); } else { content += formatCurrency(parseFloat(product.amount), currency_format, currency_sign, currency_blank); diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index a45968365..182945dfe 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -64,7 +64,7 @@ {foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} - {if isset($product.hotel_wise_data) && $product.hotel_wise_data} + {if Product::isSellableWithHotel($product.selling_preference_type) && isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} @@ -144,7 +144,7 @@ {/if} {/block} {block name='blockcart_shopping_cart_total_convenience_fee'} - {if isset($total_convenience_fee)} + {if isset($total_convenience_fee) && $total_convenience_fee}
    {convertPrice price=$total_convenience_fee} {l s='Convenience Fees' mod='blockcart'} @@ -326,7 +326,7 @@
    --> {block name='blockcart_layer_cart_total_convenience_fee'} - {if isset($total_convenience_fee)} + {if isset($total_convenience_fee) && $total_convenience_fee}
    {l s='Convenience Fees' mod='blockcart'} diff --git a/themes/hotel-reservation-theme/order-confirmation.tpl b/themes/hotel-reservation-theme/order-confirmation.tpl index e8cc450cc..2297d556b 100644 --- a/themes/hotel-reservation-theme/order-confirmation.tpl +++ b/themes/hotel-reservation-theme/order-confirmation.tpl @@ -254,9 +254,9 @@
    {l s='Unit Price'}
    {if $group_use_tax} - {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$objOrderCurrency} {/if}
    @@ -272,9 +272,9 @@
    {l s='Total Pricing'}
    {if $group_use_tax} - {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$objOrderCurrency} {/if}
    @@ -328,9 +328,9 @@
    {l s='Unit Price'}
    {if $group_use_tax} - {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.unit_price_tax_excl currency=$objOrderCurrency} {/if}
    @@ -346,9 +346,9 @@
    {l s='Total Pricing'}
    {if $group_use_tax} - {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_incl currency=$objOrderCurrency} {else} - {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$currency} + {displayWtPriceWithCurrency price=$product.total_price_tax_excl currency=$objOrderCurrency} {/if}
    diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index d1682db6a..c0bc6432d 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -1133,7 +1133,7 @@ {addJsDefL name=pending_state_msg}{l s='Pending...' js=1}{/addJsDefL} {addJsDefL name=mail_sending_err}{l s='Some error occurred while sending mail to the customer' js=1}{/addJsDefL} {addJsDefL name=refund_request_sending_error}{l s='Some error occurred while processing request for booking cancellation.' js=1}{/addJsDefL} - {addJsDefL name=no_bookings_selected}{l s='Please select at least one room to proceed for cancellation.' js=1}{/addJsDefL} + {addJsDefL name=no_bookings_selected}{l s='Please select at least one room or service to proceed for cancellation.' js=1}{/addJsDefL} {addJsDefL name=refund_request_success_txt}{l s='Request for booking cancellation is successffully created.' js=1}{/addJsDefL} {addJsDefL name=order_message_choose_txt}{l s='-- Choose --' js=1}{/addJsDefL} {addJsDefL name=order_message_success_txt}{l s='Order message sent successfully.' js=1}{/addJsDefL} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index 9492fbc86..70f6deb30 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@ {/if}
    -

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}{/if}

    +

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/day'}{/if}{/if}

    {if isset($demand['adv_option']) && $demand['adv_option']} - {foreach $associated_hotels as $hotel} - - {/foreach} - + +
    + +
    +
    + +
    {/if} {/block} + {block name='booking_form_associated_hotels'} +
    + {if isset($associated_hotels) && $associated_hotels} +
    + + +
    + {/if} +
    + {/block} {block name='booking_form_product_option'} {if isset($product_option) && $product_option} diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index a69ecd93f..51978e8fe 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -201,7 +201,7 @@ var ajaxCart = { var date_from = $('#room_check_in').val(); var date_to = $('#room_check_out').val(); - var id_hotel = $('#service_id_hotel').length ? $('#service_id_hotel').val() : 0; + var id_hotel = ($('input[name="buying_option"]').length && $('input[name="buying_option"]:checked').val() == '2') ? 0 : ($('#service_id_hotel').length ? $('#service_id_hotel').val() : 0); var occupancy = getBookingOccupancyDetails($(this).closest('.booking_room_fields'), parseInt(booking_product)); if (occupancy) { diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index b0771177c..4c375b794 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1590,4 +1590,12 @@ function getBookingOccupancy() } return occupancy; -} \ No newline at end of file +} + +$(document).on('change', 'input[name="buying_option"]', function() { + if ($(this).val() == '2') { + $('#hotel_selection_block').hide(); + } else { + $('#hotel_selection_block').show(); + } +}); \ No newline at end of file From 3acacf95f9525c90e80ba6798524105327b5482b Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Tue, 26 May 2026 17:53:50 +0530 Subject: [PATCH 18/76] Added: price calculation info tooltip on service products list --- admin/themes/default/css/admin-tooltip.css | 79 +++++++++++++++++++ admin/themes/default/js/admin-theme.js | 45 +++++++++++ .../normal_products/selected_option.tpl | 65 --------------- .../template/controllers/orders/form.tpl | 27 +++++++ .../_add_order_extra_services_tab_content.tpl | 5 +- ..._services_service_products_tab_content.tpl | 10 ++- .../_partials/_price-calculation-info.tpl | 43 ++++++++++ classes/Product.php | 4 +- .../admin/AdminNormalProductsController.php | 5 +- controllers/admin/AdminOrdersController.php | 2 + controllers/front/OrderOpcController.php | 1 + controllers/front/ProductController.php | 1 + js/admin/normal_products.js | 24 ++---- js/admin/orders.js | 19 ++++- .../_partials/cart_booking_demands.tpl | 3 +- .../_partials/order-extra-services.tpl | 1 + .../_partials/price-calculation-info.tpl | 43 ++++++++++ .../_partials/service-products-list-row.tpl | 1 + themes/hotel-reservation-theme/css/global.css | 34 ++++++++ themes/hotel-reservation-theme/js/global.js | 38 +++++++++ .../js/order-confirmation.js | 1 + .../js/order-detail.js | 1 + .../hotel-reservation-theme/js/order-opc.js | 1 + themes/hotel-reservation-theme/js/product.js | 3 +- 24 files changed, 363 insertions(+), 93 deletions(-) create mode 100644 admin/themes/default/css/admin-tooltip.css create mode 100644 admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl create mode 100644 themes/hotel-reservation-theme/_partials/price-calculation-info.tpl diff --git a/admin/themes/default/css/admin-tooltip.css b/admin/themes/default/css/admin-tooltip.css new file mode 100644 index 000000000..c4d618cb3 --- /dev/null +++ b/admin/themes/default/css/admin-tooltip.css @@ -0,0 +1,79 @@ +/* +* 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 +*/ + +/* Trigger element styles */ +.selected-option-info, +.price-calculation-info { + cursor: pointer; +} + +.price-calculation-info { + display: inline-block; + vertical-align: middle; + margin-left: 4px; +} + +.selected-option-info .icon-info-sign, +.price-calculation-info .icon-info-sign { + color: #00aff0; + font-size: 16px; +} + +/* Unified tooltip bubble */ +.ui-tooltip.admin-info-tooltip { + background: #ffffff; + border: 1px solid #ddd; + box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); + color: #333; + padding: 8px 12px; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip ul { + margin: 0; + padding: 0 0 0 16px; + list-style: disc; +} + +.ui-tooltip.admin-info-tooltip ul li { + padding: 2px 0; +} + +.ui-tooltip.admin-info-tooltip .price-info-tooltip-cont { + min-width: 160px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-label { + margin: 0 0 6px; + font-weight: 600; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-days { + margin: 0; + padding-left: 16px; + font-size: 13px; +} + +.ui-tooltip.admin-info-tooltip .applied-on-days li { + padding: 2px 0; +} diff --git a/admin/themes/default/js/admin-theme.js b/admin/themes/default/js/admin-theme.js index 1aa61350d..0fdc86b2e 100644 --- a/admin/themes/default/js/admin-theme.js +++ b/admin/themes/default/js/admin-theme.js @@ -479,3 +479,48 @@ $(document).ready(function() { $(this).prop('selected', false); }); }); //end dom ready + + +function initAdminTooltip(config) { + var $elements = $(config.selector); + if (!$elements.length) { + return; + } + $elements.each(function () { + if (config.skipIfInitialized && $(this).data('ui-tooltip')) { + return; + } + $(this).tooltip({ + content: config.getContent, + items: config.items, + trigger: 'hover', + tooltipClass: config.tooltipClass, + open: function (event, ui) { + if (typeof event.originalEvent === 'undefined') { + return false; + } + var $id = $(ui.tooltip).attr('id'); + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + }, + close: function (event, ui) { + ui.tooltip.hover( + function () { $(this).stop(true).fadeTo(400, 1); }, + function () { $(this).fadeOut(400, function () { $(this).remove(); }); } + ); + } + }); + }); +} + +$(document).ready(function () { + initAdminTooltip({ + selector: '.selected-option-info', + items: '.selected-option-info', + tooltipClass: 'admin-info-tooltip', + getContent: function () { + return $(this).data('options'); + } + }); +}); \ No newline at end of file diff --git a/admin/themes/default/template/controllers/normal_products/selected_option.tpl b/admin/themes/default/template/controllers/normal_products/selected_option.tpl index fab919780..24156a9e1 100644 --- a/admin/themes/default/template/controllers/normal_products/selected_option.tpl +++ b/admin/themes/default/template/controllers/normal_products/selected_option.tpl @@ -20,34 +20,6 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{if empty($selected_option_css_initialized)} - {assign var='selected_option_css_initialized' value=true scope='global'} - -{/if} {capture name='options_list'}
      @@ -59,40 +31,3 @@ {$selected_options|@count} Selected - -{if empty($selected_option_js_initialized)} - {assign var='selected_option_js_initialized' value=true scope='global'} - -{/if} diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index dda7d6aa5..3d6f19103 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -1595,6 +1595,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -1815,6 +1824,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -1865,6 +1883,15 @@ }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); diff --git a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl index d56daffe8..da29873a8 100644 --- a/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_add_order_extra_services_tab_content.tpl @@ -61,7 +61,10 @@
    -

    {$product['name']|escape:'html':'UTF-8'}

    +
    + {$product['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} +
    {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index d8d3ef96d..b322c7dde 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -53,7 +53,9 @@ {foreach $additionalServices['additional_services'] as $service}
    -
    {$service['name']|escape:'html':'UTF-8'}
    +
    + {$service['name']|escape:'html':'UTF-8'} +
    @@ -134,6 +136,7 @@ {$product['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} @@ -291,7 +294,10 @@ {$service['id_product']|escape:'html':'UTF-8'}{if !$service['product_deleted']} {/if} {$service['name']|escape:'html':'UTF-8'} + {$service['name']|escape:'html':'UTF-8'} + {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$service.price_calculation_method|default:0} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} diff --git a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl new file mode 100644 index 000000000..00ad669f5 --- /dev/null +++ b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl @@ -0,0 +1,43 @@ +{* +* 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 +*} + +{* Required param: pcm — price_calculation_method integer value *} + + + + + diff --git a/classes/Product.php b/classes/Product.php index f88ec4917..3267ff979 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -562,8 +562,8 @@ class ProductCore extends ObjectModel const SELLING_PREFERENCE_HOTEL_STANDALONE = 2; // Product to be sold Standalone with Hotels const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also const SELLING_PREFERENCE_STANDALONE = 4; // Product to be sold standalone - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 5; // Product to be sold standalone with Hotels and with Room types also - const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 6; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone const PRICE_ADDITION_TYPE_WITH_ROOM = 1; diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 7bea0215f..0c3986722 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -487,7 +487,7 @@ class AdminNormalProductsControllerCore extends AdminController .'template')) { $bo_theme = 'default'; } - $this->addJqueryUI('ui.tooltip', 'base', true); + $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.iframe-transport.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload.js'); $this->addJs(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$bo_theme.'/js/jquery.fileupload-process.js'); @@ -1542,6 +1542,9 @@ class AdminNormalProductsControllerCore extends AdminController _PS_JS_DIR_.'jquery/plugins/timepicker/jquery-ui-timepicker-addon.css', _PS_CSS_DIR_.'ps-hotel-reservation.css', )); + }else { + $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); + $this->addJqueryUI('ui.tooltip', 'base', true); } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 7dcae4db2..ba8a1e481 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1334,6 +1334,8 @@ class AdminOrdersControllerCore extends AdminController $this->addJqueryUI('ui.datepicker'); $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); + $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); + $this->addJqueryUI(array('ui.tooltip'), 'base', true); if ($this->display == 'view') { if ($this->loadObject()) { diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index d1814c445..1628eb376 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -416,6 +416,7 @@ class OrderOpcControllerCore extends ParentOrderController } else { $this->addJS(_THEME_MOBILE_JS_DIR_.'opc.js'); } + $this->addJqueryUI(array('ui.tooltip'), 'base', true); $this->addJS(array( _THEME_JS_DIR_.'tools/statesManagement.js', diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 2bd349a78..22e74f24b 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -40,6 +40,7 @@ class ProductControllerCore extends FrontController if (count($this->errors)) { return; } + $this->addJqueryUI(array('ui.tooltip'), 'base', true); if (!$this->useMobileTheme()) { $this->addCSS(_THEME_CSS_DIR_.'product.css'); diff --git a/js/admin/normal_products.js b/js/admin/normal_products.js index 3047cf9a0..e42f286de 100644 --- a/js/admin/normal_products.js +++ b/js/admin/normal_products.js @@ -568,26 +568,12 @@ product_tabs['Informations'] = new function(){ var withRoomType = $('#sp_with_room_type').is(':checked'); var withHotel = $('#sp_with_hotel').is(':checked'); var standalone = $('#sp_standalone').is(':checked'); + const sellingPreference = + (withRoomType ? SELLING_PREFERENCE_WITH_ROOM_TYPE : 0) | + (withHotel ? SELLING_PREFERENCE_HOTEL_STANDALONE : 0) | + (standalone ? SELLING_PREFERENCE_STANDALONE : 0); - var sellingPreference; - if (withRoomType && withHotel && standalone) { - sellingPreference = 7; // HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - } else if (withHotel && standalone) { - sellingPreference = 5; // HOTEL_STANDALONE_AND_WITH_STANDALONE - } else if (withRoomType && standalone) { - sellingPreference = 6; // STANDALONE_AND_WITH_ROOM_TYPE - } else if (withRoomType && withHotel) { - sellingPreference = 3; // HOTEL_STANDALONE_AND_WITH_ROOM_TYPE - } else if (standalone) { - sellingPreference = 4; // STANDALONE - } else if (withHotel) { - sellingPreference = 2; // HOTEL_STANDALONE - } else if (withRoomType) { - sellingPreference = 1; // WITH_ROOM_TYPE - } else { - sellingPreference = 0; - } - $('#selling_preference_type').val(sellingPreference); + $('#selling_preference_type').val(sellingPreference); var $autoAddOff = $('#auto_add_to_cart_off'); var $autoAddCheckedInput; diff --git a/js/admin/orders.js b/js/admin/orders.js index 9d88bb44a..2eb349cf8 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1410,6 +1410,15 @@ $(document).ready(function() { }, complete: function() { $(".loading_overlay").hide(); + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); } }); }); @@ -2481,7 +2490,15 @@ const EditRoomBookingModal = { // initialize datepickers EditRoomBookingModal.initDatePickers(); - + initAdminTooltip({ + selector: '.price-calculation-info', + items: 'span', + tooltipClass: 'admin-info-tooltip', + skipIfInitialized: true, + getContent: function () { + return $(this).siblings('.price-calculation-info-container').html(); + } + }); $('#edit_product .extra-services-container #id_htl_booking').val(jsonProductLineData.id); $('#edit-room-booking-modal').modal('show'); } else { diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index b22722e4f..7f218e0c8 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -134,7 +134,8 @@ {/if}
    -

    {$product['name']|escape:'html':'UTF-8'}

    + {$product['name']|escape:'html':'UTF-8'} + {include file='_partials/price-calculation-info.tpl' pcm=$product.price_calculation_method|default:0} {if $product.allow_multiple_quantity}
    diff --git a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl index 095cfc644..903ba40c8 100644 --- a/themes/hotel-reservation-theme/_partials/order-extra-services.tpl +++ b/themes/hotel-reservation-theme/_partials/order-extra-services.tpl @@ -58,6 +58,7 @@ {if $additionalService['allow_multiple_quantity']} {l s='(Quantity: %s)' sprintf=[$additionalService['quantity']|string_format:'%02d']} {/if} + {include file='_partials/price-calculation-info.tpl' pcm=$additionalService.price_calculation_method|default:0}
    diff --git a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl b/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl new file mode 100644 index 000000000..af5f05850 --- /dev/null +++ b/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl @@ -0,0 +1,43 @@ +{** +* 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 +*} + +{* Required param: pcm — price_calculation_method integer value *} + + + + + diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index fa04edfea..8df8fe516 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -38,6 +38,7 @@ {block name='service_product_name'}
    {$service_product['name']} + {include file='_partials/price-calculation-info.tpl' pcm=$service_product.price_calculation_method|default:0}
    {/block} {block name='service_product_description'} diff --git a/themes/hotel-reservation-theme/css/global.css b/themes/hotel-reservation-theme/css/global.css index 7fb667b55..5f279fe45 100644 --- a/themes/hotel-reservation-theme/css/global.css +++ b/themes/hotel-reservation-theme/css/global.css @@ -9187,3 +9187,37 @@ div a.our_properties_link{ color: #fff; font-size: 17px; font-weight: 400;} + +/* price calculation info tooltip */ +.price-calculation-info { + cursor: pointer; + display: inline-block; + vertical-align: middle; + margin-left: 4px; +} +.ui-tooltip.price-tootip { + box-shadow: 0 2px 6px 0 rgb(0 0 0 / 20%); + background: #FFFFFF; + border: unset; + color: #333; + padding: 9px 15px; +} +.ui-tooltip.price-tootip .price-info-tooltip-cont { + min-width: 160px; +} +.ui-tooltip.price-tootip .applied-on-label { + margin: 0 0 6px; + font-weight: 600; + font-size: 13px; +} +.ui-tooltip.price-tootip .applied-on-days { + margin: 0; + padding-left: 16px; + font-size: 13px; +} +.ui-tooltip.price-tootip .applied-on-days li { + padding: 2px 0; +} +.price-info-tooltip-cont ul li{ + list-style: disc;; +} diff --git a/themes/hotel-reservation-theme/js/global.js b/themes/hotel-reservation-theme/js/global.js index ff00f02c0..b842d5b47 100644 --- a/themes/hotel-reservation-theme/js/global.js +++ b/themes/hotel-reservation-theme/js/global.js @@ -457,3 +457,41 @@ window.addEventListener('online', function () { window.addEventListener('offline', function () { onlineFlag = false; }); + +function initPriceCalculationTooltip() { + if ($('.price-calculation-info').length) { + $('.price-calculation-info').each(function () { + if ($(this).hasClass('ui-tooltip-content')) { + return; + } + $(this).tooltip({ + content: $(this).siblings('.price-calculation-info-container').html(), + items: 'span', + trigger: 'hover', + tooltipClass: 'price-tootip', + open: function (event, ui) { + if (typeof (event.originalEvent) === 'undefined') { + return false; + } + var $id = $(ui.tooltip).attr('id'); + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + }, + close: function (event, ui) { + ui.tooltip.hover(function () { + $(this).stop(true).fadeTo(400, 1); + }, function () { + $(this).fadeOut('400', function () { + $(this).remove(); + }); + }); + } + }); + }); + } +} + +$(document).ready(function () { + initPriceCalculationTooltip(); +}); diff --git a/themes/hotel-reservation-theme/js/order-confirmation.js b/themes/hotel-reservation-theme/js/order-confirmation.js index 615bee6ff..d9b645df8 100644 --- a/themes/hotel-reservation-theme/js/order-confirmation.js +++ b/themes/hotel-reservation-theme/js/order-confirmation.js @@ -49,6 +49,7 @@ $(document).ready(function(){ if (result.extra_demands) { $('#rooms_extra_services').html(''); $('#rooms_extra_services').append(result.extra_demands); + initPriceCalculationTooltip(); } $.fancybox({ href: "#rooms_extra_services", diff --git a/themes/hotel-reservation-theme/js/order-detail.js b/themes/hotel-reservation-theme/js/order-detail.js index 800440304..a0e1a9ac7 100644 --- a/themes/hotel-reservation-theme/js/order-detail.js +++ b/themes/hotel-reservation-theme/js/order-detail.js @@ -362,6 +362,7 @@ $(document).on('click', '.btn-view-extra-services', function(e) { if (result.extra_demands) { $('#popup-view-extra-services').html(''); $('#popup-view-extra-services').append(result.extra_demands); + initPriceCalculationTooltip(); $.fancybox.open({ href: '#popup-view-extra-services', diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index 854f90fbb..999f73c67 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -705,6 +705,7 @@ $(document).ready(function() if (result.extra_demands) { $('#rooms_extra_services').html(''); $('#rooms_extra_services').append(result.extra_demands); + initPriceCalculationTooltip(); } $.fancybox({ href: "#rooms_extra_services", diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 4c375b794..c14bd9cff 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1171,6 +1171,7 @@ $(document).ready(function() { triggerElement.hide(); } } + initPriceCalculationTooltip(); } else { triggerElement.hide(); } @@ -1598,4 +1599,4 @@ $(document).on('change', 'input[name="buying_option"]', function() { } else { $('#hotel_selection_block').show(); } -}); \ No newline at end of file +}); From a940ad173e322d755c65776ee6649312b6091328 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Thu, 28 May 2026 19:37:51 +0530 Subject: [PATCH 19/76] Fix: Incorrect Product Selling Type Handling During Order Validation --- .../normal_products/informations.tpl | 6 +- classes/Cart.php | 58 +++++++------ classes/PaymentModule.php | 82 +++++++++++++++---- classes/Product.php | 73 +++++------------ classes/order/OrderDetail.php | 2 +- classes/order/OrderInvoice.php | 10 +-- classes/pdf/HTMLTemplateInvoice.php | 17 +--- classes/pdf/HTMLTemplateOrderSlip.php | 14 ++-- controllers/admin/AdminImportController.php | 4 +- controllers/admin/AdminOrdersController.php | 36 ++++---- controllers/admin/AdminProductsController.php | 4 +- controllers/front/CartController.php | 12 +-- controllers/front/GuestTrackingController.php | 6 +- .../front/OrderConfirmationController.php | 4 +- controllers/front/OrderDetailController.php | 6 +- controllers/front/ProductController.php | 14 ++-- modules/blockcart/blockcart.php | 8 +- modules/blockcart/blockcart.tpl | 6 +- modules/blockcart/cartrow.tpl | 12 +-- .../classes/HotelCartBookingData.php | 6 +- .../AdminHotelRoomsBookingController.php | 2 +- .../modules/blockcart/blockcart.tpl | 8 +- .../modules/blockcart/cartrow.tpl | 2 +- 23 files changed, 205 insertions(+), 187 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index b1d0b9f72..a528df729 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -241,21 +241,21 @@
    diff --git a/classes/Cart.php b/classes/Cart.php index d544f3cf9..813ff4f89 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -827,7 +827,7 @@ class CartCore extends ObjectModel $serviceProducts = array(); $context = Context::getContext(); foreach ($productList as $key => $product) { - if (!$product['booking_product'] && Product::isSellableAsStandalone($product['selling_preference_type'] && !Product::isSellableWithRoomType($product['selling_preference_type']))) { + if (!$product['booking_product'] && Product::isSellableAsStandalone($product['id_product']) && !Product::isSellableWithRoomType($product['id_product'])) { if (Validate::isLoadedObject( $objProduct = new Product($product['id_product'], false, $this->id_lang) )) { @@ -1659,9 +1659,9 @@ class CartCore extends ObjectModel continue; } - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); + $canSellWithRoomType = Product::isSellableWithRoomType($product['id_product']); + $canSellWithHotel = Product::isSellableWithHotel($product['id_product']); + $canSellAsStandalone = Product::isSellableAsStandalone($product['id_product']); if ($canSellWithRoomType) { if ($type == Cart::ONLY_STANDALONE_PRODUCTS && !$canSellAsStandalone && !$canSellWithHotel) { @@ -1753,9 +1753,6 @@ class CartCore extends ObjectModel $products_total[$id_tax_rules_group.'_'.$id_address] = 0; } if (!$product['booking_product']) { - $canSellWithRoomType = Product::isSellableWithRoomType($product['selling_preference_type']); - $canSellWithHotel = Product::isSellableWithHotel($product['selling_preference_type']); - $canSellAsStandalone = Product::isSellableAsStandalone($product['selling_preference_type']); $isRoomServiceTotalType = in_array($type, array( Cart::ONLY_ROOM_SERVICES, Cart::ONLY_CONVENIENCE_FEE, @@ -1764,10 +1761,28 @@ class CartCore extends ObjectModel Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE, )); - if ($canSellAsStandalone && !$isRoomServiceTotalType) { - $idHotelCartBooking = isset($product['id_hotel_cart_booking']) ? (int)$product['id_hotel_cart_booking'] : 0; - $idHotel = isset($product['id_hotel']) ? (int)$product['id_hotel'] : 0; + $singleContextSellTypes = [ + Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_HOTEL_STANDALONE, + Product::SELLING_PREFERENCE_STANDALONE, + ]; + $specificSellType = ($param_product + && isset($product['selling_preference_type']) + && in_array((int)$product['selling_preference_type'], $singleContextSellTypes)) + ? (int)$product['selling_preference_type'] + : null; + $sellsAsStandalone = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_STANDALONE) + : Product::isSellableAsStandalone($product['id_product']); + $sellsWithHotel = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_HOTEL_STANDALONE) + : Product::isSellableWithHotel($product['id_product']); + $sellsWithRoomType = $specificSellType !== null + ? ($specificSellType === Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) + : Product::isSellableWithRoomType($product['id_product']); + + if ($sellsAsStandalone && !$isRoomServiceTotalType) { if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -1791,8 +1806,8 @@ class CartCore extends ObjectModel } } - } - if ($canSellWithHotel ) { + } + if ($sellsWithHotel) { if ($type == Cart::ONLY_ROOM_SERVICES || $type == Cart::ONLY_CONVENIENCE_FEE || $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD @@ -1829,7 +1844,7 @@ class CartCore extends ObjectModel if ($serviceProducts) { foreach ($serviceProducts as $serviceProduct) { - if(!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { + if (!empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_hotel_cart_booking'])) { if ($with_taxes) { $priceAdd = $serviceProduct['total_price_tax_incl']; } else { @@ -1845,7 +1860,7 @@ class CartCore extends ObjectModel } } } - if ($canSellWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { + if ($sellsWithRoomType && $type !== Cart::ONLY_STANDALONE_PRODUCTS) { if ($servicesWithRoom = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, @@ -2436,7 +2451,7 @@ class CartCore extends ObjectModel } } } else { - if (Product::isSellableWithRoomType($product['selling_preference_type'])) { + if (Product::isSellableWithRoomType($product['id_product'])) { // get standard products which are booked for room types // send id_hotel = 0 for standard products with room types if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( @@ -2509,7 +2524,7 @@ class CartCore extends ObjectModel } } } - if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (Product::isSellableAsStandalone($product['id_product'])) { if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -2566,8 +2581,7 @@ class CartCore extends ObjectModel } } } - - if (Product::isSellableWithHotel($product['selling_preference_type'])) { + if (Product::isSellableWithHotel($product['id_product'])) { if ($selectedServiceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->id, [], @@ -3198,11 +3212,9 @@ class CartCore extends ObjectModel $id_address = HotelRoomType::getHotelIdAddressByIdProduct($id_product); } else { // if the product is a standard product the get the address as per the selling preference - $sellingPreferenceType = Product::getSellingPreferenceType($id_product); - - $canSellWithRoomType = Product::isSellableWithRoomType($sellingPreferenceType); - $canSellWithHotel = Product::isSellableWithHotel($sellingPreferenceType); - $canSellAsStandalone = Product::isSellableAsStandalone($sellingPreferenceType); + $canSellWithRoomType = Product::isSellableWithRoomType($id_product); + $canSellWithHotel = Product::isSellableWithHotel($id_product); + $canSellAsStandalone = Product::isSellableAsStandalone($id_product); if ($canSellWithHotel) { if ($htlAddress = HotelBranchInformation::getAddress($id_hotel)) { diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 43158862f..8b6e57e1b 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -589,12 +589,11 @@ abstract class PaymentModuleCore extends Module $virtual_product &= false; } - if ( - !$product['booking_product'] && !$product['id_hotel_cart_booking'] - && ( - Product::isSellableAsStandalone($product['selling_preference_type']) - || Product::isSellableWithHotel($product['selling_preference_type']) - ) + if (!$product['booking_product'] + && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -604,11 +603,10 @@ abstract class PaymentModuleCore extends Module $cover_img = $this->context->link->getImageLink($product['link_rewrite'], $this->context->language->iso_code."-default", 'small_default'); } $product_var_tpl['cover_img'] = $cover_img; - $idHotel = isset($product['id_hotel']) ? $product['id_hotel'] : 0; $serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $order->id_cart, [], - $idHotel, + null, 0, null, $product['id_product'] @@ -966,11 +964,9 @@ abstract class PaymentModuleCore extends Module if (!empty($normalProducts)) { $objServiceProductCartDetail = new ServiceProductCartDetail(); - foreach ($normalProducts as $product) { + foreach($normalProducts as $product) { $idProduct = $product['id_product']; - $productSellingType = $product['selling_preference_type']; - - if (Product::isSellableWithRoomType($productSellingType)) { + if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $product['selling_preference_type']) { if ($roomTypeServices = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -979,7 +975,6 @@ abstract class PaymentModuleCore extends Module null, $product['id_product'] )) { - $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, $product['selling_preference_type']); foreach ($roomTypeServices as $roomTypeService) { if (!$roomTypeService['id_hotel_cart_booking']) { @@ -1008,7 +1003,7 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->save(); } } - } elseif (Product::isSellableWithHotel($productSellingType)) { + } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $product['selling_preference_type']) { if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1042,7 +1037,7 @@ abstract class PaymentModuleCore extends Module } } - } elseif (Product::isSellableAsStandalone($productSellingType)) { + } elseif (Product::SELLING_PREFERENCE_STANDALONE == $product['selling_preference_type']) { if ($standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, [], @@ -1067,6 +1062,63 @@ abstract class PaymentModuleCore extends Module $objServiceProductOrderDetail->option_name = $standaloneProduct['option_name']; $objServiceProductOrderDetail->quantity = $standaloneProduct['quantity']; $objServiceProductOrderDetail->save(); + + } + } + } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { + $idProductRoomType = null; + $idProductHotel = null; + if (isset($product['id_room_type']) && $product['id_room_type']) { + $idProductRoomType = $product['id_room_type']; + } elseif (isset($product['id_hotel']) && $product['id_hotel']) { + $idProductHotel = $product['id_hotel']; + } + if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( + $this->context->cart->id, + [], + $idProductHotel, + null, + $idProductRoomType, + $product['id_product'] + )) { + foreach ($serviceProducts as $serviceProduct) { + if ($serviceProduct['id_hotel']) { + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + } else { + $idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); + } + $objServiceProductOrderDetail = new ServiceProductOrderDetail(); + $objServiceProductOrderDetail->id_product = $idProduct; + $objServiceProductOrderDetail->id_order = $order->id; + $objServiceProductOrderDetail->id_order_detail = $idOrderDetail; + $objServiceProductOrderDetail->id_cart = $this->context->cart->id; + $objServiceProductOrderDetail->unit_price_tax_excl = $serviceProduct['unit_price_tax_excl']; + $objServiceProductOrderDetail->unit_price_tax_incl = $serviceProduct['unit_price_tax_incl']; + $objServiceProductOrderDetail->total_price_tax_excl = $serviceProduct['total_price_tax_excl']; + $objServiceProductOrderDetail->total_price_tax_incl = $serviceProduct['total_price_tax_incl']; + $objServiceProductOrderDetail->name = $product['name']; + $objServiceProductOrderDetail->quantity = $serviceProduct['quantity']; + $objServiceProductOrderDetail->id_product_option = $serviceProduct['id_product_option']; + $objServiceProductOrderDetail->option_name = $serviceProduct['option_name']; + if ($serviceProduct['id_hotel']) { + $objServiceProductOrderDetail->id_hotel = $serviceProduct['id_hotel']; + if (Validate::isLoadedObject( + $objHotelBranch = new HotelBranchInformation($serviceProduct['id_hotel'], $this->context->cart->id_lang) + )) { + $objServiceProductOrderDetail->hotel_name = $objHotelBranch->hotel_name; + } + } else { + $roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange( + $order->id, + $serviceProduct['id_room_type'], + $serviceProduct['date_from'], + $serviceProduct['date_to'], + $serviceProduct['id_room'] + ); + $objServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id']; + $objServiceProductOrderDetail->auto_added = $product['auto_add_to_cart']; + } + $objServiceProductOrderDetail->save(); } } } diff --git a/classes/Product.php b/classes/Product.php index 3267ff979..32c6d0bfe 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -6938,64 +6938,33 @@ class ProductCore extends ObjectModel } } - public static function getSellingPreferenceChannels($sellingPreferenceType) + public static function isSellableWithRoomType($idProduct) { - $channels = [ - 'with_room_type' => false, - 'with_hotel' => false, - 'standalone' => false, - ]; - - switch ((int) $sellingPreferenceType) { - case self::SELLING_PREFERENCE_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE: - $channels['with_hotel'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - $channels['with_hotel'] = true; - break; - - case self::SELLING_PREFERENCE_STANDALONE: - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: - $channels['with_hotel'] = true; - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: - $channels['with_room_type'] = true; - $channels['standalone'] = true; - break; - - case self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: - $channels['with_room_type'] = true; - $channels['with_hotel'] = true; - $channels['standalone'] = true; - break; - } - - return $channels; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } - public static function isSellableWithRoomType($sellingPreferenceType) + public static function isSellableWithHotel($idProduct) { - return self::getSellingPreferenceChannels($sellingPreferenceType)['with_room_type']; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_HOTEL_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } - public static function isSellableWithHotel($sellingPreferenceType) + public static function isSellableAsStandalone($idProduct) { - return self::getSellingPreferenceChannels($sellingPreferenceType)['with_hotel']; - } - - public static function isSellableAsStandalone($sellingPreferenceType) - { - return self::getSellingPreferenceChannels($sellingPreferenceType)['standalone']; + return in_array((int) self::getSellingPreferenceType($idProduct), [ + self::SELLING_PREFERENCE_STANDALONE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + ]); } } diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index 926020678..f9e165503 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -390,7 +390,7 @@ class OrderDetailCore extends ObjectModel /** * Calculate tax rule groups for the service product based on each associated room type. */ - if (!$this->is_booking_product && Product::isSellableWithRoomType($this->selling_preference_type)) { + if (!$this->is_booking_product && $this->selling_preference_type == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE) { if ($this->product_auto_add && $this->product_price_addition_type == Product::PRICE_ADDITION_TYPE_WITH_ROOM) { return true; } diff --git a/classes/order/OrderInvoice.php b/classes/order/OrderInvoice.php index 457a0baa9..f3e79c9d5 100644 --- a/classes/order/OrderInvoice.php +++ b/classes/order/OrderInvoice.php @@ -415,7 +415,7 @@ class OrderInvoiceCore extends ObjectModel $order_detail = array_filter($order_detail, function($v) { return ($v['is_booking_product'] || ($v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -480,7 +480,7 @@ class OrderInvoiceCore extends ObjectModel $breakdown = array(); $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { - return (!$v['is_booking_product'] && !$v['product_auto_add'] && Product::isSellableWithRoomType($v['selling_preference_type'])); + return (!$v['is_booking_product'] && !$v['product_auto_add'] && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); }); $details = $order->getProductTaxesDetails($order_detail, false,Product::SELLING_PREFERENCE_WITH_ROOM_TYPE); @@ -545,7 +545,7 @@ class OrderInvoiceCore extends ObjectModel $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && $v['product_auto_add'] - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT ); }); @@ -612,8 +612,8 @@ class OrderInvoiceCore extends ObjectModel $order_detail = $this->getProducts(); $order_detail = array_filter($order_detail, function($v) { return (!$v['is_booking_product'] && ( - Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type']) + $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE )); }); diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 37b895353..c23fdd280 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -607,9 +607,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) { $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); } - } else if ( - Product::isSellableWithHotel($type_value['selling_preference_type']) - || Product::isSellableAsStandalone($type_value['selling_preference_type']) + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type'] + || Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type'] ) { $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order_obj->id, $type_value['id_order_detail'], $type_value['product_id']); if ($taxes = OrderDetail::getTaxListStatic($type_value['id_order_detail'])) { @@ -623,17 +622,7 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate $order_detail_tax_label = HTMLTemplateInvoice::l('No tax'); } foreach ($serviceProducts as $serviceProduct) { - $isStandaloneRow = empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - $isHotelRow = !empty($serviceProduct['id_hotel']) && empty($serviceProduct['id_htl_booking_detail']); - - if (!( - ($isStandaloneRow && Product::isSellableAsStandalone($type_value['selling_preference_type'])) - || ($isHotelRow && Product::isSellableWithHotel($type_value['selling_preference_type'])) - )) { - continue; - } - - if ($isHotelRow) { + if ($serviceProduct['id_hotel']) { $objHotel = new HotelBranchInformation($serviceProduct['id_hotel'], $order_obj->id_lang); $serviceProduct['hotel_name'] = $objHotel->hotel_name; } diff --git a/classes/pdf/HTMLTemplateOrderSlip.php b/classes/pdf/HTMLTemplateOrderSlip.php index 0c2a50c86..16396243f 100644 --- a/classes/pdf/HTMLTemplateOrderSlip.php +++ b/classes/pdf/HTMLTemplateOrderSlip.php @@ -286,7 +286,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice $order_detail = array_filter($this->order->products, function($v) { return ((isset($v['is_booking_product']) && $v['is_booking_product']) || ((isset($v['product_auto_add']) && $v['product_auto_add']) - && Product::isSellableWithRoomType($v['selling_preference_type']) + && $v['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM) ); }); @@ -347,14 +347,10 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice // - 'total_amount' $breakdown = array(); $order_detail = array_filter($this->order->products, function($v) { - return ( - !$v['is_booking_product'] - && empty($v['id_htl_booking']) - && ( - Product::isSellableAsStandalone($v['selling_preference_type']) - || Product::isSellableWithHotel($v['selling_preference_type']) - ) - ); + return (!$v['is_booking_product'] && ( + $v['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE + || $v['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE + )); }); $details = $this->order->getProductTaxesDetails($order_detail, false); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 60cfce9a0..060a01970 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1901,7 +1901,7 @@ class AdminImportControllerCore extends AdminController } $objServiceProduct = new Product($idServiceProduct); - if (Product::isSellableWithRoomType($objServiceProduct->selling_preference_type)) { + if (Product::isSellableWithRoomType($objServiceProduct->id)) { $objRoomTypeServiceProduct->addRoomProductLink( $objServiceProduct->id, $product->id, @@ -2329,7 +2329,7 @@ class AdminImportControllerCore extends AdminController $info['shop'] = explode($this->multiple_value_separator, $info['shop']); RoomTypeServiceProduct::deleteRoomProductLink($product->id); - if (Product::isSellableWithRoomType($product->selling_preference_type)) { + if (Product::isSellableWithRoomType($product->id)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if (isset($info['id_room_types']) && $info['id_room_types']) { $objRoomTypeServiceProduct->addRoomProductLink( diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ba8a1e481..fcf696f8a 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3357,14 +3357,14 @@ class AdminOrdersControllerCore extends AdminController } else { $product['image_link'] = $this->context->link->getImageLink($objProduct->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - if (Product::isSellableWithHotel($product['selling_preference_type']) - || Product::isSellableAsStandalone($product['selling_preference_type']) + if (Product::isSellableWithHotel($product['product_id']) + || Product::isSellableAsStandalone($product['product_id']) ) { $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id']); foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['selling_preference_type'])) { + if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['product_id'])) { $orderHotelServiceProducts[] = array_merge($product, $serviceProduct); - } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['selling_preference_type'])) { + } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['product_id'])) { $orderStandaloneServiceProducts[] = array_merge($product, $serviceProduct); } } @@ -3702,10 +3702,10 @@ class AdminOrdersControllerCore extends AdminController $hotelStandaloneProducts = array(); $standaloneProducts = array(); foreach ($allServiceProducts as $serviceProduct) { - if (Product::isSellableWithHotel($serviceProduct['selling_preference_type'])) { + if (Product::isSellableWithHotel($serviceProduct['id_product'])) { $hotelStandaloneProducts[] = $serviceProduct; } - if (Product::isSellableAsStandalone($serviceProduct['selling_preference_type'])) { + if (Product::isSellableAsStandalone($serviceProduct['id_product'])) { $standaloneProducts[] = $serviceProduct; } } @@ -4484,9 +4484,9 @@ class AdminOrdersControllerCore extends AdminController if ($product->booking_product || ( - Product::isSellableWithRoomType($product->selling_preference_type) - && !Product::isSellableWithHotel($product->selling_preference_type) - && !Product::isSellableAsStandalone($product->selling_preference_type) + Product::isSellableWithRoomType($product->id) + && !Product::isSellableWithHotel($product->id) + && !Product::isSellableAsStandalone($product->id) ) ) { die(Tools::jsonEncode(array( 'result' => false, @@ -5585,14 +5585,14 @@ class AdminOrdersControllerCore extends AdminController $response['error'] = Tools::displayError('The product object cannot be loaded.'); } elseif ($objProduct->booking_product || ( - Product::isSellableWithRoomType($objProduct->selling_preference_type) - && !Product::isSellableWithHotel($objProduct->selling_preference_type) - && !Product::isSellableAsStandalone($objProduct->selling_preference_type) + Product::isSellableWithRoomType($objProduct->id) + && !Product::isSellableWithHotel($objProduct->id) + && !Product::isSellableAsStandalone($objProduct->id) ) ) { $response['status'] = false; $response['error'] = Tools::displayError('Invalid product. Please try adding any other product.'); - } elseif (!Product::isSellableAsStandalone($objProduct->selling_preference_type) + } elseif (!Product::isSellableAsStandalone($objProduct->id) && (!$addressTax->id_hotel || !Validate::isLoadedObject($objHotel = new HotelBranchInformation($addressTax->id_hotel))) ) { @@ -5692,8 +5692,8 @@ class AdminOrdersControllerCore extends AdminController if ($response['status']) { // If product is standalone and current order is for a hotel then we have to create a new order for this product $response['new_id_order'] = 0; - if (Product::isSellableAsStandalone($objProduct->selling_preference_type) - && !Product::isSellableWithHotel($objProduct->selling_preference_type) + if (Product::isSellableAsStandalone($objProduct->id) + && !Product::isSellableWithHotel($objProduct->id) && $addressTax->id_hotel ) { $objPaymentModule = new BoOrder(); @@ -5777,9 +5777,9 @@ class AdminOrdersControllerCore extends AdminController $objOrderDetail = new OrderDetail(); $cartProducts = $objCart->getProducts(); - if (Product::isSellableWithHotel($cartProducts[0]['selling_preference_type']) && $addressTax->id_hotel) { + if (Product::isSellableWithHotel($cartProducts[0]['id_product']) && $addressTax->id_hotel) { $cartProducts[0]['selling_preference_type'] = Product::SELLING_PREFERENCE_HOTEL_STANDALONE; - } elseif (Product::isSellableAsStandalone($cartProducts[0]['selling_preference_type'])) { + } elseif (Product::isSellableAsStandalone($cartProducts[0]['id_product'])) { $cartProducts[0]['selling_preference_type'] = Product::SELLING_PREFERENCE_STANDALONE; } $objOrderDetail->createList($objOrder, $objCart, $objOrder->getCurrentOrderState(), $cartProducts, (isset($objOrderInvoice) ? $objOrderInvoice->id : 0), $useTaxes, (int)Tools::getValue('add_product_warehouse')); @@ -7993,7 +7993,7 @@ class AdminOrdersControllerCore extends AdminController $product['total'] = $totalPriceTaxExcl; $product['total_wt'] = $totalPriceTaxIncl; - if (Product::isSellableWithRoomType($product['selling_preference_type'])) { + if (Product::isSellableWithRoomType($product['id_product'])) { $product['selling_preference_type'] = Product::SELLING_PREFERENCE_WITH_ROOM_TYPE; } } diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 29518137e..445f7ba96 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -418,7 +418,7 @@ class AdminProductsControllerCore extends AdminController $allServiceProducts = array_values(array_filter( $objProduct->getServiceProducts(null), function ($serviceProduct) { - return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + return Product::isSellableWithRoomType($serviceProduct['id_product']); } )); $serviceProducts = array(); @@ -3227,7 +3227,7 @@ class AdminProductsControllerCore extends AdminController $allServiceProducts = array_values(array_filter( $obj->getServiceProducts(null), function ($serviceProduct) { - return Product::isSellableWithRoomType($serviceProduct['selling_preference_type']); + return Product::isSellableWithRoomType($serviceProduct['id_product']); } )); diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 67ee06439..10df365a1 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -180,8 +180,8 @@ class CartControllerCore extends FrontController } } else { $idProductOption = Tools::getValue('id_product_option', null); - $canSellWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($product->id); + $canSellStandalone = Product::isSellableAsStandalone($product->id); if ($canSellWithHotel && $this->id_hotel) { $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -460,8 +460,8 @@ class CartControllerCore extends FrontController $objHotelCartBookingData = new HotelCartBookingData(); $idProductOption = Tools::getValue('id_product_option'); $id_hotel = (int) Tools::getValue('id_hotel'); - $canSellWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($product->id); + $canSellStandalone = Product::isSellableAsStandalone($product->id); if ($canSellWithHotel && $id_hotel) { if ($operator == 'up') { @@ -643,7 +643,7 @@ class CartControllerCore extends FrontController } $this->context->cookie->avail_rooms = $availQty; } elseif ( - Product::isSellableWithHotel($product->selling_preference_type) + Product::isSellableWithHotel($product->id) && $id_hotel ) { $objServiceProductCartDetail = new ServiceProductCartDetail(); @@ -664,7 +664,7 @@ class CartControllerCore extends FrontController 'id_product_option' => isset($idProductOption) ? $idProductOption : null )); } - } elseif (Product::isSellableAsStandalone($product->selling_preference_type)) { + } elseif (Product::isSellableAsStandalone($product->id)) { $objServiceProductCartDetail = new ServiceProductCartDetail(); $update_quantity = $objServiceProductCartDetail->updateCartServiceProduct( $this->context->cart->id, diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index 3b6fd2b2b..991ffa5c5 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -497,7 +497,7 @@ class GuestTrackingControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } elseif (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + } elseif (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $type_value['selling_preference_type']) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $idOrder, @@ -524,7 +524,7 @@ class GuestTrackingControllerCore extends FrontController 1 ); } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type']) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -536,7 +536,7 @@ class GuestTrackingControllerCore extends FrontController foreach ($hotelProducts as $hotelProduct) { $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type']) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index e40a7bec0..dd428dff2 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -362,7 +362,7 @@ class OrderConfirmationControllerCore extends FrontController $totalRoomsBooked += 1; } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { @@ -385,7 +385,7 @@ class OrderConfirmationControllerCore extends FrontController } $cart_hotel_service_products[] = $type_value; } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if ($type_value['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { $cover_image_arr = $product->getCover($type_value['product_id']); if (!empty($cover_image_arr)) { diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index c71439dab..0a949c7e4 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -358,7 +358,7 @@ class OrderDetailControllerCore extends FrontController $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); } - } else if (Product::isSellableWithRoomType($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE ==$type_value['selling_preference_type']) { if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { $total_convenience_fee_ti += $objServiceProductOrderDetail->getRoomTypeServiceProducts( $id_order, @@ -385,7 +385,7 @@ class OrderDetailControllerCore extends FrontController 1 ); } - } else if (Product::isSellableWithHotel($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $type_value['selling_preference_type']) { $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); foreach ($hotelProducts as $hotelProduct) { $hotelServiceProducts[] = array_merge($type_value, $hotelProduct); @@ -404,7 +404,7 @@ class OrderDetailControllerCore extends FrontController } $serviceProductsFormatted[$hotelProduct['id_product']]['options'][] = $hotelProduct; } - } else if (Product::isSellableAsStandalone($type_value['selling_preference_type'])) { + } else if (Product::SELLING_PREFERENCE_STANDALONE == $type_value['selling_preference_type']) { $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($id_order, $type_value['id_order_detail'], $type_value['product_id']); foreach ($standaloneProducts as $standaloneProduct) { $standaloneServiceProducts[] = array_merge($type_value, $standaloneProduct); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 22e74f24b..4eeaaa987 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -135,12 +135,12 @@ class ProductControllerCore extends FrontController // if product is a service product then check type of selling preference if (!$this->product->booking_product) { if ( - Product::isSellableWithRoomType($this->product->selling_preference_type) - && !Product::isSellableWithHotel($this->product->selling_preference_type) - && !Product::isSellableAsStandalone($this->product->selling_preference_type) + Product::isSellableWithRoomType($this->product->id) + && !Product::isSellableWithHotel($this->product->id) + && !Product::isSellableAsStandalone($this->product->id) ) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); - } elseif (Product::isSellableWithHotel($this->product->selling_preference_type)) { + } elseif (Product::isSellableWithHotel($this->product->id)) { // For any hotel-sellable service product, ensure hotel associations exist. $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); $associatedHotels = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($this->product->id); @@ -921,9 +921,9 @@ class ProductControllerCore extends FrontController $buying_option = false ) { $smartyVars = array(); - $smartyVars['sellable_with_hotel'] = Product::isSellableWithHotel($this->product->selling_preference_type); - $smartyVars['sellable_as_standalone'] = Product::isSellableAsStandalone($this->product->selling_preference_type); - if (Product::isSellableWithHotel($this->product->selling_preference_type)) { + $smartyVars['sellable_with_hotel'] = Product::isSellableWithHotel($this->product->id); + $smartyVars['sellable_as_standalone'] = Product::isSellableAsStandalone($this->product->id); + if (Product::isSellableWithHotel($this->product->id)) { $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); if ($associatedHotels = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($this->product->id)['hotel']) { diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 2c2ea59ac..163d14acd 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -121,7 +121,7 @@ class Blockcart extends Module if (!$product['booking_product']) { $product['hasOptions'] = ServiceProductOption::productHasOptions($product['id_product']); - if (Product::isSellableAsStandalone($product['selling_preference_type'])) { + if (Product::isSellableAsStandalone($product['id_product'])) { $product['total_price_tax_incl'] = 0; $product['total_price_tax_excl'] = 0; $product['amount'] = 0; @@ -148,7 +148,7 @@ class Blockcart extends Module $nbTotalProducts += (int) $product['standalone_total_qty']; } - if (Product::isSellableWithHotel($product['selling_preference_type'])) { + if (Product::isSellableWithHotel($product['id_product'])) { if ($serviceProducts = $objServiceProductCartDetail->getServiceProductsInCart( $params['cart']->id, [(int) $product['selling_preference_type']], @@ -322,8 +322,8 @@ class Blockcart extends Module $addedProduct['date_from'] = Tools::displayDate($addedProduct['date_from'], null, $fullDate); $addedProduct['date_to'] = Tools::displayDate($addedProduct['date_to'], null, $fullDate); } else { - $canSellWithHotel = Product::isSellableWithHotel($objProduct->selling_preference_type); - $canSellStandalone = Product::isSellableAsStandalone($objProduct->selling_preference_type); + $canSellWithHotel = Product::isSellableWithHotel($objProduct->id); + $canSellStandalone = Product::isSellableAsStandalone($objProduct->id); if ($canSellWithHotel && !empty($addedProduct['id_hotel'])) { $addedProduct['unit_price'] = RoomTypeServiceProductPrice::getPrice( diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index ec29d14f4..6caf931e7 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -63,15 +63,15 @@
    {foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} + {if $product.booking_product || Product::isSellableAsStandalone($product.id_product) || Product::isSellableWithHotel($product.id_product)} {if isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} {/if} {if $product.booking_product - || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) - || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} + || (!Product::isSellableWithHotel($product.id_product) && !Product::isSellableWithRoomType($product.id_product)) + || (Product::isSellableAsStandalone($product.id_product) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} diff --git a/modules/blockcart/cartrow.tpl b/modules/blockcart/cartrow.tpl index 68d0cbc96..16363bca3 100644 --- a/modules/blockcart/cartrow.tpl +++ b/modules/blockcart/cartrow.tpl @@ -11,7 +11,7 @@
    {/block} {block name='blockcart_shopping_cart_hotel_name'} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)}
    {$hotel_wise_data.hotel_name|escape:'html':'UTF-8'}
    @@ -29,7 +29,7 @@ {if !isset($product.is_gift) || !$product.is_gift} {if $product.booking_product} {displayWtPrice p="`$product.bookingData.total_room_type_amount`"} - {else if Product::isSellableWithHotel($product.selling_preference_type)} + {else if Product::isSellableWithHotel($product.id_product)} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$hotel_wise_data.total_price_tax_excl`"}{else}{displayWtPrice p="`$hotel_wise_data.total_price_tax_incl`"}{/if} {else} {if $priceDisplay == $smarty.const.PS_TAX_EXC}{displayWtPrice p="`$product.total_price_tax_excl`"}{else}{displayWtPrice p="`$product.total_price_tax_incl`"}{/if} @@ -53,9 +53,9 @@ {if $product.booking_product} {$product.bookingData['total_num_rooms']} {elseif $product.allow_multiple_quantity} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)} {$hotel_wise_data.total_qty} - {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {elseif Product::isSellableAsStandalone($product.id_product)} {$product.cart_quantity} {/if} {/if} @@ -99,9 +99,9 @@ {/block} {else if $product.hasOptions} {block name='blockcart_shopping_cart_options'} - {if Product::isSellableWithHotel($product.selling_preference_type)} + {if Product::isSellableWithHotel($product.id_product)} {assign var='options' value=$hotel_wise_data.options} - {else if Product::isSellableAsStandalone($product.selling_preference_type)} + {else if Product::isSellableAsStandalone($product.id_product)} {assign var='options' value=$product.options} {/if}
    diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index 4a8565923..b77b92d4a 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -961,9 +961,9 @@ class HotelCartBookingData extends ObjectModel if (!$product->active || (!$forAdminCart && !$product->available_for_order)) { $toRemoveService = 1; } else if ($checkServiceRoomLink) { - $isSellableWithRoomType = Product::isSellableWithRoomType($product->selling_preference_type); - $isSellableWithHotel = Product::isSellableWithHotel($product->selling_preference_type); - $isSellableAsStandalone = Product::isSellableAsStandalone($product->selling_preference_type); + $isSellableWithRoomType = Product::isSellableWithRoomType($product->id); + $isSellableWithHotel = Product::isSellableWithHotel($product->id); + $isSellableAsStandalone = Product::isSellableAsStandalone($product->id); if (ServiceProductOption::productHasOptions($service['id_product'])) { $skipOptionValidation = false; diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 591e0d89d..e2572d465 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -624,7 +624,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController if (!$product->id || !$product->active) { $this->errors[] = $this->l('This product is no longer available.'); } - if ($product->booking_product || !Product::isSellableAsStandalone($product->selling_preference_type)) { + if ($product->booking_product || !Product::isSellableAsStandalone($product->id)) { // cannot be added without room type or is a booking product. $this->errors[] = $this->l('This product is either a room type or additional service and cannot be added through this method.'); } elseif (!$product->allow_multiple_quantity) { diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index 182945dfe..47121ca96 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -63,15 +63,15 @@
    {foreach from=$products key=data_k item='product' name='myLoop'} {* only show products that are booking or global without room *} - {if $product.booking_product || Product::isSellableAsStandalone($product.selling_preference_type) || Product::isSellableWithHotel($product.selling_preference_type)} - {if Product::isSellableWithHotel($product.selling_preference_type) && isset($product.hotel_wise_data) && $product.hotel_wise_data} + {if $product.booking_product || Product::isSellableAsStandalone($product.id_product) || Product::isSellableWithHotel($product.id_product)} + {if Product::isSellableWithHotel($product.id_product) && isset($product.hotel_wise_data) && $product.hotel_wise_data} {foreach $product.hotel_wise_data as $hotel_wise_data} {include file="./cartrow.tpl" hotel_wise_data=$hotel_wise_data} {/foreach} {/if} {if $product.booking_product - || (!Product::isSellableWithHotel($product.selling_preference_type) && !Product::isSellableWithRoomType($product.selling_preference_type)) - || (Product::isSellableAsStandalone($product.selling_preference_type) && $product.standalone_total_qty > 0)} + || (!Product::isSellableWithHotel($product.id_product) && !Product::isSellableWithRoomType($product.id_product)) + || (Product::isSellableAsStandalone($product.id_product) && $product.standalone_total_qty > 0)} {include file="./cartrow.tpl" hotel_wise_data=false} {/if} {/if} diff --git a/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl b/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl index f7ce76c25..8a31e3b2f 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/cartrow.tpl @@ -55,7 +55,7 @@ {elseif $product.allow_multiple_quantity} {if isset($hotel_wise_data.id_hotel) && $hotel_wise_data.id_hotel} {$hotel_wise_data.total_qty} - {elseif Product::isSellableAsStandalone($product.selling_preference_type)} + {elseif Product::isSellableAsStandalone($product.id_product)} {$product.standalone_total_qty|intval} {/if} {/if} From fa775f81693a026b0ff63ce43f0666faf0b3acc2 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 13:02:45 +0530 Subject: [PATCH 20/76] Refactor back office code by removing unused and redundant logic --- .../orders/_cart_booking_demands.tpl | 2 +- .../_add_order_extra_services_tab_content.tpl | 2 +- ..._extra_services_facilities_tab_content.tpl | 6 +- ..._services_service_products_tab_content.tpl | 6 +- classes/order/Order.php | 24 +-- controllers/admin/AdminCartsController.php | 58 ++++--- controllers/admin/AdminOrdersController.php | 152 +++++------------- 7 files changed, 86 insertions(+), 164 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl index bd695ea59..fad6ca46e 100644 --- a/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl +++ b/admin/themes/default/template/controllers/orders/_cart_booking_demands.tpl @@ -83,7 +83,7 @@ {if isset($selected_adv_option) && isset($demand['adv_option'][$selected_adv_option]['price_tax_excl'])}{convertPrice price = $demand['adv_option'][$selected_adv_option]['price_tax_excl']|escape:'html':'UTF-8'}{else if isset($demand['adv_option']) && $demand['adv_option']}{convertPrice price = $demand['adv_option'][$demand['adv_option']|@key]['price_tax_excl']}{else}{convertPrice price = $demand['price_tax_excl']|escape:'html':'UTF-8'}{/if} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if}
    {displayPrice price=$demand['unit_price_tax_excl'] currency=$orderCurrency} {if $demand['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY} - {l s='/ day'} + {l s='/ night'} {/if} {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} diff --git a/classes/order/Order.php b/classes/order/Order.php index 26ee52823..412f4460b 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2882,27 +2882,13 @@ class OrderCore extends ObjectModel } // check hotel linked products $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, $sellingPreferenceType) - ); + if ($hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)) { + $res &= $this->checkList($hotelProducts, $action, false); + $hasRoomsOrProducts = 1; } - $serviceProducts = array_filter($serviceProducts, function ($serviceProduct) { - return empty($serviceProduct['id_htl_booking_detail']); - }); - if ($serviceProducts) { - $res &= $this->checkList($serviceProducts, $action, false); + if ($standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($this->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE)) { + $res &= $this->checkList($standaloneProducts, $action, false); $hasRoomsOrProducts = 1; } diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 2b8115761..a30655767 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -354,12 +354,7 @@ class AdminCartsControllerCore extends AdminController $objServiceProductCartDetail = new ServiceProductCartDetail(); $hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $cart->id, - [ - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ], + [], $idHotel = null, 0, null, @@ -373,14 +368,15 @@ class AdminCartsControllerCore extends AdminController 1 ); + $hotelProducts = array_filter($hotelProducts, function ($product) { + return $product['id_hotel'] > 0 && $product['id_hotel_cart_booking'] == 0; + }); + $standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $cart->id, - [ - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE - ] + [], + 0, + 0 ); if (count($standaloneProducts)) { @@ -1205,20 +1201,22 @@ class AdminCartsControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) && Product::getQuantity((int)$servProduct['id_product']) <= 0 ) { unset($serviceProducts[$key]); continue; } + $numDays = Product::getPriceCalculationApplicableDays( $servProduct['price_calculation_method'], $dateFrom, @@ -1554,14 +1552,22 @@ class AdminCartsControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { + + if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) + && Product::getQuantity((int)$servProduct['id_product']) <= 0 + ) { + unset($serviceProducts[$key]); + continue; + } + $numDays = Product::getPriceCalculationApplicableDays( $servProduct['price_calculation_method'], $objCartBookingData->date_from, @@ -1578,7 +1584,7 @@ class AdminCartsControllerCore extends AdminController $objCartBookingData->date_from, $objCartBookingData->date_to, $objCartBookingData->id_cart - )/$numDays; + )/ max($numDays, 1); } } } else { @@ -1742,7 +1748,7 @@ class AdminCartsControllerCore extends AdminController $idServiceProduct, $operator, $quantity, - false, + 0, $idCartBooking ))) { $originalPrice = Product::getPriceStatic($idServiceProduct, false); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index fcf696f8a..d28c8fd23 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -992,12 +992,12 @@ class AdminOrdersControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { @@ -1156,35 +1156,18 @@ class AdminOrdersControllerCore extends AdminController } $refundReqProducts = $objOrderReturn->getOrderRefundRequestedProducts($objOrder->id, 0, 1, 1); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, $sellingPreferenceType) - ); - } - - $hotelProducts = array(); - $standaloneProducts = array(); - foreach ($serviceProducts as $product) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + foreach($hotelProducts as $key => $product) { if ((in_array($product['id_service_product_order_detail'], $refundReqProducts)) || $product['is_refunded']) { - continue; - } - if (!empty($product['id_hotel'])) { - $hotelProducts[] = $product; - } else if (!$product['id_hotel'] && !$product['id_htl_booking_detail']) { - $standaloneProducts[] = $product; + unset($hotelProducts[$key]); + } + } + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE); + foreach($standaloneProducts as $key => $product) { + if ((in_array($product['id_service_product_order_detail'], $refundReqProducts)) || $product['is_refunded']) { + unset($standaloneProducts[$key]); } } - $this->context->smarty->assign( array( @@ -2454,20 +2437,8 @@ class AdminOrdersControllerCore extends AdminController } } - $hotelProducts = array(); - $hotelSellingTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($hotelSellingTypes as $sellingPreferenceType) { - $hotelProducts = array_merge( - $hotelProducts, - $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, $sellingPreferenceType) - ); - } - if ($hotelProducts && is_array($hotelProducts)) { + + if ($hotelProducts = $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE)) { foreach ($hotelProducts as $serviceProduct) { $objRoomTypeServProdOrderDtl = new ServiceProductOrderDetail($serviceProduct['id_service_product_order_detail']); foreach ($fields as $field) { @@ -2481,20 +2452,8 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServProdOrderDtl->save(); } } - $standaloneProducts = array(); - $standaloneSellingTypes = array( - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($standaloneSellingTypes as $sellingPreferenceType) { - $standaloneProducts = array_merge( - $standaloneProducts, - $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, $sellingPreferenceType) - ); - } - if ($standaloneProducts && is_array($standaloneProducts)) { + + if ($standaloneProducts = $objRoomTypeServProdOrderDtl->getServiceProductsInOrder($order->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE)) { foreach ($standaloneProducts as $serviceProduct) { $objRoomTypeServProdOrderDtl = new ServiceProductOrderDetail($serviceProduct['id_service_product_order_detail']); foreach ($fields as $field) { @@ -2988,30 +2947,9 @@ class AdminOrdersControllerCore extends AdminController // if order has normal products the add kpi for total products $objServiceProductOrderDetail = new ServiceProductOrderDetail(); - $serviceProducts = array(); - $sellingPreferenceTypes = array( - Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, - ); - foreach ($sellingPreferenceTypes as $sellingPreferenceType) { - $serviceProducts = array_merge( - $serviceProducts, - $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, $sellingPreferenceType) - ); - } - $hotelProducts = array(); - $standaloneProducts = array(); - foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel'])) { - $hotelProducts[] = $serviceProduct; - } else if (!$serviceProduct['id_hotel'] &&!$serviceProduct['id_htl_booking_detail']) { - $standaloneProducts[] = $serviceProduct; - } - } + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($objOrder->id, 0, 0, Product::SELLING_PREFERENCE_STANDALONE); + if ($hotelProducts || $standaloneProducts) { $helper = new HelperKpi(); $helper->id = 'box-total-products'; @@ -3357,16 +3295,16 @@ class AdminOrdersControllerCore extends AdminController } else { $product['image_link'] = $this->context->link->getImageLink($objProduct->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); } - if (Product::isSellableWithHotel($product['product_id']) - || Product::isSellableAsStandalone($product['product_id']) - ) { - $serviceProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id']); - foreach ($serviceProducts as $serviceProduct) { - if (!empty($serviceProduct['id_hotel']) && Product::isSellableWithHotel($product['product_id'])) { - $orderHotelServiceProducts[] = array_merge($product, $serviceProduct); - } elseif (!$serviceProduct['id_hotel'] && !$serviceProduct['id_htl_booking_detail'] && Product::isSellableAsStandalone($product['product_id'])) { - $orderStandaloneServiceProducts[] = array_merge($product, $serviceProduct); - } + if ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE) { + $hotelProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id'], Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + foreach ($hotelProducts as $hotelProduct) { + $orderHotelServiceProducts[] = array_merge($product, $hotelProduct); + } + } + if ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE) { + $standaloneProducts = $objServiceProductOrderDetail->getServiceProductsInOrder($order->id, $product['id_order_detail'], $product['product_id'], Product::SELLING_PREFERENCE_STANDALONE); + foreach ($standaloneProducts as $standaloneProduct) { + $orderStandaloneServiceProducts[] = array_merge($product, $standaloneProduct); } } } @@ -3698,17 +3636,9 @@ class AdminOrdersControllerCore extends AdminController // send hotel standalone and standalone products $objProduct = new Product(); - $allServiceProducts = $objProduct->getServiceProducts(null); - $hotelStandaloneProducts = array(); - $standaloneProducts = array(); - foreach ($allServiceProducts as $serviceProduct) { - if (Product::isSellableWithHotel($serviceProduct['id_product'])) { - $hotelStandaloneProducts[] = $serviceProduct; - } - if (Product::isSellableAsStandalone($serviceProduct['id_product'])) { - $standaloneProducts[] = $serviceProduct; - } - } + $hotelStandaloneProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_HOTEL_STANDALONE); + $standaloneProducts = $objProduct->getServiceProducts(null, Product::SELLING_PREFERENCE_STANDALONE); + $this->tpl_view_vars = array( 'hotelStandaloneProducts' => $hotelStandaloneProducts, 'standaloneProducts' => $standaloneProducts, @@ -7502,12 +7432,12 @@ class AdminOrdersControllerCore extends AdminController if (Configuration::get('PS_ALLOW_ADD_ALL_SERVICES_IN_BOOKING')) { // get all services $objProduct = new Product(); - $serviceProducts = array_merge( - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE), - $objProduct->getServiceProducts(true, Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE) - ); + $serviceProducts = array_values(array_filter( + $objProduct->getServiceProducts(null), + function ($serviceProduct) { + return Product::isSellableWithRoomType($serviceProduct['id_product']); + } + )); if ($serviceProducts) { foreach ($serviceProducts as $key => $servProduct) { if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock((int)$servProduct['id_product'])) From 71cd5573daa4c215a2aec43547a9a76279b08c43 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 13:14:04 +0530 Subject: [PATCH 21/76] changes product const name --- .../normal_products/helpers/form/form.tpl | 2 +- .../normal_products/informations.tpl | 14 +-- .../controllers/normal_products/prices.tpl | 20 ++-- .../_add_order_extra_services_tab_content.tpl | 2 +- ..._services_service_products_tab_content.tpl | 6 +- classes/Cart.php | 2 +- classes/PaymentModule.php | 4 +- classes/Product.php | 100 +++++++++--------- classes/order/Order.php | 4 +- classes/order/OrderDetail.php | 4 +- .../WebserviceSpecificManagementBookings.php | 12 +-- config/defines.inc.php | 2 +- controllers/admin/AdminCartsController.php | 6 +- .../admin/AdminNormalProductsController.php | 32 +++--- controllers/admin/AdminOrdersController.php | 28 ++--- controllers/admin/AdminStatsController.php | 4 +- controllers/front/CartController.php | 2 +- controllers/front/ParentOrderController.php | 18 ++-- modules/blockcart/ajax-cart.js | 8 +- modules/blockcart/blockcart.tpl | 8 +- .../classes/HotelHelper.php | 12 +-- .../classes/ServiceProductCartDetail.php | 8 +- .../qlostatsserviceproducts.php | 8 +- .../_partials/cart_booking_demands.tpl | 2 +- .../_partials/service-products-list-row.tpl | 2 +- .../js/modules/blockcart/ajax-cart.js | 8 +- .../modules/blockcart/blockcart.tpl | 8 +- 27 files changed, 161 insertions(+), 165 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl index bc29f7e99..14b55a338 100644 --- a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl @@ -78,7 +78,7 @@ var SELLING_PREFERENCE_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_HOTEL_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE|intval}; - var SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE|intval}; + var SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE|intval}; var SELLING_PREFERENCE_STANDALONE = {Product::SELLING_PREFERENCE_STANDALONE|intval}; var price_addition_type_with_room = {Product::PRICE_ADDITION_TYPE_WITH_ROOM|intval}; diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index a528df729..7dcd57e42 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -261,7 +261,7 @@ -
    selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
    {include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
    -
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
    {include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
    -
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
    {displayPrice price=$service['unit_price_tax_excl'] currency=$orderCurrency} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $service['price_calculation_method'], $additionalServices['date_from'], $additionalServices['date_to'] diff --git a/classes/Cart.php b/classes/Cart.php index 813ff4f89..242072486 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -2480,7 +2480,7 @@ class CartCore extends ObjectModel 'id_hotel_cart_booking' => $selectedProduct['id_hotel_cart_booking'], ); } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $selectedProduct['price_calculation_method'], $selectedProduct['date_from'], $selectedProduct['date_to'] diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 8b6e57e1b..e289ad98a 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -592,7 +592,7 @@ abstract class PaymentModuleCore extends Module if (!$product['booking_product'] && ($product['selling_preference_type'] == Product::SELLING_PREFERENCE_STANDALONE || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE - || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE + || $product['selling_preference_type'] == Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE ) ) { $cover_image_arr = $objProduct->getCover($product['id_product']); @@ -1065,7 +1065,7 @@ abstract class PaymentModuleCore extends Module } } - } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { + } elseif (Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE == $product['selling_preference_type']) { $idProductRoomType = null; $idProductHotel = null; if (isset($product['id_room_type']) && $product['id_room_type']) { diff --git a/classes/Product.php b/classes/Product.php index 32c6d0bfe..8202e43d1 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -560,22 +560,22 @@ class ProductCore extends ObjectModel // Product selling preference types const SELLING_PREFERENCE_WITH_ROOM_TYPE = 1; // Product to be sold with Room types const SELLING_PREFERENCE_HOTEL_STANDALONE = 2; // Product to be sold Standalone with Hotels - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also + const SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = 3; // Product to be sold Standalone with Hotels and with Room types also const SELLING_PREFERENCE_STANDALONE = 4; // Product to be sold standalone - const SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also - const SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone + const SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE = 5; // Product to be sold standalone and with Room types also + const SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE = 6; // Product to be sold standalone with Hotels and with Room types also + const SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE = 7; // Product to be sold standalone with Hotels and with Room types also and standalone const PRICE_ADDITION_TYPE_WITH_ROOM = 1; const PRICE_ADDITION_TYPE_INDEPENDENT = 2; - const PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY = 1; - const PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY = 2; - const PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY = 4; + const PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY = 1; + const PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY = 2; + const PRICE_CALCULATION_METHOD_ON_DURING_STAY = 4; const PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY = 3; - const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY = 5; - const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY = 6; - const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY = 7; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY = 5; + const PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY = 6; + const PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY = 7; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1; const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2; @@ -1456,9 +1456,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND (p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. ' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE.') + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE.') AND product_shop.`id_shop` = '.(int)$context->shop->id .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') @@ -1503,9 +1503,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND (p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. ' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' - || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE.')'. ' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE.' + || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE.')'. ' AND product_shop.`id_shop` = '.(int)$context->shop->id .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') @@ -1554,9 +1554,9 @@ class ProductCore extends ObjectModel '(`element_type` = '.RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND `id_element` = '.(int)$this->id.') ) AND p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_ROOM_TYPE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE. - ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE. + ' || p.`selling_preference_type` = '.(int)self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE. ' AND product_shop.`id_shop` = '.(int)$context->shop->id; $sql .= ' GROUP BY cl.`id_category`'; @@ -6881,7 +6881,7 @@ class ProductCore extends ObjectModel ) ); - $numdays = Product::getPriceCalculationApplicableDays( + $numdays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($idProduct), $dateFrom, $dateTo @@ -6892,46 +6892,42 @@ class ProductCore extends ObjectModel } - public static function getPriceCalculationApplicableDays( + public static function getServicePriceBillableDays( $priceCalculationMethod, $dateFrom, $dateTo, - $defaultDays = 1 ) { - if (empty($dateFrom) || empty($dateTo)) { - return (int) $defaultDays; - } $numNights = (int) HotelHelper::getNumberOfDays($dateFrom, $dateTo); - if ($numNights <= 0) { - return (int) $defaultDays; + if ($numNights < 1) { + return 1; } - $checkin = 1; - $checkout = 1; - $duringStay = max($numNights - 1, 0); + $checkinDay = 1; + $checkoutDay = 1; + $stayDay = $numNights - 1; switch ((int) $priceCalculationMethod) { - case self::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY: - return $checkin; + case self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY: + return $checkinDay; - case self::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY: - return $checkout; + case self::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY: + return $checkoutDay; - case self::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY: - return $duringStay; + case self::PRICE_CALCULATION_METHOD_ON_DURING_STAY: + return $stayDay; case self::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY: - return $checkin + $checkout; + return $checkinDay + $checkoutDay; - case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY: - return $checkin + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY: + return $checkinDay + $stayDay; - case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY: - return $checkout + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY: + return $checkoutDay + $stayDay; - case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY: - return $checkin + $checkout + $duringStay; + case self::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY: + return $checkinDay + $checkoutDay + $stayDay; default: return $numNights; @@ -6942,9 +6938,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } @@ -6952,9 +6948,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_HOTEL_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } @@ -6962,9 +6958,9 @@ class ProductCore extends ObjectModel { return in_array((int) self::getSellingPreferenceType($idProduct), [ self::SELLING_PREFERENCE_STANDALONE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - self::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - self::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + self::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + self::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]); } } diff --git a/classes/order/Order.php b/classes/order/Order.php index 412f4460b..c3ed92715 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -2578,7 +2578,7 @@ class OrderCore extends ObjectModel )) { $totals = array_reduce($serviceProductDetail, function ($carry, $item) use ($order_detail) { $objHotelBookingDetail = new HotelBookingDetail((int) $item['id_htl_booking_detail']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $order_detail['product_price_calculation_method'], $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -2633,7 +2633,7 @@ class OrderCore extends ObjectModel // We are getting auto added service for specific room.There will be only on htl_booking_detail but can have multiple auto added service with room. // Note: All the auto added service with room have same id_tax_rule group $autoAddedServiceData = array_shift($autoAddedServiceData); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $order_detail['product_price_calculation_method'], $autoAddedServiceData['date_from'], $autoAddedServiceData['date_to'] diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index f9e165503..a5d0c2176 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -450,7 +450,7 @@ class OrderDetailCore extends ObjectModel $taxGroupInfo['id_room_type'], )) { $serviceProductData = array_shift($serviceProductData); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $this->product_price_calculation_method, $serviceProductData['date_from'], $serviceProductData['date_to'] @@ -484,7 +484,7 @@ class OrderDetailCore extends ObjectModel $serviceProductData = array_shift($serviceProductData); $unit_price_tax_excl = isset($serviceProductData['unit_price_tax_excl']) ? $serviceProductData['unit_price_tax_excl'] : 0; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $this->product_price_calculation_method, $serviceProductData['date_from'], $serviceProductData['date_to'] diff --git a/classes/webservice/WebserviceSpecificManagementBookings.php b/classes/webservice/WebserviceSpecificManagementBookings.php index b7c7546a8..960ab4521 100644 --- a/classes/webservice/WebserviceSpecificManagementBookings.php +++ b/classes/webservice/WebserviceSpecificManagementBookings.php @@ -1193,7 +1193,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $objOrderDetail = new OrderDetail($service['id_order_detail']); $objServiceProductOrderDetail = new ServiceProductOrderDetail($service['id_service_product_order_detail']); $quantity = $objServiceProductOrderDetail->quantity; - $quantity *= Product::getPriceCalculationApplicableDays( + $quantity *= Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -2312,7 +2312,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objBookingDetail->date_from, $objBookingDetail->date_to @@ -2670,7 +2670,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We foreach ($selectedAdditonalServices[$idHotelBooking]['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $serviceApplicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $dateFrom, $dateTo @@ -3189,7 +3189,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $priceTaxExcl = $objServiceProductOrderDetail->total_price_tax_excl; $priceTaxIncl = $objServiceProductOrderDetail->total_price_tax_incl; $objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -3285,7 +3285,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $insertedServiceProductIdOrderDetail = $objHotelBookingDetail->getLastInsertedServiceIdOrderDetail($objOrder->id, $service['id_product']); $objOrderDetail = new OrderDetail($insertedServiceProductIdOrderDetail); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($product['id_product']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -4214,7 +4214,7 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We $services['id_service'] = (int) $service['id_product']; $services['name'] = $service['name']; $services['quantity'] = (int) $service['quantity']; - $applicableDays = Product::getPriceCalculationApplicableDays( + $applicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $additionalService['date_from'], $additionalService['date_to'] diff --git a/config/defines.inc.php b/config/defines.inc.php index f16e93903..d78f92763 100644 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -26,7 +26,7 @@ /* Debug only */ if (!defined('_PS_MODE_DEV_')) { - define('_PS_MODE_DEV_', false); + define('_PS_MODE_DEV_', true); } /* Compatibility warning */ define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false); diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index a30655767..2d22649ae 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -1217,7 +1217,7 @@ class AdminCartsControllerCore extends AdminController continue; } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -1568,7 +1568,7 @@ class AdminCartsControllerCore extends AdminController continue; } - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $objCartBookingData->date_from, $objCartBookingData->date_to @@ -1683,7 +1683,7 @@ class AdminCartsControllerCore extends AdminController $cartTotalQty = Cart::getProductQtyInCart($objCart->id, $idServiceProduct); $qty = (int)$serviceQuantities[$idServiceProduct]; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 0c3986722..b41b5fd99 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,13 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY => $this->l('Only check-in day'), - Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY => $this->l('Only check-out day'), - Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY => $this->l('Only during-stay days'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('Only check-in day'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('Only check-out day'), + Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('Only during-stay days'), Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY => $this->l('Check-in | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY => $this->l('Check-out | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY => $this->l('Check-in | check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in | check-out | during-stay days'), ); $this->_join .= ' @@ -331,12 +331,12 @@ class AdminNormalProductsControllerCore extends AdminController // Code For Standard product working $sellingPreferenceTypes = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE => $this->l('With room type'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), Product::SELLING_PREFERENCE_STANDALONE => $this->l('Standalone'), Product::SELLING_PREFERENCE_HOTEL_STANDALONE => $this->l('With hotel'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), ); $this->fields_list['selling_preference_type'] = array( 'type' => 'select', @@ -3016,15 +3016,15 @@ class AdminNormalProductsControllerCore extends AdminController $roomTypeSellingPreferences = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); $hotelSellingPreferences = array( Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); if (in_array((int)$product->selling_preference_type, $roomTypeSellingPreferences, true)) { diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index d28c8fd23..a824685d0 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1013,7 +1013,7 @@ class AdminOrdersControllerCore extends AdminController unset($serviceProducts[$key]); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -4184,9 +4184,9 @@ class AdminOrdersControllerCore extends AdminController $products = array(); $standaloneSellingPreferenceTypes = array( Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ); foreach ($standaloneSellingPreferenceTypes as $sellingPreferenceType) { if ($productsByType = Product::searchByName( @@ -5396,7 +5396,7 @@ class AdminOrdersControllerCore extends AdminController )) { foreach ($services as $service) { $insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($order->id, $service['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id_product']), $objBookingDetail->date_from, $objBookingDetail->date_to @@ -6197,12 +6197,12 @@ class AdminOrdersControllerCore extends AdminController && count($orderServiceProduct['additional_services']) ) { foreach ($orderServiceProduct['additional_services'] as $serviceProduct) { - $newNumDays = Product::getPriceCalculationApplicableDays( + $newNumDays = Product::getServicePriceBillableDays( $serviceProduct['price_calculation_method'], $new_date_from, $new_date_to ); - $oldNumDays = Product::getPriceCalculationApplicableDays( + $oldNumDays = Product::getServicePriceBillableDays( $serviceProduct['price_calculation_method'], $old_date_from, $old_date_to @@ -6589,7 +6589,7 @@ class AdminOrdersControllerCore extends AdminController $serviceOrderDetail = new OrderDetail($service['id_order_detail']); $cart_quantity = $service['quantity']; - $serviceApplicableDays = Product::getPriceCalculationApplicableDays( + $serviceApplicableDays = Product::getServicePriceBillableDays( $service['price_calculation_method'], $selectedAdditonalServices[$idHotelBooking]['date_from'], $selectedAdditonalServices[$idHotelBooking]['date_to'] @@ -7452,7 +7452,7 @@ class AdminOrdersControllerCore extends AdminController unset($serviceProducts[$key]); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $servProduct['price_calculation_method'], $dateFrom, $dateTo @@ -7637,7 +7637,7 @@ class AdminOrdersControllerCore extends AdminController $objServiceProductOrderDetail->quantity = $quantity; $objServiceProductOrderDetail->unit_price_tax_excl = $unitPrice; $objServiceProductOrderDetail->unit_price_tax_incl = $unitPrice * $oldTaxMultiplier; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -7757,7 +7757,7 @@ class AdminOrdersControllerCore extends AdminController if ($objProduct->allow_multiple_quantity && Validate::isUnsignedInt($qty[$service])) { $finalQty = (int)$qty[$service]; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -7813,7 +7813,7 @@ class AdminOrdersControllerCore extends AdminController $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($service['id']), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -8133,7 +8133,7 @@ class AdminOrdersControllerCore extends AdminController $objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice(); $cartProductProcessed = 1; - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($objServiceProduct->id), $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to @@ -8369,7 +8369,7 @@ class AdminOrdersControllerCore extends AdminController if ($res &= $objServiceProductOrderDetail->delete()) { $order = new Order($objServiceProductOrderDetail->id_order); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objOrderDetail->product_price_calculation_method, $objHotelBookingDetail->date_from, $objHotelBookingDetail->date_to diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 9886d86a1..0ade4a0e5 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -2421,9 +2421,9 @@ class AdminStatsControllerCore extends AdminStatsTabController IFNULL(SUM( CASE WHEN od.`purchase_supplier_price` <> "0.000000" - THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) + THEN (od.`purchase_supplier_price` / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1))) WHEN od.`purchase_supplier_price` = "0.000000" - THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) + THEN ((od.`original_product_price` / o.`conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100) / (IF (od.`product_price_calculation_method` = '.Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.', DATEDIFF(hbd.`date_to`, hbd.`date_from`), 1)) END ), 0) FROM `'._DB_PREFIX_.'service_product_order_detail` rtspod diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 10df365a1..8e1937270 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -756,7 +756,7 @@ class CartControllerCore extends FrontController $this->errors[] = Tools::displayError('The quantity you\'ve entered is invalid.'); } else { $cartTotalQty = Cart::getProductQtyInCart((int)$this->context->cart->id,(int)$idServiceProduct); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php index 573aea7f8..6048edfdc 100644 --- a/controllers/front/ParentOrderController.php +++ b/controllers/front/ParentOrderController.php @@ -324,9 +324,9 @@ class ParentOrderControllerCore extends FrontController $objServiceProductCartDetail = new ServiceProductCartDetail(); $hotelSellingPreferences = [ Product::SELLING_PREFERENCE_HOTEL_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; if ($hotelProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, @@ -353,9 +353,9 @@ class ParentOrderControllerCore extends FrontController $standaloneSellingPreferences = [ Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; $standaloneProducts = $objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, @@ -501,9 +501,9 @@ class ParentOrderControllerCore extends FrontController $objServiceProductCartDetail = new ServiceProductCartDetail(); $standaloneSellingPreferences = [ Product::SELLING_PREFERENCE_STANDALONE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE, - Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE, - Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE, + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE, + Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE, ]; if (count($objServiceProductCartDetail->getServiceProductsInCart( $this->context->cart->id, diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index fccec2e4f..10b8df061 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -140,22 +140,22 @@ var ajaxCart = { case SELLING_PREFERENCE_HOTEL_STANDALONE: channels.with_hotel = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.with_hotel = true; break; case SELLING_PREFERENCE_STANDALONE: channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE: channels.with_hotel = true; channels.standalone = true; break; - case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: channels.with_room_type = true; channels.with_hotel = true; channels.standalone = true; diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index 6caf931e7..910a50f4a 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -405,10 +405,10 @@ {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} - {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 2cb844209..b8bea902b 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2155,7 +2155,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Room Maintenance Fees', @@ -2187,7 +2187,7 @@ class HotelHelper 'price' => '250', 'auto_add_to_cart' => 1, 'show_at_front' => 0, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_INDEPENDENT, 'en' => array( 'name' => 'Internet Handling Charges', @@ -2220,7 +2220,7 @@ class HotelHelper 'price' => '50', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Airport Shuttle', @@ -2252,7 +2252,7 @@ class HotelHelper 'price' => '200', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Cab on Demand', @@ -2284,7 +2284,7 @@ class HotelHelper 'price' => '350', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Breakfast', @@ -2316,7 +2316,7 @@ class HotelHelper 'price' => '450', 'auto_add_to_cart' => 0, 'show_at_front' => 1, - 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY, + 'price_calculation_method' => Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY, 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, 'en' => array( 'name' => 'Dinner', diff --git a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php index 512e12b6b..a7872d9a8 100644 --- a/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/ServiceProductCartDetail.php @@ -90,7 +90,7 @@ class ServiceProductCartDetail extends ObjectModel )) { $updateQty = $product['quantity']; $objHotelCartBookingData = new HotelCartBookingData($htlCartBookingId); - $numdays = Product::getPriceCalculationApplicableDays( + $numdays = Product::getServicePriceBillableDays( Product::getProductPriceCalculation($product['id_product']), $objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to @@ -251,7 +251,7 @@ class ServiceProductCartDetail extends ObjectModel $product['htl_cart_booking_id'] ); } else { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $product['date_from'], $product['date_to'] @@ -458,7 +458,7 @@ class ServiceProductCartDetail extends ObjectModel if ($objServiceProductCartDetail->save()) { if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($idHtlCartData))) { - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBooking->date_from, $objHotelCartBooking->date_to @@ -520,7 +520,7 @@ class ServiceProductCartDetail extends ObjectModel if ($updateQunatity) { if (Validate::isLoadedObject($objHotelCartBooking = new HotelCartBookingData($product['id_hotel_cart_booking']))) { $objProduct = new Product((int) $product['id_product']); - $numDays = Product::getPriceCalculationApplicableDays( + $numDays = Product::getServicePriceBillableDays( $objProduct->price_calculation_method, $objHotelCartBooking->date_from, $objHotelCartBooking->date_to diff --git a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php index 684cf15f9..c36687ef1 100644 --- a/modules/qlostatsserviceproducts/qlostatsserviceproducts.php +++ b/modules/qlostatsserviceproducts/qlostatsserviceproducts.php @@ -182,11 +182,11 @@ class QloStatsServiceProducts extends ModuleGrid $numNightsSql = 'IFNULL(DATEDIFF(hbd.`date_to`, hbd.`date_from`), 0)'; $applicableDaysSql = 'CASE WHEN spod.`id_htl_booking_detail` IS NULL OR spod.`id_htl_booking_detail` = 0 THEN 1 - WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_CHECKOUT_DAY.') THEN 1 - WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ONLY_DURINGSTAY_DAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY.', '.(int)Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY.') THEN 1 + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY.' THEN GREATEST('.$numNightsSql.' - 1, 1) WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY.' THEN 2 - WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURINGSTAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURINGSTAY.') THEN GREATEST('.$numNightsSql.', 1) - WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURINGSTAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) + WHEN od.`product_price_calculation_method` IN ('.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY.', '.(int)Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY.') THEN GREATEST('.$numNightsSql.', 1) + WHEN od.`product_price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY.' THEN GREATEST('.$numNightsSql.' + 1, 1) ELSE GREATEST('.$numNightsSql.', 1) END'; diff --git a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl index 7f218e0c8..964cba5d8 100644 --- a/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl +++ b/themes/hotel-reservation-theme/_partials/cart_booking_demands.tpl @@ -153,7 +153,7 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if !$priceDisplay}{convertPrice price=$product.price_tax_incl}{else}{convertPrice price=$product.price_tax_exc}{/if} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $product.price_calculation_method, $cartRoom.date_from|default:'', $cartRoom.date_to|default:'' diff --git a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl index 8df8fe516..c636e4129 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -55,7 +55,7 @@
    {block name='service_product_price'} {if !$priceDisplay}{convertPrice price=$service_product.price_tax_incl}{else}{convertPrice price=$service_product.price_tax_exc}{/if} - {if Product::getPriceCalculationApplicableDays( + {if Product::getServicePriceBillableDays( $service_product.price_calculation_method, $service_product.date_from|default:$date_from|default:'', $service_product.date_to|default:$date_to|default:'' diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index 51978e8fe..7c2fa5f05 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -140,22 +140,22 @@ var ajaxCart = { case SELLING_PREFERENCE_HOTEL_STANDALONE: channels.with_hotel = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.with_hotel = true; break; case SELLING_PREFERENCE_STANDALONE: channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE: channels.with_hotel = true; channels.standalone = true; break; - case SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE: + case SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE: channels.with_room_type = true; channels.standalone = true; break; - case SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: + case SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE: channels.with_room_type = true; channels.with_hotel = true; channels.standalone = true; diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index 47121ca96..fecff84c9 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -406,10 +406,10 @@ {addJsDef SELLING_PREFERENCE_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_ROOM_TYPE} {addJsDef SELLING_PREFERENCE_STANDALONE=Product::SELLING_PREFERENCE_STANDALONE} {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_STANDALONE} - {addJsDef SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_STANDALONE_AND_WITH_ROOM_TYPE} - {addJsDef SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE} + {addJsDef SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE=Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE} + {addJsDef SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE=Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE} {addJsDefL name=customizationIdMessage}{l s='Customization #' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=removingLinkText}{l s='remove this product from my cart' mod='blockcart' js=1}{/addJsDefL} From 412f43919b01bbc8ee590f05f3d40ef48ed5c604 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Fri, 29 May 2026 19:12:37 +0530 Subject: [PATCH 22/76] Fix: Incorrect selling type context during order validation for multi-preference service products --- .../normal_products/helpers/form/form.tpl | 6 +- .../normal_products/informations.tpl | 14 ++-- .../controllers/orders/helpers/view/view.tpl | 4 +- classes/Cart.php | 45 +++++------ classes/PaymentModule.php | 22 +++--- classes/Product.php | 36 ++++----- classes/order/Order.php | 4 +- classes/order/OrderInvoice.php | 4 +- classes/pdf/HTMLTemplateInvoice.php | 8 +- classes/pdf/HTMLTemplateOrderSlip.php | 4 +- .../WebserviceSpecificManagementBookings.php | 2 +- config/defines.inc.php | 2 +- .../admin/AdminNormalProductsController.php | 18 ++--- controllers/admin/AdminOrdersController.php | 32 ++++---- controllers/front/GuestTrackingController.php | 4 +- .../front/OrderConfirmationController.php | 8 +- controllers/front/OrderDetailController.php | 4 +- controllers/front/ParentOrderController.php | 14 ++-- js/admin/normal_products.js | 4 +- modules/blockcart/ajax-cart.js | 54 ++++---------- modules/blockcart/blockcart.tpl | 8 +- .../AdminHotelRoomsBookingController.php | 4 +- .../_partials/cart_booking_demands.tpl | 28 ++++++- ...e-calculation-info.tpl => htl-tooltip.tpl} | 24 ++---- .../_partials/order-extra-services.tpl | 28 ++++++- .../_partials/order-room-detail.tpl | 56 +++++++------- .../_partials/service-products-list-row.tpl | 28 ++++++- themes/hotel-reservation-theme/css/global.css | 67 ++++++++++------- themes/hotel-reservation-theme/js/global.js | 67 ++++++++--------- .../js/modules/blockcart/ajax-cart.js | 54 ++++---------- .../js/order-confirmation.js | 41 +--------- .../js/order-detail.js | 74 +------------------ .../hotel-reservation-theme/js/order-opc.js | 41 +--------- themes/hotel-reservation-theme/js/product.js | 2 +- .../modules/blockcart/blockcart.tpl | 8 +- .../order-confirmation.tpl | 56 +++++++------- .../hotel-reservation-theme/order-detail.tpl | 12 +-- .../shopping-cart-detail.tpl | 22 +++--- 38 files changed, 387 insertions(+), 522 deletions(-) rename themes/hotel-reservation-theme/_partials/{price-calculation-info.tpl => htl-tooltip.tpl} (59%) diff --git a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl index 14b55a338..d1b79abc2 100644 --- a/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/normal_products/helpers/form/form.tpl @@ -77,9 +77,9 @@ var product_type_simple = {Product::PTYPE_SIMPLE|intval}; var SELLING_PREFERENCE_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_ROOM_TYPE|intval}; - var SELLING_PREFERENCE_HOTEL_STANDALONE = {Product::SELLING_PREFERENCE_HOTEL_STANDALONE|intval}; - var SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE|intval}; - var SELLING_PREFERENCE_STANDALONE = {Product::SELLING_PREFERENCE_STANDALONE|intval}; + var SELLING_PREFERENCE_WITH_HOTEL = {Product::SELLING_PREFERENCE_WITH_HOTEL|intval}; + var SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE = {Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE|intval}; + var SELLING_PREFERENCE_WITH_STANDALONE = {Product::SELLING_PREFERENCE_WITH_STANDALONE|intval}; var price_addition_type_with_room = {Product::PRICE_ADDITION_TYPE_WITH_ROOM|intval}; var price_addition_type_independent = {Product::PRICE_ADDITION_TYPE_INDEPENDENT|intval}; diff --git a/admin/themes/default/template/controllers/normal_products/informations.tpl b/admin/themes/default/template/controllers/normal_products/informations.tpl index 7dcd57e42..3437c1d03 100644 --- a/admin/themes/default/template/controllers/normal_products/informations.tpl +++ b/admin/themes/default/template/controllers/normal_products/informations.tpl @@ -261,7 +261,7 @@
    -
    selling_preference_type != Product::SELLING_PREFERENCE_HOTEL_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE)}style="display:none;"{/if}>
    {include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
    -
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0)}style="display:none;"{/if}>
    {include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
    -
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTE_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}> +
    selling_preference_type != Product::SELLING_PREFERENCE_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE && $product->selling_preference_type != Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE && $product->selling_preference_type != 0}style="display:none;"{/if}>
    {$product['name']|escape:'html':'UTF-8'} - {include file='_partials/price-calculation-info.tpl' pcm=$product.price_calculation_method|default:0} + {assign var='priceCalcMethod' value=$product.price_calculation_method|default:0} + {capture name='htl_pcm_tooltip'} +
    +

    {l s='Applied on:'}

    +
      + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-in day'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='During-stay days'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-out day'}
    • + {/if} +
    +
    + {/capture} + {include file='_partials/htl-tooltip.tpl' tooltip_content=$smarty.capture.htl_pcm_tooltip allow_html=true} {if $product.allow_multiple_quantity}
    diff --git a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl b/themes/hotel-reservation-theme/_partials/htl-tooltip.tpl similarity index 59% rename from themes/hotel-reservation-theme/_partials/price-calculation-info.tpl rename to themes/hotel-reservation-theme/_partials/htl-tooltip.tpl index af5f05850..997e93fa7 100644 --- a/themes/hotel-reservation-theme/_partials/price-calculation-info.tpl +++ b/themes/hotel-reservation-theme/_partials/htl-tooltip.tpl @@ -20,24 +20,14 @@ * @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 *} -{* Required param: pcm — price_calculation_method integer value *} - + -
    diff --git a/themes/hotel-reservation-theme/_partials/order-room-detail.tpl b/themes/hotel-reservation-theme/_partials/order-room-detail.tpl index aaf47aa0c..35f3ac7c9 100644 --- a/themes/hotel-reservation-theme/_partials/order-room-detail.tpl +++ b/themes/hotel-reservation-theme/_partials/order-room-detail.tpl @@ -125,41 +125,35 @@ {displayWtPriceWithCurrency price=($rm_v.amount_tax_excl + $rm_v.extra_demands_price_te + $rm_v.additional_services_price_te + $rm_v.additional_services_price_auto_add_te) currency=$currency} {/if} {if (isset($rm_v.extra_demands) && $rm_v.extra_demands) || isset($rm_v.additional_services) && $rm_v.additional_services} - - - -
    {l s='Total rooms cost'} {if $use_taxes && $display_tax_label == 1}{if $priceDisplay == 1}{l s='(tax excl.)'}{elseif $priceDisplay == 0}{l s='(tax incl.)'}{/if} {/if}
    {$product['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} + {capture name='room_type_service_tooltip_content'} + {assign var="priceCalcMethod" value=$product['price_calculation_method']|default:0} +
    +
    +
      + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-in day'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='During-stay days'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-out day'}
    • + {/if} +
    +
    + {/capture} + + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_tooltip_content allow_html=true}
    diff --git a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl index 65d1c2344..f98d22808 100644 --- a/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_extra_services_service_products_tab_content.tpl @@ -55,6 +55,35 @@
    {$service['name']|escape:'html':'UTF-8'} + {capture name='room_type_service_tooltip_content'} + {assign var="priceCalcMethod" value=$service['price_calculation_method']|default:0} +
    +
    +
      + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-in day'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='During-stay days'}
    • + {/if} + {if $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY + || $priceCalcMethod == Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY} +
    • {l s='Check-out day'}
    • + {/if} +
    +
    + {/capture} + + {include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.room_type_service_tooltip_content allow_html=true} +
    {$product['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$product['price_calculation_method']|default:0} - {if $product['auto_add_to_cart'] && $product['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'}
    @@ -296,8 +351,33 @@
    {$service['name']|escape:'html':'UTF-8'} - {include file='controllers/orders/modals/_partials/_price-calculation-info.tpl' pcm=$service.price_calculation_method|default:0} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} diff --git a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl b/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl deleted file mode 100644 index 00ad669f5..000000000 --- a/admin/themes/default/template/controllers/orders/modals/_partials/_price-calculation-info.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{* -* 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 -*} - -{* Required param: pcm — price_calculation_method integer value *} - - - - - diff --git a/admin/themes/default/template/controllers/normal_products/selected_option.tpl b/admin/themes/default/template/helpers/tooltip.tpl similarity index 59% rename from admin/themes/default/template/controllers/normal_products/selected_option.tpl rename to admin/themes/default/template/helpers/tooltip.tpl index 24156a9e1..8d38c8982 100644 --- a/admin/themes/default/template/controllers/normal_products/selected_option.tpl +++ b/admin/themes/default/template/helpers/tooltip.tpl @@ -21,13 +21,20 @@ *} -{capture name='options_list'} -
      - {foreach $selected_options as $opt} -
    • {$opt|escape:'html'}
    • - {/foreach} -
    -{/capture} - - {$selected_options|@count} Selected + + + + diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 8978f4662..a9723fccc 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -200,13 +200,13 @@ class AdminNormalProductsControllerCore extends AdminController Product::PRICE_ADDITION_TYPE_INDEPENDENT => $this->l('Convenience Fee') ); $priceCalculationMethod = array( - Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('Only check-in day'), - Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('Only check-out day'), - Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('Only during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in and check-out days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out | during-stay days'), - Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in | check-out | during-stay days'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY => $this->l('On Check-in day'), + Product::PRICE_CALCULATION_METHOD_ON_CHECKOUT_DAY => $this->l('On Check-out day'), + Product::PRICE_CALCULATION_METHOD_ON_DURING_STAY => $this->l('On During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_DAY_AND_CHECKOUT_DAY => $this->l('Check-in day | Check-out days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_DURING_STAY => $this->l('Check-in day | During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKOUT_AND_DURING_STAY => $this->l('Check-out day | During-stay days'), + Product::PRICE_CALCULATION_METHOD_CHECKIN_AND_CHECKOUT_AND_DURING_STAY => $this->l('Check-in day | During-stay days | Check-out day'), ); $this->_join .= ' @@ -331,12 +331,12 @@ class AdminNormalProductsControllerCore extends AdminController // Code For Standard product working $sellingPreferenceTypes = array( Product::SELLING_PREFERENCE_WITH_ROOM_TYPE => $this->l('With room type'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE => $this->l('With hotel|room type'), - Product::SELLING_PREFERENCE_WITH_STANDALONE => $this->l('Standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE => $this->l('With hotel | With room type'), + Product::SELLING_PREFERENCE_WITH_STANDALONE => $this->l('With Standalone'), Product::SELLING_PREFERENCE_WITH_HOTEL => $this->l('With hotel'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel|standalone'), - Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type|standalone'), - Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel|room type|standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_STANDALONE => $this->l('With hotel | With standalone'), + Product::SELLING_PREFERENCE_WITH_STANDALONE_AND_WITH_ROOM_TYPE => $this->l('With room type | With standalone'), + Product::SELLING_PREFERENCE_WITH_HOTEL_AND_WITH_ROOM_TYPE_AND_WITH_STANDALONE => $this->l('With hotel | With room type | With standalone'), ); $this->fields_list['selling_preference_type'] = array( 'type' => 'select', @@ -435,27 +435,38 @@ class AdminNormalProductsControllerCore extends AdminController { $list = $this->fields_list['selling_preference_type']['list']; - if (!isset($list[$selling_preference_type])) { + if (empty($list[$selling_preference_type])) { return '--'; } - $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$selling_preference_type]))); + $options = array_map('trim', explode('|', $list[$selling_preference_type])); - return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + $this->context->smarty->assign(array( + 'tooltip_items' => $options, + )); + + $tooltip = $this->context->smarty->fetch('helpers/tooltip.tpl'); + + return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; } - public function getPriceCalculationMethod($txt, $row) + public function getPriceCalculationMethod($price_calculation_method, $row) { $list = $this->fields_list['price_calculation_method']['list']; - $method = (int)$row['price_calculation_method']; - if (!isset($list[$method])) { + if (empty($list[$price_calculation_method])) { return '--'; } - $this->context->smarty->assign('selected_options', array_map('trim', explode('|', $list[$method]))); + $options = array_map('trim', explode('|', $list[$price_calculation_method])); - return $this->context->smarty->fetch('controllers/normal_products/selected_option.tpl'); + $this->context->smarty->assign(array( + 'tooltip_items' => $options, + )); + + $tooltip = $this->context->smarty->fetch('helpers/tooltip.tpl'); + + return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip; } public function getHotelName($hotelName, $row) @@ -1543,7 +1554,6 @@ class AdminNormalProductsControllerCore extends AdminController _PS_CSS_DIR_.'ps-hotel-reservation.css', )); }else { - $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); $this->addJqueryUI('ui.tooltip', 'base', true); } } @@ -2374,7 +2384,10 @@ class AdminNormalProductsControllerCore extends AdminController $this->errors[] = $this->l('Please select at least one buying option.'); } - if (!Tools::getValue('price_calculation_method')) { + $priceCalculationMethod = Tools::getValue('price_calculation_method'); + $id = Tools::getValue('id_'.$this->table); + + if (isset($priceCalculationMethod, $id) && empty($priceCalculationMethod) && !empty($id)) { $this->errors[] = $this->l('Please select at least one price calculation method.'); } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b6c9418a6..c42480eca 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1379,7 +1379,6 @@ class AdminOrdersControllerCore extends AdminController $this->addJqueryUI('ui.datepicker'); $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); - $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/default/css/admin-tooltip.css'); $this->addJqueryUI(array('ui.tooltip'), 'base', true); if ($this->display == 'view') { diff --git a/js/admin/orders.js b/js/admin/orders.js index 567c9c164..981e75051 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -1466,15 +1466,7 @@ $(document).ready(function() { }, complete: function() { $(".loading_overlay").hide(); - initAdminTooltip({ - selector: '.price-calculation-info', - items: 'span', - tooltipClass: 'admin-info-tooltip', - skipIfInitialized: true, - getContent: function () { - return $(this).siblings('.price-calculation-info-container').html(); - } - }); + initTooltip(); } }); }); @@ -2546,15 +2538,7 @@ const EditRoomBookingModal = { // initialize datepickers EditRoomBookingModal.initDatePickers(); - initAdminTooltip({ - selector: '.price-calculation-info', - items: 'span', - tooltipClass: 'admin-info-tooltip', - skipIfInitialized: true, - getContent: function () { - return $(this).siblings('.price-calculation-info-container').html(); - } - }); + initTooltip(); $('#edit_product .extra-services-container #id_htl_booking').val(jsonProductLineData.id); $('#edit-room-booking-modal').modal('show'); } else { diff --git a/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js b/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js index 7bf27b61f..a74ad4bf1 100644 --- a/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js +++ b/modules/hotelreservationsystem/views/js/admin/wk_refund_request.js @@ -41,45 +41,6 @@ $(document).ready(function() { $('#voucher_expiry').parent().removeClass('has-error'); }); - // initialize tootip for room price - if ($('#rooms_refund_info .price_info').length) { - $('#rooms_refund_info .price_info').each(function (i, element) { - $(this).find('img').tooltip({ - content: $(this).closest('td').find('.price_info_container').html(), - items: "span", - trigger : 'hover', - tooltipClass: "price_info-tooltip", - open: function(event, ui) - { - if (typeof(event.originalEvent) === 'undefined') - { - return false; - } - - var $id = $(ui.tooltip).attr('id'); - - if ($('div.ui-tooltip').not('#' + $id).length) { - return false; - } - }, - close: function(event, ui) - { - ui.tooltip.hover(function() - { - $(this).stop(true).fadeTo(400, 1); - }, - function() - { - $(this).fadeOut('400', function() - { - $(this).remove(); - }); - }); - } - }); - }); - } - $(document).on('change', '#refundTransactionAmount', function() { if ($(this).is(':checked')) { $(".refund_transaction_fields").show(200); diff --git a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl index 3a181b149..84faaa7a9 100644 --- a/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/order_refund_requests/helpers/view/view.tpl @@ -171,35 +171,23 @@
    {dateFormat date=$booking['date_from'] full=$is_full_date} {l s='To' mod='hotelreservationsystem'} {dateFormat date=$booking['date_to'] full=$is_full_date} {displayPrice price=($booking['total_price_tax_incl'] + $booking['extra_service_total_price_tax_incl']) currency=$orderCurrency['id']} - -   - - {displayPrice price=($booking['room_paid_amount'] + $booking['extra_service_total_paid_amount']) currency=$orderCurrency['id']} - -   - - diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index f9836c246..67f4a03fe 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -455,7 +455,7 @@ {/if}
    -

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/night'}{/if}{/if}

    +

    {$demand['name']|escape:'html':'UTF-8'} {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{convertPrice price = $demand['price']}{if $demand['price_calc_method'] == $WK_PRICE_CALC_METHOD_EACH_DAY}{l s='/Night'}{/if}{/if}

    {if isset($demand['adv_option']) && $demand['adv_option']}
    {l s='Check-In'} {l s='Check-Out'} {l s='Allotment'}{l s='Room status'}{l s='Refund'} {l s='Action'}
    + {if isset($htl_booking_statuses[$data.id_status])} + {$htl_booking_statuses[$data.id_status].name|escape:'html':'UTF-8'} + {/if} + + {if $data.refund_count} + {displayPrice price=$data.refund_amount currency=$currency->id} ({$data.refund_count}) + {else} + -- + {/if} + {if $data.num_checkin_documents > 0}{$data.num_checkin_documents}{else}0{/if} - {if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded} + {if $data.id_status == $ROOM_STATUS_NO_SHOW || $data.id_status == $ROOM_STATUS_CANCELLED} + {if $data.id_status == $ROOM_STATUS_NO_SHOW}{l s='No-show'}{else}{l s='Cancelled'}{/if} + {elseif isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded} {if $data.is_cancelled}{l s='Cancelled'}{else}{l s='Refunded'}{/if} {elseif $can_edit} @@ -1367,9 +1383,12 @@ {addJsDefL name='no_children_allowed_txt'}{l s='Only adults can be accommodated' js=1}{/addJsDefL} {addJsDefL name='invalid_occupancy_txt'}{l s='Invalid occupancy(adults/children) found.' js=1}{/addJsDefL} {addJsDefL name='select_room_txt'}{l s='Select room' js=1}{/addJsDefL} + {addJsDefL name='room_status_sealed_warning_txt'}{l s='Are you sure? You cannot change the booking status after this.' js=1}{/addJsDefL} {addJsDef max_child_age=$max_child_age|escape:'quotes':'UTF-8'} {addJsDef ROOM_STATUS_CHECKED_IN=$ROOM_STATUS_CHECKED_IN|escape:'quotes':'UTF-8'} {addJsDef ROOM_STATUS_CHECKED_OUT=$ROOM_STATUS_CHECKED_OUT|escape:'quotes':'UTF-8'} + {addJsDef ROOM_STATUS_NO_SHOW=$ROOM_STATUS_NO_SHOW|escape:'quotes':'UTF-8'} + {addJsDef ROOM_STATUS_CANCELLED=$ROOM_STATUS_CANCELLED|escape:'quotes':'UTF-8'} {addJsDef ALLOTMENT_MANUAL=$ALLOTMENT_MANUAL|escape:'quotes':'UTF-8'} {addJsDef PS_OS_CANCELED=Configuration::get('PS_OS_CANCELED')|escape:'quotes':'UTF-8'} {addJsDef PS_OS_REFUND=Configuration::get('PS_OS_REFUND')|escape:'quotes':'UTF-8'} diff --git a/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl b/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl index 12058bee8..4f23794b5 100644 --- a/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_edit_room_tab_content.tpl @@ -31,7 +31,7 @@ - {if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ALLOTED)} + {if isset($data.id_status) && ($data.id_status != HotelBookingDetail::STATUS_ASSIGNED)}
    {if $data.id_status == HotelBookingDetail::STATUS_CHECKED_IN} {l s='The check-in date cannot be changed as the booking has already been checked in.'} @@ -49,7 +49,7 @@ {if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_refunded} {dateFormat date=$data.date_from} {else} - +
    {/if}
    diff --git a/admin/themes/default/template/controllers/orders/modals/_room_status_form.tpl b/admin/themes/default/template/controllers/orders/modals/_room_status_form.tpl index 204395b1a..37948c8dc 100644 --- a/admin/themes/default/template/controllers/orders/modals/_room_status_form.tpl +++ b/admin/themes/default/template/controllers/orders/modals/_room_status_form.tpl @@ -30,7 +30,7 @@ {/foreach} -
    +
    @@ -46,6 +46,11 @@
    +
    + + +
    + diff --git a/classes/order/Order.php b/classes/order/Order.php index e5ed30602..52b6cbbd4 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -45,6 +45,7 @@ class OrderCore extends ObjectModel const ORDER_COMPLETE_REFUND_FLAG = 1; const ORDER_COMPLETE_CANCELLATION_FLAG = 2; const ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG = 3; + const ORDER_COMPLETE_NOSHOW_FLAG = 4; /** @var int Delivery address id */ public $id_address_delivery; @@ -2924,6 +2925,28 @@ class OrderCore extends ObjectModel if (count($uniqueRefunded) == 1 && $uniqueRefunded[0] == 1) { return true; } + // If action is Order::ORDER_COMPLETE_NOSHOW_FLAG then we check every room is + // No-show — no mixing with Cancelled. A mixed order (some No-show, some + // Cancelled) matches neither this flag nor ORDER_COMPLETE_CANCELLATION_FLAG, + // same all-or-nothing strictness that flag already uses. + } elseif ($action == Order::ORDER_COMPLETE_NOSHOW_FLAG) { + if (empty($list)) { + return false; + } + foreach ($list as $product) { + if (isset($product['id_status'])) { + // room booking row + if ($product['id_status'] != HotelBookingDetail::STATUS_NO_SHOW) { + return false; + } + } elseif (!$product['is_cancelled']) { + // service products can't be "no-show" — just require them to + // already be resolved, same bar as ORDER_COMPLETE_CANCELLATION_FLAG + return false; + } + } + + return true; // If action is Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG (for cancelled and refund requests) then we will check that all rooms are either cancelled or requested for refund } elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG) { foreach ($list as $product) { @@ -2956,7 +2979,7 @@ class OrderCore extends ObjectModel foreach ($list as $product) { if ($product['is_refunded'] == 0 && !OrderReturn::getOrdersReturnDetail($this->id, 0, isset($product['id']) ? $product['id'] : 0) - && $product['id_status'] == HotelBookingDetail::STATUS_ALLOTED + && $product['id_status'] == HotelBookingDetail::STATUS_ASSIGNED ) { return false; } @@ -2971,7 +2994,12 @@ class OrderCore extends ObjectModel public function getOrderCompleteRefundStatus() { $idOrderState = 0; - if ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) { + // checked first, on purpose: a paid No-show room that's been approved ends up with + // is_refunded=1 and is_cancelled=0 (same shape ORDER_COMPLETE_REFUND_FLAG looks for), + // so No-show has to win the race or a fully no-show order would wrongly become "Refunded" + if ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_NOSHOW_FLAG)) { + $idOrderState = Configuration::get('PS_OS_NO_SHOW'); + } elseif ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) { $idOrderState = Configuration::get('PS_OS_REFUND'); } elseif ($this->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) { $idOrderState = Configuration::get('PS_OS_CANCELED'); diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index 3da74d335..c4d62e05e 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -57,6 +57,9 @@ class OrderReturnCore extends ObjectModel /** @var int whether $id_return_type is cart_rule or order_slip */ public $return_type; + /** @var int why this refund request exists: EVENT_TYPE_CANCELLATION/_NO_SHOW/_REFUND */ + public $event_type; + /** @var string Object creation date */ public $date_add; @@ -67,6 +70,11 @@ class OrderReturnCore extends ObjectModel const RETURN_TYPE_CART_RULE = 1; const RETURN_TYPE_ORDER_SLIP = 2; + /** possible values for $event_type */ + const EVENT_TYPE_CANCELLATION = 1; + const EVENT_TYPE_NO_SHOW = 2; + const EVENT_TYPE_REFUND = 3; + /** * @see ObjectModel::$definition */ @@ -84,6 +92,7 @@ class OrderReturnCore extends ObjectModel 'by_admin' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_return_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'return_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'event_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), @@ -771,20 +780,36 @@ class OrderReturnCore extends ObjectModel return false; } - public function getRefundedAmount($idOrder, $idOrderReturn = 0, $idHtlBooking = 0) + /** + * @param int $idOrder + * @param int $idOrderReturn + * @param int $idHtlBooking + * @param bool $detailedInfo when true, also returns the number of refund + * requests (not just the refunded amount) — e.g. for the order + * detail page's per-room "Refund" column + * @return float|array plain refunded amount by default; array('amount', 'count') when $detailedInfo + */ + public function getRefundedAmount($idOrder, $idOrderReturn = 0, $idHtlBooking = 0, $detailedInfo = false) { - $sql = 'SELECT SUM(ord.`refunded_amount`) FROM `'._DB_PREFIX_.'order_return_detail` ord'; - $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (orr.`id_order_return` = ord.`id_order_return`)'; - $sql .= ' WHERE orr.`id_order` = '.(int)$idOrder; + $where = ' WHERE orr.`id_order` = '.(int) $idOrder; if ($idOrderReturn) { - $sql .= ' AND ord.`id_order_return` = '.(int)$idOrderReturn; + $where .= ' AND ord.`id_order_return` = '.(int) $idOrderReturn; } if ($idHtlBooking) { - $sql .= ' AND ord.`id_htl_booking` = '.(int)$idHtlBooking; + $where .= ' AND ord.`id_htl_booking` = '.(int) $idHtlBooking; } + $from = ' FROM `'._DB_PREFIX_.'order_return_detail` ord + LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (orr.`id_order_return` = ord.`id_order_return`)'; + + if ($detailedInfo) { + $sql = 'SELECT COUNT(ord.`id_order_return_detail`) AS count, SUM(ord.`refunded_amount`) AS amount'.$from.$where; + return Db::getInstance()->getRow($sql); + } + + $sql = 'SELECT SUM(ord.`refunded_amount`) AS amount'.$from.$where; return Db::getInstance()->getValue($sql); } } diff --git a/config/defines.inc.php b/config/defines.inc.php index f16e93903..d78f92763 100644 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -26,7 +26,7 @@ /* Debug only */ if (!defined('_PS_MODE_DEV_')) { - define('_PS_MODE_DEV_', false); + define('_PS_MODE_DEV_', true); } /* Compatibility warning */ define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index bcbe5868c..25511823e 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -313,9 +313,11 @@ class AdminOrdersControllerCore extends AdminController 'displayed' => false, 'type' => 'select', 'list' => array( - HotelBookingDetail::STATUS_ALLOTED => $this->l('Alloted'), + HotelBookingDetail::STATUS_ASSIGNED => $this->l('Assigned'), HotelBookingDetail::STATUS_CHECKED_IN => $this->l('Checked in'), HotelBookingDetail::STATUS_CHECKED_OUT => $this->l('Checked out'), + HotelBookingDetail::STATUS_NO_SHOW => $this->l('No-show'), + HotelBookingDetail::STATUS_CANCELLED => $this->l('Cancelled'), ), ) )); @@ -402,9 +404,7 @@ class AdminOrdersControllerCore extends AdminController } if ($this->tabAccess['edit'] === 1) { - if (((int) $order->isReturnable()) - && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0) - ) { + if ((int) $order->isReturnable()) { $orderTotalPaid = $order->getTotalPaid(); $orderDiscounts = $order->getCartRules(); $hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false; @@ -784,13 +784,17 @@ class AdminOrdersControllerCore extends AdminController // set modal details $response['hasError'] = 1; if (Validate::isLoadedObject($objOrder = new Order(Tools::getValue('id_order')))) { - $htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus(); + $objHotelBookingStatus = new HotelBookingStatus(); + $htlOrderStatus = $objHotelBookingStatus->getAllStatuses( + $this->context->language->id, + (int) Tools::getValue('current_room_status') + ); $this->context->smarty->assign( array( 'order' => $objOrder, 'current_index' => self::$currentIndex, 'hotel_order_status' => $htlOrderStatus, - 'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED, + 'ROOM_STATUS_ASSIGNED' => HotelBookingDetail::STATUS_ASSIGNED, 'current_room_status' => Tools::getValue('current_room_status') ) ); @@ -812,7 +816,7 @@ class AdminOrdersControllerCore extends AdminController $this->context->smarty->assign($modal); $response['hasError'] = 0; - $response['STATUS_ALLOTED'] = HotelBookingDetail::STATUS_ALLOTED; + $response['STATUS_ASSIGNED'] = HotelBookingDetail::STATUS_ASSIGNED; $response['STATUS_CHECKED_IN'] = HotelBookingDetail::STATUS_CHECKED_IN; $response['STATUS_CHECKED_OUT'] = HotelBookingDetail::STATUS_CHECKED_OUT; $response['modalHtml'] = $this->context->smarty->fetch('modal.tpl'); @@ -1063,11 +1067,12 @@ class AdminOrdersControllerCore extends AdminController $objBookingDetail = new HotelBookingDetail(); $objServiceProductOrderDetail = new ServiceProductOrderDetail(); $objOrderReturn = new OrderReturn(); - $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1, 0, 1); if ($bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($objOrder->id)) { $objBookingDemand = new HotelBookingDemands(); foreach($bookingOrderInfo as $key => $booking) { - if ((in_array($booking['id'], $refundReqBookings)) || $booking['is_refunded']) { + // multiple refund requests are now allowed per booking — only still + // exclude a booking that's already fully refunded, not a re-request + if ($booking['is_refunded']) { unset($bookingOrderInfo[$key]); } else { $bookingOrderInfo[$key]['total_price_tax_incl'] += $objBookingDemand->getRoomTypeBookingExtraDemands( @@ -1495,7 +1500,7 @@ class AdminOrdersControllerCore extends AdminController LEFT JOIN ( SELECT GROUP_CONCAT( CASE - WHEN `id_status`='.HotelBookingDetail::STATUS_ALLOTED.' THEN \''.$this->l('Alloted').'\' + WHEN `id_status`='.HotelBookingDetail::STATUS_ASSIGNED.' THEN \''.$this->l('Assigned').'\' WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_IN.' THEN \''.$this->l('Checked in').'\' WHEN `id_status`='.HotelBookingDetail::STATUS_CHECKED_OUT.' THEN \''.$this->l('Checked out').'\' ELSE \''.$this->l('Invalid status').'\' @@ -1916,10 +1921,11 @@ class AdminOrdersControllerCore extends AdminController $objOrderReturn = new OrderReturn(); $bookings = Tools::getValue('id_htl_booking'); if ($bookings && count($bookings)) { - $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1, 0, 1); + // multiple refund requests are now allowed per booking — only still + // block a booking that's already fully refunded, not a re-request foreach ($bookings as $idHtlBooking) { $objBookingDetail = new HotelBookingDetail($idHtlBooking); - if ((in_array($idHtlBooking, $refundReqBookings)) || $objBookingDetail->is_refunded) { + if ($objBookingDetail->is_refunded) { $this->errors[] = Tools::displayError('Wrong bookings found for cancelation.'); break; } @@ -1955,6 +1961,7 @@ class AdminOrdersControllerCore extends AdminController $objOrderReturn->by_admin = 1; $objOrderReturn->question = $refundReason; $objOrderReturn->refunded_amount = 0; + $objOrderReturn->event_type = OrderReturn::EVENT_TYPE_REFUND; $objOrderReturn->save(); if ($objOrderReturn->id) { if ($bookings) { @@ -3119,7 +3126,7 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color1'; $helper->title = $this->l('Arrivals', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ALLOTED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')); + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ASSIGNED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_arrivals'; $helper->tooltip = $this->l('Total number of arrivals for today.', null, null, false); $this->kpis[] = $helper; @@ -3642,6 +3649,18 @@ class AdminOrdersControllerCore extends AdminController } } $bookingOrderRoomInfo['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($bookingOrderRoomInfo['id']); + + $roomRefundInfo = $objOrderReturn->getRefundedAmount($bookingOrderRoomInfo['id_order'], 0, $bookingOrderRoomInfo['id'], true); + $bookingOrderRoomInfo['refund_amount'] = $roomRefundInfo['amount']; + $bookingOrderRoomInfo['refund_count'] = (int) $roomRefundInfo['count']; + } + unset($bookingOrderRoomInfo); + + // catalog of the 5 booking statuses (id_booking_status => color/name), for the + // Rooms Booking Detail table's status badge + $htlBookingStatuses = array(); + foreach ((new HotelBookingStatus())->getAllStatuses($this->context->language->id) as $htlBookingStatus) { + $htlBookingStatuses[$htlBookingStatus['id_status']] = $htlBookingStatus; } $objHotelBookingDetail = new HotelBookingDetail(); @@ -3724,6 +3743,7 @@ class AdminOrdersControllerCore extends AdminController 'totalRoomsCostTE' => $totalRoomsCostTE, 'total_room_tax' => $total_room_tax, 'htl_booking_order_data' => $bookingOrderInfo, + 'htl_booking_statuses' => $htlBookingStatuses, 'hotel_order_status' => $htlOrderStatus, 'order_detail_data' => $order_detail_data, 'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'), @@ -3808,6 +3828,8 @@ class AdminOrdersControllerCore extends AdminController 'orderDocuments' => $order->getDocuments(), 'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN, 'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT, + 'ROOM_STATUS_NO_SHOW' => HotelBookingDetail::STATUS_NO_SHOW, + 'ROOM_STATUS_CANCELLED' => HotelBookingDetail::STATUS_CANCELLED, 'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL, 'order_convenience_fee_services' => $orderConvenienceFeeServices, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn, @@ -7007,7 +7029,7 @@ class AdminOrdersControllerCore extends AdminController } } - if ($objBookingDetail->id_status != HotelBookingDetail::STATUS_ALLOTED + if ($objBookingDetail->id_status != HotelBookingDetail::STATUS_ASSIGNED && strtotime($old_date_from) != strtotime($new_date_from) ) { die(json_encode(array( @@ -8804,6 +8826,7 @@ class AdminOrdersControllerCore extends AdminController $idHotelBookingDetail = (int) Tools::getValue('id_hotel_booking_detail'); if (Validate::isLoadedObject($objHotelBookingDetail = new HotelBookingDetail($idHotelBookingDetail))) { $newStatus = (int) Tools::getValue('booking_order_status'); + $statusRemark = Tools::getValue('status_remark'); // date choosen for the status change if ($statusDate = Tools::getValue('status_date')) { $statusDate = date('Y-m-d H:i:s', strtotime($statusDate)); @@ -8823,6 +8846,12 @@ class AdminOrdersControllerCore extends AdminController ) { $this->errors[] = Tools::displayError('Date should be between booking from date and to date.'); } + } elseif ($newStatus == HotelBookingDetail::STATUS_NO_SHOW && strtotime($dateFrom) > time()) { + $this->errors[] = Tools::displayError('Room cannot be marked as No-show before the booking\'s check-in date.'); + } + + if (!$statusRemark) { + $this->errors[] = Tools::displayError('Please enter a note for this status change.'); } if ($objHotelBookingDetail->id_status == HotelBookingDetail::STATUS_CHECKED_OUT @@ -8854,7 +8883,7 @@ class AdminOrdersControllerCore extends AdminController if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) { $orderBookings = $objHotelBookingDetail->getOrderCurrentDataByOrderId( $id_order, - array(HotelBookingDetail::STATUS_ALLOTED, HotelBookingDetail::STATUS_CHECKED_IN), + array(HotelBookingDetail::STATUS_ASSIGNED, HotelBookingDetail::STATUS_CHECKED_IN), 0, 0 ); @@ -8865,7 +8894,6 @@ class AdminOrdersControllerCore extends AdminController if ($remainingCheckoutRooms == 1 && $newStatus == HotelBookingDetail::STATUS_CHECKED_OUT && $hasPendingBills) { $this->errors[] = Tools::displayError('You cannot checkout the last room while there are pending bills for this order.'); } else { - $objHotelBookingDetail->id_status = $newStatus; if ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN) { $objHotelBookingDetail->check_in = $statusDate; } elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) { @@ -8874,17 +8902,91 @@ class AdminOrdersControllerCore extends AdminController $objHotelBookingDetail->check_in = ''; $objHotelBookingDetail->check_out = ''; } - if ($objHotelBookingDetail->save()) { - Hook::exec( - 'actionRoomBookingStatusUpdateAfter', - array( - 'id_hotel_booking_detail' => $objHotelBookingDetail->id, - 'id_order' => $objHotelBookingDetail->id_order, - 'id_room' => $objHotelBookingDetail->id_room, - 'date_from' => $objHotelBookingDetail->date_from, - 'date_to' => $objHotelBookingDetail->date_to - ) + + $changeParams = array( + 'id_employee' => (int) $this->context->employee->id, + 'remark' => $statusRemark, + ); + + if ($newStatus == HotelBookingDetail::STATUS_CANCELLED || $newStatus == HotelBookingDetail::STATUS_NO_SHOW) { + // picking Cancelled/No-show also creates the matching refund + // request — unpaid: everything resolves immediately together; + // paid: room status stays as-is until the request is approved + // in Manage Order Refund Requests + $eventType = ($newStatus == HotelBookingDetail::STATUS_CANCELLED) + ? OrderReturn::EVENT_TYPE_CANCELLATION + : OrderReturn::EVENT_TYPE_NO_SHOW; + $hasOrderDiscountOrPayment = ((float) $order->getTotalPaid() > 0 || $order->getCartRules()) ? true : false; + + $objOrderReturn = new OrderReturn(); + $objOrderReturn->id_customer = $order->id_customer; + $objOrderReturn->id_order = $order->id; + $objOrderReturn->state = 0; + $objOrderReturn->by_admin = 1; + $objOrderReturn->question = $statusRemark; + $objOrderReturn->refunded_amount = 0; + $objOrderReturn->event_type = $eventType; + $objOrderReturn->save(); + + $objOrderReturnDetail = new OrderReturnDetail(); + $objOrderReturnDetail->id_order_return = $objOrderReturn->id; + $objOrderReturnDetail->id_order_detail = $objHotelBookingDetail->id_order_detail; + $objOrderReturnDetail->product_quantity = HotelHelper::getNumberOfDays( + $objHotelBookingDetail->date_from, + $objHotelBookingDetail->date_to ); + $objOrderReturnDetail->id_htl_booking = $objHotelBookingDetail->id; + $objOrderReturnDetail->refunded_amount = 0; + if (!$hasOrderDiscountOrPayment) { + $objOrderReturnDetail->id_customization = 1; + } + $objOrderReturnDetail->save(); + + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); + + $statusChanged = false; + if (!$hasOrderDiscountOrPayment) { + $statusChanged = $objHotelBookingDetail->changeStatus($newStatus, $changeParams); + if ($statusChanged) { + $objHotelBookingDetail->processRefundInBookingTables(); + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_REFUNDED')); + + // if every room in the order is now No-show (or fully + // cancelled/refunded), bump the order's own status — + // same pattern already used by the initiateRefund handler + $order = new Order($order->id); + if ($idOrderState = $order->getOrderCompleteRefundStatus()) { + $objOrderHistory = new OrderHistory(); + $objOrderHistory->id_order = (int) $order->id; + $useExistingPayment = !$order->hasInvoice(); + $objOrderHistory->changeIdOrderState($idOrderState, $order, $useExistingPayment); + $objOrderHistory->addWithemail(); + } + } + $success = $statusChanged; + } else { + // paid: request is Pending, room status doesn't change yet — + // nothing to announce via the room-status-update hook below + $success = true; + } + } else { + $statusChanged = $objHotelBookingDetail->changeStatus($newStatus, $changeParams); + $success = $statusChanged; + } + + if ($success) { + if ($statusChanged) { + Hook::exec( + 'actionRoomBookingStatusUpdateAfter', + array( + 'id_hotel_booking_detail' => $objHotelBookingDetail->id, + 'id_order' => $objHotelBookingDetail->id_order, + 'id_room' => $objHotelBookingDetail->id_room, + 'date_from' => $objHotelBookingDetail->date_from, + 'date_to' => $objHotelBookingDetail->date_to + ) + ); + } Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $objHotelBookingDetail->id_order . '&vieworder&token=' . $this->token . '&conf=4'); } else { diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index d3933c954..87947d0b4 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -1118,7 +1118,7 @@ class AdminStatsControllerCore extends AdminStatsTabController date('Y-m-d'), date('Y-m-d', strtotime('+1 day')), $idHotels, - HotelBookingDetail::STATUS_ALLOTED + HotelBookingDetail::STATUS_ASSIGNED ); break; diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 25111fbad..3ce20f47e 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -497,7 +497,7 @@ class OrderDetailControllerCore extends FrontController 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), - 'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED, + 'ROOM_STATUS_ASSIGNED' => HotelBookingDetail::STATUS_ASSIGNED, 'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN, 'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT, ) @@ -610,12 +610,14 @@ class OrderDetailControllerCore extends FrontController } // the room has already been checked in/checked out, room will not be able to be cancelled by the customer - if ($objHotelBookingDetail->id_status != HotelBookingDetail::STATUS_ALLOTED) { + if ($objHotelBookingDetail->id_status != HotelBookingDetail::STATUS_ASSIGNED) { $this->errors[] = Tools::displayError('Some selected rooms have already been checked-in/checked-out.'); break; } - if (OrderReturn::getOrdersReturnDetail($objOrder->id, 0, $idHtlBooking)) { + // multiple refund requests are now allowed per booking — only still + // block a booking that's already fully refunded, not a re-request + if ($objHotelBookingDetail->is_refunded) { $this->errors[] = Tools::displayError('Some selected rooms have already been requested for cancellation.'); break; } @@ -640,6 +642,7 @@ class OrderDetailControllerCore extends FrontController $objOrderReturn->by_admin = 0; $objOrderReturn->question = $cancellationReason; $objOrderReturn->refunded_amount = 0; + $objOrderReturn->event_type = OrderReturn::EVENT_TYPE_REFUND; $objOrderReturn->save(); if ($objOrderReturn->id) { if ($idsHtlBooking) { diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 9520ec459..732fbbed2 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1350,6 +1350,7 @@ CREATE TABLE `PREFIX_order_return` ( `by_admin` tinyint(1) unsigned NOT NULL DEFAULT '0', `id_return_type` tinyint(1) unsigned NOT NULL DEFAULT '0', `return_type` tinyint(1) unsigned NOT NULL DEFAULT '0', + `event_type` tinyint(1) unsigned NOT NULL DEFAULT '0', `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_order_return`), diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 9e5658518..184d69dd0 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -461,6 +461,9 @@ 12 + + 13 + diff --git a/install/data/xml/order_state.xml b/install/data/xml/order_state.xml index cc016ffcd..b94ac7fd0 100644 --- a/install/data/xml/order_state.xml +++ b/install/data/xml/order_state.xml @@ -38,5 +38,7 @@ + diff --git a/install/langs/bg/data/order_state.xml b/install/langs/bg/data/order_state.xml index f4661ce31..268dff528 100644 --- a/install/langs/bg/data/order_state.xml +++ b/install/langs/bg/data/order_state.xml @@ -48,4 +48,8 @@ Получено частично плащане + + Неявяване +