From 34a0604a4519637672fae0a2d3b3816bd41b345e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 2 Mar 2023 20:31:56 +0530 Subject: [PATCH 1/7] fixed service product issues --- .../controllers/normal_products/prices.tpl | 9 - .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++-------- .../orders/_room_services_block.tpl | 194 +++++++++--------- .../controllers/orders/helpers/view/view.tpl | 11 +- classes/Cart.php | 4 - classes/Product.php | 7 +- classes/SpecificPrice.php | 3 +- .../admin/AdminNormalProductsController.php | 27 ++- controllers/admin/AdminOrdersController.php | 1 + controllers/admin/AdminProductsController.php | 1 - controllers/front/OrderOpcController.php | 4 +- controllers/front/ProductController.php | 20 +- install/data/db_structure.sql | 1 - install/data/xml/category_group.xml | 6 +- .../bankwire/controllers/front/payment.php | 3 + .../bankwire/controllers/front/validation.php | 3 + modules/cheque/controllers/front/payment.php | 3 + .../cheque/controllers/front/validation.php | 3 + .../classes/RoomTypeServiceProduct.php | 2 + .../RoomTypeServiceProductCartDetail.php | 16 ++ .../_partials/service-products-list-row.tpl | 35 ++-- .../_partials/service-products.tpl | 2 +- themes/hotel-reservation-theme/js/product.js | 44 ++-- 24 files changed, 319 insertions(+), 253 deletions(-) diff --git a/admin/themes/default/template/controllers/normal_products/prices.tpl b/admin/themes/default/template/controllers/normal_products/prices.tpl index 5c6e4550b..9296a4701 100644 --- a/admin/themes/default/template/controllers/normal_products/prices.tpl +++ b/admin/themes/default/template/controllers/normal_products/prices.tpl @@ -469,15 +469,6 @@ $(document).ready(function () { -
- -
-
- {l s='unit'} - -
-
-
@@ -51,8 +46,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { - font-size: 14px;} + /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ + /* font-size: 14px;} */ #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..1b96dba9b 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} -
- - {if isset($orderEdit) && $orderEdit} -

- - -

+
+ + {if isset($orderEdit) && $orderEdit} +

+ + +

- {* Already selected room demands *} -
- - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - - {/foreach} + {* Already selected room demands *} +
+
{$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
+ + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + {/foreach} - {else} - - - - {/if} - -
{$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
- {l s='No facilities added yet.'} -
-
+ {/foreach} + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
- {* Room demands available for the current editing room*} -
-
- {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
-
-
-
- -
-
-

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

- {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} -
+ {* Room demands available for the current editing room*} +
+
+ {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
+
+
+
+ +
+
+

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

+ {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/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}

-
- {/foreach} - {/if} -
- -
- {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
- {foreach $roomDemand['extra_demands'] as $demand} -
-

- {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

+
+

{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}

+
{/foreach} -
- {/foreach} - {/if} -
-{/if} \ No newline at end of file + {/if} +
+ +
+ {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
+ {foreach $roomDemand['extra_demands'] as $demand} +
+

+ {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

+
+ {/foreach} +
+ {/foreach} + {else} + {l s='No facilities available!'} + {/if} +
\ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 66c2e5b21..7566f1e5b 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,114 +17,114 @@ * @license https://store.webkul.com/license.html *} -{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} -
- {if isset($orderEdit) && $orderEdit} +
+ {if isset($orderEdit) && $orderEdit} -

- - -

+

+ + +

- {* Already selected room services *} -
- - - {if isset($additionalServices) && $additionalServices} - {foreach $additionalServices['additional_services'] as $service} - - - + + + + {/foreach} + {else} + + + + {/if} + +
-
{$service['name']|escape:'html':'UTF-8'}
- {if $service['allow_multiple_quantity']} -
- -
- {/if} -
- {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} - {l s='Convenience fee'} + {* Already selected room services *} +
+ + + {if isset($additionalServices) && $additionalServices} + {foreach $additionalServices['additional_services'] as $service} + + - - - - {/foreach} - {else} - - - - {/if} - -
+
{$service['name']|escape:'html':'UTF-8'}
+ {if $service['allow_multiple_quantity']} +
+ +
{/if} - {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} - {l s='Auto added'} - {/if} -
{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
- {l s='No services added yet.'}
-
-
-
- {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} - {foreach $roomTypeServiceProducts as $product} -
-
-
-
- -
-
-

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

- {if $product.allow_multiple_quantity} -
- -
- {/if} -
-
-
-
-

- {convertPrice price=$product.price_tax_incl} -

-
-
- {/foreach} - {else} - {l s='No services available to select, All services already added.'} - {/if} -
- - -
- - {elseif isset($additionalServices) && $additionalServices} -
- {foreach $additionalServices['additional_services'] as $service} -
-
-
- +
{if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} {l s='Convenience fee'} {/if} {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} {l s='Auto added'} {/if} - -
{$service['name']|escape:'html':'UTF-8'}
- {if $service['allow_multiple_quantity']} -
{l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
- {/if} - +
{displayPrice price=$service['total_price_tax_excl']|escape:'html':'UTF-8' currency=$orderCurrency}
+ {l s='No services added yet.'} +
+
+
+
+ {if isset($roomTypeServiceProducts) && $roomTypeServiceProducts} + {foreach $roomTypeServiceProducts as $product} +
+
+
+
+ +
+
+

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

+ {if $product.allow_multiple_quantity} +
+ +
+ {/if} +
+
-
- {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
+

+ {convertPrice price=$product.price_tax_incl} +

-
- {/foreach} + {/foreach} + {else} + {l s='No services available to select, All services already added.'} + {/if}
- {/if} -
-{/if} + + + + + {elseif isset($additionalServices) && $additionalServices} +
+ {foreach $additionalServices['additional_services'] as $service} +
+
+
+ + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT} + {l s='Convenience fee'} + {/if} + {if $service['product_auto_add'] && $service['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM} + {l s='Auto added'} + {/if} + +
{$service['name']|escape:'html':'UTF-8'}
+ {if $service['allow_multiple_quantity']} +
{l s='Qty:'} {$service['quantity']|escape:'html':'UTF-8'}
+ {/if} + +
+
+ {displayPrice price=$service['total_price_tax_excl'] currency=$orderCurrency} +
+
+
+ {/foreach} +
+ {else} + {l s='No services available!'} + {/if} +
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 8a2b5b313..5dd42117e 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,14 +1717,21 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { $(this).val(1); } updateServiceProducts($(this)); }); + $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { + var qty_wntd = $(this).val(); + if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + $(this).val(1); + } + }); + function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/classes/Cart.php b/classes/Cart.php index fe5e5a1a1..574459920 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -568,10 +568,6 @@ class CartCore extends ObjectModel $sql->where('cp.`id_product` = '.(int)$id_product); } $sql->where('p.`id_product` IS NOT NULL'); - // hide invisible products - // if ($front) { - // $sql->where('p.`is_invisible` = 0'); - // } // Build ORDER BY $sql->orderBy('cp.`date_add`, cp.`id_product`, cp.`id_product_attribute` ASC'); diff --git a/classes/Product.php b/classes/Product.php index 33d169e23..5664c139b 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -240,7 +240,6 @@ class ProductCore extends ObjectModel public $cache_has_attachments; public $is_virtual; public $booking_product; - public $is_invisible; public $id_pack_product_attribute; public $cache_default_attribute; @@ -297,7 +296,6 @@ class ProductCore extends ObjectModel 'cache_has_attachments' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'is_virtual' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'booking_product' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), - 'is_invisible' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'service_product_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), /* Shop fields */ @@ -992,7 +990,7 @@ class ProductCore extends ObjectModel public function deleteServiceInfo() { if (!RoomTypeServiceProduct::deleteRoomProductLink($this->id) - ||RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) + || !RoomTypeServiceProductPrice::deleteRoomProductPrices($this->id) ) { return false; } @@ -1339,7 +1337,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -1384,7 +1381,6 @@ class ProductCore extends ObjectModel .($sub_category? ' AND product_shop.`id_category_default` = '.(int)$sub_category : '') .($front ? ' AND product_shop.`show_at_front` = 1':'') .(!is_null($auto_add_to_cart) ? ' AND product_shop.`auto_add_to_cart` = '.$auto_add_to_cart:'') - .($front ? ' AND p.`is_invisible` = 0':'') .($available_for_order != 2 ? ' AND p.`available_for_order` = '.(int)$available_for_order:'') .($active ? ' AND product_shop.`active` = 1' : ''); @@ -1429,7 +1425,6 @@ class ProductCore extends ObjectModel AND p.`service_product_type` = '.(int)self::SERVICE_PRODUCT_WITH_ROOMTYPE. ' AND product_shop.`id_shop` = '.(int)$context->shop->id .($front ? ' AND product_shop.`auto_add_to_cart` = 0 AND product_shop.`show_at_front` = 1':'') - .($front ? ' AND p.`is_invisible` = 0':'') .($active ? ' AND product_shop.`active` = 1' : ''); diff --git a/classes/SpecificPrice.php b/classes/SpecificPrice.php index 139b392ab..2794311ff 100644 --- a/classes/SpecificPrice.php +++ b/classes/SpecificPrice.php @@ -145,8 +145,7 @@ class SpecificPriceCore extends ObjectModel FROM `'._DB_PREFIX_.'specific_price` WHERE 1 '.self::filterOutField('id_product', $id_product). ($id_product_attribute ? ' AND id_product_attribute = '.(int) $id_product_attribute : '').' - AND id_cart = '.(int) $id_cart.' - GROUP BY `id_specific_price_rule`' + AND id_cart = '.(int) $id_cart ); } diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..5210546c9 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -99,7 +99,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs_lang = array( 'Informations' => $this->l('Information'), 'Prices' => $this->l('Prices'), - 'Seo' => $this->l('SEO'), + // 'Seo' => $this->l('SEO'), 'Images' => $this->l('Images'), 'Associations' => $this->l('Associations'), ); @@ -108,7 +108,7 @@ class AdminNormalProductsControllerCore extends AdminController $this->available_tabs = array_merge($this->available_tabs, array( 'Informations' => 0, 'Prices' => 1, - 'Seo' => 2, + // 'Seo' => 2, 'Associations' => 3, 'Images' => 4, )); @@ -948,7 +948,7 @@ class AdminNormalProductsControllerCore extends AdminController $id_groups = Tools::getValue('spm_id_group'); $id_customers = Tools::getValue('spm_id_customer'); $prices = Tools::getValue('spm_price'); - $from_quantities = Tools::getValue('spm_from_quantity'); + $from_quantities = 1; $reductions = Tools::getValue('spm_reduction'); $reduction_types = Tools::getValue('spm_reduction_type'); $froms = Tools::getValue('spm_from'); @@ -1939,7 +1939,7 @@ class AdminNormalProductsControllerCore extends AdminController if ($this->isTabSubmitted('Prices')) { // $this->processAdvancedPayment(); $this->processPriceAddition(); - // $this->processSpecificPricePriorities(); + $this->processSpecificPricePriorities(); } if ($this->isTabSubmitted('Images')) { $this->processImageLegends(); @@ -2016,6 +2016,22 @@ class AdminNormalProductsControllerCore extends AdminController $default_language = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); + + // we have removed seo tab as it is currently not required, but in product object requires link_rewrite + // so adding link_rewrite in $_POST + if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { + $link_rewrite = $_POST['name_'.$default_language->id]; + if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { + $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + } + $link_rewrite = str_replace(' ', '-', $link_rewrite); + $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); + $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; + } else { + $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + } + // end + // Check required fields foreach ($rules['required'] as $field) { if (!$this->isProductFieldUpdated($field)) { @@ -2855,13 +2871,12 @@ class AdminNormalProductsControllerCore extends AdminController $tree = new HelperTreeCategories('associated-categories-tree', 'Associated categories'); $tree->setTemplate('tree_associated_categories.tpl') ->setHeaderTemplate('tree_associated_header.tpl') - ->setRootCategory((int)Configuration::get('PS_PRODUCTS_CATEGORY')) + ->setRootCategory((int)Configuration::get('PS_SERVICE_CATEGORY')) ->setUseCheckBox(true) ->setUseSearch(false) ->setFullTree(0) ->setSelectedCategories($categories) ->setUseBulkActions(false); - // ->setDisablAllCategories(true); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index df4af2e8d..ca9b99ff1 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,6 +4738,7 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } + $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d49a74365..cb73e6fa6 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2081,7 +2081,6 @@ class AdminProductsControllerCore extends AdminController } } - // shreesh check if product is virtual, then set categories according to hotel // if (Tools::getValue('is_virtual')) { $id_hotel = Tools::getValue('id_hotel'); if (!$id_hotel || !Validate::isUnsignedInt($id_hotel)) { diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f5a5bec2b..cc11fa369 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,6 +389,9 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + parent::initContent(); // check ORDER RESTRICT condition before payment by the customer @@ -452,7 +455,6 @@ class OrderOpcControllerCore extends ParentOrderController $this->context->smarty->assign('checkout_process_steps', $this->checkoutProcess->getSteps()); - // @todo shreesh get this checked with sumit sir // set room type demands // $objGlobalDemand = new HotelRoomTypeGlobalDemand(); // $allDemands = $objGlobalDemand->getAllDemands(); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a97a90577..054555062 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,12 +1318,13 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'status' => false + 'success' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); + $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1334,7 +1335,22 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - $response['status'] = true; + if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { + $response['success'] = true; + if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { + if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } else { + $response['msg'] = 'Service already added.'; + } + } else { + $response['add'] = true; + $response['msg'] = 'Service is added to cart.'; + } + } else { + $response['error'] = Tools::displayError('Service not Found'); + } } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index 5bc961640..8d5607c38 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -1554,7 +1554,6 @@ CREATE TABLE `PREFIX_product` ( `cache_has_attachments` tinyint(1) NOT NULL DEFAULT '0', `is_virtual` tinyint(1) NOT NULL DEFAULT '0', `booking_product` tinyint(1) NOT NULL DEFAULT '1', - `is_invisible` tinyint(1) NOT NULL DEFAULT '0', `cache_default_attribute` int(10) unsigned DEFAULT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index a0187a2f0..902335903 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index cee1fe886..59dc5ab17 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,6 +50,9 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index c96ff78ec..5df9b7411 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,6 +49,9 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index e1415337d..1d5e0f76b 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,6 +50,9 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index 6f75120a9..f280abd3f 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,6 +48,9 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); + // check all service products are available + RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); + /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 199d3a178..6a16c420d 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,6 +182,8 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); + + $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index eafa043bb..f9446f9f9 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,4 +341,20 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } + + public static function validateServiceProductsInCart() + { + $context = Context::getContext(); + if ($cartProducts = $context->cart->getProducts()) { + $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); + foreach ($cartProducts as $product) { + if (!$product['active'] && !$product['booking_product']) { + $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); + foreach ($serviceProducts as $serviceProduct) { + $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); + } + } + } + } + } } \ No newline at end of file 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 f700c7720..08e3c1b8e 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,9 +20,15 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} + {foreach $product.images as $image} + {if $image['cover'] == 0} + + {/if} + {/foreach}
    @@ -36,7 +42,7 @@ {/if}
    - {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {if !$PS_CATALOG_MODE && !$order_date_restrict && ($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} @@ -46,20 +52,21 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if} {/if} {/if} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} +
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 2b3565520..370f10de9 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 96ae9a806..57a0add94 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,6 +1201,15 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } + var added_service_product = []; + + $('#additional_products input.service_product').each(function () { + added_service_product.push({ + 'id_product': $(this).data('id_product'), + 'quantity':$(this).val(), + }); + }); + $.ajax({ type: 'POST', headers: { @@ -1215,31 +1224,36 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, + added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.status) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); + if (result.success) { + if (result.add) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); + } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - showSuccessMessage(cart_extra_service_add); + if (result.msg) { + showSuccessMessage(result.msg); + } BookingForm.refresh(); } else { if (result.error) { From f34b8a4b67c05cf2fae8f6239eb00ba9a9e8c7c2 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:43:40 +0530 Subject: [PATCH 2/7] updated link_rewrite field of service product --- controllers/admin/AdminNormalProductsController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 5210546c9..1ffa75ae4 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2020,15 +2020,13 @@ class AdminNormalProductsControllerCore extends AdminController // we have removed seo tab as it is currently not required, but in product object requires link_rewrite // so adding link_rewrite in $_POST if (Configuration::get('PS_FORCE_FRIENDLY_PRODUCT') || !Validate::isLoadedObject($this->object)) { - $link_rewrite = $_POST['name_'.$default_language->id]; - if (!Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) { - $link_rewrite = Tools::replaceAccentedChars($link_rewrite); + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = Tools::link_rewrite(Tools::getValue('name_'.$lang['id_lang'])); } - $link_rewrite = str_replace(' ', '-', $link_rewrite); - $link_rewrite = preg_replace('/[\/\\"\'|,;%]*/', '', $link_rewrite); - $_POST['link_rewrite_'.$default_language->id] = $link_rewrite; } else { - $_POST['link_rewrite_'.$default_language->id] = $this->object->link_rewrite[$default_language->id]; + foreach ($languages as $lang) { + $_POST['link_rewrite_'.$lang['id_lang']] = $this->object->link_rewrite[$lang['id_lang']]; + } } // end From 103d2ccfd863eeefad7029471573c4a2156bba5e Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Fri, 3 Mar 2023 12:53:45 +0530 Subject: [PATCH 3/7] fixed undefined index issue when booking multiple rooms --- controllers/front/OrderDetailController.php | 66 ++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 2a898f8b6..20ed72474 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); } - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); // calculate averages now foreach ($cartHotelData[$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); From 49da8574d7e1af3ca1ee33cd26fa1dcacbc84b47 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Sun, 5 Mar 2023 12:24:35 +0530 Subject: [PATCH 4/7] resolve export issue --- controllers/admin/AdminCartsController.php | 1 + controllers/admin/AdminNormalProductsController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index db54f518c..fd7802f8b 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -135,6 +135,7 @@ class AdminCartsControllerCore extends AdminController $smartyVars['type'] = 'non_orderd'; } } + $smartyVars['link'] = $this->context->link; $tpl = $this->createTemplate('_orders.tpl'); $tpl->assign($smartyVars); diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 17cbc74d1..e14345a50 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -90,7 +90,7 @@ class AdminNormalProductsControllerCore extends AdminController parent::__construct(); $this->imageType = 'jpg'; - $this->_defaultOrderBy = 'position'; + $this->_defaultOrderBy = 'id_product'; $this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000); $this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'); $this->allow_export = true; From b5b1022bf89bca3c14e7118b1fa8bd86b38fb3ae Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 7 Mar 2023 18:12:58 +0530 Subject: [PATCH 5/7] removed addition changes --- .../orders/_room_extra_services_modal.tpl | 13 +- .../orders/_room_facilities_block.tpl | 160 +++++++++--------- .../orders/_room_services_block.tpl | 10 +- .../controllers/orders/helpers/view/view.tpl | 11 +- controllers/admin/AdminOrdersController.php | 1 - controllers/front/OrderDetailController.php | 66 ++++---- controllers/front/OrderOpcController.php | 3 - controllers/front/ProductController.php | 20 +-- install/data/xml/category_group.xml | 6 +- .../bankwire/controllers/front/payment.php | 3 - .../bankwire/controllers/front/validation.php | 3 - modules/cheque/controllers/front/payment.php | 3 - .../cheque/controllers/front/validation.php | 3 - .../classes/RoomTypeServiceProduct.php | 2 - .../RoomTypeServiceProductCartDetail.php | 16 -- .../_partials/service-products-list-row.tpl | 35 ++-- .../_partials/service-products.tpl | 2 +- themes/hotel-reservation-theme/js/product.js | 44 ++--- 18 files changed, 164 insertions(+), 237 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl index 4714a077b..2e0cd1415 100644 --- a/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl +++ b/admin/themes/default/template/controllers/orders/_room_extra_services_modal.tpl @@ -22,8 +22,12 @@
    @@ -46,8 +51,8 @@ margin: 0px;} #rooms_type_extra_demands .demand_edit_badge { font-size: 14px;} - /* #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { */ - /* font-size: 14px;} */ + #rooms_extra_demands .room_ordered_demands td, #rooms_extra_demands .room_demand_detail { + font-size: 14px;} #rooms_extra_demands .demand_header { padding: 10px; color: #333; diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index 1b96dba9b..abc426f8d 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -17,91 +17,91 @@ * @license https://store.webkul.com/license.html *} -
    - - {if isset($orderEdit) && $orderEdit} -

    - - -

    +{if (isset($extraDemands) && $extraDemands) || (isset($roomTypeDemands) && $roomTypeDemands)} +
    + + {if isset($orderEdit) && $orderEdit} +

    + + +

    - {* Already selected room demands *} -
    - - - {if isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} - {foreach $roomDemand['extra_demands'] as $demand} - - - - - + {* Already selected room demands *} +
    +
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    + + {if isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} + {foreach $roomDemand['extra_demands'] as $demand} + + + + + + {/foreach} {/foreach} - {/foreach} - {else} - - - - {/if} - -
    {$demand['name']}{displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency}
    - {l s='No facilities added yet.'} -
    -
    + {else} + + + {l s='No facilities added yet.'} + + + {/if} + + +
    - {* Room demands available for the current editing room*} -
    -
    - {if isset($roomTypeDemands) && $roomTypeDemands} - {foreach $roomTypeDemands as $idGlobalDemand => $demand} -
    -
    -
    -
    - -
    -
    -

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

    - {if isset($demand['adv_option']) && $demand['adv_option']} - - {else} - - {/if} + {* Room demands available for the current editing room*} +
    +
    + {if isset($roomTypeDemands) && $roomTypeDemands} + {foreach $roomTypeDemands as $idGlobalDemand => $demand} +
    +
    +
    +
    + +
    +
    +

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

    + {if isset($demand['adv_option']) && $demand['adv_option']} + + {else} + + {/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 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}

    -
    + {/foreach} + {/if} +
    + +
    + {elseif isset($extraDemands) && $extraDemands} + {foreach $extraDemands as $roomDemand} +
    + {foreach $roomDemand['extra_demands'] as $demand} +
    +

    + {$demand['name']} + {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} +

    {/foreach} - {/if} -
    - -
    - {elseif isset($extraDemands) && $extraDemands} - {foreach $extraDemands as $roomDemand} -
    - {foreach $roomDemand['extra_demands'] as $demand} -
    -

    - {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} -

    -
    - {/foreach} -
    - {/foreach} - {else} - {l s='No facilities available!'} - {/if} -
    \ No newline at end of file +
    + {/foreach} + {/if} +
    +{/if} \ No newline at end of file diff --git a/admin/themes/default/template/controllers/orders/_room_services_block.tpl b/admin/themes/default/template/controllers/orders/_room_services_block.tpl index 7566f1e5b..1bbf2ad64 100644 --- a/admin/themes/default/template/controllers/orders/_room_services_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_services_block.tpl @@ -17,7 +17,8 @@ * @license https://store.webkul.com/license.html *} -
    +{if (isset($additionalServices) && $additionalServices) || (isset($roomTypeServiceProducts) && $roomTypeServiceProducts)} +
    {if isset($orderEdit) && $orderEdit}

    @@ -36,7 +37,7 @@

    {$service['name']|escape:'html':'UTF-8'}
    {if $service['allow_multiple_quantity']}
    - +
    {/if} @@ -76,7 +77,7 @@

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

    {if $product.allow_multiple_quantity}
    - +
    {/if}
    @@ -124,7 +125,6 @@
    {/foreach}
    - {else} - {l s='No services available!'} {/if}
    +{/if} 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 5dd42117e..8a2b5b313 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -1717,21 +1717,14 @@ $('#room_extra_demand_content #back_to_service_btn').hide(); }); - $(document).on('focusout', '#rooms_type_extra_demands .room_ordered_services .qty', function(e) { + $(document).on('focusout', '#rooms_type_extra_demands .qty', function(e) { var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { + if (qty_wntd == '' || !$.isNumeric(qty_wntd)) { $(this).val(1); } updateServiceProducts($(this)); }); - $(document).on('focusout', '#rooms_type_extra_demands #add_room_services_form .qty', function(e) { - var qty_wntd = $(this).val(); - if (qty_wntd == '' || !$.isNumeric(qty_wntd) || qty_wntd < 1) { - $(this).val(1); - } - }); - function updateServiceProducts(element) { var id_room_type_service_product_order_detail = $(element).data('id_room_type_service_product_order_detail'); diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index ca9b99ff1..df4af2e8d 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -4738,7 +4738,6 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } } - $smartyVars['show_active'] = true; $this->context->smarty->assign($smartyVars); $servicesTpl = $this->context->smarty->fetch( diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index 20ed72474..2a898f8b6 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -479,40 +479,40 @@ class OrderDetailControllerCore extends FrontController 1, 0 ); - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); } + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); // calculate averages now foreach ($cartHotelData[$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); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index cc11fa369..347e82f96 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -389,9 +389,6 @@ class OrderOpcControllerCore extends ParentOrderController */ public function initContent() { - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - parent::initContent(); // check ORDER RESTRICT condition before payment by the customer diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index 054555062..a97a90577 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -1318,13 +1318,12 @@ class ProductControllerCore extends FrontController public function displayAjaxCheckServiceProductWithRoomType() { $response = array( - 'success' => false + 'status' => false ); if ($this->isTokenValid()) { $idProduct = Tools::getValue('id_product'); $idServiceProduct = Tools::getValue('service_product'); - $addedServiceProduct = Tools::getValue('added_service_product'); if (Validate::isLoadedObject($objProduct = new Product($idProduct))) { if (!Product::isBookingProduct($idProduct)) { $response['error'] = Tools::displayError('Room Type info not Found'); @@ -1335,22 +1334,7 @@ class ProductControllerCore extends FrontController if (!$objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) { $response['error'] = Tools::displayError('Selected product is not available with current room type'); } else { - if (Validate::isLoadedObject($objServiceProduct = new Product($idServiceProduct))) { - $response['success'] = true; - if (!$objServiceProduct->allow_multiple_quantity && !empty($addedServiceProduct)) { - if (!in_array($idServiceProduct, array_column($addedServiceProduct, 'id_product'))) { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } else { - $response['msg'] = 'Service already added.'; - } - } else { - $response['add'] = true; - $response['msg'] = 'Service is added to cart.'; - } - } else { - $response['error'] = Tools::displayError('Service not Found'); - } + $response['status'] = true; } } else { $response['error'] = Tools::displayError('Room Type not Found'); diff --git a/install/data/xml/category_group.xml b/install/data/xml/category_group.xml index 902335903..a0187a2f0 100644 --- a/install/data/xml/category_group.xml +++ b/install/data/xml/category_group.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/modules/bankwire/controllers/front/payment.php b/modules/bankwire/controllers/front/payment.php index 59dc5ab17..cee1fe886 100644 --- a/modules/bankwire/controllers/front/payment.php +++ b/modules/bankwire/controllers/front/payment.php @@ -50,9 +50,6 @@ class BankwirePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/bankwire/controllers/front/validation.php b/modules/bankwire/controllers/front/validation.php index 5df9b7411..c96ff78ec 100644 --- a/modules/bankwire/controllers/front/validation.php +++ b/modules/bankwire/controllers/front/validation.php @@ -49,9 +49,6 @@ class BankwireValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - // Check Order restrict condition before Payment by the customer if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/cheque/controllers/front/payment.php b/modules/cheque/controllers/front/payment.php index 1d5e0f76b..e1415337d 100644 --- a/modules/cheque/controllers/front/payment.php +++ b/modules/cheque/controllers/front/payment.php @@ -50,9 +50,6 @@ class ChequePaymentModuleFrontController extends ModuleFrontController $total = $cart->getOrderTotal(true, Cart::BOTH); } - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - $restrict_order = false; /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { diff --git a/modules/cheque/controllers/front/validation.php b/modules/cheque/controllers/front/validation.php index f280abd3f..6f75120a9 100644 --- a/modules/cheque/controllers/front/validation.php +++ b/modules/cheque/controllers/front/validation.php @@ -48,9 +48,6 @@ class ChequeValidationModuleFrontController extends ModuleFrontController if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); - // check all service products are available - RoomTypeServiceProductCartDetail::validateServiceProductsInCart(); - /*Check Order restrict condition before Payment by the customer*/ if (Module::isInstalled('hotelreservationsystem') && Module::isEnabled('hotelreservationsystem')) { require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php index 6a16c420d..199d3a178 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProduct.php @@ -182,8 +182,6 @@ class RoomTypeServiceProduct extends ObjectModel 1, $useTax ); - - $serviceProduct['images'] = Image::getImages((int)Context::getContext()->language->id, $serviceProduct['id_product']); } } diff --git a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php index f9446f9f9..eafa043bb 100644 --- a/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php +++ b/modules/hotelreservationsystem/classes/RoomTypeServiceProductCartDetail.php @@ -341,20 +341,4 @@ class RoomTypeServiceProductCartDetail extends ObjectModel } return false; } - - public static function validateServiceProductsInCart() - { - $context = Context::getContext(); - if ($cartProducts = $context->cart->getProducts()) { - $objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail(); - foreach ($cartProducts as $product) { - if (!$product['active'] && !$product['booking_product']) { - $serviceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($context->cart->id, $product['id_product']); - foreach ($serviceProducts as $serviceProduct) { - $objRoomTypeServiceProductCartDetail->removeServiceProductByIdHtlCartBooking($serviceProduct['htl_cart_booking_id']); - } - } - } - } - } } \ No newline at end of file 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 08e3c1b8e..f700c7720 100644 --- a/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products-list-row.tpl @@ -20,15 +20,9 @@ {if isset($product) && $product}
  • - + {if !empty($product.legend)}{$product.legend|escape:'html':'UTF-8'}{else}{$product.name|escape:'html':'UTF-8'}{/if} - {foreach $product.images as $image} - {if $image['cover'] == 0} - - {/if} - {/foreach}
    @@ -42,7 +36,7 @@ {/if}
    - {if !$PS_CATALOG_MODE && !$order_date_restrict && ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} + {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} @@ -52,21 +46,20 @@ {if ($product.show_price && !isset($restricted_country_mode)) || isset($groups)} {if $product.available_for_order && !$PS_CATALOG_MODE && !$order_date_restrict && !((isset($restricted_country_mode) && $restricted_country_mode))} - {if $product.allow_multiple_quantity && $product.available_for_order} -
    - -
    - {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} -
    -
    - - -
    -
    - {/if} {/if} {/if} - + {if $product.allow_multiple_quantity && $product.available_for_order} +
    + +
    + {if isset($product.quantity_added) && $product.quantity_added}{$product.quantity_added|escape:'html':'UTF-8'}{else}1{/if} +
    +
    + + +
    +
    + {/if}
    diff --git a/themes/hotel-reservation-theme/_partials/service-products.tpl b/themes/hotel-reservation-theme/_partials/service-products.tpl index 370f10de9..2b3565520 100644 --- a/themes/hotel-reservation-theme/_partials/service-products.tpl +++ b/themes/hotel-reservation-theme/_partials/service-products.tpl @@ -45,7 +45,7 @@ {/foreach} {else}
      - {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products init=true} + {include file="{$tpl_dir}_partials/service-products-list.tpl" service_products=$service_products group='all' init=true}
    {if RoomTypeServiceProduct::WK_NUM_RESULTS < $num_total_service_products}
    diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 57a0add94..96ae9a806 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1201,15 +1201,6 @@ $(document).ready(function() { if (typeof(qty) == 'undefined') { qty = 1; } - var added_service_product = []; - - $('#additional_products input.service_product').each(function () { - added_service_product.push({ - 'id_product': $(this).data('id_product'), - 'quantity':$(this).val(), - }); - }); - $.ajax({ type: 'POST', headers: { @@ -1224,36 +1215,31 @@ $(document).ready(function() { qty: qty, id_product: $('#product_page_product_id').val(), service_product: id_product, - added_service_product: added_service_product, action: 'checkServiceProductWithRoomType', ajax: true, token: static_token }, success: function(result) { - if (result.success) { - if (result.add) { - if ($('input#service_product_'+ id_product).length) { - var prevQty = $('input#service_product_'+ id_product).val(); - if (parseInt(prevQty) > 0) { - qty = parseInt(qty) + parseInt(prevQty); - } - $('input#service_product_'+ id_product).val(qty); - } else { - $('').attr({ - id: 'service_product_'+ id_product, - name: 'service_product['+ id_product +'][]', - class: 'service_product', - 'data-id_product': id_product, - value: qty - }).appendTo('#additional_products'); + if (result.status) { + if ($('input#service_product_'+ id_product).length) { + var prevQty = $('input#service_product_'+ id_product).val(); + if (parseInt(prevQty) > 0) { + qty = parseInt(qty) + parseInt(prevQty); } + $('input#service_product_'+ id_product).val(qty); + } else { + $('').attr({ + id: 'service_product_'+ id_product, + name: 'service_product['+ id_product +'][]', + class: 'service_product', + 'data-id_product': id_product, + value: qty + }).appendTo('#additional_products'); } // reset input $(that).closest('.service_product_action_block').find('input.service_product_qty').val(1); $(that).closest('.service_product_action_block').find('.qty_count span').text(1); - if (result.msg) { - showSuccessMessage(result.msg); - } + showSuccessMessage(cart_extra_service_add); BookingForm.refresh(); } else { if (result.error) { From 0e1beed76e109d14365dc118db3e0af4eafd5c46 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 14 Mar 2023 13:14:24 +0530 Subject: [PATCH 6/7] fix inconsistent price in list and view admin order --- .../template/controllers/orders/_room_facilities_block.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl index abc426f8d..fbe41ba0a 100644 --- a/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl +++ b/admin/themes/default/template/controllers/orders/_room_facilities_block.tpl @@ -35,7 +35,7 @@ {foreach $roomDemand['extra_demands'] as $demand} {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} + {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency} {/foreach} @@ -96,7 +96,7 @@

    {$demand['name']} - {displayPrice price=$demand['total_price_tax_incl'] currency=$orderCurrency} + {displayPrice price=$demand['total_price_tax_excl'] currency=$orderCurrency}

    {/foreach} From 98e6bcf54af13f77c1d35ddd7fd0149679fc4c7f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 14 Mar 2023 18:44:03 +0530 Subject: [PATCH 7/7] enable custom handler in admin controller --- classes/controller/Controller.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 0484f6544..a21ca409c 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -93,9 +93,9 @@ abstract class ControllerCore */ public function init() { - // if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { - // set_error_handler(array(__CLASS__, 'myErrorHandler')); - // } + if (_PS_MODE_DEV_ && $this->controller_type == 'admin') { + set_error_handler(array(__CLASS__, 'myErrorHandler')); + } if (!defined('_PS_BASE_URL_')) { define('_PS_BASE_URL_', Tools::getShopDomain(true));