3 * FusionForge reporting system
5 * Copyright 2003-2004, Tim Perdue/GForge, LLC
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'reporting/Report.class.php';
26 class ReportUserTime extends Report {
28 function ReportUserTime($user_id,$type,$start=0,$end=0) {
32 $start=mktime(0,0,0,date('m'),1,date('Y'));;
41 $this->setError('No User_id');
48 if (!$type || $type=='tasks') {
49 $res = db_query_params ('SELECT pt.summary,sum(rtt.hours) AS hours
50 FROM rep_time_tracking rtt, project_task pt
52 AND rtt.report_date BETWEEN $2 AND $3
53 AND rtt.project_task_id=pt.project_task_id
62 } elseif ($type=='category') {
63 $res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours
64 FROM rep_time_tracking rtt, rep_time_category rtc
66 AND rtt.report_date BETWEEN $2 AND $3
67 AND rtt.time_code=rtc.time_code
68 GROUP BY rtc.category_name
74 // Percentage this user spent on a specific subproject
76 } elseif ($type=='subproject') {
77 $res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours
78 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
80 AND rtt.report_date BETWEEN $2 AND $3
81 AND rtt.project_task_id=pt.project_task_id
82 AND pt.group_project_id=pgl.group_project_id
83 GROUP BY pgl.project_name
90 $this->start_date=$start;
93 if (!$res || db_error()) {
94 $this->setError('ReportUserAct:: '.db_error());
98 $this->labels = util_result_column_to_array($res,0);
99 $this->setData($res,1);
107 // c-file-style: "bsd"