3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'reporting/Report.class.php';
26 class ReportTrackerAct extends Report {
33 function ReportTrackerAct($span,$group_id,$atid,$start=0,$end=0) {
36 $group = group_get_object($group_id);
37 $at = new ArtifactType($group, $atid);
39 if ($at->isPermissionDeniedError()) {
40 exit_permission_denied('','tracker');
42 exit_error($at->getErrorMessage(),'tracker');
46 // Set start date from the project date.
48 $start=mktime(0,0,0,date('m'),1,date('Y')-1);
58 $this->setError('No group_id');
61 if (!$span || $span == REPORT_TYPE_MONTHLY) {
63 $arr =& $this->getMonthStartArr();
65 for ($i=0; $i<count($arr); $i++) {
66 if ($arr[$i]<$start || $arr[$i]>$end) {
67 //skip this month as it's not in the range
70 $this->labels[]=date('M d',$arr[$i]).' <-> '.date('M d',($arr[$i-1]-1));
71 $this->avgtime[]=$this->getAverageTime($atid,$arr[$i],($arr[$i-1]-1));
72 $this->opencount[]=$this->getOpenCount($atid,$arr[$i],($arr[$i-1]-1));
73 $this->stillopencount[]=$this->getStillOpenCount($atid,$arr[$i],($arr[$i-1]-1));
78 } elseif ($span == REPORT_TYPE_WEEKLY) {
80 $arr =& $this->getWeekStartArr();
82 for ($i=0; $i<count($arr); $i++) {
83 if ($arr[$i]<$start || $arr[$i]>$end) {
84 //skip this month as it's not in the range
87 $this->labels[]=date('M d',$arr[$i]).' <-> '.date('M d',($arr[$i-1]-1));
88 $this->avgtime[]=$this->getAverageTime($atid,$arr[$i],($arr[$i-1]-1));
89 $this->opencount[]=$this->getOpenCount($atid,$arr[$i],($arr[$i-1]-1));
90 $this->stillopencount[]=$this->getStillOpenCount($atid,$arr[$i],($arr[$i-1]-1));
97 $this->start_date=$start;
100 $this->setSpan($span);
101 $this->setDates($res,1);
106 function getAverageTime($atid,$start,$end) {
107 $res = db_query_params ('SELECT avg((close_date-open_date)/(24*60*60)) AS avgtime
109 WHERE group_artifact_id=$1
111 AND open_date BETWEEN $2 AND $3',
115 return db_result($res,0,0);
118 function getOpenCount($atid,$start,$end) {
119 $res = db_query_params ('SELECT count(*)
123 AND open_date BETWEEN $2 AND $3',
127 return db_result($res,0,0);
130 function getStillOpenCount($atid,$start,$end) {
131 $res = db_query_params ('SELECT count(*)
136 AND (close_date >= $3 OR close_date < 1 OR close_date is null)',
138 $end, // Yes, really.
140 return db_result($res,0,0);
143 function &getAverageTimeData() {
144 return $this->avgtime;
147 function &getOpenCountData() {
148 return $this->opencount;
151 function &getStillOpenCountData() {
152 return $this->stillopencount;
159 // c-file-style: "bsd"