Fix numeric locale configuration.

This commit is contained in:
SteveIreland
2019-10-16 21:37:46 -04:00
parent 61e28302ce
commit d4c2693511
2 changed files with 35 additions and 37 deletions

View File

@@ -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,

View File

@@ -98,9 +98,9 @@
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_cash_decimals'), 'cash_decimals', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_dropdown('cash_decimals', array(
'-1' => '-1',
'0' => '0',
@@ -109,23 +109,23 @@
),
$this->config->item('cash_decimals'), array('class' => 'form-control input-sm'));
?>
</div>
<div class='col-xs-1'>
<label class="control-label">
<span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="right" title="<?php echo $this->lang->line('config_cash_decimals_tooltip'); ?>"></span>
</label>
</div>
</div>
</div>
<div class='col-xs-1'>
<label class="control-label">
<span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="right" title="<?php echo $this->lang->line('config_cash_decimals_tooltip'); ?>"></span>
</label>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_cash_rounding'), 'cash_rounding_code', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_dropdown('cash_rounding_code', $rounding_options, $this->config->item('cash_rounding_code'), array('class' => 'form-control input-sm'));
?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_payment_options_order'), 'payment_options_order', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-4'>
<?php echo form_dropdown('payment_options_order', array(
@@ -193,15 +193,15 @@
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_date_or_time_format'), 'date_or_time_format', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<?php echo form_checkbox(array(
'name' => 'date_or_time_format',
'id' => 'date_or_time_format',
'value' => 'date_or_time_format',
'checked'=>$this->config->item('date_or_time_format'))); ?>
</div>
</div>
<?php echo form_label($this->lang->line('config_date_or_time_format'), 'date_or_time_format', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<?php echo form_checkbox(array(
'name' => 'date_or_time_format',
'id' => 'date_or_time_format',
'value' => 'date_or_time_format',
'checked'=>$this->config->item('date_or_time_format'))); ?>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->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("<?php echo site_url($controller_name . '/ajax_check_number_locale')?>",
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()
},