Fixed: added new changes

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
amit sharma
2026-09-16 15:26:19 +05:30
parent c9774aad95
commit 93c64493ea
4 changed files with 59 additions and 51 deletions

View File

@@ -1,30 +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
*}
{capture name='tooltip_list_content'}
<ul>
{foreach $tooltip_items as $tooltip_item}
<li>{$tooltip_item|escape:'html':'UTF-8'}</li>
{/foreach}
</ul>
{/capture}
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.tooltip_list_content allow_html=true}

View File

@@ -212,10 +212,23 @@ $(document).ready(function () {
</div> *}
<div class="form-group">
<label class="control-label required col-lg-3">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Select which booking days should be counted when calculating the service price.'}">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Choose whether this price is added once for the whole booking range, or added again for each day of the booking.'}">
{l s='Price calculation method'}
</span>
</label>
<div class="col-lg-3">
<select id="pcm_type" name="price_calculation_type">
<option value="{Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval}" {if !$product->price_calculation_method || $product->price_calculation_method == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING}selected="selected"{/if}>{l s='Once for the booking range'}</option>
<option value="0" {if $product->price_calculation_method && $product->price_calculation_method != Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING}selected="selected"{/if}>{l s='For each day of the booking'}</option>
</select>
</div>
</div>
<div class="form-group" id="pcm_days_container" style="margin-top: 10px;{if !$product->price_calculation_method || $product->price_calculation_method == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING} display:none;{/if}">
<label class="control-label required col-lg-3">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Select which booking days should be counted when calculating the service price.'}">
{l s='Applied on: '}
</span>
</label>
<div class="col-lg-9">
<div class="checkbox">
<label>
@@ -240,6 +253,19 @@ $(document).ready(function () {
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
var togglePcmDays = function() {
if ($('#pcm_type').val() == '{Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING|intval}') {
$('#pcm_days_container').hide();
} else {
$('#pcm_days_container').show();
}
};
togglePcmDays();
$('#pcm_type').on('change', togglePcmDays);
});
</script>
{* As no use in QloApps currently so commented *}
{* <div class="form-group">
<div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="unit_price" type="unit_price"}</span></div>

View File

@@ -567,11 +567,12 @@ class ProductCore extends ObjectModel
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_ON_DURING_STAY = 4;
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 PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING = 8;
const STANDARD_PRODUCT_ADDRESS_PREFERENCE_CUSTOMER = 1;
const STANDARD_PRODUCT_ADDRESS_PREFERENCE_HOTEL = 2;
@@ -6913,6 +6914,9 @@ class ProductCore extends ObjectModel
$stayDay = $numNights - 1;
switch ((int) $priceCalculationMethod) {
case self::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING:
return 1;
case self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY:
return $checkinDay;
@@ -6947,6 +6951,12 @@ class ProductCore extends ObjectModel
if (is_null($module)) {
$module = Module::getInstanceByName('hotelreservationsystem');
}
if ($priceCalculationMethod == self::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) {
$labels[] = $module->l('Once per booking');
return $labels;
}
if ($priceCalculationMethod & self::PRICE_CALCULATION_METHOD_ON_CHECKIN_DAY) {
$labels[] = $module->l('Check-in day');
}

View File

@@ -207,6 +207,7 @@ class AdminNormalProductsControllerCore extends AdminController
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'),
Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING => $this->l('Once per booking'),
);
$this->_join .= '
@@ -433,31 +434,28 @@ class AdminNormalProductsControllerCore extends AdminController
public function getBuyingOption($selling_preference_type, $row)
{
return $this->renderMultiSelectTooltip('selling_preference_type', $selling_preference_type);
$list = $this->fields_list['selling_preference_type']['list'];
if (empty($list[$selling_preference_type])) {
return '--';
}
$options = array_map('trim', explode('|', $list[$selling_preference_type]));
return implode(', ', $options);
}
public function getPriceCalculationMethod($price_calculation_method, $row)
{
return $this->renderMultiSelectTooltip('price_calculation_method', $price_calculation_method);
}
$list = $this->fields_list['price_calculation_method']['list'];
private function renderMultiSelectTooltip($fieldKey, $value)
{
$list = $this->fields_list[$fieldKey]['list'];
if (empty($list[$value])) {
if (empty($list[$price_calculation_method])) {
return '--';
}
$options = array_map('trim', explode('|', $list[$value]));
$options = array_map('trim', explode('|', $list[$price_calculation_method]));
$this->context->smarty->assign(array(
'tooltip_items' => $options,
));
$tooltip = $this->context->smarty->fetch('controllers/normal_products/_price_calculation_method_options.tpl');
return count($options) . ' ' . $this->l('Selected') . ' ' . $tooltip;
return implode(', ', $options);
}
public function getHotelName($hotelName, $row)
@@ -522,7 +520,9 @@ class AdminNormalProductsControllerCore extends AdminController
*/
protected function copyFromPost(&$object, $table)
{
if (is_array(Tools::getValue('price_calculation_method'))) {
if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) {
$_POST['price_calculation_method'] = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING;
} elseif (is_array(Tools::getValue('price_calculation_method'))) {
$_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method')));
}
parent::copyFromPost($object, $table);
@@ -2254,7 +2254,9 @@ class AdminNormalProductsControllerCore extends AdminController
*/
public function checkProduct()
{
if (is_array(Tools::getValue('price_calculation_method'))) {
if (Tools::getValue('price_calculation_type') == Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING) {
$_POST['price_calculation_method'] = Product::PRICE_CALCULATION_METHOD_ONCE_FOR_BOOKING;
} elseif (is_array(Tools::getValue('price_calculation_method'))) {
$_POST['price_calculation_method'] = array_sum(array_map('intval', Tools::getValue('price_calculation_method')));
}
@@ -2420,7 +2422,7 @@ class AdminNormalProductsControllerCore extends AdminController
// }
if (Tools::getValue('id_product') && !Tools::getValue('price_calculation_method')) {
$this->errors[] = $this->l('Please select at least one price calculation method.');
$this->errors[] = $this->l('Please select at least one day to apply the price calculation method on.');
}
// Tags