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 ReportSiteTime extends Report {
30 function ReportSiteTime($type,$start=0,$end=0) {
34 $start=mktime(0,0,0,date('m'),1,date('Y'));;
45 if (!$type || $type=='tasks') {
46 $res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours
47 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
48 WHERE pgl.group_project_id=pt.group_project_id
49 AND rtt.report_date BETWEEN $1 AND $2
50 AND rtt.project_task_id=pt.project_task_id
58 } elseif ($type=='category') {
59 $res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours
60 FROM rep_time_tracking rtt, rep_time_category rtc
61 WHERE rtt.report_date BETWEEN $1 AND $2
62 AND rtt.time_code=rtc.time_code
63 GROUP BY rtc.category_name
68 // Percentage this user spent on a specific subproject
70 } elseif ($type=='subproject') {
72 $res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours
73 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
74 WHERE rtt.report_date BETWEEN $1 AND $2
75 AND rtt.project_task_id=pt.project_task_id
76 AND pt.group_project_id=pgl.group_project_id
77 GROUP BY pgl.project_name
83 $res = db_query_params ('SELECT u.realname, sum(rtt.hours) AS hours
84 FROM users u, rep_time_tracking rtt, project_task pt, project_group_list pgl
85 WHERE rtt.report_date BETWEEN $1 AND $2
86 AND u.user_id=rtt.user_id
93 $this->start_date=$start;
96 if (!$res || db_error()) {
97 $this->setError('ReportUserAct:: '.db_error());
101 $this->labels = util_result_column_to_array($res,0);
102 $this->setData($res,1);
110 // c-file-style: "bsd"