3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'reporting/Report.class.php';
28 class ReportProjectTime extends Report {
30 function ReportProjectTime($group_id,$type,$start=0,$end=0) {
34 $start=mktime(0,0,0,date('m'),1,date('Y'));;
43 $this->setError('No User_id');
50 if (!$type || $type=='tasks') {
51 $res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours
52 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
53 WHERE pgl.group_project_id=pt.group_project_id
55 AND rtt.report_date BETWEEN $2 AND $3
56 AND rtt.project_task_id=pt.project_task_id
65 } elseif ($type=='category') {
67 $res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours
68 FROM rep_time_tracking rtt, rep_time_category rtc, project_task pt, project_group_list pgl
70 AND pgl.group_project_id=pt.group_project_id
71 AND rtt.project_task_id=pt.project_task_id
72 AND rtt.report_date BETWEEN $2 AND $3
73 AND rtt.time_code=rtc.time_code
74 GROUP BY rtc.category_name
80 // Percentage this user spent on a specific subproject
82 } elseif ($type=='subproject') {
84 $res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours
85 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
87 AND rtt.report_date BETWEEN $2 AND $3
88 AND rtt.project_task_id=pt.project_task_id
89 AND pt.group_project_id=pgl.group_project_id
90 GROUP BY pgl.project_name
100 $res = db_query_params ('SELECT u.realname, sum(rtt.hours) AS hours
101 FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
102 WHERE pgl.group_id=$1
103 AND rtt.report_date BETWEEN $2 AND $3
104 AND rtt.project_task_id=pt.project_task_id
105 AND pt.group_project_id=pgl.group_project_id
106 AND u.user_id=rtt.user_id
108 ORDER BY hours DESC',
114 $this->start_date=$start;
115 $this->end_date=$end;
117 if (!$res || db_error()) {
118 $this->setError('ReportUserAct:: '.db_error());
122 $this->labels = util_result_column_to_array($res,0);
123 $this->setData($res,1);
131 // c-file-style: "bsd"