5 * Copyright 2003-2004 (c) GForge LLC
6 * http://fusionforge.org
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('../env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require_once(forge_get_config('jpgraph_path').'/jpgraph.php');
27 require_once(forge_get_config('jpgraph_path').'/jpgraph_pie.php');
28 require_once(forge_get_config('jpgraph_path').'/jpgraph_pie3d.php');
29 require_once $gfcommon.'reporting/Report.class.php';
30 require_once $gfcommon.'reporting/report_utils.php';
31 require_once $gfwww.'tracker/include/ArtifactTypeHtml.class.php';
33 session_require_global_perm ('forge_stats', 'read') ;
41 // Check for error, such as license key problem
43 if ($report->isError()) {
44 exit_error($report->getErrorMessage());
47 $area = getStringFromRequest('area');
48 $start = getIntFromRequest('start');
49 $end = getIntFromRequest('end');
56 $start=mktime(0,0,0,date('m'),1,date('Y'));;
65 if ($area == 'category') {
66 $res = db_query_params ('SELECT ac.category_name,count(*)
67 FROM artifact a, artifact_category ac
68 WHERE a.group_artifact_id=$1
69 AND a.category_id=ac.id
70 AND a.open_date BETWEEN $2 AND $3
71 GROUP BY category_name',
75 } elseif ($area == 'group') {
76 $res = db_query_params ('SELECT ag.group_name,count(*)
77 FROM artifact a, artifact_group ag
78 WHERE a.group_artifact_id=$1
79 AND a.artifact_group_id=ag.id
80 AND a.open_date BETWEEN $2 AND $3
85 } elseif ($area == 'resolution') {
86 $res = db_query_params ('SELECT ar.resolution_name,count(*)
87 FROM artifact a, artifact_resolution ar
88 WHERE a.group_artifact_id=$1
89 AND a.resolution_id=ar.id
90 AND a.open_date BETWEEN $2 AND $3
91 GROUP BY resolution_name',
97 $res = db_query_params ('SELECT u.realname,count(*)
98 FROM artifact a, users u
99 WHERE a.group_artifact_id=$1
100 AND a.assigned_to=u.user_id
101 AND a.open_date BETWEEN $2 AND $3
109 exit_error(db_error());
112 // Create the graph. These two calls are always required
113 $graph = new PieGraph(640, 480,"auto");
114 //$graph->SetMargin(50,10,35,50);
117 $arr['category']='By Category';
118 $arr['group']='By Group';
119 $arr['resolution']='By Resolution';
120 $arr['assignee']='By Assignee';
121 $graph->title->Set($arr[$area]." (".date('m/d/Y',$start) ."-". date('m/d/Y',$end) .")");
122 $graph->subtitle->Set(forge_get_config ('forge_name'));
124 // Create the tracker open plot
125 report_pie_arr(util_result_column_to_array($res,0), util_result_column_to_array($res,1));
127 $p1 = new PiePlot3D($pie_vals);
128 $p1->ExplodeSlice (0);
129 $p1->SetLegends($pie_labels);