forked from Wavyzz/dolibarr
Augmentation des decimales suivants bug #17811
This commit is contained in:
@@ -1768,36 +1768,51 @@ function print_fleche_navigation($page,$file,$options='',$nextpage)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Fonction qui retourne un montant mon<6F>taire format<61>
|
\brief Fonction qui retourne un montant mon<6F>taire format<61>
|
||||||
\remarks Fonction utilis<69>e dans les pdf et les pages html
|
\remarks Fonction utilis<69>e dans les pdf et les pages html
|
||||||
\param amount Montant a formater
|
\param amount Montant a formater
|
||||||
\param html Formatage html ou pas (0 par defaut)
|
\param html Formatage html ou pas (0 par defaut)
|
||||||
\param outlangs Objet langs pour formatage
|
\param outlangs Objet langs pour formatage
|
||||||
\seealso price2num Fonction inverse de price
|
\seealso price2num Fonction inverse de price
|
||||||
*/
|
*/
|
||||||
function price($amount, $html=0, $outlangs='')
|
function price($amount, $html=0, $outlangs='')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
// Separateurs par defaut
|
// Separateurs par defaut
|
||||||
$dec='.'; $thousand=' ';
|
$dec='.'; $thousand=' ';
|
||||||
|
|
||||||
|
// Si $outlangs non force, on prend langue utilisateur
|
||||||
|
if (! is_object($outlangs)) $outlangs=$langs;
|
||||||
|
|
||||||
|
if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
|
||||||
|
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
|
||||||
|
//print "x".$langs->trans("SeparatorThousand")."x";
|
||||||
|
|
||||||
// Si $outlangs non force, on prend langue utilisateur
|
// On pose par defaut 2 decimales
|
||||||
if (! is_object($outlangs)) $outlangs=$langs;
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
if ($outlangs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->trans("SeparatorDecimal");
|
// Formate nombre
|
||||||
if ($outlangs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->trans("SeparatorThousand");
|
if ($html)
|
||||||
//print "x".$langs->trans("SeparatorThousand")."x";
|
{
|
||||||
|
return ereg_replace(' ',' ',number_format($amount, $decimal, $dec, $thousand));
|
||||||
// Formate nombre
|
}
|
||||||
if ($html)
|
else
|
||||||
{
|
{
|
||||||
return ereg_replace(' ',' ',number_format($amount, 2, $dec, $thousand));
|
return number_format($amount, $decimal, $dec, $thousand);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return number_format($amount, 2, $dec, $thousand);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user