mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-23 09:51:33 +01:00
New: SeparatorThousand and SeparatorDecimal accepts ' chars.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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='';
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user