forked from Wavyzz/dolibarr
New: SeparatorThousand and SeparatorDecimal accepts ' chars.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user