1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: toolspie_graph.php 4199 2005-03-27 21:04:58Z gsmet $
* @author Tim Perdue tim@gforge.org
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('pre.php');
require_once($sys_path_to_jpgraph.'/jpgraph.php');
require_once($sys_path_to_jpgraph.'/jpgraph_pie.php');
require_once($sys_path_to_jpgraph.'/jpgraph_pie3d.php');
require_once('common/reporting/Report.class');
require_once('common/reporting/report_utils.php');
session_require( array('group'=>$sys_stats_group) );
$datatype = getIntFromRequest('datatype');
$start = getIntFromRequest('start');
$end = getIntFromRequest('end');
//
// Create Report
//
$report=new Report();
//
// Check for error, such as license key problem
//
if ($report->isError()) {
echo $report->getErrorMessage();
exit;
}
if (!isset($datatype)) {
$datatype=1;
}
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if ($datatype < 5) {
$sql="SELECT g.group_name,count(*) AS count
FROM groups g, artifact_group_list agl, artifact a
WHERE g.group_id=agl.group_id
AND agl.group_artifact_id=a.group_artifact_id
AND a.open_date BETWEEN '$start' AND '$end'
AND agl.datatype='$datatype'
GROUP BY group_name
ORDER BY count DESC";
} elseif ($datatype == 5) {
$sql="SELECT g.group_name,count(*) AS count
FROM groups g, forum_group_list fgl, forum f
WHERE g.group_id=fgl.group_id
AND fgl.group_forum_id=f.group_forum_id
AND f.post_date BETWEEN '$start' AND '$end'
GROUP BY group_name
ORDER BY count DESC";
} elseif ($datatype == 6) {
$sql="SELECT g.group_name,count(*) AS count
FROM groups g, project_group_list pgl, project_task pt
WHERE g.group_id=pgl.group_id
AND pgl.group_project_id=pt.group_project_id
AND pt.start_date BETWEEN '$start' AND '$end'
GROUP BY group_name
ORDER BY count DESC";
} else {
$sql="SELECT g.group_name,count(*) AS count
FROM groups g, frs_package fp, frs_release fr, frs_file ff, frs_dlstats_file fdf
WHERE g.group_id=fp.group_id
AND fp.package_id=fr.package_id
AND fr.release_id=ff.release_id
AND ff.file_id=fdf.file_id
AND (((fdf.month > '". date('Ym',$start) ."') OR (fdf.month = '". date('Ym',$start) ."' AND fdf.day >= '". date('d',$start) ."'))
AND ((fdf.month < '". date('Ym',$end) ."') OR (fdf.month = '". date('Ym',$end) ."' AND fdf.day < '". date('d',$end) ."')))
GROUP BY group_name
ORDER BY count DESC";
}
//echo $sql;
//exit;
$res=db_query($sql);
if (db_error()) {
exit_error('Error',db_error());
}
// Create the graph. These two calls are always required
$graph = new PieGraph(640, 480,"auto");
//$graph->SetMargin(50,10,35,50);
$arr[1]='Bugs';
$arr[2]='Support Requests';
$arr[3]='Patches';
$arr[4]='Feature Requests';
$arr[0]='Other Trackers';
$arr[5]='Forum Messages';
$arr[6]='Tasks';
$arr[7]='Downloads';
$graph->title->Set($arr[$datatype]." By Project (".date('m/d/Y',$start) ."-". date('m/d/Y',$end) .")");
$graph->subtitle->Set($sys_name);
// Create the tracker open plot
report_pie_arr(util_result_column_to_array($res,0), util_result_column_to_array($res,1));
$p1 = new PiePlot3D($pie_vals);
$p1->ExplodeSlice (0);
$p1->SetLegends($pie_labels);
$graph->Add( $p1);
// Display the graph
$graph->Stroke();
?>
|