5 * Copyright 2004 (c) GForge LLC
8 * @author Tim Perdue tim@gforge.org
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('common/reporting/Report.class.php');
30 class ReportProjectTime extends Report {
32 function ReportProjectTime($group_id,$type,$start=0,$end=0) {
36 $start=mktime(0,0,0,date('m'),1,date('Y'));;
45 $this->setError('No User_id');
52 if (!$type || $type=='tasks') {
54 $res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours
55 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
56 WHERE pgl.group_project_id=pt.group_project_id
57 AND pgl.group_id='$group_id'
58 AND rtt.report_date BETWEEN '$start' AND '$end'
59 AND rtt.project_task_id=pt.project_task_id
61 ORDER BY hours DESC");
66 } elseif ($type=='category') {
68 $res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours
69 FROM rep_time_tracking rtt, rep_time_category rtc, project_task pt, project_group_list pgl
70 WHERE pgl.group_id='$group_id'
71 AND pgl.group_project_id=pt.group_project_id
72 AND rtt.project_task_id=pt.project_task_id
73 AND rtt.report_date BETWEEN '$start' AND '$end'
74 AND rtt.time_code=rtc.time_code
75 GROUP BY rtc.category_name
76 ORDER BY hours DESC");
79 // Percentage this user spent on a specific subproject
81 } elseif ($type=='subproject') {
83 $res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
84 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
85 WHERE pgl.group_id='$group_id'
86 AND rtt.report_date BETWEEN '$start' AND '$end'
87 AND rtt.project_task_id=pt.project_task_id
88 AND pt.group_project_id=pgl.group_project_id
89 GROUP BY pgl.project_name
90 ORDER BY hours DESC");
97 $res=db_query("SELECT u.realname, sum(rtt.hours) AS hours
98 FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
99 WHERE pgl.group_id='$group_id'
100 AND rtt.report_date BETWEEN '$start' AND '$end'
101 AND rtt.project_task_id=pt.project_task_id
102 AND pt.group_project_id=pgl.group_project_id
103 AND u.user_id=rtt.user_id
105 ORDER BY hours DESC");
109 $this->start_date=$start;
110 $this->end_date=$end;
112 if (!$res || db_error()) {
113 $this->setError('ReportUserAct:: '.db_error());
117 $this->labels = util_result_column_to_array($res,0);
118 $this->setData($res,1);