From a55893930a290c8123521f456ec0e75b117d4e15 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Thu, 7 Mar 2019 16:01:03 +0400 Subject: [PATCH 01/10] Create 3.4.0_add_iso_4217.sql --- application/migrations/sqlscripts/3.4.0_add_iso_4217.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 application/migrations/sqlscripts/3.4.0_add_iso_4217.sql diff --git a/application/migrations/sqlscripts/3.4.0_add_iso_4217.sql b/application/migrations/sqlscripts/3.4.0_add_iso_4217.sql new file mode 100644 index 000000000..c9a7d714c --- /dev/null +++ b/application/migrations/sqlscripts/3.4.0_add_iso_4217.sql @@ -0,0 +1,4 @@ +INSERT INTO +`ospos_app_config` (`key`,`value`) +VALUES +('currency_code',''); From 34d3352d73b3ddd4af7ff9f8d16533e27487a128 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Fri, 8 Mar 2019 11:09:21 +0400 Subject: [PATCH 02/10] Create 20190317102600_add_iso_4217.php --- .../20190317102600_add_iso_4217.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 application/migrations/20190317102600_add_iso_4217.php diff --git a/application/migrations/20190317102600_add_iso_4217.php b/application/migrations/20190317102600_add_iso_4217.php new file mode 100644 index 000000000..eb1ddbfcb --- /dev/null +++ b/application/migrations/20190317102600_add_iso_4217.php @@ -0,0 +1,20 @@ + From f284823707907445c1ae110734123f5cc704d601 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Fri, 8 Mar 2019 11:48:38 +0400 Subject: [PATCH 03/10] Add ISO currency code --- application/controllers/Config.php | 10 +++++++++- application/language/en-US/config_lang.php | 1 + .../migrations/20190317102600_add_iso_4217.php | 2 +- application/views/configs/locale_config.php | 13 ++++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 4dd1f8cae..f78976adb 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -311,25 +311,33 @@ 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'); + $currency_code = empty($this->input->post('currency_code')) ? $fmt->getSymbol(\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_CODE, $currency_code); $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_code' => $currency_code, 'currency_symbol' => $currency_symbol, 'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != '' )); } - + public function save_locale() { $exploded = explode(":", $this->input->post('language')); $batch_save_data = array( 'currency_symbol' => $this->input->post('currency_symbol'), + 'currency_code' => $this->input->post('currency_code'), 'language_code' => $exploded[0], 'language' => $exploded[1], 'timezone' => $this->input->post('timezone'), diff --git a/application/language/en-US/config_lang.php b/application/language/en-US/config_lang.php index 6b69d3700..59628faf5 100644 --- a/application/language/en-US/config_lang.php +++ b/application/language/en-US/config_lang.php @@ -44,6 +44,7 @@ $lang["config_company_select_image"] = "Select Image"; $lang["config_company_website_url"] = "Company website is not a valid URL (http://...)."; $lang["config_country_codes"] = "Country Codes"; $lang["config_country_codes_tooltip"] = "Comma separated list of country codes for nominatim address lookup."; +$lang["config_currency_code"] = "Currency Code"; $lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_currency_symbol"] = "Currency Symbol"; $lang["config_customer_reward"] = "Reward"; diff --git a/application/migrations/20190317102600_add_iso_4217.php b/application/migrations/20190317102600_add_iso_4217.php index eb1ddbfcb..eaea60c86 100644 --- a/application/migrations/20190317102600_add_iso_4217.php +++ b/application/migrations/20190317102600_add_iso_4217.php @@ -17,4 +17,4 @@ class Migration_add_iso_4217 extends CI_Migration } } -?> +?> \ No newline at end of file diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 3e872c19b..6b4a7f517 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -45,6 +45,17 @@ +
+ lang->line('config_currency_code'), 'currency_code', array('class' => 'control-label col-xs-2')); ?> +
+ 'currency_code', + 'id' => 'currency_code', + 'class' => 'form-control input-sm number_locale', + 'value'=>$this->config->item('currency_code'))); ?> +
+
+
lang->line('config_currency_decimals'), 'currency_decimals', array('class' => 'control-label col-xs-2')); ?>
@@ -229,7 +240,7 @@ $(document).ready(function() { $('span').tooltip(); - $('#currency_symbol, #thousands_separator').change(function() { + $('#currency_symbol, #thousands_separator, #currency_code').change(function() { var field = $(this).attr('id'); var value = $(this).is(':checkbox') ? $(this).is(':checked') : $(this).val(); var data = { number_locale: $('#number_locale').val() }; From 12104c21c62cc6fe03bfd10582b221bd93f802a1 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Fri, 8 Mar 2019 11:59:02 +0400 Subject: [PATCH 04/10] Correct error in the code --- application/controllers/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index f78976adb..a3edc0603 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -318,7 +318,7 @@ class Config extends Secure_Controller $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); } - $fmt->setSymbol(\NumberFormatter::CURRENCY_CODE, $currency_code); + $fmt->setTextAttribute(\NumberFormatter::CURRENCY_CODE, $currency_code); $fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $currency_symbol); $number_local_example = $fmt->format(1234567890.12300); From dd77bb563203e5800fc5e53c501126aff20bf1f1 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Fri, 8 Mar 2019 12:15:16 +0400 Subject: [PATCH 05/10] Language additions and code corrections --- application/controllers/Config.php | 2 +- application/language/en-GB/config_lang.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index a3edc0603..127f8134d 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -311,7 +311,7 @@ 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'); - $currency_code = empty($this->input->post('currency_code')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_CODE) : $this->input->post('currency_code'); + $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') { diff --git a/application/language/en-GB/config_lang.php b/application/language/en-GB/config_lang.php index 8c710893f..05e935de6 100644 --- a/application/language/en-GB/config_lang.php +++ b/application/language/en-GB/config_lang.php @@ -44,6 +44,7 @@ $lang["config_company_select_image"] = "Select Image"; $lang["config_company_website_url"] = "Company website is not a valid URL (http://...)"; $lang["config_country_codes"] = "Country Codes"; $lang["config_country_codes_tooltip"] = "Comma separated list of country codes for nominatim address lookup"; +$lang["config_currency_code"] = "Currency Code"; $lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_currency_symbol"] = "Currency Symbol"; $lang["config_customer_reward"] = "Reward"; From 8d8ab9add611e6433f950844f6fa2f7a079ff8b5 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Tue, 12 Mar 2019 13:23:40 +0400 Subject: [PATCH 06/10] Currency code auto update --- application/controllers/Config.php | 334 ++++++++++---------- application/views/configs/locale_config.php | 5 +- 2 files changed, 171 insertions(+), 168 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 127f8134d..1132947d3 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -7,23 +7,23 @@ class Config extends Secure_Controller public function __construct() { parent::__construct('config'); - + $this->load->library('barcode_lib'); $this->load->library('sale_lib'); } - + /* - * This function loads all the licenses starting with the first one being OSPOS one - */ + * This function loads all the licenses starting with the first one being OSPOS one + */ private function _licenses() { $i = 0; $bower = FALSE; $composer = FALSE; $license = array(); - + $license[$i]['title'] = 'Open Source Point Of Sale ' . $this->config->item('application_version'); - + if(file_exists('license/LICENSE')) { $license[$i]['text'] = $this->xss_clean(file_get_contents('license/LICENSE', NULL, NULL, 0, 2000)); @@ -32,10 +32,10 @@ class Config extends Secure_Controller { $license[$i]['text'] = 'LICENSE file must be in OSPOS license directory. You are not allowed to use OSPOS application until the distribution copy of LICENSE file is present.'; } - + // read all the files in the dir license $dir = new DirectoryIterator('license'); - + foreach($dir as $fileinfo) { // license files must be in couples: .version (name & version) & .license (license text) @@ -44,13 +44,13 @@ class Config extends Secure_Controller if($fileinfo->getExtension() == 'version') { ++$i; - + $basename = 'license/' . $fileinfo->getBasename('.version'); - + $license[$i]['title'] = $this->xss_clean(file_get_contents($basename . '.version', NULL, NULL, 0, 100)); - + $license_text_file = $basename . '.license'; - + if(file_exists($license_text_file)) { $license[$i]['text'] = $this->xss_clean(file_get_contents($license_text_file , NULL, NULL, 0, 2000)); @@ -72,17 +72,17 @@ class Config extends Secure_Controller } } } - + // attach the licenses from the LICENSES file generated by bower if($composer) { ++$i; $license[$i]['title'] = 'Composer Libraries'; $license[$i]['text'] = ''; - + $file = file_get_contents('license/composer.LICENSES'); $array = json_decode($file, TRUE); - + foreach($array as $key => $val) { if(is_array($val) && $key == 'dependencies') @@ -92,18 +92,18 @@ class Config extends Secure_Controller if(is_array($val1)) { $license[$i]['text'] .= 'component: ' . $key1 . "\n"; - + foreach($val1 as $key2 => $val2) { if(is_array($val2)) { $license[$i]['text'] .= $key2 . ': '; - + foreach($val2 as $key3 => $val3) { $license[$i]['text'] .= $val3 . ' '; } - + $license[$i]['text'] .= "\n"; } else @@ -111,7 +111,7 @@ class Config extends Secure_Controller $license[$i]['text'] .= $key2 . ': ' . $val2 . "\n"; } } - + $license[$i]['text'] .= "\n"; } else @@ -121,37 +121,37 @@ class Config extends Secure_Controller } } } - + $license[$i]['text'] = $this->xss_clean($license[$i]['text']); } - + // attach the licenses from the LICENSES file generated by bower if($bower) { ++$i; $license[$i]['title'] = 'JS Plugins'; $license[$i]['text'] = ''; - + $file = file_get_contents('license/bower.LICENSES'); $array = json_decode($file, TRUE); - + foreach($array as $key => $val) { if(is_array($val)) { $license[$i]['text'] .= 'component: ' . $key . "\n"; - + foreach($val as $key1 => $val1) { if(is_array($val1)) { $license[$i]['text'] .= $key1 . ': '; - + foreach($val1 as $key2 => $val2) { $license[$i]['text'] .= $val2 . ' '; } - + $license[$i]['text'] .= "\n"; } else @@ -159,27 +159,27 @@ class Config extends Secure_Controller $license[$i]['text'] .= $key1 . ': ' . $val1 . "\n"; } } - + $license[$i]['text'] .= "\n"; } } - + $license[$i]['text'] = $this->xss_clean($license[$i]['text']); } - + return $license; } - + /* - * This function loads all the available themes in the dist/bootswatch directory - */ + * This function loads all the available themes in the dist/bootswatch directory + */ private function _themes() { $themes = array(); - + // read all themes in the dist folder $dir = new DirectoryIterator('dist/bootswatch'); - + foreach($dir as $dirinfo) { if($dirinfo->isDir() && !$dirinfo->isDot() && $dirinfo->getFileName() != 'fonts') @@ -188,12 +188,12 @@ class Config extends Secure_Controller $themes[$file] = $file; } } - + asort($themes); - + return $themes; } - + public function index() { $data['stock_locations'] = $this->Stock_location->get_all()->result_array(); @@ -209,14 +209,14 @@ 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 = $this->xss_clean($data); - + // load all the license statements, they are already XSS cleaned in the private function $data['licenses'] = $this->_licenses(); // load all the themes, already XSS cleaned in the private function $data['themes'] = $this->_themes(); - + $data['mailchimp'] = array(); if($this->_check_encryption()) { @@ -228,18 +228,18 @@ class Config extends Secure_Controller $data['mailchimp']['api_key'] = ''; $data['mailchimp']['list_id'] = ''; } - + // load mailchimp lists associated to the given api key, already XSS cleaned in the private function $data['mailchimp']['lists'] = $this->_mailchimp(); - + $this->load->view("configs/manage", $data); } - + public function save_info() { $upload_success = $this->_handle_logo_upload(); $upload_data = $this->upload->data(); - + $batch_save_data = array( 'company' => $this->input->post('company'), 'address' => $this->input->post('address'), @@ -249,7 +249,7 @@ class Config extends Secure_Controller 'website' => $this->input->post('website'), 'return_policy' => $this->input->post('return_policy') ); - + if(!empty($upload_data['orig_name'])) { // XSS file image sanity check @@ -258,18 +258,18 @@ class Config extends Secure_Controller $batch_save_data['company_logo'] = $upload_data['raw_name'] . $upload_data['file_ext']; } } - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $upload_success && $result ? TRUE : FALSE; $message = $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully'); $message = $upload_success ? $message : strip_tags($this->upload->display_errors()); - + echo json_encode(array( 'success' => $success, 'message' => $message )); } - + public function save_general() { $batch_save_data = array( @@ -294,18 +294,18 @@ class Config extends Secure_Controller 'multi_pack_enabled' => $this->input->post('multi_pack_enabled') != NULL, 'include_hsn' => $this->input->post('include_hsn') != NULL ); - + $this->Module->set_show_office_group($this->input->post('show_office_group') != NULL); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function ajax_check_number_locale() { $number_locale = $this->input->post('number_locale'); @@ -318,16 +318,16 @@ class Config extends Secure_Controller $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); } - $fmt->setTextAttribute(\NumberFormatter::CURRENCY_CODE, $currency_code); $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_code' => $currency_code, 'currency_symbol' => $currency_symbol, + 'currency_code' => $currency_code, 'thousands_separator' => $fmt->getAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL) != '' )); } @@ -355,25 +355,25 @@ class Config extends Secure_Controller 'cash_rounding_code' => $this->input->post('cash_rounding_code'), 'financial_year' => $this->input->post('financial_year') ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_email() { $password = ''; - + if($this->_check_encryption()) { $password = $this->encryption->encrypt($this->input->post('smtp_pass')); } - + $batch_save_data = array( 'protocol' => $this->input->post('protocol'), 'mailpath' => $this->input->post('mailpath'), @@ -384,50 +384,50 @@ class Config extends Secure_Controller 'smtp_timeout' => $this->input->post('smtp_timeout'), 'smtp_crypto' => $this->input->post('smtp_crypto') ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_message() { $password = ''; - + if($this->_check_encryption()) { $password = $this->encryption->encrypt($this->input->post('msg_pwd')); } - + $batch_save_data = array( 'msg_msg' => $this->input->post('msg_msg'), 'msg_uid' => $this->input->post('msg_uid'), 'msg_pwd' => $password, 'msg_src' => $this->input->post('msg_src') ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + /* - * This function fetches all the available lists from Mailchimp for the given API key - */ + * This function fetches all the available lists from Mailchimp for the given API key + */ private function _mailchimp($api_key = '') { $this->load->library('mailchimp_lib', array('api_key' => $api_key)); - + $result = array(); - + if(($lists = $this->mailchimp_lib->getLists()) !== FALSE) { if(is_array($lists) && !empty($lists['lists']) && is_array($lists['lists'])) @@ -439,87 +439,87 @@ class Config extends Secure_Controller } } } - + return $result; } - + /* - AJAX call from mailchimp config form to fetch the Mailchimp lists when a valid API key is inserted - */ + AJAX call from mailchimp config form to fetch the Mailchimp lists when a valid API key is inserted + */ public function ajax_check_mailchimp_api_key() { // load mailchimp lists associated to the given api key, already XSS cleaned in the private function $lists = $this->_mailchimp($this->input->post('mailchimp_api_key')); $success = count($lists) > 0 ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_mailchimp_key_' . ($success ? '' : 'un') . 'successfully'), 'mailchimp_lists' => $lists )); } - + public function save_mailchimp() { $api_key = ''; $list_id = ''; - + if($this->_check_encryption()) { $api_key = $this->encryption->encrypt($this->input->post('mailchimp_api_key')); $list_id = $this->encryption->encrypt($this->input->post('mailchimp_list_id')); } - + $batch_save_data = array( 'mailchimp_api_key' => $api_key, 'mailchimp_list_id' => $list_id ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function ajax_stock_locations() { $stock_locations = $this->Stock_location->get_all()->result_array(); - + $stock_locations = $this->xss_clean($stock_locations); - + $this->load->view('partial/stock_locations', array('stock_locations' => $stock_locations)); } - + public function ajax_dinner_tables() { $dinner_tables = $this->Dinner_table->get_all()->result_array(); - + $dinner_tables = $this->xss_clean($dinner_tables); - + $this->load->view('partial/dinner_tables', array('dinner_tables' => $dinner_tables)); } - + public function ajax_tax_categories() { $tax_categories = $this->Tax->get_all_tax_categories()->result_array(); - + $tax_categories = $this->xss_clean($tax_categories); - + $this->load->view('partial/tax_categories', array('tax_categories' => $tax_categories)); } - + public function ajax_customer_rewards() { $customer_rewards = $this->Customer_rewards->get_all()->result_array(); - + $customer_rewards = $this->xss_clean($customer_rewards); - + $this->load->view('partial/customer_rewards', array('customer_rewards' => $customer_rewards)); } - + private function _clear_session_state() { $this->sale_lib->clear_sale_location(); @@ -530,18 +530,18 @@ class Config extends Secure_Controller $this->receiving_lib->clear_stock_destination(); $this->receiving_lib->clear_all(); } - + public function save_locations() { $this->db->trans_start(); - + $not_to_delete = array(); foreach($this->input->post() as $key => $value) { if(strstr($key, 'stock_location')) { $location_id = preg_replace("/.*?_(\d+)$/", "$1", $key); - + // save or update $location_data = array('location_name' => $value); if($this->Stock_location->save($location_data, $location_id)) @@ -552,10 +552,10 @@ class Config extends Secure_Controller } } } - + // all locations not available in post will be deleted now $deleted_locations = $this->Stock_location->get_all()->result_array(); - + foreach($deleted_locations as $location => $location_data) { if(!in_array($location_data['location_id'], $not_to_delete)) @@ -563,25 +563,25 @@ class Config extends Secure_Controller $this->Stock_location->delete($location_data['location_id']); } } - + $this->db->trans_complete(); - + $success = $this->db->trans_status(); - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_tables() { $this->db->trans_start(); - + $dinner_table_enable = $this->input->post('dinner_table_enable') != NULL; - + $this->Appconfig->save('dinner_table_enable', $dinner_table_enable); - + if($dinner_table_enable) { $not_to_delete = array(); @@ -599,10 +599,10 @@ class Config extends Secure_Controller } } } - + // all tables not available in post will be deleted now $deleted_tables = $this->Dinner_table->get_all()->result_array(); - + foreach($deleted_tables as $dinner_tables => $table) { if(!in_array($table['dinner_table_id'], $not_to_delete)) @@ -611,21 +611,21 @@ class Config extends Secure_Controller } } } - + $this->db->trans_complete(); - + $success = $this->db->trans_status(); - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_tax() { $this->db->trans_start(); - + $batch_save_data = array( 'default_tax_1_rate' => parse_decimals($this->input->post('default_tax_1_rate')), 'default_tax_1_name' => $this->input->post('default_tax_1_name'), @@ -638,29 +638,29 @@ class Config extends Secure_Controller 'default_tax_jurisdiction' => $this->input->post('default_tax_jurisdiction'), 'tax_id' => $this->input->post('tax_id') ); - + $success = $this->Appconfig->batch_save($batch_save_data) ? TRUE : FALSE; - + $this->db->trans_complete(); - + $success &= $this->db->trans_status(); - + $message = $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully'); - + echo json_encode(array( 'success' => $success, 'message' => $message )); } - + public function save_rewards() { $this->db->trans_start(); - + $customer_reward_enable = $this->input->post('customer_reward_enable') != NULL; - + $this->Appconfig->save('customer_reward_enable', $customer_reward_enable); - + if($customer_reward_enable) { $not_to_delete = array(); @@ -679,7 +679,7 @@ class Config extends Secure_Controller $array_save[$customer_reward_id]['points_percent'] = $value; } } - + if(!empty($array_save)) { foreach($array_save as $key => $value) @@ -689,10 +689,10 @@ class Config extends Secure_Controller $this->Customer_rewards->save($package_data, $key); } } - + // all packages not available in post will be deleted now $deleted_packages = $this->Customer_rewards->get_all()->result_array(); - + foreach($deleted_packages as $customer_rewards => $reward_category) { if(!in_array($reward_category['package_id'], $not_to_delete)) @@ -701,17 +701,17 @@ class Config extends Secure_Controller } } } - + $this->db->trans_complete(); - + $success = $this->db->trans_status(); - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_barcode() { $batch_save_data = array( @@ -731,16 +731,16 @@ class Config extends Secure_Controller 'barcode_content' => $this->input->post('barcode_content'), 'barcode_formats' => json_encode($this->input->post('barcode_formats')) ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_receipt() { $batch_save_data = array ( @@ -762,16 +762,16 @@ class Config extends Secure_Controller 'print_bottom_margin' => $this->input->post('print_bottom_margin'), 'print_right_margin' => $this->input->post('print_right_margin') ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function save_invoice() { $batch_save_data = array ( @@ -791,10 +791,10 @@ class Config extends Secure_Controller 'last_used_work_order_number' => $this->input->post('last_used_work_order_number'), 'invoice_type' => $this->input->post('invoice_type') ); - + $result = $this->Appconfig->batch_save($batch_save_data); $success = $result ? TRUE : FALSE; - + // Update the register mode with the latest change so that if the user // switches immediately back to the register the mode reflects the change if($success == TRUE) @@ -808,64 +808,64 @@ class Config extends Secure_Controller $this->sale_lib->set_mode('sale'); } } - + echo json_encode(array( 'success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully') )); } - + public function remove_logo() { $result = $this->Appconfig->batch_save(array('company_logo' => '')); - + echo json_encode(array('success' => $result)); } - + private function _handle_logo_upload() { $this->load->helper('directory'); - + // load upload library $config = array('upload_path' => './uploads/', - 'allowed_types' => 'gif|jpg|png', - 'max_size' => '1024', - 'max_width' => '800', - 'max_height' => '680', - 'file_name' => 'company_logo'); + 'allowed_types' => 'gif|jpg|png', + 'max_size' => '1024', + 'max_width' => '800', + 'max_height' => '680', + 'file_name' => 'company_logo'); $this->load->library('upload', $config); $this->upload->do_upload('company_logo'); - + return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '

'.$this->lang->line('upload_no_file_selected').'

'); } - + private function _check_encryption() { $encryption_key = $this->config->item('encryption_key'); - + // check if the encryption_key config item is the default one if($encryption_key == '' || $encryption_key == 'YOUR KEY') { // Config path $config_path = APPPATH . 'config/config.php'; - + // Open the file $config = file_get_contents($config_path); - + // $key will be assigned a 32-byte (256-bit) hex-encoded random key $key = bin2hex($this->encryption->create_key(32)); - + // set the encryption key in the config item $this->config->set_item('encryption_key', $key); - + // replace the empty placeholder with a real randomly generated encryption key $config = preg_replace("/(.*encryption_key.*)('');/", "$1'$key';", $config); - + $result = FALSE; - + // Chmod the file @chmod($config_path, 0777); - + // Verify file permissions if(is_writable($config_path)) { @@ -873,33 +873,33 @@ class Config extends Secure_Controller $handle = @fopen($config_path, 'w+'); // Write the file $result = (fwrite($handle, $config) === FALSE) ? FALSE : TRUE; - + fclose($handle); } - + // Chmod the file @chmod($config_path, 0444); - + return $result; } - + return TRUE; } - + public function backup_db() { $employee_id = $this->Employee->get_logged_in_employee_info()->person_id; if($this->Employee->has_module_grant('config', $employee_id)) { $this->load->dbutil(); - + $prefs = array( 'format' => 'zip', 'filename' => 'ospos.sql' ); - + $backup = $this->dbutil->backup($prefs); - + $file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip'; $save = 'uploads/' . $file_name; $this->load->helper('download'); @@ -907,7 +907,7 @@ class Config extends Secure_Controller { ob_end_clean(); } - + force_download($file_name, $backup); } else @@ -916,4 +916,4 @@ class Config extends Secure_Controller } } } -?> +?> \ No newline at end of file diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 6b4a7f517..87f5e45a3 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -249,6 +249,8 @@ $(document).ready(function() data, function(response) { $('#number_locale_example').text(response.number_locale_example); + $('#currency_symbol').val(response.currency_symbol); + $('#currency_code').text(response.currency_code); }, 'json' ); @@ -272,6 +274,7 @@ $(document).ready(function() var response = JSON.parse(data); $('#number_locale_example').text(response.number_locale_example); $('#currency_symbol').val(response.currency_symbol); + $('#currency_code').text(response.currency_code); $('#thousands_separator').prop('checked', response.thousands_separator); return response.success; } @@ -290,4 +293,4 @@ $(document).ready(function() errorLabelContainer: '#locale_error_message_box' })); }); - + \ No newline at end of file From 75b548b81ef17e0a7e4354658ef5070194fbced7 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Wed, 13 Mar 2019 12:02:00 +0400 Subject: [PATCH 07/10] Update locale_config.php Fix jquery to update currency code --- application/views/configs/locale_config.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 87f5e45a3..34a9ec31d 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -240,7 +240,7 @@ $(document).ready(function() { $('span').tooltip(); - $('#currency_symbol, #thousands_separator, #currency_code').change(function() { + $('#number_locale').change(function() { var field = $(this).attr('id'); var value = $(this).is(':checkbox') ? $(this).is(':checked') : $(this).val(); var data = { number_locale: $('#number_locale').val() }; @@ -250,7 +250,7 @@ $(document).ready(function() function(response) { $('#number_locale_example').text(response.number_locale_example); $('#currency_symbol').val(response.currency_symbol); - $('#currency_code').text(response.currency_code); + $('#currency_code').val(response.currency_code); }, 'json' ); @@ -268,13 +268,14 @@ $(document).ready(function() type: 'POST', data: { 'number_locale': $('#number_locale').val(), - 'thousands_separator': $('#thousands_separator').is(':checked') + 'thousands_separator': $('#thousands_separator').is(':checked'), + 'currency_code': $('#currency_code').val() }, dataFilter: function(data) { var response = JSON.parse(data); $('#number_locale_example').text(response.number_locale_example); $('#currency_symbol').val(response.currency_symbol); - $('#currency_code').text(response.currency_code); + $('#currency_code').val(response.currency_code); $('#thousands_separator').prop('checked', response.thousands_separator); return response.success; } @@ -293,4 +294,4 @@ $(document).ready(function() errorLabelContainer: '#locale_error_message_box' })); }); - \ No newline at end of file + From 59260241cb47ead776b2031828b339dc4d633676 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Wed, 13 Mar 2019 12:11:58 +0400 Subject: [PATCH 08/10] Update Language code definition Removed two-character locales as those are deprecated. --- application/language/Language code definition | 80 ------------------- 1 file changed, 80 deletions(-) diff --git a/application/language/Language code definition b/application/language/Language code definition index fb6d86c0b..effe2c39d 100644 --- a/application/language/Language code definition +++ b/application/language/Language code definition @@ -2,9 +2,7 @@ ISO Language Code Table ----------------------- Code Name -af Afrikaans af-ZA Afrikaans (South Africa) -ar Arabic ar-AE Arabic (U.A.E.) ar-BH Arabic (Bahrain) ar-DZ Arabic (Algeria) @@ -21,33 +19,22 @@ ar-SA Arabic (Saudi Arabia) ar-SY Arabic (Syria) ar-TN Arabic (Tunisia) ar-YE Arabic (Yemen) -az Azeri (Latin) az-AZ Azeri (Latin) (Azerbaijan) az-AZ Azeri (Cyrillic) (Azerbaijan) -be Belarusian be-BY Belarusian (Belarus) -bg Bulgarian bg-BG Bulgarian (Bulgaria) bs-BA Bosnian (Bosnia and Herzegovina) -ca Catalan ca-ES Catalan (Spain) -cs Czech cs-CZ Czech (Czech Republic) -cy Welsh cy-GB Welsh (United Kingdom) -da Danish da-DK Danish (Denmark) -de German de-AT German (Austria) de-CH German (Switzerland) de-DE German (Germany) de-LI German (Liechtenstein) de-LU German (Luxembourg) -dv Divehi dv-MV Divehi (Maldives) -el Greek el-GR Greek (Greece) -en English en-AU English (Australia) en-BZ English (Belize) en-CA English (Canada) @@ -61,8 +48,6 @@ en-TT English (Trinidad and Tobago) en-US English (United States) en-ZA English (South Africa) en-ZW English (Zimbabwe) -eo Esperanto -es Spanish es-AR Spanish (Argentina) es-BO Spanish (Bolivia) es-CL Spanish (Chile) @@ -83,104 +68,61 @@ es-PY Spanish (Paraguay) es-SV Spanish (El Salvador) es-UY Spanish (Uruguay) es-VE Spanish (Venezuela) -et Estonian et-EE Estonian (Estonia) -eu Basque eu-ES Basque (Spain) -fa Farsi fa-IR Farsi (Iran) -fi Finnish fi-FI Finnish (Finland) -fo Faroese fo-FO Faroese (Faroe Islands) -fr French fr-BE French (Belgium) fr-CA French (Canada) fr-CH French (Switzerland) fr-FR French (France) fr-LU French (Luxembourg) fr-MC French (Principality of Monaco) -gl Galician gl-ES Galician (Spain) -gu Gujarati gu-IN Gujarati (India) -he Hebrew he-IL Hebrew (Israel) -hi Hindi hi-IN Hindi (India) -hr Croatian hr-BA Croatian (Bosnia and Herzegovina) hr-HR Croatian (Croatia) -hu Hungarian hu-HU Hungarian (Hungary) -hy Armenian hy-AM Armenian (Armenia) -id Indonesian id-ID Indonesian (Indonesia) -is Icelandic is-IS Icelandic (Iceland) -it Italian it-CH Italian (Switzerland) it-IT Italian (Italy) -ja Japanese ja-JP Japanese (Japan) -ka Georgian ka-GE Georgian (Georgia) -kk Kazakh kk-KZ Kazakh (Kazakhstan) -kn Kannada kn-IN Kannada (India) -ko Korean ko-KR Korean (Korea) -kok Konkani kok-IN Konkani (India) -ky Kyrgyz ky-KG Kyrgyz (Kyrgyzstan) -lt Lithuanian lt-LT Lithuanian (Lithuania) -lv Latvian lv-LV Latvian (Latvia) -mi Maori mi-NZ Maori (New Zealand) -mk FYRO Macedonian mk-MK FYRO Macedonian (Former Yugoslav Republic of Macedonia) -mn Mongolian mn-MN Mongolian (Mongolia) -mr Marathi mr-IN Marathi (India) -ms Malay ms-BN Malay (Brunei Darussalam) ms-MY Malay (Malaysia) -mt Maltese mt-MT Maltese (Malta) -nb Norwegian (Bokm?l) nb-NO Norwegian (Bokm?l) (Norway) -nl Dutch nl-BE Dutch (Belgium) nl-NL Dutch (Netherlands) nn-NO Norwegian (Nynorsk) (Norway) -ns Northern Sotho ns-ZA Northern Sotho (South Africa) -pa Punjabi pa-IN Punjabi (India) -pl Polish pl-PL Polish (Poland) -ps Pashto ps-AR Pashto (Afghanistan) -pt Portuguese pt-BR Portuguese (Brazil) pt-PT Portuguese (Portugal) -qu Quechua qu-BO Quechua (Bolivia) qu-EC Quechua (Ecuador) qu-PE Quechua (Peru) -ro Romanian ro-RO Romanian (Romania) -ru Russian ru-RU Russian (Russia) -sa Sanskrit sa-IN Sanskrit (India) -se Sami (Northern) se-FI Sami (Northern) (Finland) se-FI Sami (Skolt) (Finland) se-FI Sami (Inari) (Finland) @@ -190,50 +132,30 @@ se-NO Sami (Southern) (Norway) se-SE Sami (Northern) (Sweden) se-SE Sami (Lule) (Sweden) se-SE Sami (Southern) (Sweden) -sk Slovak sk-SK Slovak (Slovakia) -sl Slovenian sl-SI Slovenian (Slovenia) -sq Albanian sq-AL Albanian (Albania) sr-BA Serbian (Latin) (Bosnia and Herzegovina) sr-BA Serbian (Cyrillic) (Bosnia and Herzegovina) sr-SP Serbian (Latin) (Serbia and Montenegro) sr-SP Serbian (Cyrillic) (Serbia and Montenegro) -sv Swedish sv-FI Swedish (Finland) sv-SE Swedish (Sweden) -sw Swahili sw-KE Swahili (Kenya) -syr Syriac syr-SY Syriac (Syria) -ta Tamil ta-IN Tamil (India) -te Telugu te-IN Telugu (India) -th Thai th-TH Thai (Thailand) -tl Tagalog tl-PH Tagalog (Philippines) -tn Tswana tn-ZA Tswana (South Africa) -tr Turkish tr-TR Turkish (Turkey) -tt Tatar tt-RU Tatar (Russia) -ts Tsonga -uk Ukrainian uk-UA Ukrainian (Ukraine) -ur Urdu ur-PK Urdu (Islamic Republic of Pakistan) -uz Uzbek (Latin) uz-UZ Uzbek (Latin) (Uzbekistan) uz-UZ Uzbek (Cyrillic) (Uzbekistan) -vi Vietnamese vi-VN Vietnamese (Viet Nam) -xh Xhosa xh-ZA Xhosa (South Africa) -zh Chinese zh-CN Chinese (S) zh-Hans Chinese in the simplified scrip zh-Hant Chinese in the traditional script @@ -241,6 +163,4 @@ zh-HK Chinese (Hong Kong) zh-MO Chinese (Macau) zh-SG Chinese (Singapore) zh-TW Chinese (T) -zu Zulu zu-ZA Zulu (South Africa) - From 2e755c6806f8070f31231961fd59e26842776cc2 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Wed, 13 Mar 2019 13:52:21 +0400 Subject: [PATCH 09/10] Rename 3.4.0_add_iso_4217.sql to 3.3.0_add_iso_4217.sql 3.3.0 release --- .../sqlscripts/{3.4.0_add_iso_4217.sql => 3.3.0_add_iso_4217.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename application/migrations/sqlscripts/{3.4.0_add_iso_4217.sql => 3.3.0_add_iso_4217.sql} (100%) diff --git a/application/migrations/sqlscripts/3.4.0_add_iso_4217.sql b/application/migrations/sqlscripts/3.3.0_add_iso_4217.sql similarity index 100% rename from application/migrations/sqlscripts/3.4.0_add_iso_4217.sql rename to application/migrations/sqlscripts/3.3.0_add_iso_4217.sql From 2cd9c23ac0b92c20a17e997e6e26a25cc3565f94 Mon Sep 17 00:00:00 2001 From: objecttothis <17935339+objecttothis@users.noreply.github.com> Date: Wed, 13 Mar 2019 13:53:14 +0400 Subject: [PATCH 10/10] Update 20190317102600_add_iso_4217.php --- application/migrations/20190317102600_add_iso_4217.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/migrations/20190317102600_add_iso_4217.php b/application/migrations/20190317102600_add_iso_4217.php index eaea60c86..0a851f55b 100644 --- a/application/migrations/20190317102600_add_iso_4217.php +++ b/application/migrations/20190317102600_add_iso_4217.php @@ -9,7 +9,7 @@ class Migration_add_iso_4217 extends CI_Migration public function up() { - execute_script(APPPATH . 'migrations/sqlscripts/3.4.0_add_iso_4217.sql'); + execute_script(APPPATH . 'migrations/sqlscripts/3.3.0_add_iso_4217.sql'); } public function down() @@ -17,4 +17,4 @@ class Migration_add_iso_4217 extends CI_Migration } } -?> \ No newline at end of file +?>