Look: Amélioration des libellés de mois sur graphiques.

This commit is contained in:
Laurent Destailleur 2005-07-16 12:20:51 +00:00
parent 9bfc3f8756
commit 9bd0b2ca61

View File

@ -548,56 +548,50 @@ class Product
} }
/** /**
* \brief Renvoie des stats * \brief Renvoie tableau des stats pour une requete donnée
* \param sql requete a exécuter * \param sql Requete a exécuter
* \return array tableau ? * \return array Tableau de stats
*/ */
function _get_stats($sql)
function _get_stats($sql)
{ {
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
if ($result)
{
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num)
{
$arr = $this->db->fetch_array($result);
$tab[$arr[1]] = $arr[0];
$i++;
}
}
if ( $result ) $year = strftime('%Y',time());
{ $month = strftime('%m',time());
$num = $this->db->num_rows(); $result = array();
$i = 0;
while ($i < $num)
{
$arr = $this->db->fetch_array($i);
$ventes[$arr[1]] = $arr[0];
$i++;
}
}
$year = strftime('%Y',time()); for ($j = 0 ; $j < 12 ; $j++)
$month = strftime('%m',time()); {
$result = array(); $idx=ucfirst(substr( strftime("%b",mktime(12,0,0,$month,1,$year)) ,0,3) );
$monthnum=sprintf("%02s",$month);
for ($j = 0 ; $j < 12 ; $j++) $result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0);
{ // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0);
$idx=ucfirst(strftime("%b",mktime(12,0,0,$month,1,$year)));
if (isset($ventes[$year . $month]))
{
$result[$j] = array($idx, $ventes[$year . $month]);
}
else
{
$result[$j] = array($idx,0);
}
$month = "0".($month - 1); $month = "0".($month - 1);
if (strlen($month) == 3) if (strlen($month) == 3)
{ {
$month = substr($month,1); $month = substr($month,1);
} }
if ($month == 0) if ($month == 0)
{ {
$month = 12; $month = 12;
$year = $year - 1; $year = $year - 1;
} }
} }
return array_reverse($result); return array_reverse($result);
} }