3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2 of the License,
12 * or (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FusionForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 require_once $gfcommon.'reporting/Report.class.php';
27 class ReportProjectTime extends Report {
29 function ReportProjectTime($group_id,$type,$start=0,$end=0) {
33 $start=mktime(0,0,0,date('m'),1,date('Y'));;
42 $this->setError('No User_id');
49 if (!$type || $type=='tasks') {
51 $res=db_query("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
54 AND pgl.group_id='$group_id'
55 AND rtt.report_date BETWEEN '$start' AND '$end'
56 AND rtt.project_task_id=pt.project_task_id
58 ORDER BY hours DESC");
63 } elseif ($type=='category') {
65 $res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours
66 FROM rep_time_tracking rtt, rep_time_category rtc, project_task pt, project_group_list pgl
67 WHERE pgl.group_id='$group_id'
68 AND pgl.group_project_id=pt.group_project_id
69 AND rtt.project_task_id=pt.project_task_id
70 AND rtt.report_date BETWEEN '$start' AND '$end'
71 AND rtt.time_code=rtc.time_code
72 GROUP BY rtc.category_name
73 ORDER BY hours DESC");
76 // Percentage this user spent on a specific subproject
78 } elseif ($type=='subproject') {
80 $res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
81 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
82 WHERE pgl.group_id='$group_id'
83 AND rtt.report_date BETWEEN '$start' AND '$end'
84 AND rtt.project_task_id=pt.project_task_id
85 AND pt.group_project_id=pgl.group_project_id
86 GROUP BY pgl.project_name
87 ORDER BY hours DESC");
94 $res=db_query("SELECT u.realname, sum(rtt.hours) AS hours
95 FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
96 WHERE pgl.group_id='$group_id'
97 AND rtt.report_date BETWEEN '$start' AND '$end'
98 AND rtt.project_task_id=pt.project_task_id
99 AND pt.group_project_id=pgl.group_project_id
100 AND u.user_id=rtt.user_id
102 ORDER BY hours DESC");
106 $this->start_date=$start;
107 $this->end_date=$end;
109 if (!$res || db_error()) {
110 $this->setError('ReportUserAct:: '.db_error());
114 $this->labels = util_result_column_to_array($res,0);
115 $this->setData($res,1);
123 // c-file-style: "bsd"