3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
7 * Copyright 2013, Franck Villaume - TrivialDev
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'reporting/Report.class.php';
27 class ReportTrackerAct extends Report {
34 function ReportTrackerAct($span,$group_id,$atid,$start=0,$end=0) {
37 $group = group_get_object($group_id);
38 $at = new ArtifactType($group, $atid);
40 if ($at->isPermissionDeniedError()) {
41 exit_permission_denied('','tracker');
43 exit_error($at->getErrorMessage(),'tracker');
47 // Set start date from the project date.
49 $start=mktime(0,0,0,date('m'),1,date('Y')-1);
59 $this->setError('No group_id');
64 case REPORT_TYPE_WEEKLY: {
65 $arr = $this->getWeekStartArr();
69 $arr = $this->getMonthStartArr();
74 for ($i=0; $i<count($arr); $i++) {
75 if ($arr[$i]<$start || $arr[$i]>$end) {
76 //skip this month as it's not in the range
79 $this->labels[]=date('M d',($arr[$i-1]-1)).' <-> '.date('M d',$arr[$i]);
80 $this->avgtime[]=$this->getAverageTime($atid,($arr[$i-1]-1),$arr[$i]);
81 $this->opencount[]=$this->getOpenCount($atid,($arr[$i-1]-1),$arr[$i]);
82 $this->stillopencount[]=$this->getStillOpenCount($atid,$arr[$i]);
86 $this->start_date=$start;
89 $this->setSpan($span);
90 $arr = array_values($arr);
91 $this->setDates($arr, 1);
96 function getAverageTime($atid,$start,$end) {
97 $res = db_query_params ('SELECT avg((close_date-open_date)/(24*60*60)) AS avgtime
99 WHERE group_artifact_id=$1
101 AND open_date BETWEEN $2 AND $3',
105 return db_result($res,0,0);
108 function getOpenCount($atid,$start,$end) {
109 $res = db_query_params ('SELECT count(*)
113 AND open_date BETWEEN $2 AND $3',
117 return db_result($res,0,0);
120 function getStillOpenCount($atid,$end) {
121 $res = db_query_params ('SELECT count(*)
126 AND (close_date >= $3 OR close_date < 1 OR close_date is null)',
128 $end, // Yes, really.
130 return db_result($res,0,0);
133 function getPerAssignee($atid, $start, $end) {
134 $res = db_query_params('SELECT u.realname,count(*)
135 FROM artifact a, users u
136 WHERE a.group_artifact_id=$1
137 AND a.assigned_to=u.user_id
138 AND a.open_date BETWEEN $2 AND $3
146 function &getAverageTimeData() {
147 return $this->avgtime;
150 function &getOpenCountData() {
151 return $this->opencount;
154 function &getStillOpenCountData() {
155 return $this->stillopencount;
162 // c-file-style: "bsd"