Augmentation des decimales suivants bug #17811

This commit is contained in:
Rodolphe Quiedeville
2006-12-07 10:19:38 +00:00
parent b1222e9673
commit 6e592b2e37

View File

@@ -1789,14 +1789,29 @@ function price($amount, $html=0, $outlangs='')
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
//print "x".$langs->trans("SeparatorThousand")."x";
// On pose par defaut 2 decimales
$decimal = 2;
$amount = ereg_replace(',','.',$amount);
$datas = explode('.',$amount);
$cents = $datas[1];
// On augmente au besoin
if ($cents > 99 )
{
$decimal = 3;
}
if ($cents > 999 )
{
$decimal = 4;
}
// Formate nombre
if ($html)
{
return ereg_replace(' ',' ',number_format($amount, 2, $dec, $thousand));
return ereg_replace(' ',' ',number_format($amount, $decimal, $dec, $thousand));
}
else
{
return number_format($amount, 2, $dec, $thousand);
return number_format($amount, $decimal, $dec, $thousand);
}
}