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 ReportUserTime extends Report {
30 function ReportUserTime($user_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
54 AND rtt.report_date BETWEEN $2 AND $3
55 AND rtt.project_task_id=pt.project_task_id
64 } elseif ($type=='category') {
65 $res = db_query_params ('SELECT rtc.category_name, sum(rtt.hours) AS hours
66 FROM rep_time_tracking rtt, rep_time_category rtc
68 AND rtt.report_date BETWEEN $2 AND $3
69 AND rtt.time_code=rtc.time_code
70 GROUP BY rtc.category_name
76 // Percentage this user spent on a specific subproject
78 } elseif ($type=='subproject') {
79 $res = db_query_params ('SELECT pgl.project_name, sum(rtt.hours) AS hours
80 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
82 AND rtt.report_date BETWEEN $2 AND $3
83 AND rtt.project_task_id=pt.project_task_id
84 AND pt.group_project_id=pgl.group_project_id
85 GROUP BY pgl.project_name
92 $this->start_date=$start;
95 if (!$res || db_error()) {
96 $this->setError('ReportUserAct:: '.db_error());
100 $this->labels = util_result_column_to_array($res,0);
101 $this->setData($res,1);
109 // c-file-style: "bsd"