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,57 +548,51 @@ 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)
if ( $result ) {
{ $num = $this->db->num_rows($result);
$num = $this->db->num_rows(); $i = 0;
$i = 0; while ($i < $num)
while ($i < $num) {
{ $arr = $this->db->fetch_array($result);
$arr = $this->db->fetch_array($i); $tab[$arr[1]] = $arr[0];
$ventes[$arr[1]] = $arr[0]; $i++;
$i++; }
} }
}
$year = strftime('%Y',time());
$year = strftime('%Y',time()); $month = strftime('%m',time());
$month = strftime('%m',time()); $result = array();
$result = array();
for ($j = 0 ; $j < 12 ; $j++)
for ($j = 0 ; $j < 12 ; $j++) {
{ $idx=ucfirst(substr( strftime("%b",mktime(12,0,0,$month,1,$year)) ,0,3) );
$idx=ucfirst(strftime("%b",mktime(12,0,0,$month,1,$year))); $monthnum=sprintf("%02s",$month);
if (isset($ventes[$year . $month]))
{ $result[$j] = array($idx,isset($tab[$year.$month])?$tab[$year.$month]:0);
$result[$j] = array($idx, $ventes[$year . $month]); // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0);
}
else $month = "0".($month - 1);
{ if (strlen($month) == 3)
$result[$j] = array($idx,0); {
} $month = substr($month,1);
}
$month = "0".($month - 1); if ($month == 0)
if (strlen($month) == 3) {
{ $month = 12;
$month = substr($month,1); $year = $year - 1;
} }
if ($month == 0) }
{ return array_reverse($result);
$month = 12;
$year = $year - 1;
}
}
return array_reverse($result);
} }