diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index 2613ba59469..75b17a6776e 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -132,27 +132,27 @@ $var=!$var;
print '
| '.$langs->trans("CurrentUserLanguage").' | '.$langs->getDefaultLang().' |
'."\n";
// Thousands
$var=!$var;
-$thousand=$langs->trans("SeparatorThousand");
+$thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
if ($thousand == 'SeparatorThousand') $thousand=' '; // ' ' does not work on trans method
if ($thousand == 'None') $thousand='';
-print '| '.$langs->trans("CurrentValueSeparatorThousand").' | '.($thousand==' '?$langs->trans("Space"):$thousand).' |
'."\n";
+print '| '.$langs->trans("CurrentValueSeparatorThousand").' | '.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).' |
'."\n";
// Decimals
$var=!$var;
-$dec=$langs->trans("SeparatorDecimal");
+$dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
print '| '.$langs->trans("CurrentValueSeparatorDecimal").' | '.$dec.' |
'."\n";
// Show results of functions to see if everything works
$var=!$var;
-print '| => price2num(1233.56+1) | '.price2num(1233.56+1,'2').' |
';
+print '| => price2num(1233.56+1) | '.price2num(1233.56+1,'2').' |
'."\n";
$var=!$var;
-print "| => price2num('."'1".$thousand."234".$dec."56') | ".price2num("1".$thousand."234".$dec."56",'2')." | ";
+print "
| => price2num('."'1".$thousand."234".$dec."56') | ".price2num("1".$thousand."234".$dec."56",'2')." |
\n";
if (($thousand != ',' && $thousand != '.') || ($thousand != ' '))
{
$var=!$var;
- print "| => price2num('."'1 234.56') | ".price2num("1 234.56",'2')." | ";
+ print "
| => price2num('."'1 234.56') | ".price2num("1 234.56",'2')." | ";
print "
\n";
}
$var=!$var;
-print '| => price(1234.56) | '.price(1234.56).' | ';
+print '
| => price(1234.56) | '.price(1234.56).' |
'."\n";
// Timezone
$txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'
'."\n";
$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3dec3cecc7f..22e4892af5f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2563,7 +2563,7 @@ function vatrate($rate,$addpercent=false,$info_bits=0,$usestarfornpr=0)
* @param int $trunc 1=Truncate if there is too much decimals (default), 0=Does not truncate
* @param int $rounding Minimum number of decimal to show. If not defined we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
* @param int $forcerounding Force the number of decimal
- * @param string $currency_code To add currency symbol (''=add nothing, 'XXX'=add currency symbols for XXX currency)
+ * @param string $currency_code To add currency symbol (''=add nothing, 'XXX'=add currency symbols for XXX currency)
* @return string Chaine avec montant formate
*
* @see price2num Revert function of price
@@ -2585,8 +2585,8 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
// If $outlangs not forced, we use use language
if (! is_object($outlangs)) $outlangs=$langs;
- if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
- if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
+ if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->transnoentitiesnoconv("SeparatorDecimal");
+ if ($outlangs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->transnoentitiesnoconv("SeparatorThousand");
if ($thousand == 'None') $thousand='';
//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
";
@@ -2616,13 +2616,11 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
if ($forcerounding >= 0) $nbdecimal = $forcerounding;
// Format number
+ $output=number_format($amount, $nbdecimal, $dec, $thousand);
if ($form)
{
- $output=preg_replace('/\s/',' ',number_format($amount, $nbdecimal, $dec, $thousand));
- }
- else
- {
- $output=number_format($amount, $nbdecimal, $dec, $thousand);
+ $output=preg_replace('/\s/',' ',$output);
+ $output=preg_replace('/\'/',''',$output);
}
// Add symbol of currency if requested
$cursymbolbefore=$cursymbolafter='';
@@ -2633,7 +2631,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
else $cursymbolafter.=$outlangs->getCurrencySymbol($currency_code);
}
$output.=$cursymbolbefore.$end.$cursymbolafter;
-
+
return $output;
}
@@ -2660,15 +2658,15 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
// Numbers must be '1234.56'
// Decimal delimiter for PHP and database SQL requests must be '.'
$dec=','; $thousand=' ';
- if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal");
- if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand");
+ if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");
+ if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand");
if ($thousand == 'None') $thousand='';
//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'
";
// Convert value to universal number format (no thousand separator, '.' as decimal separator)
if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format
{
- //print 'PP'.$amount.' - '.$dec.' - '.$thousand.'
';
+ //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
';
// Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
// to format defined by LC_NUMERIC after a calculation and we want source format to be like defined by Dolibarr setup.