5 * Copyright 2004 (c) GForge LLC
7 * @author Tim Perdue tim@gforge.org
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require_once('../env.inc.php');
28 require_once $gfwww.'include/pre.php';
29 require_once(forge_get_config('jpgraph_path').'/jpgraph.php');
30 require_once(forge_get_config('jpgraph_path').'/jpgraph_pie.php');
31 require_once(forge_get_config('jpgraph_path').'/jpgraph_pie3d.php');
32 require_once $gfcommon.'reporting/Report.class.php';
33 require_once $gfcommon.'reporting/report_utils.php';
35 session_require( array('group'=>forge_get_config('stats_group')) );
43 // Check for error, such as license key problem
45 if ($report->isError()) {
46 echo $report->getErrorMessage();
50 $datatype = getIntFromRequest('datatype');
51 $start = getIntFromRequest('start');
52 $end = getIntFromRequest('end');
54 if (!isset($datatype)) {
59 $start=mktime(0,0,0,date('m'),1,date('Y'));;
69 $res = db_query_params ('SELECT g.group_name,count(*) AS count
70 FROM groups g, artifact_group_list agl, artifact a
71 WHERE g.group_id=agl.group_id
72 AND agl.group_artifact_id=a.group_artifact_id
73 AND a.open_date BETWEEN $1 AND $2
80 } elseif ($datatype == 5) {
81 $res = db_query_params ('SELECT g.group_name,count(*) AS count
82 FROM groups g, forum_group_list fgl, forum f
83 WHERE g.group_id=fgl.group_id
84 AND fgl.group_forum_id=f.group_forum_id
85 AND f.post_date BETWEEN $1 AND $2
90 } elseif ($datatype == 6) {
91 $res = db_query_params ('SELECT g.group_name,count(*) AS count
92 FROM groups g, project_group_list pgl, project_task pt
93 WHERE g.group_id=pgl.group_id
94 AND pgl.group_project_id=pt.group_project_id
95 AND pt.start_date BETWEEN $1 AND $2
101 $res = db_query_params ('SELECT g.group_name,count(*) AS count
102 FROM groups g, frs_package fp, frs_release fr, frs_file ff, frs_dlstats_file fdf
103 WHERE g.group_id=fp.group_id
104 AND fp.package_id=fr.package_id
105 AND fr.release_id=ff.release_id
106 AND ff.file_id=fdf.file_id
107 AND (((fdf.month > $1) OR (fdf.month = $1 AND fdf.day >= $2))
108 AND ((fdf.month < $3) OR (fdf.month = $3 AND fdf.day < $4)))
110 ORDER BY count DESC',
111 array (date('Ym',$start),
122 exit_error('Error',db_error());
125 // Create the graph. These two calls are always required
126 $graph = new PieGraph(640, 480,"auto");
127 //$graph->SetMargin(50,10,35,50);
130 $arr[2]='Support Requests';
132 $arr[4]='Feature Requests';
133 $arr[0]='Other Trackers';
134 $arr[5]='Forum Messages';
137 $graph->title->Set($arr[$datatype]." By Project (".date('m/d/Y',$start) ."-". date('m/d/Y',$end) .")");
138 $graph->subtitle->Set(forge_get_config ('forge_name'));
140 // Create the tracker open plot
141 report_pie_arr(util_result_column_to_array($res,0), util_result_column_to_array($res,1));
143 $p1 = new PiePlot3D($pie_vals);
144 $p1->ExplodeSlice (0);
145 $p1->SetLegends($pie_labels);
153 // c-file-style: "bsd"