From b906619ce1826babbaca1c8fd89914fb6349bb67 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Dec 2022 10:31:11 +0100 Subject: [PATCH 1/2] FIX : methods declaration (backport fix 67b9a7dc07d708231d12b5e58800334d4a01ef98) --- htdocs/projet/class/taskstats.class.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index a5b088f01e8..16bd0afd480 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -193,4 +193,35 @@ class TaskStats extends Stats // var_dump($res);print '
'; return $res; } + + /** + * Return the Task amount by month for a year + * + * @param int $year Year to scan + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + // Return an empty array at the moment because task has no amount + return array(); + } + + /** + * Return average of entity by month + * @param int $year year number + * @return int value + */ + protected function getAverageByMonth($year) + { + $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } + } From d679a321551fc33cc610ef66770326088e157eb9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Dec 2022 09:36:25 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/projet/class/taskstats.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 16bd0afd480..39efd957bb5 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -223,5 +223,4 @@ class TaskStats extends Stats return $this->_getAverageByMonth($year, $sql); } - }