-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathreport.php
170 lines (152 loc) · 6.19 KB
/
report.php
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
// report.php - Generate reports on various bug activities
// ------------------------------------------------------------------------
// Copyright (c) 2001 - 2004 The phpBugTracker Group
// ------------------------------------------------------------------------
// This file is part of phpBugTracker
//
// phpBugTracker 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.
//
// phpBugTracker 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 phpBugTracker; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ------------------------------------------------------------------------
// $Id: report.php,v 1.28 2007/09/16 03:39:16 brycen Exp $
include 'include.php';
function resolution_by_engineer($projectid = 0) {
global $db, $t, $restricted_projects, $perm, $QUERY;
// Start off our query
$querystring = $QUERY['report-resbyeng-1'];
$resfields = array(translate("Assigned To"), translate("Open"));
// Grab the resolutions from the database
$rs = $db->query($QUERY['report-resbyeng-2'] .
db_concat($QUERY['report-resbyeng-3'], 'resolution_id', $QUERY['report-resbyeng-4'], 'resolution_name', "'\"' ") .
$QUERY['report-resbyeng-5']);
while (list($fieldname, $countquery) = $rs->fetchRow(DB_FETCHMODE_ORDERED)) {
$resfields[] = $fieldname;
$querystring .= $countquery;
}
$resfields[] = translate("Total");
if ($projectid && is_numeric($projectid)) {
$projectquery = $QUERY['join-where'] . " project_id = $projectid";
} elseif (!$perm->have_perm('Admin')) {
$projectquery = $QUERY['join-where'] .
" project_id not in ($restricted_projects)";
} else {
$projectquery = '';
}
// $db->setOption('optimize', 'performance'); // For Oracle to do this loop //removed on PDO migration
$t->assign(array(
'resfields' => $resfields,
'developers' => $db->getAll(sprintf($QUERY['report-resbyeng-6'], $querystring, $projectquery))
));
// $db->setOption('optimize', 'portability'); //removed on PDO migration
$t->render('report.html.php', translate("Reporting"));
}
// @deprecated
function new_bugs_by_date($date_range) {
global $db, $t, $now;
include_once(JPGRAPH_PATH . 'jpgraph.php');
include_once(JPGRAPH_PATH . 'jpgraph_bar.php');
//include_once("jpgraph.php");
//include_once("jpgraph_bar.php");
$colors = array('red', 'cadetblue', 'gold', 'darkmagenta');
$graph = new Graph(450, 300);
$graph->SetShadow();
$graph->SetScale("textlin");
$graph->title->Set(translate("Bug Counts by Date"));
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->img->SetMargin(40, 140, 40, 80);
if ($date_range > 30) {
$graph->xaxis->SetTextTickInterval(14);
} elseif ($date_range > 14) {
$graph->xaxis->SetTextTickInterval(7);
} elseif ($date_range > 7) {
$graph->xaxis->SetTextTickInterval(2);
}
$dates = array();
$then = $now - (ONEDAY * $date_range);
// New bugs
$dates = $db->getCol("select created_date from " . TBL_BUG . " where created_date between $then and $now order by 1");
if ($date_range == 365) {
$date_format = 'M Y';
} else {
$date_format = 'j M';
for ($i = $date_range - 1; $i >= 0; $i--) {
$dates[date($date_format, ($now - (ONEDAY * $i)))] = 0.00000001;
}
}
foreach ($dates as $date) {
//$date = date($date_format, $date);
$dates[date($date_format, $date)] += 1;
}
foreach ($dates as $date => $count) {
#echo "$date:$count<br>";
$xlabel[] = $date;
$xvalue[] = $count;
}
$p1 = new BarPlot($xvalue);
$p1->SetLegend("Created");
$p1->SetColor("blue");
$p1->SetFillColor("blue");
#$p1->SetCenter();
$graph->xaxis->SetTickLabels($xlabel);
#$graph->xaxis->SetLabelAngle(90);
$graph->SetTickDensity(TICKD_SPARSE);
#$graph->yscale->SetGrace(50);
$graph->Add($p1);
// Resolutions
if (isset($_GET['resolutions'])) {
$color = 0;
foreach ($_GET['resolutions'] as $resolution) {
$stats = array(
'dates' => array(),
'labels' => array(),
'values' => array(),
'plot' => null);
if ($date_range == 365) {
$date_format = 'M Y';
} else {
$date_format = 'j M';
for ($i = $date_range - 1; $i >= 0; $i--) {
$stats['dates'][date($date_format, ($now - (ONEDAY * $i)))] = 0.00000001;
}
}
$dates = $db->getCol("select created_date from bug_history where changed_field = 'resolution' and new_value = '$resolution' and created_date between $then and $now order by 1");
foreach ($dates as $date) {
//$date = date($date_format, $date);
$stats['dates'][date($date_format, $date)] += 1;
}
foreach ($stats['dates'] as $date => $count) {
#echo "$date:$count<br>";
array_push($stats['labels'], $date);
array_push($stats['values'], $count);
}
$stats['plot'] = new BarPlot($stats['values']);
$stats['plot']->SetLegend($resolution);
$stats['plot']->SetColor($colors[$color]);
$stats['plot']->SetFillColor($colors[$color++]);
$graph->Add($stats['plot']);
}
}
$graph->Stroke();
}
$projectid = isset($_GET['projectid']) ? $_GET['projectid'] : 0;
if (isset($_GET['op'])) {
switch ($_GET['op']) {
case 'bugsbydate' :
new_bugs_by_date(isset($_GET['date_range']) ? $_GET['date_range'] : 7);
break;
}
} else {
resolution_by_engineer($projectid);
}
//