From 13d11c7c6be58b67edd6bf1daa699607aa49c352 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Tue, 28 Mar 2023 17:32:27 +0530 Subject: [PATCH] update price input block --- .../products/additionalfacilities.tpl | 29 ++++++++++++------- controllers/admin/AdminProductsController.php | 4 +-- js/admin/products.js | 15 ++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/admin/themes/default/template/controllers/products/additionalfacilities.tpl b/admin/themes/default/template/controllers/products/additionalfacilities.tpl index 896c9f6bf..5939c795a 100644 --- a/admin/themes/default/template/controllers/products/additionalfacilities.tpl +++ b/admin/themes/default/template/controllers/products/additionalfacilities.tpl @@ -29,7 +29,7 @@ {if isset($allDemands) && $allDemands}
- +
@@ -39,7 +39,7 @@ - {if $rowcount <= 1} - {if $rowcount == 1} -
{l s='Option'} + {l s='Price'} @@ -65,8 +65,8 @@
- - + + {$demand['name']|escape:'html':'UTF-8'} @@ -75,11 +75,15 @@ {$option['name']|escape:'html':'UTF-8'} -
+
+
{$defaultcurrencySign|escape:'html':'UTF-8'} - +
+
+ {displayPrice price={$option['price']|escape:'html':'UTF-8'} currency=$module->id_currency} +
+
@@ -97,18 +101,21 @@ {foreachelse}
- + {$demand['name']|escape:'html':'UTF-8'} -
+
+
{$defaultcurrencySign|escape:'html':'UTF-8'} + value="{if isset($selectedDemands[$demand['id_global_demand']]['price'])}{Tools::ps_round($selectedDemands[$demand['id_global_demand']]['price'], 2)|escape:'html':'UTF-8'}{elseif isset($demand['price'])}{Tools::ps_round($demand['price'], 2)|escape:'html':'UTF-8'}{/if}"/> +
+
+ {displayPrice price={$demand['price']|escape:'html':'UTF-8'} currency=$module->id_currency}
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index ccf12c8ec..88df3cd66 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -3291,11 +3291,11 @@ class AdminProductsControllerCore extends AdminController // get room type additional facilities $objRoomDemand = new HotelRoomTypeDemand(); - $roomDemandPrices = $objRoomDemand->getRoomTypeDemands($obj->id, 0, 0); + $selectedDemands = $objRoomDemand->getRoomTypeDemands($obj->id, 0, 0); $data->assign(array( 'product' => $obj, - 'roomDemandPrices' => $roomDemandPrices, + 'selectedDemands' => $selectedDemands, 'allDemands' => $allDemands, 'defaultcurrencySign' => $objCurrency->sign, )); diff --git a/js/admin/products.js b/js/admin/products.js index 5c9c7bd38..34863cfa9 100644 --- a/js/admin/products.js +++ b/js/admin/products.js @@ -654,6 +654,21 @@ product_tabs['Features'] = new function(){ displayFlags(languages, id_language, allowEmployeeFormLang); } } +product_tabs['AdditionalFacilities'] = new function(){ + this.onReady = function(){ + $('#demands_table .selected_demand').on('click', function() { + let input_block = $('#demands_table').find('.demand_price_'+$(this).val()); + if ($(this).is(':checked')) { + $(input_block).find('.price_input').show(); + $(input_block).find('.price_display').hide(); + } else { + $(input_block).find('.price_input'); + $(input_block).find('.price_input').hide(); + $(input_block).find('.price_display').show(); + } + }); + } +} /** * Update the product image list position buttons