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 ReportUserTime extends Report {
29 function ReportUserTime($user_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
53 WHERE rtt.user_id='$user_id'
54 AND rtt.report_date BETWEEN '$start' AND '$end'
55 AND rtt.project_task_id=pt.project_task_id
57 ORDER BY hours DESC");
62 } elseif ($type=='category') {
64 $res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS hours
65 FROM rep_time_tracking rtt, rep_time_category rtc
66 WHERE rtt.user_id='$user_id'
67 AND rtt.report_date BETWEEN '$start' AND '$end'
68 AND rtt.time_code=rtc.time_code
69 GROUP BY rtc.category_name
70 ORDER BY hours DESC");
73 // Percentage this user spent on a specific subproject
75 } elseif ($type=='subproject') {
77 $res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
78 FROM rep_time_tracking rtt, project_task pt, project_group_list pgl
79 WHERE rtt.user_id='$user_id'
80 AND rtt.report_date BETWEEN '$start' AND '$end'
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
84 ORDER BY hours DESC");
88 $this->start_date=$start;
91 if (!$res || db_error()) {
92 $this->setError('ReportUserAct:: '.db_error());
96 $this->labels = util_result_column_to_array($res,0);
97 $this->setData($res,1);
105 // c-file-style: "bsd"