diff --git a/.travis.yml b/.travis.yml index cc319fe1f..3deed8f97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,5 @@ script: - docker-compose up -d after_success: - - > - '[ -n ${DOCKER_USERNAME} ] && - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && - docker tag opensourcepos_php_1 jekkos/opensourcepos:$TRAVIS_BRANCH && - docker tag opensourcepos_sqlscript_1 jekkos/opensourcepos:sqlscript && - docker push jekkos/opensourcepos:master && docker push jekkos/opensourcepos:sqlscript' + - '[ -n ${DOCKER_USERNAME} ] && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && docker tag opensourcepos_php jekkos/opensourcepos:${TRAVIS_BRANCH} && docker tag opensourcepos_sqlscript jekkos/opensourcepos:sqlscript && docker push jekkos/opensourcepos:master && docker push jekkos/opensourcepos:sqlscript' diff --git a/README.md b/README.md index 432bae4e3..69b240cc1 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,6 @@ FAQ --- * If a blank page (HTTP status 500) shows after search completion or receipt generation, then double check php5-gd presence in your php installation. On windows check in php.ini whether the lib is installed. On Ubuntu issue `sudo apt-get install php5-gd`. Also have a look at the Dockerfile for a complete list of recommended packages. -* If following error is sene in sales module `Message: Class 'NumberFormatter' not found` then you don't have `php5-intl` extension installed. Please check the [wiki](https://github.com/jekkos/opensourcepos/wiki/Localisation-support#php5-intl-extension-installation) to resolve this issue on your platform. +* If the following error is seen in sales module `Message: Class 'NumberFormatter' not found` then you don't have `php5-intl` extension installed. Please check the [wiki](https://github.com/jekkos/opensourcepos/wiki/Localisation-support#php5-intl-extension-installation) to resolve this issue on your platform. ca diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 3a0c480bf..3049bea2f 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -142,9 +142,18 @@ class Config extends Secure_Controller $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'); + if ($this->input->post('thousands_separator') == "false") + { + $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); + } $fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $currency_symbol); $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)); + echo json_encode(array( + 'success' => $number_local_example != FALSE, + 'number_locale_example' => $number_local_example, + 'currency_symbol' => $currency_symbol, + 'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != '' + )); } public function save_locale() @@ -155,7 +164,8 @@ class Config extends Secure_Controller 'timezone' => $this->input->post('timezone'), 'dateformat' => $this->input->post('dateformat'), 'timeformat' => $this->input->post('timeformat'), - 'number_locale' => $this->input->post('number_locale'), + 'thousands_separator' => $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'), 'quantity_decimals' => $this->input->post('quantity_decimals'), diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php index c24935ab3..75b9c0cfe 100644 --- a/application/controllers/Receivings.php +++ b/application/controllers/Receivings.php @@ -101,7 +101,7 @@ class Receivings extends Secure_Controller function numeric($str) { - return parse_decimals($str, 2); + return parse_decimals($str, 3); } public function edit_item($item_id) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 355aed2d2..0046051b3 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -224,7 +224,7 @@ class Sales extends Secure_Controller } else { - $amount_tendered = parse_decimals($this->input->post('amount_tendered')); + $amount_tendered = $this->input->post('amount_tendered'); $this->sale_lib->add_payment($payment_type, $amount_tendered); } @@ -286,7 +286,7 @@ class Sales extends Secure_Controller function numeric($str) { - return parse_decimals($str, 2); + return parse_decimals($str, 3); } public function edit_item($item_id) diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index 06dadbd8d..d39a4fb0a 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -64,6 +64,10 @@ function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL) $fmt = new \NumberFormatter($config->item('number_locale'), $type); $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals)); $fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item($decimals)); + if (empty($config->item('thousands_separator'))) + { + $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); + } $fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol')); return $fmt->format($number); } diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 6fc5697ff..796c8077e 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -4,17 +4,6 @@
lang->line('common_fields_required_message'); ?>
-
- lang->line('config_currency_symbol'), 'currency_symbol', array('class' => 'control-label col-xs-2')); ?> -
- 'currency_symbol', - 'id' => 'currency_symbol', - 'class' => 'form-control input-sm number_locale', - 'value'=>$this->config->item('currency_symbol'))); ?> -
-
-
lang->line('config_number_locale'), 'number_locale', array('class' => 'control-label col-xs-2')); ?>
@@ -34,6 +23,28 @@
+
+ lang->line('config_thousands_separator'), 'thousands_separator', array('class' => 'control-label col-xs-2')); ?> +
+ 'thousands_separator', + 'id' => 'thousands_separator', + 'value' => 'thousands_separator', + 'checked'=>$this->config->item('thousands_separator'))); ?> +
+
+ +
+ lang->line('config_currency_symbol'), 'currency_symbol', array('class' => 'control-label col-xs-2')); ?> +
+ 'currency_symbol', + 'id' => 'currency_symbol', + 'class' => 'form-control input-sm number_locale', + 'value'=>$this->config->item('currency_symbol'))); ?> +
+
+
lang->line('config_currency_decimals'), 'currency_decimals', array('class' => 'control-label col-xs-2')); ?>
@@ -269,11 +280,16 @@ $(document).ready(function() type: "POST" }; - $("#currency_symbol").change(function() { + $("#currency_symbol, #thousands_separator").change(function() { + var field = $(this).attr('id'); + var value = $(this).is(":checkbox") ? $(this).is(":checked") : $(this).val(); + var data = + { + number_locale: $("#number_locale").val() + }; + data[field] = value; $.post($.extend(number_locale_params, { - data: $.extend(csrf_form_base(), { - "currency_symbol": $("#currency_symbol").val() - }), + data: $.extend(csrf_form_base(), data), success: function(response) { $("#number_locale_example").text(response.number_locale_example); } @@ -292,12 +308,16 @@ $(document).ready(function() "number_locale" : function() { return $("#number_locale").val(); }, + "thousands_separator": function() { + return $("#thousands_separator").is(":checked"); + } }), dataFilter: function(data, dataType) { setup_csrf_token(); var response = JSON.parse(data); $("#number_locale_example").text(response.number_locale_example); $("#currency_symbol").val(response.currency_symbol); + $("#thousands_separator").prop('checked', response.thousands_separator); return response.success; } }) diff --git a/database/tables.sql b/database/tables.sql index 76d2158f0..a7bf31066 100644 --- a/database/tables.sql +++ b/database/tables.sql @@ -61,6 +61,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('timeformat', 'H:i:s'), ('currency_symbol', '$'), ('number_locale', 'en_US'), +('thousands_separator', '1'), ('currency_decimals', '2'), ('tax_decimals', '2'), ('quantity_decimals', '0'),