diff --git a/application/config/autoload.php b/application/config/autoload.php index ccee7912d..114114780 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -83,7 +83,7 @@ $autoload['drivers'] = array(); | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array('form', 'url', 'table', 'text', 'currency', 'html', 'download', 'directory', 'dateformat', 'quantity'); +$autoload['helper'] = array('form', 'url', 'table', 'text', 'locale', 'html', 'download', 'directory'); /* | ------------------------------------------------------------------- diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 799755f11..1859c9ce5 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -63,12 +63,12 @@ class Config extends Secure_area $message = $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully'); $message = $upload_success ? $message : $this->upload->display_errors(); - echo json_encode(array('success'=>$success,'message'=>$message)); + echo json_encode(array('success'=>$success, 'message'=>$message)); } function save_locale() { - $batch_save_data=array( + $batch_save_data = array( 'currency_symbol'=>$this->input->post('currency_symbol'), 'currency_side'=>$this->input->post('currency_side') != null, 'language'=>$this->input->post('language'), @@ -77,10 +77,11 @@ class Config extends Secure_area 'timeformat'=>$this->input->post('timeformat'), 'thousands_separator'=>$this->input->post('thousands_separator'), 'decimal_point'=>$this->input->post('decimal_point'), + 'currency_decimals'=>$this->input->post('currency_decimals'), 'quantity_decimals'=>$this->input->post('quantity_decimals') ); - $result = $this->Appconfig->batch_save( $batch_save_data ); + $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'))); @@ -131,7 +132,7 @@ class Config extends Secure_area $success = $this->db->trans_complete(); - echo json_encode(array('success'=>$success,'message'=>$this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully'))); + echo json_encode(array('success'=>$success, 'message'=>$this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully'))); } function save_barcode() @@ -185,7 +186,7 @@ class Config extends Secure_area { $result = $this->Appconfig->batch_save(array('company_logo' => '')); - echo json_encode(array('success' => $result)); + echo json_encode(array('success'=>$result)); } private function _handle_logo_upload() @@ -221,7 +222,8 @@ class Config extends Secure_area $file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip'; $save = 'uploads/'.$file_name; $this->load->helper('download'); - while (ob_get_level()) { + while (ob_get_level()) + { ob_end_clean(); } force_download($file_name, $backup); diff --git a/application/helpers/currency_helper.php b/application/helpers/currency_helper.php deleted file mode 100644 index 09f535e43..000000000 --- a/application/helpers/currency_helper.php +++ /dev/null @@ -1,40 +0,0 @@ -config->item('currency_symbol') ? $CI->config->item('currency_symbol') : '$'; - $currency_symbol = $currency_symbol == '$' && $escape ? '\$' : $currency_symbol; - $thousands_separator = $CI->config->item('thousands_separator') ? $CI->config->item('thousands_separator') : ''; - $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.'; - $decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 2; - - if($number >= 0) - { - if($CI->config->item('currency_side') !== 'currency_side') - return $currency_symbol.number_format($number, $decimals, $decimal_point, $thousands_separator); - else - return number_format($number, $decimals, $decimal_point, $thousands_separator).$currency_symbol; - } - else - { - if($CI->config->item('currency_side') !== 'currency_side') - return '-'.$currency_symbol.number_format(abs($number), $decimals, $decimal_point, $thousands_separator); - else - return '-'.number_format(abs($number), $decimals, $decimal_point, $thousands_separator).$currency_symbol; - } -} - -function to_currency_no_money($number) -{ - $CI =& get_instance(); - - $thousands_separator = $CI->config->item('thousands_separator') ? $CI->config->item('thousands_separator') : ''; - $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.'; - $decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 2; - - return number_format($number, $decimals, $decimal_point, $thousands_separator); -} - -?> diff --git a/application/helpers/dateformat_helper.php b/application/helpers/locale_helper.php similarity index 66% rename from application/helpers/dateformat_helper.php rename to application/helpers/locale_helper.php index 6d31437d3..48bec9a41 100644 --- a/application/helpers/dateformat_helper.php +++ b/application/helpers/locale_helper.php @@ -1,9 +1,72 @@ config->item('currency_symbol') ? $CI->config->item('currency_symbol') : '$'; + $currency_symbol = $currency_symbol == '$' && $escape ? '\$' : $currency_symbol; + $thousands_separator = $CI->config->item('thousands_separator') ? $CI->config->item('thousands_separator') : ''; + $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.'; + $decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0; + + if($number >= 0) + { + if($CI->config->item('currency_side') !== 'currency_side') + return $currency_symbol.number_format($number, $decimals, $decimal_point, $thousands_separator); + else + return number_format($number, $decimals, $decimal_point, $thousands_separator).$currency_symbol; + } + else + { + if($CI->config->item('currency_side') !== 'currency_side') + return '-'.$currency_symbol.number_format(abs($number), $decimals, $decimal_point, $thousands_separator); + else + return '-'.number_format(abs($number), $decimals, $decimal_point, $thousands_separator).$currency_symbol; + } } + +function to_currency_no_money($number) +{ + // ignore empty strings as they are just for empty input + if( empty($number) ) + { + return $number; + } + + $CI =& get_instance(); + + $decimals = $CI->config->item('currency_decimals') ? $CI->config->item('currency_decimals') : 0; + + return number_format($number, $decimals, '.', ''); +} + +/* + * Quantity decimals + */ + +function to_quantity($number) +{ + $CI =& get_instance(); + + $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.'; + $decimals = $CI->config->item('quantity_decimals') ? $CI->config->item('quantity_decimals') : 0; + + return number_format($number, $decimals, $decimal_point, ''); +} + +function quantity_decimals() +{ + $CI =& get_instance(); + + return $CI->config->item('quantity_decimals') ? $CI->config->item('quantity_decimals') : 0; +} + + /* * Matches each symbol of PHP date format standard * with jQuery equivalent codeword @@ -112,6 +175,7 @@ function dateformat_momentjs($php_format) 'r' => '', // no equivalent 'U' => 'X' ); + return strtr($php_format, $SYMBOLS_MATCHING); } @@ -178,4 +242,4 @@ function dateformat_bootstrap($php_format) return $bootstrap_format; } -?> \ No newline at end of file +?> diff --git a/application/helpers/quantity_helper.php b/application/helpers/quantity_helper.php deleted file mode 100644 index cc289d393..000000000 --- a/application/helpers/quantity_helper.php +++ /dev/null @@ -1,13 +0,0 @@ -config->item('quantity_decimals') ? $CI->config->item('quantity_decimals') : 0; - $decimal_point = $CI->config->item('decimal_point') ? $CI->config->item('decimal_point') : '.'; - - return number_format($number, $decimals, $decimal_point, ''); -} - -?> diff --git a/application/language/de-CH/config_lang.php b/application/language/de-CH/config_lang.php index a39f1c707..df87bf318 100644 --- a/application/language/de-CH/config_lang.php +++ b/application/language/de-CH/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Firmenname ist erforderlich"; $lang["config_company_website_url"] = "Webseite ist nicht in korrektem Format"; $lang["config_currency_side"] = "Pos. rechts"; $lang["config_currency_symbol"] = "Währungssymbol"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Zusatzfeld 1"; $lang["config_custom10"] = "Zusatzfeld 10"; $lang["config_custom2"] = "Zusatzfeld 2"; diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index c4391a51a..77dc77147 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Company name is a required field"; $lang["config_company_website_url"] = "Company website is not a valid URL (http://...)"; $lang["config_currency_side"] = "Right side"; $lang["config_currency_symbol"] = "Currency Symbol"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Custom Field 1"; $lang["config_custom10"] = "Custom Field 10"; $lang["config_custom2"] = "Custom Field 2"; diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php index d188bc951..d68612d76 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Nombre del Comercio es requerido"; $lang["config_company_website_url"] = "Sitio Web no es una URL estándar (http://...)"; $lang["config_currency_side"] = "Lado derecho"; $lang["config_currency_symbol"] = "Símbolo de moneda"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Campo Libre 1"; $lang["config_custom10"] = "Campo Libre 10"; $lang["config_custom2"] = "Campo Libre 2"; diff --git a/application/language/fr/config_lang.php b/application/language/fr/config_lang.php index 67fd7cff3..576fcee7d 100644 --- a/application/language/fr/config_lang.php +++ b/application/language/fr/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Le nom d'entreprise est requis"; $lang["config_company_website_url"] = "Le site web de l'entreprise n'est pas une URL valide (http://...)"; $lang["config_currency_side"] = "Symbole à droite"; $lang["config_currency_symbol"] = "Symbole Monétaire"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Champ Personnalisé 1"; $lang["config_custom10"] = "Champ Personnalisé 10"; $lang["config_custom2"] = "Champ Personnalisé 2"; diff --git a/application/language/hu-HU/config_lang.php b/application/language/hu-HU/config_lang.php index e7fdfd7a6..d88e4ba18 100644 --- a/application/language/hu-HU/config_lang.php +++ b/application/language/hu-HU/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Cégnév kötelező mező"; $lang["config_company_website_url"] = "A cég webcime nem érvényes URL (http://...)"; $lang["config_currency_side"] = "Jobb oldal"; $lang["config_currency_symbol"] = "Pénznem"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Egyedi mező 1"; $lang["config_custom10"] = "Egyedi mező 10"; $lang["config_custom2"] = "Egyedi mező 2"; diff --git a/application/language/id/config_lang.php b/application/language/id/config_lang.php index a405993bd..04c8a070f 100644 --- a/application/language/id/config_lang.php +++ b/application/language/id/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Nama Perusahaan wajib diisi"; $lang["config_company_website_url"] = "Situs Perusahaan bukan URL yang benar(http://...)"; $lang["config_currency_side"] = "Sisi Kanan"; $lang["config_currency_symbol"] = "Simbol Mata Uang"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Custom Field 1"; $lang["config_custom10"] = "Custom Field 10"; $lang["config_custom2"] = "Custom Field 2"; diff --git a/application/language/nl-BE/config_lang.php b/application/language/nl-BE/config_lang.php index 548701fb7..4589224bb 100755 --- a/application/language/nl-BE/config_lang.php +++ b/application/language/nl-BE/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "De bedrijfsnaam moet ingevuld worden"; $lang["config_company_website_url"] = "De website van het bedrijf is geen geldige URL (http://...)"; $lang["config_currency_side"] = "Rechterkant"; $lang["config_currency_symbol"] = "Valuta"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Custom Veld 1"; $lang["config_custom10"] = "Custom Veld 10"; $lang["config_custom2"] = "Custom Veld 2"; diff --git a/application/language/ru/config_lang.php b/application/language/ru/config_lang.php index c3d8e88d4..a2900e81d 100644 --- a/application/language/ru/config_lang.php +++ b/application/language/ru/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Имя Компании обязательн $lang["config_company_website_url"] = "Веб-сайт Компании не является допустимым URL (http://...)"; $lang["config_currency_side"] = "Правая сторона"; $lang["config_currency_symbol"] = "Символ валюты"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Изготовленный пробел 1"; $lang["config_custom10"] = "Изготовленный пробел 10"; $lang["config_custom2"] = "Изготовленный пробел 2"; diff --git a/application/language/th/config_lang.php b/application/language/th/config_lang.php index 79558e78e..32da3918b 100644 --- a/application/language/th/config_lang.php +++ b/application/language/th/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "ชื่อร้านค้าต้อ $lang["config_company_website_url"] = "เว็บไซต์ร้านค้าไม่ถูกต้อง"; $lang["config_currency_side"] = "ด้านขวา"; $lang["config_currency_symbol"] = "สัญลักษณ์ค่าเงิน"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "พื้นที่เพิ่มเติม 1"; $lang["config_custom10"] = "พื้นที่เพิ่มเติม 10"; $lang["config_custom2"] = "พื้นที่เพิ่มเติม 2"; diff --git a/application/language/tr/config_lang.php b/application/language/tr/config_lang.php index ba8e8d28c..35dbc6056 100644 --- a/application/language/tr/config_lang.php +++ b/application/language/tr/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "Şirket Adı zorunlu alandır"; $lang["config_company_website_url"] = "website adresi yanlış (http://...)"; $lang["config_currency_side"] = "Sağda"; $lang["config_currency_symbol"] = "Para Birimi"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Özel Alan 1"; $lang["config_custom10"] = "Özel Alan 10"; $lang["config_custom2"] = "Özel Alan 2"; diff --git a/application/language/zh/config_lang.php b/application/language/zh/config_lang.php index d1005636b..2e37cf52f 100755 --- a/application/language/zh/config_lang.php +++ b/application/language/zh/config_lang.php @@ -34,6 +34,7 @@ $lang["config_company_required"] = "公司名稱為必填"; $lang["config_company_website_url"] = "公司網址格式錯誤 (http://...)"; $lang["config_currency_side"] = "Right side"; $lang["config_currency_symbol"] = "貨幣符號"; +$lang["config_currency_decimals"] = "Currency Decimals"; $lang["config_custom1"] = "Custom Field 1"; $lang["config_custom10"] = "Custom Field 10"; $lang["config_custom2"] = "Custom Field 2"; diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 43dc0be01..dbfd74b35 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -25,6 +25,19 @@ +
+ lang->line('config_currency_decimals'), 'language', array('class'=>'control-label col-xs-2')); ?> +
+ '0', + '1' => '1', + '2' => '2' + ), + $this->config->item('currency_decimals'), array('class'=>'form-control input-sm')); + ?> +
+
+
lang->line('config_decimal_point'), 'language', array('class'=>'control-label col-xs-2')); ?>
diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index 373ddf3a2..3df179b7a 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -38,7 +38,7 @@ 'name'=>'value', 'id'=>'value', 'class'=>'form-control input-sm', - 'value'=>$giftcard_info->value) + 'value'=>to_currency_no_money($giftcard_info->value)) );?>
diff --git a/application/views/items/count_details.php b/application/views/items/count_details.php index da7988e59..1b816df5f 100644 --- a/application/views/items/count_details.php +++ b/application/views/items/count_details.php @@ -106,7 +106,7 @@ $(document).ready(function() function display_stock(location_id) { var item_quantities = ; - document.getElementById("quantity").value = item_quantities[location_id]; + document.getElementById("quantity").value = parseFloat(item_quantities[location_id]).toFixed(); var inventory_data = ; var employee_data = ; @@ -137,7 +137,7 @@ function display_stock(location_id) tr.appendChild(td); td = document.createElement('td'); - td.appendChild(document.createTextNode(data['trans_inventory'])); + td.appendChild(document.createTextNode(parseFloat(data['trans_inventory']).toFixed())); td.setAttribute("style", "text-align:center"); tr.appendChild(td); @@ -149,5 +149,4 @@ function display_stock(location_id) } } } - \ No newline at end of file diff --git a/application/views/items/form.php b/application/views/items/form.php index 2808964f0..35bc7e2ff 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -62,7 +62,7 @@ 'name'=>'cost_price', 'id'=>'cost_price', 'class'=>'form-control input-sm', - 'value'=>$item_info->cost_price) + 'value'=>to_currency_no_money($item_info->cost_price)) );?> @@ -77,7 +77,7 @@ 'name'=>'unit_price', 'id'=>'unit_price', 'class'=>'form-control input-sm', - 'value'=>$item_info->unit_price) + 'value'=>to_currency_no_money($item_info->unit_price)) );?> diff --git a/application/views/items/inventory.php b/application/views/items/inventory.php index 773c73e01..bca48e1d6 100644 --- a/application/views/items/inventory.php +++ b/application/views/items/inventory.php @@ -132,10 +132,9 @@ $(document).ready(function() }); }); - function fill_quantity(val) { var item_quantities = ; - document.getElementById("quantity").value = item_quantities[val]; + document.getElementById("quantity").value = parseFloat(item_quantities[val]).toFixed(); } \ No newline at end of file diff --git a/application/views/receivings/receiving.php b/application/views/receivings/receiving.php index 06130fdc2..53851a3a3 100644 --- a/application/views/receivings/receiving.php +++ b/application/views/receivings/receiving.php @@ -119,7 +119,7 @@ if (isset($error)) ');?> -
[ in ] +
@@ -127,7 +127,7 @@ if (isset($error)) if ($items_module_allowed && $mode !='requisition') { ?> - 'price', 'class'=>'form-control input-sm', 'value'=>$item['price']));?> + 'price', 'class'=>'form-control input-sm', 'value'=>to_currency_no_money($item['price'])));?> ');?> -
[ in ] +
@@ -134,7 +134,7 @@ if (isset($success)) if ($items_module_allowed) { ?> - 'price', 'class'=>'form-control input-sm', 'value'=>$item['price']));?> + 'price', 'class'=>'form-control input-sm', 'value'=>to_currency_no_money($item['price'])));?> lang->line('sales_amount_tendered'); ?>"); - $("#amount_tendered").val(''); + $("#amount_tendered").val(''); } } diff --git a/database/database.sql b/database/database.sql index 17eba62b1..8f684c1ea 100644 --- a/database/database.sql +++ b/database/database.sql @@ -57,7 +57,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('show_total_discount', '1'), ('dateformat', 'm/d/Y'), ('timeformat', 'H:i:s'), -('currency_symbol', '$'); +('currency_symbol', '$'), +('decimal_point', '.'), +('currency_decimals', '2'), +('quantity_decimals', '0'); -- -------------------------------------------------------- diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index cf1b11108..09ceaca22 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.sql @@ -57,7 +57,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('show_total_discount', '1'), ('dateformat', 'm/d/Y'), ('timeformat', 'H:i:s'), -('currency_symbol', '$'); +('currency_symbol', '$'), +('decimal_point', '.'), +('currency_decimals', '2'), +('quantity_decimals', '0'); -- -------------------------------------------------------- diff --git a/database/tables.sql b/database/tables.sql index e441a8af5..9fbabfa73 100644 --- a/database/tables.sql +++ b/database/tables.sql @@ -57,7 +57,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('show_total_discount', '1'), ('dateformat', 'm/d/Y'), ('timeformat', 'H:i:s'), -('currency_symbol', '$'); +('currency_symbol', '$'), +('decimal_point', '.'), +('currency_decimals', '2'), +('quantity_decimals', '0'); -- -------------------------------------------------------- diff --git a/translations/config_lang.csv b/translations/config_lang.csv index db2b51db6..cc170848a 100644 --- a/translations/config_lang.csv +++ b/translations/config_lang.csv @@ -33,6 +33,7 @@ config_company_required,Cégnév kötelező mező,Firmenname ist erforderlich,De config_company_website_url,A cég webcime nem érvényes URL (http://...),Webseite ist nicht in korrektem Format,De website van het bedrijf is geen geldige URL (http://...),Sitio Web no es una URL estándar (http://...),Company website is not a valid URL (http://...),Le site web de l'entreprise n'est pas une URL valide (http://...),公司網址格式錯誤 (http://...),Веб-сайт Компании не является допустимым URL (http://...),เว็บไซต์ร้านค้าไม่ถูกต้อง,website adresi yanlış (http://...),Situs Perusahaan bukan URL yang benar(http://...) config_currency_side,Jobb oldal,Pos. rechts,Rechterkant,Lado derecho,Right side,Symbole à droite,Right side,Правая сторона,ด้านขวา,Sağda,Sisi Kanan config_currency_symbol,Pénznem,Währungssymbol,Valuta,Símbolo de moneda,Currency Symbol,Symbole Monétaire,貨幣符號,Символ валюты,สัญลักษณ์ค่าเงิน,Para Birimi,Simbol Mata Uang +config_currency_decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals,Currency Decimals config_custom1,Egyedi mező 1,Zusatzfeld 1,Custom Veld 1,Campo Libre 1,Custom Field 1,Champ Personnalisé 1,Custom Field 1,Изготовленный пробел 1,พื้นที่เพิ่มเติม 1,Özel Alan 1,Custom Field 1 config_custom10,Egyedi mező 10,Zusatzfeld 10,Custom Veld 10,Campo Libre 10,Custom Field 10,Champ Personnalisé 10,Custom Field 10,Изготовленный пробел 10,พื้นที่เพิ่มเติม 10,Özel Alan 10,Custom Field 10 config_custom2,Egyedi mező 2,Zusatzfeld 2,Custom Veld 2,Campo Libre 2,Custom Field 2,Champ Personnalisé 2,Custom Field 2,Изготовленный пробел 2,พื้นที่เพิ่มเติม 2,Özel Alan 2,Custom Field 2