diff --git a/controllers/admin/AdminTaxesController.php b/controllers/admin/AdminTaxesController.php index a087c0252..1c42235f8 100644 --- a/controllers/admin/AdminTaxesController.php +++ b/controllers/admin/AdminTaxesController.php @@ -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'); } /** diff --git a/js/admin/tourism_tax_form.js b/js/admin/tourism_tax_form.js index 7a89f73f4..0fa04c2de 100644 --- a/js/admin/tourism_tax_form.js +++ b/js/admin/tourism_tax_form.js @@ -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); + }); +});