diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 2613ba594691609ebf8b2967ab0ec97fd2702b27..75b17a6776efcca48617461b938b8b7953b100cd 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -132,27 +132,27 @@ $var=!$var; print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentUserLanguage").'</td><td>'.$langs->getDefaultLang().'</td></tr>'."\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 '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorThousand").'</td><td>'.($thousand==' '?$langs->trans("Space"):$thousand).'</td></tr>'."\n"; +print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorThousand").'</td><td>'.($thousand==' '?$langs->transnoentitiesnoconv("Space"):$thousand).'</td></tr>'."\n"; // Decimals $var=!$var; -$dec=$langs->trans("SeparatorDecimal"); +$dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentValueSeparatorDecimal").'</td><td>'.$dec.'</td></tr>'."\n"; // Show results of functions to see if everything works $var=!$var; -print '<tr '.$bc[$var].'><td width="300"> => price2num(1233.56+1)</td><td>'.price2num(1233.56+1,'2').'</td></tr>'; +print '<tr '.$bc[$var].'><td width="300"> => price2num(1233.56+1)</td><td>'.price2num(1233.56+1,'2').'</td></tr>'."\n"; $var=!$var; -print "<tr ".$bc[$var].'><td width=\"300\"> => price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56",'2')."</td>"; +print "<tr ".$bc[$var].'><td width="300"> => price2num('."'1".$thousand."234".$dec."56')</td><td>".price2num("1".$thousand."234".$dec."56",'2')."</td></tr>\n"; if (($thousand != ',' && $thousand != '.') || ($thousand != ' ')) { $var=!$var; - print "<tr ".$bc[$var].'><td width=\"300\"> => price2num('."'1 234.56')</td><td>".price2num("1 234.56",'2')."</td>"; + print "<tr ".$bc[$var].'><td width="300"> => price2num('."'1 234.56')</td><td>".price2num("1 234.56",'2')."</td>"; print "</tr>\n"; } $var=!$var; -print '<tr '.$bc[$var].'><td width="300"> => price(1234.56)</td><td>'.price(1234.56).'</td>'; +print '<tr '.$bc[$var].'><td width="300"> => price(1234.56)</td><td>'.price(1234.56).'</td></tr>'."\n"; // Timezone $txt =$langs->trans("OSTZ").' (variable system TZ): '.(! empty($_ENV["TZ"])?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\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 3dec3cecc7fa82fcb0fddf9c2bc83fbf133aa6a2..22e4892af5f7f1090777441904f5c2e491edca51 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."'<br>"; @@ -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."'<br>"; // 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.'<br>'; + //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>'; // 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.