diff --git a/htdocs/stats.class.php b/htdocs/stats.class.php index cd7c14c86f123b8b4bd97215e039ff109162972f..e3e964a23893cb0fb671b570054566eb13f1c348 100644 --- a/htdocs/stats.class.php +++ b/htdocs/stats.class.php @@ -49,65 +49,67 @@ class Stats * \brief Renvoie le nombre de proposition par mois pour une ann�e donn�e * */ - - function _getNbByMonth($year, $sql) - { - $result = array(); - - if ($this->db->query($sql)) - { - $num = $this->db->num_rows(); - $i = 0; - while ($i < $num) - { - $row = $this->db->fetch_row($i); - $j = $row[0] * 1; - $result[$j] = $row[1]; - $i++; - } - $this->db->free(); - } + function _getNbByMonth($year, $sql) + { + $result = array(); - for ($i = 1 ; $i < 13 ; $i++) - { - $res[$i] = $result[$i] + 0; - } - - $data = array(); + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $this->db->fetch_row($resql); + $j = $row[0] * 1; + $result[$j] = $row[1]; + $i++; + } + $this->db->free($resql); + } - for ($i = 1 ; $i < 13 ; $i++) - { - $data[$i-1] = array(strftime("%b",mktime(12,12,12,$i,1,$year)), $res[$i]); - } + for ($i = 1 ; $i < 13 ; $i++) + { + $res[$i] = $result[$i] + 0; + } - return $data; - } + $data = array(); + + for ($i = 1 ; $i < 13 ; $i++) + { + $data[$i-1] = array(ucfirst(substr(strftime("%b",mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]); + } + + return $data; + } /** * \brief Renvoie le nombre d'element par ann�e * */ - - function _getNbByYear($sql) - { - $result = array(); - - if ($this->db->query($sql)) - { - $num = $this->db->num_rows(); - $i = 0; - while ($i < $num) - { - $row = $this->db->fetch_row($i); - $result[$i] = $row; + function _getNbByYear($sql) + { + $result = array(); + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $i = 0; + while ($i < $num) + { + $row = $this->db->fetch_row($i); + $result[$i] = $row; + $i++; + } + $this->db->free(); + } + else { + dolibarr_print_error($this->db); + } + return $result; + } - $i++; - } - $this->db->free(); - } - return $result; - } /** * \brief Renvoie le nombre d'element par mois pour une ann�e donn�e *