View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0007024 | mantisbt | customization | public | 2006-05-04 15:33 | 2013-03-13 06:17 |
| Reporter | papaganoush | Assigned To | |||
| Priority | normal | Severity | feature | Reproducibility | always |
| Status | new | Resolution | open | ||
| Summary | 0007024: New Report for Summary Page | ||||
| Description | This is a new report for the Sumary page. This report is a total count of defects by catagory. It also has three totals (total open, total closed and total) the reason for the three totals is that in our implementation there might be a defect that is no longer under development but not yet released to the clients. These defects are listed as "closed" but form the client's perspective they are still "open". I have uploaded a screen capture and the required files to add the report to the summary page. | ||||
| Tags | No tags attached. | ||||
| Attached Files | summary_page.php.txt (12,353 bytes)
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: summary_page.php,v 1.45 2005/04/27 02:20:13 thraxisp Exp $
# --------------------------------------------------------
?>
<?php
require_once( 'core.php' );
$t_core_path = config_get( 'core_path' );
require_once( $t_core_path.'summary_api.php' );
?>
<?php
access_ensure_project_level( config_get( 'view_summary_threshold' ) );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
if ( ALL_PROJECTS == $t_project_id ) {
$t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
foreach ( $t_topprojects as $t_project ) {
$t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
}
$t_project_ids = array_unique( $t_project_ids );
} else {
$t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $t_project_id );
array_unshift( $t_project_ids, $t_project_id );
}
$t_project_ids = array_map( 'db_prepare_int', $t_project_ids );
if ( 0 == count( $t_project_ids ) ) {
$specific_where = ' 1 <> 1';
} elseif ( 1 == count( $t_project_ids ) ) {
$specific_where = ' project_id=' . $t_project_ids[0];
} else {
$specific_where = ' project_id IN (' . join( ',', $t_project_ids ) . ')';
}
$t_bug_table = config_get( 'mantis_bug_table' );
$t_history_table = config_get( 'mantis_bug_history_table' );
$t_clo_val = config_get( 'bug_resolved_status_threshold' );
$query = "SELECT id, date_submitted, last_updated, status
FROM $t_bug_table
WHERE $specific_where AND status>='$t_clo_val'";
$result = db_query( $query );
$bug_count = db_num_rows( $result );
$t_bug_id = 0;
$t_largest_diff = 0;
$t_total_time = 0;
for ($i=0;$i<$bug_count;$i++) {
$row = db_fetch_array( $result );
$t_date_submitted = db_unixtimestamp( $row['date_submitted'] );
$t_last_updated = db_unixtimestamp( $row['last_updated'] );
$t_id = $row['id'];
$t_status = $row['status'];
# if the status is not the closed value, it may have passed through the
# status we consider closed (e.g., bug is CLOSED, not RESOLVED)
# we should look for the last time it was RESOLVED in the history
if ( $t_status <> $t_clo_val ) {
$query2 = "SELECT date_modified
FROM " . $t_history_table . "
WHERE bug_id=$t_id AND type=" . NORMAL_TYPE .
" AND field_name='status' AND new_value='$t_clo_val'
ORDER BY date_modified DESC";
$result2 = db_query( $query2 );
if ( db_num_rows( $result2 ) >= 1 ) {
# if any were found, read the first (oldest) one and update the timestamp
$row2 = db_fetch_array( $result2 );
$t_last_updated = db_unixtimestamp( $row2['date_modified'] );
}
}
if ($t_last_updated < $t_date_submitted) {
$t_last_updated = 0;
$t_date_submitted = 0;
}
$t_diff = $t_last_updated - $t_date_submitted;
$t_total_time = $t_total_time + $t_diff;
if ( $t_diff > $t_largest_diff ) {
$t_largest_diff = $t_diff;
$t_bug_id = $row['id'];
}
}
if ( $bug_count < 1 ) {
$bug_count = 1;
}
$t_average_time = $t_total_time / $bug_count;
$t_largest_diff = number_format( $t_largest_diff / 86400, 2 );
$t_total_time = number_format( $t_total_time / 86400, 2 );
$t_average_time = number_format( $t_average_time / 86400, 2 );
$t_orct_arr = preg_split( '/[\)\/\(]/', lang_get( 'orct' ), -1, PREG_SPLIT_NO_EMPTY );
$t_orcttab = "";
foreach ( $t_orct_arr as $t_orct_s ) {
$t_orcttab .= '<td class="right">';
$t_orcttab .= ucwords( $t_orct_s );
$t_orcttab .= '</td>';
}
//Added 2005.03.24
if(config_get('display_totals'))
{
//Displays the header for the new tables
$t_nfaaifrcttt_arr = preg_split( '/[\)\/\(]/',lang_get( 'nfaaifrcttt' ), -1, PREG_SPLIT_NO_EMPTY );
$t_detail_tab = "";
foreach ( $t_nfaaifrcttt_arr as $t_nfaaifrcttt_s )
{
$t_detail_tab .= '<td class="right" width="8%">';
$t_detail_tab .= ucwords( $t_nfaaifrcttt_s );
$t_detail_tab .= '</td>';
}
}
else
{
//Displays the header for the new tables
$t_nfacafrci_arr = preg_split( '/[\)\/\(]/',lang_get( 'nfaairc' ), -1, PREG_SPLIT_NO_EMPTY );
$t_detail_tab = "";
foreach ( $t_nfacafrci_arr as $t_nfacafrci_s )
{
$t_detail_tab .= '<td class="right" width="10%">';
$t_detail_tab .= ucwords( $t_nfacafrci_s );
$t_detail_tab .= '</td>';
}
}
?>
<?php html_page_top1( lang_get( 'summary_link' ) ) ?>
<?php html_page_top2() ?>
<br />
<?php print_summary_menu( 'summary_page.php' ) ?>
<?php print_menu_graph() ?>
<br />
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="2">
<?php echo lang_get( 'summary_title' ) ?>
</td>
</tr>
<? //Added 2005.03.30 ?>
<? if(config_get( 'by_public_severity' ))
{
?>
<tr>
<td colspan="2">
<?php # Public By Severity # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_public_severity' ) ?>
</td>
<?php echo $t_detail_tab ?>
</tr>
<?php summary_print_details_by_severity(10,lang_get( 'by_public_severity' )) ?>
<?php //summary_print_public_by_severity() ?>
</table>
</td>
</tr>
<?
}
if(config_get( 'by_private_severity' ))
{
?>
<tr>
<td colspan="2">
<?php # Private By Severity # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_private_severity' ) ?>
</td>
<?php echo $t_detail_tab ?>
</tr>
<?php summary_print_details_by_severity(50,lang_get( 'by_private_severity' )) ?>
</table>
</td>
</tr>
<?
}
if(config_get( 'by_totals_severity' ))
{
?>
<tr>
<td colspan="2">
<?php # Totals by severity # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_totals_severity' ) ?>
</td>
<?php echo $t_detail_tab ?>
</tr>
<?php summary_print_details_by_severity(0,lang_get( 'by_totals_severity' )) ?>
</table>
</td>
</tr>
<? } ?>
<tr valign="top">
<td width="50%">
<?php # PROJECT # ?>
<?php if ( 1 < count( $t_project_ids ) ) { ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_project' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_project(); ?>
</table>
<br />
<?php } ?>
<?php # STATUS # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_status' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_enum( config_get( 'status_enum_string' ), 'status' ) ?>
</table>
<br />
<?php # SEVERITY # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_severity' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_enum( config_get( 'severity_enum_string' ), 'severity' ) ?>
</table>
<br />
<?php # CATEGORY # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_category' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_category() ?>
</table>
<br />
<?php # MISCELLANEOUS # ?>
<table class="width100">
<tr>
<td class="form-title" colspan="5">
<?php echo lang_get( 'time_stats' ) ?>
</td>
</tr>
<tr class="row-1">
<td width="50%">
<?php echo lang_get( 'longest_open_bug' ) ?>
</td>
<td width="50%">
<?php
if ($t_bug_id>0) {
print_bug_link( $t_bug_id );
}
?>
</td>
</tr>
<tr class="row-2">
<td>
<?php echo lang_get( 'longest_open' ) ?>
</td>
<td>
<?php echo $t_largest_diff ?>
</td>
</tr>
<tr class="row-1">
<td>
<?php echo lang_get( 'average_time' ) ?>
</td>
<td>
<?php echo $t_average_time ?>
</td>
</tr>
<tr class="row-2">
<td>
<?php echo lang_get( 'total_time' ) ?>
</td>
<td>
<?php echo $t_total_time ?>
</td>
</tr>
</table>
<br />
<?php # DEVELOPER # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'developer_stats' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_developer() ?>
</table>
</td>
<td width="50%">
<?php # DATE # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="5">
<?php echo lang_get( 'by_date' ) ?>
</td>
</tr>
<?php summary_print_by_date( config_get( 'date_partitions' ) ) ?>
</table>
<br />
<?php # RESOLUTION # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_resolution' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_enum( config_get( 'resolution_enum_string' ), 'resolution' ) ?>
</table>
<br />
<?php # PRIORITY # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'by_priority' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_enum( config_get( 'priority_enum_string' ), 'priority' ) ?>
</table>
<br />
<?php # REPORTER # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'reporter_stats' ) ?>
</td>
<?php echo $t_orcttab ?>
</tr>
<?php summary_print_by_reporter() ?>
</table>
<br />
<?php # REPORTER EFFECTIVENESS # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'reporter_effectiveness' ) ?>
</td>
<td>
<?php echo lang_get( 'severity' ) ?>
</td>
<td>
<?php echo lang_get( 'errors' ) ?>
</td>
<td>
<?php echo lang_get( 'total' ) ?>
</td>
</tr>
<?php summary_print_reporter_effectiveness( config_get( 'severity_enum_string' ), config_get( 'resolution_enum_string' ) ) ?>
</table>
</td>
</tr>
<tr valign="top">
<td colspan="2">
<?php # REPORTER / RESOLUTION # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'reporter_by_resolution' ) ?>
</td>
<?php
$t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
$enum_count = count( $t_arr );
for ($i=0;$i<$enum_count;$i++) {
print '<td>';
$t_s = explode_enum_arr( $t_arr[$i] );
$c_s[0] = db_prepare_string( $t_s[0] );
echo ucwords( get_enum_element( 'resolution', $c_s[0] ) );
print '</td>';
}
print '<td>';
print lang_get( 'percentage_errors' );
print '</td>';
?>
</tr>
<?php summary_print_reporter_resolution( config_get( 'resolution_enum_string' ) ) ?>
</table>
</td>
</tr>
<tr valign="top">
<td colspan="2">
<?php # DEVELOPER / RESOLUTION # ?>
<table class="width100" cellspacing="1">
<tr>
<td class="form-title" colspan="1">
<?php echo lang_get( 'developer_by_resolution' ) ?>
</td>
<?php
$t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
$enum_count = count( $t_arr );
for ($i=0;$i<$enum_count;$i++) {
print '<td>';
$t_s = explode_enum_arr( $t_arr[$i] );
$c_s[0] = db_prepare_string( $t_s[0] );
echo ucwords( get_enum_element( 'resolution', $c_s[0] ) );
print '</td>';
}
print '<td>';
print lang_get( 'percentage_fixed' );
print '</td>';
?>
</tr>
<?php summary_print_developer_resolution( config_get( 'resolution_enum_string' ) ) ?>
</table>
</td>
</tr>
</table>
<?php html_page_bottom1( __FILE__ ) ?>
summary_api.php.txt (39,603 bytes)
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2004 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: summary_api.php,v 1.39 2005/04/22 22:11:18 prichards Exp $
# --------------------------------------------------------
### Summary printing API ###
# --------------------
function summary_helper_print_row( $p_label, $p_open, $p_resolved, $p_closed, $p_total ) {
printf( '<tr %s>', helper_alternate_class() );
printf( '<td width="50%%">%s</td>', string_display( $p_label ) );
printf( '<td width="12%%" class="right">%s</td>', $p_open );
printf( '<td width="12%%" class="right">%s</td>', $p_resolved );
printf( '<td width="12%%" class="right">%s</td>', $p_closed );
printf( '<td width="12%%" class="right">%s</td>', $p_total );
print( '</tr>' );
}
# --------------------
# Used in summary reports
# Given the enum string this function prints out the summary
# for each enum setting
# The enum field name is passed in through $p_enum
function summary_print_by_enum( $p_enum_string, $p_enum ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_arr = explode_enum_string( $p_enum_string );
$enum_count = count( $t_arr );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$t_project_filter = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $t_project_filter ) {
return;
}
$query = "SELECT status, $p_enum
FROM $t_mantis_bug_table
WHERE $t_project_filter
ORDER BY $p_enum";
$result = db_query( $query );
$t_last_value = -1;
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
$t_resolved_val = config_get( 'bug_resolved_status_threshold' );
$t_closed_val = CLOSED;
while ( $row = db_fetch_array( $result ) ) {
if ( ( $row[$p_enum] != $t_last_value ) &&
( -1 != $t_last_value ) ) {
# Build up the hyperlinks to bug views
$t_bug_link = '';
switch ( $p_enum ) {
case 'status':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_status=' . $t_last_value;
break;
case 'severity':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_severity=' . $t_last_value;
break;
case 'resolution':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_resolution=' . $t_last_value;
break;
case 'priority':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_priority=' . $t_last_value;
break;
}
if ( !is_blank( $t_bug_link ) ) {
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( $t_last_value >= $t_resolved_val ) ) {
$t_bugs_open = '-';
}
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( ( $t_last_value < $t_resolved_val ) || ( $t_last_value >= $t_closed_val ) ) ) {
$t_bugs_resolved = '-';
}
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( $t_last_value < $t_closed_val ) ){
$t_bugs_closed = '-';
}
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
}
summary_helper_print_row( get_enum_element( $p_enum, $t_last_value), $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
}
$t_bugs_total++;
if ( $t_closed_val <= $row['status'] ) {
$t_bugs_closed++;
} else if ( $t_resolved_val <= $row['status'] ) {
$t_bugs_resolved++;
} else {
$t_bugs_open++;
}
$t_last_value = $row[$p_enum];
}
if ( 0 < $t_bugs_total ) {
# Build up the hyperlinks to bug views
$t_bug_link = '';
switch ( $p_enum ) {
case 'status':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_status=' . $t_last_value;
break;
case 'severity':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_severity=' . $t_last_value;
break;
case 'resolution':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_resolution=' . $t_last_value;
break;
case 'priority':
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_priority=' . $t_last_value;
break;
}
if ( !is_blank( $t_bug_link ) ) {
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( $t_last_value >= $t_resolved_val ) ) {
$t_bugs_open = '-';
}
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( ( $t_last_value < $t_resolved_val ) || ( $t_last_value >= $t_closed_val ) ) ) {
$t_bugs_resolved = '-';
}
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
} else {
if ( ( 'status' == $p_enum ) && ( $t_last_value < $t_closed_val ) ){
$t_bugs_closed = '-';
}
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
}
summary_helper_print_row( get_enum_element( $p_enum, $t_last_value), $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
}
}
# --------------------
# prints the bugs submitted in the last X days (default is 1 day) for the
# current project
function summary_bug_count_by_date( $p_time_length=1 ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$c_time_length = (int)$p_time_length;
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
$query = "SELECT COUNT(*)
FROM $t_mantis_bug_table
WHERE ".db_helper_compare_days(db_now(),"date_submitted","<= '$c_time_length'")." AND $specific_where";
$result = db_query( $query );
return db_result( $result, 0 );
}
# --------------------
# This function shows the number of bugs submitted in the last X days
# An array of integers representing days is passed in
function summary_print_by_date( $p_date_array ) {
$arr_count = count( $p_date_array );
for ($i=0;$i<$arr_count;$i++) {
$t_enum_count = summary_bug_count_by_date( $p_date_array[$i] );
$t_start_date = mktime( 0, 0, 0, date( 'm' ), ( date( 'd' ) - $p_date_array[$i] ), date( 'Y' ) );
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&do_filter_by_date=on&start_year=' . date( 'Y', $t_start_date ) . '&start_month=' . date( 'm', $t_start_date ) . '&start_day=' . date( 'd', $t_start_date ) . '&hide_status=">';
printf( '<tr %s>', helper_alternate_class() );
printf( '<td width="50%%">%s</td>', $p_date_array[$i] );
if ( 0 < $t_enum_count ) {
printf( '<td class="right">%s</td>', $t_bug_link . $t_enum_count . '</a>' );
} else {
printf( '<td class="right">%s</td>', $t_enum_count );
}
print( '</tr>' );
} # end for
}
# --------------------
# print bug counts by assigned to each developer
function summary_print_by_developer() {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_user_table = config_get( 'mantis_user_table' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
$query = "SELECT handler_id, status
FROM $t_mantis_bug_table
WHERE handler_id>0 AND $specific_where
ORDER BY handler_id";
$result = db_query( $query );
$t_last_handler = -1;
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
$t_resolved_val = RESOLVED;
$t_closed_val = CLOSED;
while ( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
if ( ($v_handler_id != $t_last_handler) && (-1 != $t_last_handler) ) {
$t_user = user_get_name( $t_last_handler );
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&handler_id=' . $t_last_handler;
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED .'">' . $t_bugs_resolved . '</a>';
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
}
$t_bugs_total++;
switch( $v_status ) {
case $t_resolved_val: $t_bugs_resolved++;
break;
case $t_closed_val: $t_bugs_closed++;
break;
default: $t_bugs_open++;
break;
}
$t_last_handler = $v_handler_id;
}
if ( 0 < $t_bugs_total ) {
$t_user = user_get_name( $t_last_handler );
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&handler_id=' . $t_last_handler;
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
}
}
# --------------------
# print bug counts by reporter id
function summary_print_by_reporter() {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_user_table = config_get( 'mantis_user_table' );
$t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
$query = "SELECT reporter_id, COUNT(*) as num
FROM $t_mantis_bug_table
WHERE $specific_where
GROUP BY reporter_id
ORDER BY num DESC";
$result = db_query( $query, $t_reporter_summary_limit );
while ( $row = db_fetch_array( $result ) ) {
$v_reporter_id = $row['reporter_id'];
$query = "SELECT status FROM $t_mantis_bug_table
WHERE reporter_id=$v_reporter_id
AND $specific_where";
$result2 = db_query( $query );
$last_reporter = -1;
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
$t_resolved_val = RESOLVED;
$t_closed_val = CLOSED;
while ( $row2 = db_fetch_array( $result2 ) ) {
$t_bugs_total++;
switch( $row2['status'] ) {
case $t_resolved_val: $t_bugs_resolved++;
break;
case $t_closed_val: $t_bugs_closed++;
break;
default: $t_bugs_open++;
break;
}
}
if ( 0 < $t_bugs_total ) {
$t_user = user_get_name( $v_reporter_id );
$result3 = db_query( $query );
$row3 = db_fetch_array( $result3 );
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&reporter_id=' . $v_reporter_id;
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
summary_helper_print_row( $t_user, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
}
}
}
# --------------------
# print a bug count per category
function summary_print_by_category() {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_project_table = config_get( 'mantis_project_table' );
$t_summary_category_include_project = config_get( 'summary_category_include_project' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
$query = "SELECT project_id, category, status
FROM $t_mantis_bug_table
WHERE category>'' AND $specific_where
ORDER BY project_id, category, status";
$result = db_query( $query );
$last_category = -1;
$last_project = -1;
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
$t_resolved_val = RESOLVED;
$t_closed_val = CLOSED;
while ( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
if ( ( $v_category != $last_category ) && ( $last_category != -1 ) ) {
$label = $last_category;
if ( ( ON == $t_summary_category_include_project ) && ( ALL_PROJECTS == $t_project_id ) ) {
$query = "SELECT name
FROM $t_mantis_project_table
WHERE id=$last_project";
$result2 = db_query( $query );
$row2 = db_fetch_array( $result2 );
$label = sprintf( '[%s] %s', $row2['name'], $label );
}
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_category=' . $last_category;
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
summary_helper_print_row( $label, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
$t_bugs_open = 0;
$t_bugs_resolved = 0;
$t_bugs_closed = 0;
$t_bugs_total = 0;
}
$t_bugs_total++;
switch( $v_status ) {
case $t_resolved_val:
$t_bugs_resolved++;
break;
case $t_closed_val:
$t_bugs_closed++;
break;
default:
$t_bugs_open++;
break;
}
$last_category = $v_category;
$last_project = $v_project_id;
}
if ( 0 < $t_bugs_total ) {
$label = $last_category;
if ( ( ON == $t_summary_category_include_project ) && ( ALL_PROJECTS == $t_project_id ) ) {
$query = "SELECT name
FROM $t_mantis_project_table
WHERE id=$last_project";
$result2 = db_query( $query );
$row2 = db_fetch_array( $result2 );
$label = sprintf( '[%s] %s', $row2['name'], $label );
}
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&show_category=' . $last_category;
if ( !is_blank( $t_bug_link ) ) {
if ( 0 < $t_bugs_open ) {
$t_bugs_open = $t_bug_link . '&hide_status=' . RESOLVED . '">' . $t_bugs_open . '</a>';
}
if ( 0 < $t_bugs_resolved ) {
$t_bugs_resolved = $t_bug_link . '&show_status=' . RESOLVED . '&hide_status=' . CLOSED . '">' . $t_bugs_resolved . '</a>';
}
if ( 0 < $t_bugs_closed ) {
$t_bugs_closed = $t_bug_link . '&show_status=' . CLOSED . '&hide_status=">' . $t_bugs_closed . '</a>';
}
if ( 0 < $t_bugs_total ) {
$t_bugs_total = $t_bug_link . '&hide_status=">' . $t_bugs_total . '</a>';
}
}
summary_helper_print_row( $label, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
}
}
# --------------------
# print bug counts by project
function summary_print_by_project( $p_projects = null, $p_level = 0, $p_cache = null ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_project_table = config_get( 'mantis_project_table' );
$t_project_id = helper_get_current_project();
if ( null == $p_projects ) {
if ( ALL_PROJECTS == $t_project_id ) {
$p_projects = current_user_get_accessible_projects();
} else {
$p_projects = Array( $t_project_id );
}
}
# Retrieve statistics one time to improve performance.
if ( null == $p_cache ) {
$query = "SELECT project_id, status, COUNT( status ) AS count
FROM $t_mantis_bug_table
GROUP BY project_id, status";
$result = db_query( $query );
$p_cache = Array();
$t_resolved_val = RESOLVED;
$t_closed_val = CLOSED;
while ( $row = db_fetch_array( $result ) ) {
extract( $row, EXTR_PREFIX_ALL, 'v' );
switch( $v_status ) {
case $t_resolved_val:
$p_cache[ $v_project_id ][ 'resolved' ] = $v_count;
break;
case $t_closed_val:
$p_cache[ $v_project_id ][ 'closed' ] = $v_count;
break;
default:
$p_cache[ $v_project_id ][ 'open' ] = $v_count;
break;
}
}
}
foreach ( $p_projects as $t_project ) {
$t_name = str_repeat( "� ", $p_level ) . project_get_name( $t_project );
$t_pdata = isset( $p_cache[ $t_project ] ) ? $p_cache[ $t_project ]
: array( 'open' => 0, 'resolved' => 0, 'closed' => 0 );
$t_bugs_open = isset( $t_pdata['open'] ) ? $t_pdata['open'] : 0;
$t_bugs_resolved = isset( $t_pdata['resolved'] ) ? $t_pdata['resolved'] : 0;
$t_bugs_closed = isset( $t_pdata['closed'] ) ? $t_pdata['closed'] : 0;
$t_bugs_total = $t_bugs_open + $t_bugs_resolved + $t_bugs_closed;
summary_helper_print_row( $t_name, $t_bugs_open, $t_bugs_resolved, $t_bugs_closed, $t_bugs_total );
$t_subprojects = current_user_get_accessible_subprojects( $t_project );
if ( count( $t_subprojects ) > 0 ) {
summary_print_by_project( $t_subprojects, $p_level + 1, $p_cache );
}
}
}
# --------------------
# Print developer / resolution report
function summary_print_developer_resolution( $p_resolution_enum_string ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_user_table = config_get( 'mantis_user_table' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
# Organise an array of resolution values to be used later
$t_res_arr = explode_enum_string( $p_resolution_enum_string );
$enum_res_count = count( $t_res_arr );
$c_res_s = array();
for ( $i = 0; $i < $enum_res_count; $i++ ) {
$t_res_s = explode_enum_arr( $t_res_arr[$i] );
$c_res_s[$i] = db_prepare_string( $t_res_s[0] );
}
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
$specific_where .= ' AND handler_id > 0';
# Get all of the bugs and split them up into an array
$query = "SELECT handler_id, resolution
FROM $t_mantis_bug_table
WHERE $specific_where";
$result = db_query( $query );
$t_handler_res_arr = array();
$t_arr = db_fetch_array( $result );
while ( $t_arr ) {
if ( !isset( $t_handler_res_arr[$t_arr['handler_id']] ) ) {
$t_handler_res_arr[$t_arr['handler_id']] = array();
$t_handler_res_arr[$t_arr['handler_id']]['total'] = 0;
}
if ( !isset( $t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']] ) ) {
$t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']] = 0;
}
$t_handler_res_arr[$t_arr['handler_id']][$t_arr['resolution']]++;
$t_handler_res_arr[$t_arr['handler_id']]['total']++;
$t_arr = db_fetch_array( $result );
}
$t_row_count = 0;
# We now have a multi dimensional array of users and resolutions, with the value of each resolution for each user
foreach( $t_handler_res_arr as $t_handler_id => $t_arr2 ) {
# Only print developers who have had at least one bug assigned to them. This helps
# prevent divide by zeroes, showing developers not on this project, and showing
# users that aren't actually developers...
if ( $t_arr2['total'] > 0 ) {
PRINT '<tr align="center" ' . helper_alternate_class( $t_row_count ) . '>';
$t_row_count++;
PRINT '<td>';
PRINT user_get_name( $t_handler_id );
PRINT '</td>';
# We need to track the percentage of bugs that are considered fix, as well as
# those that aren't considered bugs to begin with (when looking at %age)
$t_bugs_fixed = 0;
$t_bugs_notbugs = 0;
for ( $j = 0; $j < $enum_res_count; $j++ ) {
$res_bug_count = 0;
if ( isset( $t_arr2[$c_res_s[$j]] ) ) {
$res_bug_count = $t_arr2[$c_res_s[$j]];
}
PRINT '<td>';
if ( 0 < $res_bug_count ) {
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&handler_id=' . $t_handler_id;
$t_bug_link = $t_bug_link . '&show_resolution=' . $c_res_s[$j] . '">';
PRINT $t_bug_link . $res_bug_count . '</a>';
} else {
PRINT $res_bug_count;
}
PRINT '</td>';
# These resolutions are considered fixed
if ( FIXED == $c_res_s[$j] ) {
$t_bugs_fixed += $res_bug_count;
}
# These are not counted as bugs
else if ( (WONT_FIX == $c_res_s[$j] ) ||
(SUSPENDED == $c_res_s[$j] ) ||
(DUPLICATE == $c_res_s[$j] ) ||
(NOT_A_BUG == $c_res_s[$j] ) ) {
$t_bugs_notbugs += $res_bug_count;
}
}
$t_percent_fixed = 0;
if ( ( $t_arr2['total'] - $t_bugs_notbugs ) > 0 ) {
$t_percent_fixed = ( $t_bugs_fixed / ( $t_arr2['total'] - $t_bugs_notbugs ) );
}
PRINT '<td>';
printf( '% 1.0f%%', ( $t_percent_fixed * 100 ) );
PRINT '</td>';
}
}
}
# --------------------
# Print reporter / resolution report
function summary_print_reporter_resolution( $p_resolution_enum_string ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_user_table = config_get( 'mantis_user_table' );
$t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
# Organise an array of resolution values to be used later
$t_res_arr = explode_enum_string( $p_resolution_enum_string );
$enum_res_count = count( $t_res_arr );
$c_res_s = array();
for ( $i = 0; $i < $enum_res_count; $i++ ) {
$t_res_s = explode_enum_arr( $t_res_arr[$i] );
$c_res_s[$i] = db_prepare_string( $t_res_s[0] );
}
# Checking if it's a per project statistic or all projects
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
# Get all of the bugs and split them up into an array
$query = "SELECT reporter_id, resolution
FROM $t_mantis_bug_table
WHERE $specific_where";
$result = db_query( $query );
$t_reporter_res_arr = array();
$t_reporter_bugcount_arr = array();
$t_arr = db_fetch_array( $result );
while ( $t_arr ) {
if ( !isset( $t_reporter_res_arr[$t_arr['reporter_id']] ) ) {
$t_reporter_res_arr[$t_arr['reporter_id']] = array();
$t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
}
if ( !isset( $t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] ) ) {
$t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']] = 0;
}
$t_reporter_res_arr[$t_arr['reporter_id']][$t_arr['resolution']]++;
$t_reporter_bugcount_arr[$t_arr['reporter_id']]++;
$t_arr = db_fetch_array( $result );
}
# Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
arsort( $t_reporter_bugcount_arr );
$t_row_count = 0;
# We now have a multi dimensional array of users and resolutions, with the value of each resolution for each user
foreach( $t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs ) {
# Limit the number of reporters listed
if ( $t_row_count > $t_reporter_summary_limit ) {
break;
}
# Only print reporters who have reported at least one bug. This helps
# prevent divide by zeroes, showing reporters not on this project, and showing
# users that aren't actually reporters...
if ( $t_total_user_bugs > 0 ) {
$t_arr2 = $t_reporter_res_arr[$t_reporter_id];
PRINT '<tr align="center" ' . helper_alternate_class( $t_row_count ) . '>';
$t_row_count++;
PRINT '<td>';
PRINT user_get_name( $t_reporter_id );
PRINT '</td>';
# We need to track the percentage of bugs that are considered fix, as well as
# those that aren't considered bugs to begin with (when looking at %age)
$t_bugs_fixed = 0;
$t_bugs_notbugs = 0;
for ( $j = 0; $j < $enum_res_count; $j++ ) {
$res_bug_count = 0;
if ( isset( $t_arr2[$c_res_s[$j]] ) ) {
$res_bug_count = $t_arr2[$c_res_s[$j]];
}
PRINT '<td>';
if ( 0 < $res_bug_count ) {
$t_bug_link = '<a class="subtle" href="' . config_get( 'bug_count_hyperlink_prefix' ) . '&reporter_id=' . $t_reporter_id;
$t_bug_link = $t_bug_link . '&show_resolution=' . $c_res_s[$j] . '">';
PRINT $t_bug_link . $res_bug_count . '</a>';
} else {
PRINT $res_bug_count;
}
PRINT '</td>';
# These resolutions are considered fixed
if ( FIXED == $c_res_s[$j] ) {
$t_bugs_fixed += $res_bug_count;
}
# These are not counted as bugs
else if ( (UNABLE_TO_DUPLICATE == $c_res_s[$j] ) ||
(DUPLICATE == $c_res_s[$j] ) ||
(NOT_A_BUG == $c_res_s[$j] ) ) {
$t_bugs_notbugs += $res_bug_count;
}
}
$t_percent_errors = 0;
if ( $t_total_user_bugs > 0 ) {
$t_percent_errors = ( $t_bugs_notbugs / $t_total_user_bugs );
}
PRINT '<td>';
printf( '% 1.0f%%', ( $t_percent_errors * 100 ) );
PRINT '</td>';
PRINT '</tr>';
}
}
} # --------------------
# Print reporter effectiveness report
function summary_print_reporter_effectiveness( $p_severity_enum_string, $p_resolution_enum_string ) {
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
$t_mantis_user_table = config_get( 'mantis_user_table' );
$t_reporter_summary_limit = config_get( 'reporter_summary_limit' );
$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
# These are our overall "values" for severities and non-bug results
$t_severity_multiplier[FEATURE] = 1;
$t_severity_multiplier[TRIVIAL] = 2;
$t_severity_multiplier[TEXT] = 3;
$t_severity_multiplier[TWEAK] = 2;
$t_severity_multiplier[MINOR] = 5;
$t_severity_multiplier[MAJOR] = 8;
$t_severity_multiplier[CRASH] = 8;
$t_severity_multiplier[BLOCK] = 10;
$t_severity_multiplier['average'] = 5;
$t_notbug_multiplier[UNABLE_TO_DUPLICATE] = 2;
$t_notbug_multiplier[DUPLICATE] = 3;
$t_notbug_multiplier[NOT_A_BUG] = 5;
$t_sev_arr = explode_enum_string( $p_severity_enum_string );
$enum_sev_count = count( $t_sev_arr );
$c_sev_s = array();
for ( $i = 0; $i < $enum_sev_count; $i++ ) {
$t_sev_s = explode_enum_arr( $t_sev_arr[$i] );
$c_sev_s[$i] = db_prepare_string( $t_sev_s[0] );
}
$t_res_arr = explode_enum_string( $p_resolution_enum_string );
$enum_res_count = count( $t_res_arr );
$c_res_s = array();
for ( $i = 0; $i < $enum_res_count; $i++ ) {
$t_res_s = explode_enum_arr( $t_res_arr[$i] );
$c_res_s[$i] = db_prepare_string( $t_res_s[0] );
}
# Checking if it's a per project statistic or all projects
$specific_where = helper_project_specific_where( $t_project_id );
if ( ' 1<>1' == $specific_where ) {
return;
}
# Get all of the bugs and split them up into an array
$query = "SELECT reporter_id, resolution, severity
FROM $t_mantis_bug_table
WHERE $specific_where";
$result = db_query( $query );
$t_reporter_ressev_arr = array();
$t_reporter_bugcount_arr = array();
$t_arr = db_fetch_array( $result );
while ( $t_arr ) {
if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']] ) ) {
$t_reporter_ressev_arr[$t_arr['reporter_id']] = array();
$t_reporter_bugcount_arr[$t_arr['reporter_id']] = 0;
}
if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] ) ) {
$t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']] = array();
$t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total'] = 0;
}
if ( !isset( $t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] ) ) {
$t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']] = 0;
}
$t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']][$t_arr['resolution']]++;
$t_reporter_ressev_arr[$t_arr['reporter_id']][$t_arr['severity']]['total']++;
$t_reporter_bugcount_arr[$t_arr['reporter_id']]++;
$t_arr = db_fetch_array( $result );
}
# Sort our total bug count array so that the reporters with the highest number of bugs are listed first,
arsort( $t_reporter_bugcount_arr );
$t_row_count = 0;
# We now have a multi dimensional array of users, resolutions and severities, with the
# value of each resolution and severity for each user
foreach( $t_reporter_bugcount_arr as $t_reporter_id => $t_total_user_bugs ) {
# Limit the number of reporters listed
if ( $t_row_count > $t_reporter_summary_limit ) {
break;
}
# Only print reporters who have reported at least one bug. This helps
# prevent divide by zeroes, showing reporters not on this project, and showing
# users that aren't actually reporters...
if ( $t_total_user_bugs > 0 ) {
$t_arr2 = $t_reporter_ressev_arr[$t_reporter_id];
PRINT '<tr ' . helper_alternate_class( $t_row_count ) . '>';
$t_row_count++;
PRINT '<td>';
PRINT user_get_name( $t_reporter_id );
PRINT '</td>';
$t_total_severity = 0;
$t_total_errors = 0;
for ( $j = 0; $j < $enum_sev_count; $j++ ) {
if ( !isset( $t_arr2[$c_sev_s[$j]] ) ) {
continue;
}
$sev_bug_count = $t_arr2[$c_sev_s[$j]]['total'];
$t_sev_mult = $t_severity_multiplier['average'];
if ( $t_severity_multiplier[$c_sev_s[$j]] ) {
$t_sev_mult = $t_severity_multiplier[$c_sev_s[$j]];
}
if ( $sev_bug_count > 0 ) {
$t_total_severity += ( $sev_bug_count * $t_sev_mult );
}
# Calculate the "error value" of bugs reported
$t_notbug_res_arr = array( UNABLE_TO_DUPLICATE, DUPLICATE, NOT_A_BUG );
foreach ( $t_notbug_res_arr as $t_notbug_res ) {
if ( isset( $t_arr2[$c_sev_s[$j]][$t_notbug_res] ) ) {
$t_notbug_mult = 1;
if ( $t_notbug_multiplier[$t_notbug_res] ) {
$t_notbug_mult = $t_notbug_multiplier[$t_notbug_res];
}
$t_total_errors += ( $t_sev_mult * $t_notbug_mult );
}
}
}
PRINT '<td>';
PRINT $t_total_severity;
PRINT '</td>';
PRINT '<td>';
PRINT $t_total_errors;
PRINT '</td>';
PRINT '<td>';
PRINT ( $t_total_severity - $t_total_errors );
PRINT '</td>';
PRINT '</tr>';
}
}
}
function summary_print_details_by_severity($view_state,$s_title)
{
//Explode the status enumeration string
$status_enum_arr = explode_enum_string(config_get( 'status_enum_string2' ));
$severity_enum_arr = explode_enum_string(config_get( 'severity_enum_string' ));
//Get the project id
$t_project_id = helper_get_current_project();
//
$query = "SELECT mbt.severity AS 'SeverityID',";
$open = "";
$closed = "";
$statusTotal = 0;
for($index = 0; $index < count($status_enum_arr);$index++)
{
$statusTotal++;
//Explode each status accoring to 'ID:NAME:OPEN/CLOSED'
$status_arr = explode(':',$status_enum_arr[$index]);
$status_id = $status_arr[0];
$status = $status_arr[1];
$oc = $status_arr[2];
if($oc == 'o')
{
$open .= $status_id.",";
}
else
{
$closed .= $status_id.",";
}
$query .=" COUNT(DISTINCT CASE WHEN status = ".$status_id ." THEN mbt.id ELSE NULL END) AS '".$status."',";
}
//Remove triling commas
$open = substr($open,0,strlen($open ) -1);
$closed = substr($closed,0,strlen($closed ) -1);
$severities[] = array(1,2);
for($index = 0; $index < count($severity_enum_arr);$index++)
{
$statusTotal++;
//Explode each severity accoring to 'ID:NAME'
$severity_arr = explode(':',$severity_enum_arr[$index]);
$severity_id = $severity_arr[0];
$severity = $severity_arr[1];
$severities[$severity_id] = $severity;
}
$query .=" COUNT(DISTINCT CASE WHEN status IN (".$open.") THEN mbt.id ELSE NULL END) AS 'TOTAL OPEN',";
$query .=" COUNT(DISTINCT CASE WHEN status IN (".$closed.") THEN mbt.id ELSE NULL END) AS 'TOTAL CLOSED',";
$query .=" COUNT(*) AS TOTAL";
$query .=" FROM mantis_bug_table mbt";
if ( ALL_PROJECTS != $t_project_id )
{
$query .= " WHERE (mbt.project_id = ".$t_project_id;
$query .= " OR mbt.project_id IN (SELECT child_id FROM mantis_project_hierarchy_table m WHERE m.parent_id = ".$t_project_id."))";
}
if($view_state != 0 && ALL_PROJECTS == $t_project_id)
{
$query .= " WHERE mbt.view_state = ".$view_state;
}
else if($view_state != 0)
{
$query .= " AND mbt.view_state = ".$view_state;
}
$query .= " GROUP BY mbt.severity";
$query .= " ORDER BY mbt.severity desc";
$result = db_query( $query );
#printf($query);
$totals_arr;
//$nIndex = 0;
while ( $row = db_fetch_array( $result ) )
{
printf( '<tr %s>', helper_alternate_class() );
printf("<td >%s</td>",$severities[$row['severityid']]);
for($index = 0; $index < count($status_enum_arr);$index++)
{
$status_arr = explode(":",$status_enum_arr[$index]);
$status_id = $status_arr[0];
$status = $status_arr[1];
#printf($status.'*'.$row[strtolower($status)].'*'.$status_arr[1]);
if($row[strtolower($status)] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&view_state=".$view_state."&show_status=".$status_id."&show_severity=%s'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$row['severityid'],$row[strtolower($status)]);
}
else
{
printf("<td class='right'>%s</td>",$row[strtolower($status)]);
}
$totals_arr[$index] += $row[strtolower($status)];
}
if(config_get('display_totals'))
{
if($row['total open'] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&hide_status=".RESOLVED."&show_severity=%s'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$row['severityid'],$row['total open']);
}
else
{
printf("<td class='right'>%s</td>",$row['total open']);
}
$totals_arr[$statusTotal + 1] += $row['total open'];
if($row['total closed'] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&show_severity=%s&show_status=".CLOSED."'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$row['severityid'],$row['total closed']);
}
else
{
printf("<td class='right'>%s</td>",$row['total closed']);
}
$totals_arr[$statusTotal + 2] += $row['total closed'];
if($row['total'] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&show_severity=%s'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$row['severityid'],$row['total']);
}
else
{
printf("<td class='right'>%s</td>",$row['total']);
}
$totals_arr[$statusTotal + 3] += $row['total'];
}
print("</tr>");
}
printf( '<tr %s>', helper_alternate_class() );
printf("<td >Totals</td>");
for($index = 0; $index < count($status_enum_arr);$index++)
{
printf("<td class='right'><a class='subtle' href='%s&view_state=".$view_state."&show_status=".$status_id."'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$totals_arr[$index]);
}
if(config_get('display_totals'))
{
if($totals_arr[$statusTotal + 1] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&hide_status=".RESOLVED."'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$totals_arr[$statusTotal + 1]);
}
else
{
printf("<td class='right'>%s</td>",$totals_arr[$statusTotal + 1]);
}
if($totals_arr[$statusTotal + 2] > 0)
{
printf("<td class='right'><a class='subtle' href='%s&show_status=".CLOSED."'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$totals_arr[$statusTotal + 2]);
}
else
{
printf("<td class='right'>%s</td>",$totals_arr[$statusTotal + 2]);
}
if($totals_arr[$statusTotal + 3] > 0)
{
printf("<td class='right'><a class='subtle' href='%s'>%s</a></td>",config_get( 'bug_count_hyperlink_prefix' ),$totals_arr[$statusTotal + 3]);
}
else
{
printf("<td class='right'>%s</td>",$totals_arr[$statusTotal + 3]);
}
}
print("</tr>");
}
?>
| ||||
|
summary_page.php replaces the standard mantis summary page file summary_api.php replaces the standard mantis summary api page (in the core folder) You also need to add the folowing lines to your config file And these lines into your custom strings |
|
|
The labels are not working in version 1.0.2 I am upgrading to 1.0.3 and will try to get the report working with that version and post the updated files to this defect report. |
|
|
Hi Papaganoush, This customization does work in version 1.2.10 of Mantis? Thanks, Regards |
|
|
Hi Papaganoush, Please Help! I need to add the status of issue to show a new report for summary page - "By PROJECT". See attach screenshot. you could tell me how I can add this change and if it is equal to the change you've done "By Severity" Thanks, Regards |
|