From d4c2693511adee5dbf65a16101cc192fc23c052c Mon Sep 17 00:00:00 2001 From: SteveIreland Date: Wed, 16 Oct 2019 21:37:46 -0400 Subject: [PATCH] Fix numeric locale configuration. --- application/controllers/Config.php | 17 +++---- application/views/configs/locale_config.php | 55 +++++++++++---------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index c1fce53b5..976de8607 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -305,33 +305,30 @@ class Config extends Secure_Controller 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function ajax_check_number_locale() { $number_locale = $this->input->post('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($this->input->post('thousands_separator') == 'false') { $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); } - + $fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $currency_symbol); - $fmt->setTextAttribute(\NumberFormatter::CURRENCY_CODE, $currency_code); - $number_local_example = $fmt->format(1234567890.12300); - + echo json_encode(array( 'success' => $number_local_example != FALSE, 'number_locale_example' => $number_local_example, 'currency_symbol' => $currency_symbol, 'currency_code' => $currency_code, - 'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != '' )); } - + public function save_locale() { $exploded = explode(":", $this->input->post('language')); @@ -343,7 +340,7 @@ class Config extends Secure_Controller 'timezone' => $this->input->post('timezone'), 'dateformat' => $this->input->post('dateformat'), 'timeformat' => $this->input->post('timeformat'), - 'thousands_separator' => $this->input->post('thousands_separator'), + 'thousands_separator' => !empty($this->input->post('thousands_separator')), 'number_locale' => $this->input->post('number_locale'), 'currency_decimals' => $this->input->post('currency_decimals'), 'tax_decimals' => $this->input->post('tax_decimals'), @@ -751,7 +748,7 @@ class Config extends Secure_Controller 'print_receipt_check_behaviour' => $this->input->post('print_receipt_check_behaviour'), 'receipt_show_company_name' => $this->input->post('receipt_show_company_name') != NULL, 'receipt_show_taxes' => ($this->input->post('receipt_show_taxes') != NULL), - 'receipt_show_tax_ind' => ($this->input->post('receipt_show_tax_ind') != NULL), + 'receipt_show_tax_ind' => ($this->input->post('receipt_show_tax_ind') != NULL), 'receipt_show_total_discount' => $this->input->post('receipt_show_total_discount') != NULL, 'receipt_show_description' => $this->input->post('receipt_show_description') != NULL, 'receipt_show_serialnumber' => $this->input->post('receipt_show_serialnumber') != NULL, diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 34a9ec31d..cc9e2f729 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -98,9 +98,9 @@ -
+
lang->line('config_cash_decimals'), 'cash_decimals', array('class' => 'control-label col-xs-2')); ?> -
+
'-1', '0' => '0', @@ -109,23 +109,23 @@ ), $this->config->item('cash_decimals'), array('class' => 'form-control input-sm')); ?> -
-
- -
-
+
+
+ +
+
-
+
lang->line('config_cash_rounding'), 'cash_rounding_code', array('class' => 'control-label col-xs-2')); ?> -
+
config->item('cash_rounding_code'), array('class' => 'form-control input-sm')); ?> -
-
+
+
-
+
lang->line('config_payment_options_order'), 'payment_options_order', array('class' => 'control-label col-xs-2')); ?>
- lang->line('config_date_or_time_format'), 'date_or_time_format', array('class' => 'control-label col-xs-2')); ?> -
- 'date_or_time_format', - 'id' => 'date_or_time_format', - 'value' => 'date_or_time_format', - 'checked'=>$this->config->item('date_or_time_format'))); ?> -
-
+ lang->line('config_date_or_time_format'), 'date_or_time_format', array('class' => 'control-label col-xs-2')); ?> +
+ 'date_or_time_format', + 'id' => 'date_or_time_format', + 'value' => 'date_or_time_format', + 'checked'=>$this->config->item('date_or_time_format'))); ?> +
+
lang->line('config_financial_year'), 'financial_year', array('class' => 'control-label col-xs-2')); ?> @@ -240,11 +240,11 @@ $(document).ready(function() { $('span').tooltip(); - $('#number_locale').change(function() { - var field = $(this).attr('id'); - var value = $(this).is(':checkbox') ? $(this).is(':checked') : $(this).val(); + $('#currency_symbol, #thousands_separator, #currency_code').change(function() { var data = { number_locale: $('#number_locale').val() }; - data[field] = value; + data['currency_symbol'] = $('#currency_symbol').val(); + data['currency_code'] = $('#currency_code').val(); + data['thousands_separator'] = $('#thousands_separator').is(":checked") $.post("", data, function(response) { @@ -268,6 +268,7 @@ $(document).ready(function() type: 'POST', data: { 'number_locale': $('#number_locale').val(), + 'currency_symbol': $('#currency_symbol').val(), 'thousands_separator': $('#thousands_separator').is(':checked'), 'currency_code': $('#currency_code').val() },