[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> summary_page.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: summary_page.php,v 1.54.2.1 2007-10-13 22:34:43 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      require_once ( 'core.php' );
  26  
  27      $t_core_path = config_get( 'core_path' );
  28  
  29      require_once( $t_core_path.'summary_api.php' );
  30  ?>
  31  <?php
  32      access_ensure_project_level( config_get( 'view_summary_threshold' ) );
  33  
  34      $f_project_id = gpc_get_int( 'project_id', helper_get_current_project() );
  35  
  36      # Override the current page to make sure we get the appropriate project-specific configuration
  37      $g_project_override = $f_project_id;
  38  
  39      $t_user_id = auth_get_current_user_id();
  40  
  41      # @@@ giallu: this block of code is duplicated from helper_project_specific_where
  42      # the only diff is the commented line below: can we do better than this ?
  43      if ( ALL_PROJECTS == $f_project_id ) {
  44          $t_topprojects = $t_project_ids = user_get_accessible_projects( $t_user_id );
  45          foreach ( $t_topprojects as $t_project ) {
  46              $t_project_ids = array_merge( $t_project_ids, user_get_all_accessible_subprojects( $t_user_id, $t_project ) );
  47          }
  48  
  49          $t_project_ids = array_unique( $t_project_ids );
  50      } else {
  51          # access_ensure_project_level( VIEWER, $p_project_id );
  52          $t_project_ids = user_get_all_accessible_subprojects( $t_user_id, $f_project_id );
  53          array_unshift( $t_project_ids, $f_project_id );
  54      }
  55  
  56      $t_project_ids = array_map( 'db_prepare_int', $t_project_ids );
  57  
  58      if ( 0 == count( $t_project_ids ) ) {
  59          $specific_where = ' 1 <> 1';
  60      } elseif ( 1 == count( $t_project_ids ) ) {
  61          $specific_where = ' project_id=' . $t_project_ids[0];
  62      } else {
  63          $specific_where = ' project_id IN (' . join( ',', $t_project_ids ) . ')';
  64      }
  65      # end @@@ block
  66  
  67      $t_bug_table = config_get( 'mantis_bug_table' );
  68      $t_history_table = config_get( 'mantis_bug_history_table' );
  69  
  70      $t_resolved = config_get( 'bug_resolved_status_threshold' );
  71      # the issue may have passed through the status we consider resolved
  72      #  (e.g., bug is CLOSED, not RESOLVED). The linkage to the history field
  73      #  will look up the most recent 'resolved' status change and return it as well
  74      $query = "SELECT b.id, b.date_submitted, b.last_updated, MAX(h.date_modified) as hist_update, b.status 
  75          FROM $t_bug_table b LEFT JOIN $t_history_table h 
  76              ON b.id = h.bug_id  AND h.type=0 AND h.field_name='status' AND h.new_value='$t_resolved'  
  77              WHERE b.status >='$t_resolved' AND $specific_where
  78              GROUP BY b.id, b.status, b.date_submitted, b.last_updated 
  79              ORDER BY b.id ASC";
  80      $result = db_query( $query );
  81      $bug_count = db_num_rows( $result );
  82  
  83      $t_bug_id       = 0;
  84      $t_largest_diff = 0;
  85      $t_total_time   = 0;
  86      for ($i=0;$i<$bug_count;$i++) {
  87          $row = db_fetch_array( $result );
  88          $t_date_submitted = db_unixtimestamp( $row['date_submitted'] );        
  89          $t_id = $row['id'];
  90          $t_status = $row['status'];
  91          if ( $row['hist_update'] !== NULL ) {
  92              $t_last_updated   = db_unixtimestamp( $row['hist_update'] );
  93          } else {
  94              $t_last_updated   = db_unixtimestamp( $row['last_updated'] );
  95          }
  96            
  97          if ($t_last_updated < $t_date_submitted) {
  98              $t_last_updated   = 0;
  99              $t_date_submitted = 0;
 100          }
 101  
 102          $t_diff = $t_last_updated - $t_date_submitted;
 103          $t_total_time = $t_total_time + $t_diff;
 104          if ( $t_diff > $t_largest_diff ) {
 105              $t_largest_diff = $t_diff;
 106              $t_bug_id = $row['id'];
 107          }
 108      }
 109      if ( $bug_count < 1 ) {
 110          $bug_count = 1;
 111      }
 112      $t_average_time     = $t_total_time / $bug_count;
 113  
 114      $t_largest_diff     = number_format( $t_largest_diff / 86400, 2 );
 115      $t_total_time        = number_format( $t_total_time / 86400, 2 );
 116      $t_average_time     = number_format( $t_average_time / 86400, 2 );
 117  
 118      $t_orct_arr = preg_split( '/[\)\/\(]/', lang_get( 'orct' ), -1, PREG_SPLIT_NO_EMPTY );
 119  
 120      $t_orcttab = "";
 121      foreach ( $t_orct_arr as $t_orct_s ) {
 122          $t_orcttab .= '<td class="right">';
 123          $t_orcttab .= $t_orct_s;
 124          $t_orcttab .= '</td>';
 125      }
 126  ?>
 127  <?php html_page_top1( lang_get( 'summary_link' ) ) ?>
 128  <?php html_page_top2() ?>
 129  
 130  <br />
 131  <?php print_summary_menu( 'summary_page.php' ) ?>
 132  
 133  <?php print_menu_graph() ?>
 134  <br />
 135  <table class="width100" cellspacing="1">
 136  <tr>
 137      <td class="form-title" colspan="2">
 138          <?php echo lang_get( 'summary_title' ) ?>
 139      </td>
 140  </tr>
 141  <tr valign="top">
 142      <td width="50%">
 143          <?php # PROJECT # ?>
 144          <?php if ( 1 < count( $t_project_ids ) ) { ?>
 145          <table class="width100" cellspacing="1">
 146          <tr>
 147              <td class="form-title" colspan="1">
 148                  <?php echo lang_get( 'by_project' ) ?>
 149              </td>
 150              <?php echo $t_orcttab ?>
 151          </tr>
 152          <?php summary_print_by_project(); ?>
 153          </table>
 154  
 155          <br />
 156          <?php } ?>
 157  
 158          <?php # STATUS # ?>
 159          <table class="width100" cellspacing="1">
 160          <tr>
 161              <td class="form-title" colspan="1">
 162                  <?php echo lang_get( 'by_status' ) ?>
 163              </td>
 164              <?php echo $t_orcttab ?>
 165          </tr>
 166          <?php summary_print_by_enum( config_get( 'status_enum_string' ), 'status' ) ?>
 167          </table>
 168  
 169          <br />
 170  
 171          <?php # SEVERITY # ?>
 172          <table class="width100" cellspacing="1">
 173          <tr>
 174              <td class="form-title" colspan="1">
 175                  <?php echo lang_get( 'by_severity' ) ?>
 176              </td>
 177              <?php echo $t_orcttab ?>
 178          </tr>
 179          <?php summary_print_by_enum( config_get( 'severity_enum_string' ), 'severity' ) ?>
 180          </table>
 181  
 182          <br />
 183  
 184          <?php # CATEGORY # ?>
 185          <table class="width100" cellspacing="1">
 186          <tr>
 187              <td class="form-title" colspan="1">
 188                  <?php echo lang_get( 'by_category' ) ?>
 189              </td>
 190              <?php echo $t_orcttab ?>
 191          </tr>
 192          <?php summary_print_by_category() ?>
 193          </table>
 194  
 195          <br />
 196  
 197          <?php # MISCELLANEOUS # ?>
 198          <table class="width100">
 199          <tr>
 200              <td class="form-title" colspan="5">
 201                  <?php echo lang_get( 'time_stats' ) ?>
 202              </td>
 203          </tr>
 204          <tr class="row-1">
 205              <td width="50%">
 206                  <?php echo lang_get( 'longest_open_bug' ) ?>
 207              </td>
 208              <td width="50%">
 209                  <?php
 210                      if ($t_bug_id>0) {
 211                          print_bug_link( $t_bug_id );
 212                      }
 213                  ?>
 214              </td>
 215          </tr>
 216          <tr class="row-2">
 217              <td>
 218                  <?php echo lang_get( 'longest_open' ) ?>
 219              </td>
 220              <td>
 221                  <?php echo $t_largest_diff ?>
 222              </td>
 223          </tr>
 224          <tr class="row-1">
 225              <td>
 226                  <?php echo lang_get( 'average_time' ) ?>
 227              </td>
 228              <td>
 229                  <?php echo $t_average_time ?>
 230              </td>
 231          </tr>
 232          <tr class="row-2">
 233              <td>
 234                  <?php echo lang_get( 'total_time' ) ?>
 235              </td>
 236              <td>
 237                  <?php echo $t_total_time ?>
 238              </td>
 239          </tr>
 240          </table>
 241  
 242          <br />
 243  
 244          <?php # DEVELOPER # ?>
 245          <table class="width100" cellspacing="1">
 246          <tr>
 247              <td class="form-title" colspan="1">
 248                  <?php echo lang_get( 'developer_stats' ) ?>
 249              </td>
 250              <?php echo $t_orcttab ?>
 251          </tr>
 252          <?php summary_print_by_developer() ?>
 253          </table>
 254      </td>
 255  
 256  
 257  
 258      <td width="50%">
 259          <?php # DATE # ?>
 260          <table class="width100" cellspacing="1">
 261          <tr>
 262              <td class="form-title"><?php echo lang_get( 'by_date' ); ?></td>
 263              <td class="right"><?php echo lang_get( 'legend_opened' ); ?></td>
 264              <td class="right"><?php echo lang_get( 'legend_resolved' ); ?></td>
 265              <td class="right"><?php echo lang_get( 'balance' ); ?></td>
 266          </tr>
 267          <?php summary_print_by_date( config_get( 'date_partitions' ) ) ?>
 268          </table>
 269  
 270          <br />
 271  
 272          <?php # ACTIVITY # ?>
 273          <table class="width100" cellspacing="1">
 274          <tr>
 275              <td class="form-title" width="86%"><?php echo lang_get( 'most_active' ); ?></td>
 276              <td class="right" width="14%"><?php echo lang_get( 'score' ); ?></td>
 277          </tr>
 278          <?php summary_print_by_activity() ?>
 279          </table>
 280  
 281          <br />
 282  
 283          <?php # LONGEST OPEN # ?>
 284          <table class="width100" cellspacing="1">
 285          <tr>
 286              <td class="form-title" width="86%"><?php echo lang_get( 'longest_open' ); ?></td>
 287              <td class="right" width="14%"><?php echo lang_get( 'days' ); ?></td>
 288          </tr>
 289          <?php summary_print_by_age() ?>
 290          </table>
 291  
 292          <br />
 293  
 294          <?php # RESOLUTION # ?>
 295          <table class="width100" cellspacing="1">
 296          <tr>
 297              <td class="form-title" colspan="1">
 298                  <?php echo lang_get( 'by_resolution' ) ?>
 299              </td>
 300              <?php echo $t_orcttab ?>
 301          </tr>
 302          <?php summary_print_by_enum( config_get( 'resolution_enum_string' ), 'resolution' ) ?>
 303          </table>
 304  
 305          <br />
 306  
 307          <?php # PRIORITY # ?>
 308          <table class="width100" cellspacing="1">
 309          <tr>
 310              <td class="form-title" colspan="1">
 311                  <?php echo lang_get( 'by_priority' ) ?>
 312              </td>
 313              <?php echo $t_orcttab ?>
 314          </tr>
 315          <?php summary_print_by_enum( config_get( 'priority_enum_string' ), 'priority' ) ?>
 316          </table>
 317  
 318          <br />
 319  
 320          <?php # REPORTER # ?>
 321          <table class="width100" cellspacing="1">
 322          <tr>
 323              <td class="form-title" colspan="1">
 324                  <?php echo lang_get( 'reporter_stats' ) ?>
 325              </td>
 326              <?php echo $t_orcttab ?>
 327          </tr>
 328          <?php summary_print_by_reporter() ?>
 329          </table>
 330  
 331          <br />
 332  
 333          <?php # REPORTER EFFECTIVENESS # ?>
 334          <table class="width100" cellspacing="1">
 335          <tr>
 336              <td class="form-title" colspan="1">
 337                  <?php echo lang_get( 'reporter_effectiveness' ) ?>
 338              </td>
 339              <td>
 340                  <?php echo lang_get( 'severity' ) ?>
 341              </td>
 342              <td>
 343                  <?php echo lang_get( 'errors' ) ?>
 344              </td>
 345              <td>
 346                  <?php echo lang_get( 'total' ) ?>
 347              </td>
 348          </tr>
 349          <?php summary_print_reporter_effectiveness( config_get( 'severity_enum_string' ), config_get( 'resolution_enum_string' ) ) ?>
 350          </table>
 351      </td>
 352  </tr>
 353  
 354  <tr valign="top">
 355      <td colspan="2">
 356          <?php # REPORTER / RESOLUTION # ?>
 357          <table class="width100" cellspacing="1">
 358          <tr>
 359              <td class="form-title" colspan="1">
 360                  <?php echo lang_get( 'reporter_by_resolution' ) ?>
 361              </td>
 362              <?php
 363              $t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
 364              $enum_count = count( $t_arr );
 365  
 366              for ($i=0;$i<$enum_count;$i++) {
 367                  print '<td>';
 368                  $t_s = explode_enum_arr( $t_arr[$i] );
 369                  $c_s[0] = db_prepare_string( $t_s[0] );
 370                  echo get_enum_element( 'resolution', $c_s[0] );
 371                  print '</td>';
 372              }
 373  
 374              print '<td>';
 375              print lang_get( 'percentage_errors' );
 376              print '</td>';
 377              ?>
 378          </tr>
 379          <?php summary_print_reporter_resolution( config_get( 'resolution_enum_string' ) ) ?>
 380          </table>
 381      </td>
 382  </tr>
 383  
 384  <tr valign="top">
 385      <td colspan="2">
 386          <?php # DEVELOPER / RESOLUTION # ?>
 387          <table class="width100" cellspacing="1">
 388          <tr>
 389              <td class="form-title" colspan="1">
 390                  <?php echo lang_get( 'developer_by_resolution' ) ?>
 391              </td>
 392              <?php
 393              $t_arr = explode_enum_string( config_get( 'resolution_enum_string' ) );
 394              $enum_count = count( $t_arr );
 395  
 396              for ($i=0;$i<$enum_count;$i++) {
 397                  print '<td>';
 398                  $t_s = explode_enum_arr( $t_arr[$i] );
 399                  $c_s[0] = db_prepare_string( $t_s[0] );
 400                  echo get_enum_element( 'resolution', $c_s[0] );
 401                  print '</td>';
 402              }
 403  
 404              print '<td>';
 405              print lang_get( 'percentage_fixed' );
 406              print '</td>';
 407              ?>
 408          </tr>
 409          <?php summary_print_developer_resolution( config_get( 'resolution_enum_string' ) ) ?>
 410          </table>
 411      </td>
 412  </tr>
 413  </table>
 414  
 415  <?php html_page_bottom1( __FILE__ ) ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics