Updated: Taxes global configuration fields now handled through JS

Co-authored-by: Name <sumit201@webkul.in>
This commit is contained in:
shazar rahman
2026-09-18 15:30:49 +05:30
parent 37ff17ec56
commit eb17526f7b
2 changed files with 59 additions and 24 deletions

View File

@@ -140,31 +140,29 @@ class AdminTaxesControllerCore extends AdminController
'type' => 'bool',
);
if (Configuration::get('QLO_USE_TOURISM_TAX') || Tools::getValue('QLO_USE_TOURISM_TAX')) {
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_GROSSED_UP'] = array(
'title' => $this->l('Include tourism tax in displayed prices'),
'desc' => $this->l('When enabled, tourism tax is included in displayed prices. Whether the applicable tourism tax is also shown as a separate line depends on the settings below.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_GROSSED_UP'] = array(
'title' => $this->l('Include tourism tax in displayed prices'),
'desc' => $this->l('When enabled, tourism tax is included in displayed prices. Whether the applicable tourism tax is also shown as a separate line depends on the settings below.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_SHOW_SEPARATE'] = array(
'title' => $this->l('Show tourism tax separately in price summary'),
'desc' => $this->l('When enabled, tourism tax is shown as its own line, separate from the room/service tax, on the cart summary, order confirmation, and order detail pages.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_SHOW_SEPARATE'] = array(
'title' => $this->l('Show tourism tax separately in price summary'),
'desc' => $this->l('When enabled, tourism tax is shown as its own line, separate from the room/service tax, on the cart summary, order confirmation, and order detail pages.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_SHOW_SEPARATE_DOCS'] = array(
'title' => $this->l('Show tourism tax separately on invoices / booking vouchers'),
'desc' => $this->l('When enabled, tourism tax is shown as its own line, separate from the room/service tax, on the invoice and booking voucher totals.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
}
$this->fields_options['general']['fields']['QLO_TOURISM_TAX_SHOW_SEPARATE_DOCS'] = array(
'title' => $this->l('Show tourism tax separately on invoices / booking vouchers'),
'desc' => $this->l('When enabled, tourism tax is shown as its own line, separate from the room/service tax, on the invoice and booking voucher totals.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
);
parent::__construct();
@@ -1150,8 +1148,8 @@ class AdminTaxesControllerCore extends AdminController
parent::setMedia();
if ($this->display == 'edit' || $this->display == 'add') {
$this->addCSS(_MODULE_DIR_ . 'hotelreservationsystem/views/css/HotelReservationAdmin.css');
$this->addJs(_PS_JS_DIR_ . 'admin/tourism_tax_form.js');
}
$this->addJs(_PS_JS_DIR_ . 'admin/tourism_tax_form.js');
}
/**

View File

@@ -153,3 +153,40 @@ $(document).ready(function () {
$(this).closest('tr').remove();
});
});
function toggleTourismTaxOptionFields(animate)
{
var $fields = $('#conf_id_QLO_TOURISM_TAX_GROSSED_UP, #conf_id_QLO_TOURISM_TAX_SHOW_SEPARATE, #conf_id_QLO_TOURISM_TAX_SHOW_SEPARATE_DOCS').closest('.form-group');
var taxEnabled = $('#PS_TAX_on').prop('checked') === true;
var tourismTaxEnabled = $('#QLO_USE_TOURISM_TAX_on').prop('checked') === true;
var show = taxEnabled && tourismTaxEnabled;
if (animate) {
show ? $fields.fadeIn() : $fields.fadeOut();
} else {
show ? $fields.show() : $fields.hide();
}
}
function toggleMainTaxOptionFields(animate)
{
var $fields = $('#conf_id_PS_TAX_DISPLAY, #conf_id_QLO_USE_TOURISM_TAX').closest('.form-group');
var show = $('#PS_TAX_on').prop('checked') === true;
if (animate) {
show ? $fields.fadeIn() : $fields.fadeOut();
} else {
show ? $fields.show() : $fields.hide();
}
toggleTourismTaxOptionFields(animate);
}
$(document).ready(function () {
toggleMainTaxOptionFields(false);
$('#PS_TAX_on, #PS_TAX_off').click(function (e) {
toggleMainTaxOptionFields(true);
});
$('#QLO_USE_TOURISM_TAX_on, #QLO_USE_TOURISM_TAX_off').click(function (e) {
toggleTourismTaxOptionFields(true);
});
});