Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / summary_page.php
blobc7f1d9c9d9e5ffd5c7f2485e7bb7f4760826ac5a
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses core.php
24 * @uses access_api.php
25 * @uses authentication_api.php
26 * @uses config_api.php
27 * @uses constant_inc.php
28 * @uses database_api.php
29 * @uses gpc_api.php
30 * @uses helper_api.php
31 * @uses html_api.php
32 * @uses lang_api.php
33 * @uses print_api.php
34 * @uses summary_api.php
35 * @uses user_api.php
38 require_once( 'core.php' );
39 require_api( 'access_api.php' );
40 require_api( 'authentication_api.php' );
41 require_api( 'config_api.php' );
42 require_api( 'constant_inc.php' );
43 require_api( 'database_api.php' );
44 require_api( 'gpc_api.php' );
45 require_api( 'helper_api.php' );
46 require_api( 'html_api.php' );
47 require_api( 'lang_api.php' );
48 require_api( 'print_api.php' );
49 require_api( 'summary_api.php' );
50 require_api( 'user_api.php' );
52 $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
54 # Override the current page to make sure we get the appropriate project-specific configuration
55 $g_project_override = $f_project_id;
57 access_ensure_project_level( config_get( 'view_summary_threshold' ) );
59 $t_user_id = auth_get_current_user_id();
61 $t_project_ids = user_get_all_accessible_projects( $t_user_id, $f_project_id);
62 $specific_where = helper_project_specific_where( $f_project_id, $t_user_id);
64 $t_bug_table = db_get_table( 'bug' );
65 $t_history_table = db_get_table( 'bug_history' );
67 $t_resolved = config_get( 'bug_resolved_status_threshold' );
68 # the issue may have passed through the status we consider resolved
69 # (e.g., bug is CLOSED, not RESOLVED). The linkage to the history field
70 # will look up the most recent 'resolved' status change and return it as well
71 $query = "SELECT b.id, b.date_submitted, b.last_updated, MAX(h.date_modified) as hist_update, b.status
72 FROM $t_bug_table b LEFT JOIN $t_history_table h
73 ON b.id = h.bug_id AND h.type=0 AND h.field_name='status' AND h.new_value=" . db_param() . "
74 WHERE b.status >=" . db_param() . " AND $specific_where
75 GROUP BY b.id, b.status, b.date_submitted, b.last_updated
76 ORDER BY b.id ASC";
77 $result = db_query_bound( $query, Array( $t_resolved, $t_resolved ) );
78 $bug_count = db_num_rows( $result );
80 $t_bug_id = 0;
81 $t_largest_diff = 0;
82 $t_total_time = 0;
83 for ($i=0;$i<$bug_count;$i++) {
84 $row = db_fetch_array( $result );
85 $t_date_submitted = $row['date_submitted'];
86 $t_id = $row['id'];
87 $t_status = $row['status'];
88 if ( $row['hist_update'] !== NULL ) {
89 $t_last_updated = $row['hist_update'];
90 } else {
91 $t_last_updated = $row['last_updated'];
94 if ($t_last_updated < $t_date_submitted) {
95 $t_last_updated = 0;
96 $t_date_submitted = 0;
99 $t_diff = $t_last_updated - $t_date_submitted;
100 $t_total_time = $t_total_time + $t_diff;
101 if ( $t_diff > $t_largest_diff ) {
102 $t_largest_diff = $t_diff;
103 $t_bug_id = $row['id'];
106 if ( $bug_count < 1 ) {
107 $bug_count = 1;
109 $t_average_time = $t_total_time / $bug_count;
111 $t_largest_diff = number_format( $t_largest_diff / SECONDS_PER_DAY, 2 );
112 $t_total_time = number_format( $t_total_time / SECONDS_PER_DAY, 2 );
113 $t_average_time = number_format( $t_average_time / SECONDS_PER_DAY, 2 );
115 $t_orct_arr = preg_split( '/[\)\/\(]/', lang_get( 'orct' ), -1, PREG_SPLIT_NO_EMPTY );
117 $t_orcttab = "";
118 foreach ( $t_orct_arr as $t_orct_s ) {
119 $t_orcttab .= '<td class="right">';
120 $t_orcttab .= $t_orct_s;
121 $t_orcttab .= '</td>';
124 html_page_top( lang_get( 'summary_link' ) );
127 <br />
128 <?php
129 print_summary_menu( 'summary_page.php' );
130 print_summary_submenu(); ?>
131 <br />
132 <table class="width100" cellspacing="1">
133 <tr>
134 <td class="form-title" colspan="2">
135 <?php echo lang_get( 'summary_title' ) ?>
136 </td>
137 </tr>
138 <tr valign="top">
139 <td width="50%">
140 <?php # PROJECT #
141 if ( 1 < count( $t_project_ids ) ) { ?>
142 <table class="width100" cellspacing="1">
143 <tr>
144 <td class="form-title" colspan="1">
145 <?php echo lang_get( 'by_project' ) ?>
146 </td>
147 <?php echo $t_orcttab ?>
148 </tr>
149 <?php summary_print_by_project(); ?>
150 </table>
152 <br />
153 <?php } ?>
155 <table class="width100" cellspacing="1">
156 <tr>
157 <td class="form-title" colspan="1">
158 <?php echo lang_get( 'by_status' ) ?>
159 </td>
160 <?php echo $t_orcttab ?>
161 </tr>
162 <?php summary_print_by_enum( 'status' ) ?>
163 </table>
165 <br />
167 <table class="width100" cellspacing="1">
168 <tr>
169 <td class="form-title" colspan="1">
170 <?php echo lang_get( 'by_severity' ) ?>
171 </td>
172 <?php echo $t_orcttab ?>
173 </tr>
174 <?php summary_print_by_enum( 'severity' ) ?>
175 </table>
177 <br />
179 <table class="width100" cellspacing="1">
180 <tr>
181 <td class="form-title" colspan="1">
182 <?php echo lang_get( 'by_category' ) ?>
183 </td>
184 <?php echo $t_orcttab ?>
185 </tr>
186 <?php summary_print_by_category() ?>
187 </table>
189 <br />
191 <table class="width100">
192 <tr>
193 <td class="form-title" colspan="5">
194 <?php echo lang_get( 'time_stats' ) ?>
195 </td>
196 </tr>
197 <tr class="row-1">
198 <td width="50%">
199 <?php echo lang_get( 'longest_open_bug' ) ?>
200 </td>
201 <td width="50%">
202 <?php
203 if ($t_bug_id>0) {
204 print_bug_link( $t_bug_id );
207 </td>
208 </tr>
209 <tr class="row-2">
210 <td>
211 <?php echo lang_get( 'longest_open' ) ?>
212 </td>
213 <td>
214 <?php echo $t_largest_diff ?>
215 </td>
216 </tr>
217 <tr class="row-1">
218 <td>
219 <?php echo lang_get( 'average_time' ) ?>
220 </td>
221 <td>
222 <?php echo $t_average_time ?>
223 </td>
224 </tr>
225 <tr class="row-2">
226 <td>
227 <?php echo lang_get( 'total_time' ) ?>
228 </td>
229 <td>
230 <?php echo $t_total_time ?>
231 </td>
232 </tr>
233 </table>
235 <br />
237 <table class="width100" cellspacing="1">
238 <tr>
239 <td class="form-title" colspan="1">
240 <?php echo lang_get( 'developer_stats' ) ?>
241 </td>
242 <?php echo $t_orcttab ?>
243 </tr>
244 <?php summary_print_by_developer() ?>
245 </table>
246 </td>
250 <td width="50%">
251 <table class="width100" cellspacing="1">
252 <tr>
253 <td class="form-title"><?php echo lang_get( 'by_date' ); ?></td>
254 <td class="right"><?php echo lang_get( 'opened' ); ?></td>
255 <td class="right"><?php echo lang_get( 'resolved' ); ?></td>
256 <td class="right"><?php echo lang_get( 'balance' ); ?></td>
257 </tr>
258 <?php summary_print_by_date( config_get( 'date_partitions' ) ) ?>
259 </table>
261 <br />
263 <table class="width100" cellspacing="1">
264 <tr>
265 <td class="form-title" width="86%"><?php echo lang_get( 'most_active' ); ?></td>
266 <td class="right" width="14%"><?php echo lang_get( 'score' ); ?></td>
267 </tr>
268 <?php summary_print_by_activity() ?>
269 </table>
271 <br />
273 <table class="width100" cellspacing="1">
274 <tr>
275 <td class="form-title" width="86%"><?php echo lang_get( 'longest_open' ); ?></td>
276 <td class="right" width="14%"><?php echo lang_get( 'days' ); ?></td>
277 </tr>
278 <?php summary_print_by_age() ?>
279 </table>
281 <br />
283 <table class="width100" cellspacing="1">
284 <tr>
285 <td class="form-title" colspan="1">
286 <?php echo lang_get( 'by_resolution' ) ?>
287 </td>
288 <?php echo $t_orcttab ?>
289 </tr>
290 <?php summary_print_by_enum( 'resolution' ) ?>
291 </table>
293 <br />
295 <table class="width100" cellspacing="1">
296 <tr>
297 <td class="form-title" colspan="1">
298 <?php echo lang_get( 'by_priority' ) ?>
299 </td>
300 <?php echo $t_orcttab ?>
301 </tr>
302 <?php summary_print_by_enum( 'priority' ) ?>
303 </table>
305 <br />
307 <table class="width100" cellspacing="1">
308 <tr>
309 <td class="form-title" colspan="1">
310 <?php echo lang_get( 'reporter_stats' ) ?>
311 </td>
312 <?php echo $t_orcttab ?>
313 </tr>
314 <?php summary_print_by_reporter() ?>
315 </table>
317 <br />
319 <table class="width100" cellspacing="1">
320 <tr>
321 <td class="form-title" colspan="1">
322 <?php echo lang_get( 'reporter_effectiveness' ) ?>
323 </td>
324 <td>
325 <?php echo lang_get( 'severity' ) ?>
326 </td>
327 <td>
328 <?php echo lang_get( 'errors' ) ?>
329 </td>
330 <td>
331 <?php echo lang_get( 'total' ) ?>
332 </td>
333 </tr>
334 <?php summary_print_reporter_effectiveness( config_get( 'severity_enum_string' ), config_get( 'resolution_enum_string' ) ) ?>
335 </table>
336 </td>
337 </tr>
339 <tr valign="top">
340 <td colspan="2">
341 <table class="width100" cellspacing="1">
342 <tr>
343 <td class="form-title" colspan="1">
344 <?php echo lang_get( 'reporter_by_resolution' ) ?>
345 </td>
346 <?php
347 $t_resolutions = MantisEnum::getValues( config_get( 'resolution_enum_string' ) );
349 foreach ( $t_resolutions as $t_resolution ) {
350 echo '<td>', get_enum_element( 'resolution', $t_resolution ), '</td>';
353 echo '<td>', lang_get( 'percentage_errors' ), '</td>';
355 </tr>
356 <?php summary_print_reporter_resolution( config_get( 'resolution_enum_string' ) ) ?>
357 </table>
358 </td>
359 </tr>
361 <tr valign="top">
362 <td colspan="2">
363 <table class="width100" cellspacing="1">
364 <tr>
365 <td class="form-title" colspan="1">
366 <?php echo lang_get( 'developer_by_resolution' ) ?>
367 </td>
368 <?php
369 $t_resolutions = MantisEnum::getValues( config_get( 'resolution_enum_string' ) );
371 foreach ( $t_resolutions as $t_resolution ) {
372 echo '<td>', get_enum_element( 'resolution', $t_resolution ), '</td>';
375 echo '<td>', lang_get( 'percentage_fixed' ), '</td>';
377 </tr>
378 <?php summary_print_developer_resolution( config_get( 'resolution_enum_string' ) ) ?>
379 </table>
380 </td>
381 </tr>
382 </table>
384 <?php
385 html_page_bottom();