mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Fix numeric locale configuration.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<div class='row'>
|
||||
<div class='col-xs-1'>
|
||||
<?php echo form_input('number_locale', $this->config->item('number_locale'), array('class' => 'form-control input-sm', 'id' => 'number_locale')); ?>
|
||||
<?php echo form_hidden('save_number_locale', $this->config->item('number_locale')); ?>
|
||||
</div>
|
||||
<div class="col-xs-2">
|
||||
<label class="control-label">
|
||||
@@ -52,7 +53,7 @@
|
||||
'name' => 'currency_code',
|
||||
'id' => 'currency_code',
|
||||
'class' => 'form-control input-sm number_locale',
|
||||
'value'=>$this->config->item('currency_code'))); ?>
|
||||
'value'=>$currency_code)); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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("<?php echo site_url($controller_name . '/ajax_check_number_locale')?>",
|
||||
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: "<?php echo site_url($controller_name . '/ajax_check_number_locale')?>",
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user