diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index a0a0366fd59..3ed2f00f325 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -65,6 +65,15 @@ $var=!$var;
print "
| ".$langs->trans("LanguageParameter","PHP LC_TIME")." | ".setlocale(LC_TIME,0)." |
\n";
$var=!$var;
print "| ".$langs->trans("LanguageParameter","PHP LC_MONETARY")." | ".setlocale(LC_MONETARY,0)." |
\n";
+// Decimals
+$var=!$var;
+$dec=$langs->trans("SeparatorDecimal");
+print "| ".$langs->trans("CurrentValueSeparatorDecimal")." | ".$dec." |
\n";
+$var=!$var;
+$thousand=$langs->trans("SeparatorThousand");
+if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method
+print "| ".$langs->trans("CurrentValueSeparatorThousand")." | ".$thousand." |
\n";
+// Timezone
$var=!$var;
print "| ".$langs->trans("DolibarrTZ")." | ".$langs->trans("FeatureNotYetAvailable")." |
\n";
$var=!$var;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index a8c2a424eba..a85d2bcec25 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -59,6 +59,8 @@ Active=Active
SetupShort=Setup
OtherOptions=Other options
OtherSetup=Other setup
+CurrentValueSeparatorDecimal=Decimal separator
+CurrentValueSeparatorThousand=Thousand separator
Modules=Modules
ModulesCommon=Common modules
ModulesInterfaces=Interfaces modules
@@ -69,7 +71,7 @@ ParameterInDolibarr=Parameter %s
LanguageParameter=Language parameter %s
LanguageBrowserParameter=Parameter %s
LocalisationDolibarrParameters=Localisation parameters
-DolibarrTZ=Time Zone
+DolibarrTZ=Time Zone Dolibarr
ServerTZ=Time Zone Server
PHPTZ=Time Zone PHP
PHPServerOffsetWithGreenwich=Offset for PHP server width Greenwich (secondes)
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 73523cd2415..5ede850a9a9 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -59,6 +59,8 @@ Active=Actif
SetupShort=Config
OtherOptions=Autres options
OtherSetup=Divers
+CurrentValueSeparatorDecimal=Séparateur décimal
+CurrentValueSeparatorThousand=Séparateur de milliers
Modules=Modules
ModulesCommon=Modules standards
ModulesInterfaces=Modules interfaces
@@ -69,7 +71,7 @@ ParameterInDolibarr=Variable %s
LanguageParameter=Variable langue %s
LanguageBrowserParameter=Variable %s
LocalisationDolibarrParameters=Paramètres de localisation
-DolibarrTZ=Time Zone
+DolibarrTZ=Time Zone Dolibarr
ServerTZ=Time Zone Serveur
PHPTZ=Time Zone PHP
PHPServerOffsetWithGreenwich=Offset serveur PHP avec Greenwich (secondes)
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 43db659211e..292ff4e368c 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -1963,14 +1963,14 @@ function vatrate($rate,$addpercent=false,$info_bits=0)
* \param trunc 1=Tronque affichage si trop de decimales,0=Force le non troncage
* \param nbdecimal Nbre decimals minimum.
* \return string Chaine avec montant formate
- * \seealso price2num Fonction inverse de price
+ * \seealso price2num Revert function of price
*/
function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
{
global $langs,$conf;
- // Separateurs par defaut
- $dec='.'; $thousand=' ';
+ // Output separators by default (french)
+ $dec=','; $thousand=' ';
// Si $outlangs non force, on prend langue utilisateur
if (! is_object($outlangs)) $outlangs=$langs;
@@ -1980,15 +1980,15 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
//print "amount=".$amount." html=".$html." trunc=".$trunc." nbdecimal=".$nbdecimal." dec=".$dec." thousand=".$thousand;
//print "amount=".$amount."-";
- $amount = ereg_replace(',','.',$amount);
+ $amount = ereg_replace(',','.',$amount); // should be useless
//print $amount."-";
$datas = split('\.',$amount);
$decpart = $datas[1];
- $decpart = eregi_replace('0+$','',$decpart); // Supprime les 0 de fin de partie d�cimale
+ $decpart = eregi_replace('0+$','',$decpart); // Supprime les 0 de fin de partie decimale
//print "decpart=".$decpart."
";
$end='';
- // On augmente au besoin si il y a plus de 2 d�cimales
+ // On augmente nbdecimal au besoin si il y a plus de decimales que nbdecimal
if (strlen($decpart) > $nbdecimal) $nbdecimal=strlen($decpart);
// Si on depasse max
if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN)
@@ -1996,7 +1996,7 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
$nbdecimal=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
if (eregi('\.\.\.',$conf->global->MAIN_MAX_DECIMALS_SHOWN))
{
- // Si un affichage est tronqu�, on montre des ...
+ // Si un affichage est tronque, on montre des ...
$end='...';
}
}
@@ -2029,21 +2029,30 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $nbdecimal=2)
*/
function price2num($amount,$rounding='')
{
- global $conf;
+ global $langs,$conf;
- // Round PHP function does not allow number like '1,234.5'.
+ // Round PHP function does not allow number like '1,234.5'
// Numbers must be '1234.5'
- // \TODO If there is already a ".", we remove ",", otherwise replace by "."
- $amount=ereg_replace(',','.',$amount);
- $amount=ereg_replace(' ','',$amount);
+ // Decimal delimiter for database SQL request must be '.'
+
+ $dec=','; $thousand=' ';
+ if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal");
+ if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand");
+
+ if ($thousand != ',') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users
+ $amount=str_replace(' ','',$amount); // To avoid spaces
+ $amount=str_replace($dec,'.',$amount);
+ $amount=str_replace($thousand,'',$amount);
if ($rounding)
{
if ($rounding == 'MU') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_UNIT);
elseif ($rounding == 'MT') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_TOT);
elseif ($rounding == 'MS') $amount = round($amount,$conf->global->MAIN_MAX_DECIMALS_SHOWN);
else $amount='ErrorBadParameterProvidedToFunction';
- $amount=ereg_replace(',','.',$amount);
- $amount=ereg_replace(' ','',$amount);
+ if ($thousand != ',') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users
+ $amount=str_replace(' ','',$amount); // To avoid spaces
+ $amount=str_replace($dec,'.',$amount);
+ $amount=str_replace($thousand,'',$amount);
}
return $amount;
}