From a353068ca527e2436866e210c8db08d57c9be955 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Mon, 12 Mar 2018 21:36:42 +0000 Subject: [PATCH] Fix locale support to Giftcard with decimals (#1694) --- application/controllers/Giftcards.php | 13 +++++++++---- application/views/configs/locale_config.php | 1 + application/views/giftcards/form.php | 9 ++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/application/controllers/Giftcards.php b/application/controllers/Giftcards.php index 5a8fae760..9663d279d 100644 --- a/application/controllers/Giftcards.php +++ b/application/controllers/Giftcards.php @@ -49,7 +49,7 @@ class Giftcards extends Secure_Controller echo json_encode($suggestions); } - + public function suggest_search() { $suggestions = $this->xss_clean($this->Giftcard->get_search_suggestions($this->input->post('term'))); @@ -86,7 +86,7 @@ class Giftcards extends Secure_Controller $this->load->view("giftcards/form", $data); } - + public function save($giftcard_id = -1) { $giftcard_number = $this->input->post('giftcard_number'); @@ -106,7 +106,7 @@ class Giftcards extends Secure_Controller if($this->Giftcard->save($giftcard_data, $giftcard_id)) { $giftcard_data = $this->xss_clean($giftcard_data); - + //New giftcard if($giftcard_id == -1) { @@ -130,7 +130,12 @@ class Giftcards extends Secure_Controller public function ajax_check_number_giftcard() { - $parsed_value = parse_decimals($this->input->post('giftcard_amount')); + $value = $this->input->post('giftcard_amount'); + $parsed_value = parse_decimals($value); + if(strcmp(strval($parsed_value), strval($value)) != 0) + { + $parsed_value = FALSE; + } echo json_encode(array('success' => !empty($parsed_value), 'giftcard_amount' => $parsed_value)); } diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 35b775da9..eae39c363 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -256,6 +256,7 @@ $(document).ready(function() 'thousands_separator': $("#thousands_separator").is(":checked") }), dataFilter: function(data) { + setup_csrf_token(); var response = JSON.parse(data); $("#number_locale_example").text(response.number_locale_example); $("#currency_symbol").val(response.currency_symbol); diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index efe6225d7..5184be405 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -106,7 +106,7 @@ $(document).ready(function() }, rules: { - config->item('giftcard_number') == "series") { ?> + config->item('giftcard_number') == "series") { ?> giftcard_number: { required: true, @@ -120,12 +120,11 @@ $(document).ready(function() { url: "", type: 'post', - data: $.extend(csrf_form_base(), - { + data: $.extend(csrf_form_base(), { 'amount': $("#giftcard_amount").val() }), - dataFilter: function(data) - { + dataFilter: function(data) { + setup_csrf_token(); var response = JSON.parse(data); $("#giftcard_amount").text(response.value); return response.success;