From 4c4725795cdcabc83105c0abf3b270fc00bd3b55 Mon Sep 17 00:00:00 2001 From: SteveIreland Date: Sat, 19 Oct 2019 13:49:19 -0400 Subject: [PATCH] Fix numeric locale configuration. --- application/controllers/Config.php | 17 +++++++++++++++-- application/views/configs/locale_config.php | 16 ++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 976de8607..0ff258699 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -209,6 +209,7 @@ class Config extends Secure_Controller $data['tax_category_options'] = $this->tax_lib->get_tax_category_options(); $data['tax_jurisdiction_options'] = $this->tax_lib->get_tax_jurisdiction_options(); $data['show_office_group'] = $this->Module->get_show_office_group(); + $data['currency_code'] = $this->config->item('currency_code'); $data = $this->xss_clean($data); @@ -309,9 +310,20 @@ class Config extends Secure_Controller public function ajax_check_number_locale() { $number_locale = $this->input->post('number_locale'); + $save_number_locale = $this->input->post('save_number_locale'); + $fmt = new \NumberFormatter($number_locale, \NumberFormatter::CURRENCY); - $currency_symbol = empty($this->input->post('currency_symbol')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL) : $this->input->post('currency_symbol'); - $currency_code = empty($this->input->post('currency_code')) ? $fmt->getTextAttribute(\NumberFormatter::CURRENCY_CODE) : $this->input->post('currency_code'); + if($number_locale != $save_number_locale) + { + $currency_symbol = $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL); + $currency_code = $fmt->getTextAttribute(\NumberFormatter::CURRENCY_CODE); + $save_number_locale = $number_locale; + } + else + { + $currency_symbol = empty($this->input->post('currency_symbol')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL) : $this->input->post('currency_symbol'); + $currency_code = empty($this->input->post('currency_code')) ? $fmt->getTextAttribute(\NumberFormatter::CURRENCY_CODE) : $this->input->post('currency_code'); + } if($this->input->post('thousands_separator') == 'false') { @@ -323,6 +335,7 @@ class Config extends Secure_Controller echo json_encode(array( 'success' => $number_local_example != FALSE, + 'save_number_locale' => $save_number_locale, 'number_locale_example' => $number_local_example, 'currency_symbol' => $currency_symbol, 'currency_code' => $currency_code, diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index cc9e2f729..b076a8191 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -9,6 +9,7 @@
config->item('number_locale'), array('class' => 'form-control input-sm', 'id' => 'number_locale')); ?> + config->item('number_locale')); ?>
@@ -242,12 +243,14 @@ $(document).ready(function() $('#currency_symbol, #thousands_separator, #currency_code').change(function() { var data = { number_locale: $('#number_locale').val() }; + data['save_number_locale'] = $("input[name='save_number_locale']").val(); data['currency_symbol'] = $('#currency_symbol').val(); data['currency_code'] = $('#currency_code').val(); data['thousands_separator'] = $('#thousands_separator').is(":checked") $.post("", data, function(response) { + $("input[name='save_number_locale']").val(response.save_number_locale); $('#number_locale_example').text(response.number_locale_example); $('#currency_symbol').val(response.currency_symbol); $('#currency_code').val(response.currency_code); @@ -267,17 +270,18 @@ $(document).ready(function() url: "", type: 'POST', data: { - 'number_locale': $('#number_locale').val(), - 'currency_symbol': $('#currency_symbol').val(), - 'thousands_separator': $('#thousands_separator').is(':checked'), - 'currency_code': $('#currency_code').val() + 'number_locale': function() { return $('#number_locale').val(); }, + 'save_number_locale': function() { return $("input[name='save_number_locale']").val(); }, + 'currency_symbol': function() { return $('#currency_symbol').val(); }, + 'thousands_separator': function() { return $('#thousands_separator').is(':checked'); }, + 'currency_code': function() { return $('#currency_code').val(); } }, dataFilter: function(data) { var response = JSON.parse(data); + $("input[name='save_number_locale']").val(response.save_number_locale); $('#number_locale_example').text(response.number_locale_example); $('#currency_symbol').val(response.currency_symbol); $('#currency_code').val(response.currency_code); - $('#thousands_separator').prop('checked', response.thousands_separator); return response.success; } }