[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/graphs/ -> graph_by_severity_status.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: graph_by_severity_status.php,v 1.8.22.1 2007-10-13 22:35:54 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.'graph_api.php' );
  30  ?>
  31  <?php
  32      # Grab Data
  33      # ---
  34  
  35      $t_project_id = helper_get_current_project();
  36  
  37      $critical_count_arr     = array(2);
  38      $high_count_arr         = array(2);
  39      $medium_count_arr         = array(2);
  40      $low_count_arr             = array(2);
  41      $none_count_arr         = array(2);
  42      $duplicate_count_arr     = array(2);
  43  
  44      $critical_count_arr[0] = 0;
  45      $critical_count_arr[1] = 0;
  46      $critical_count_arr[2] = 0;
  47      $high_count_arr[0] = 0;
  48      $high_count_arr[1] = 0;
  49      $high_count_arr[2] = 0;
  50      $medium_count_arr[0] = 0;
  51      $medium_count_arr[1] = 0;
  52      $medium_count_arr[2] = 0;
  53      $low_count_arr[0] = 0;
  54      $low_count_arr[1] = 0;
  55      $low_count_arr[2] = 0;
  56      $none_count_arr[0] = 0;
  57      $none_count_arr[1] = 0;
  58      $none_count_arr[2] = 0;
  59      $duplicate_count_arr[0] = 0;
  60      $duplicate_count_arr[1] = 0;
  61      $duplicate_count_arr[2] = 0;
  62  
  63      $severity_arr = explode( ',', $g_severity_enum_string );
  64      $severity_count = count( $severity_arr );
  65  
  66      # GET OPEN
  67      for ($i=0;$i<$severity_count;$i++) {
  68          $t_severity_arr = explode( ':', $severity_arr[$i] );
  69          $t_severity = $t_severity_arr[0];
  70          $query = "SELECT COUNT(*) as count
  71                  FROM mantis_bug_table
  72                  WHERE project_id='$t_project_id' AND
  73                          status<80 AND
  74                          severity='$t_severity'";
  75          $result = db_query( $query );
  76          $count = db_result( $result, 0, 0 );
  77          switch ( $t_severity ) {
  78              case 20:$critical_count_arr[0] = $count;
  79                      break;
  80              case 30:$high_count_arr[0] = $count;
  81                      break;
  82              case 40:$medium_count_arr[0] = $count;
  83                      break;
  84              case 50:$low_count_arr[0] = $count;
  85                      break;
  86              case 60:$none_count_arr[0] = $count;
  87                      break;
  88              case 70:$duplicate_count_arr[0] = $count;
  89                      break;
  90          }
  91      }
  92      # GET RESOLVED
  93      for ($i=0;$i<$severity_count;$i++) {
  94          $t_severity_arr = explode( ':', $severity_arr[$i] );
  95          $t_severity = $t_severity_arr[0];
  96          $query = "SELECT COUNT(*) as count
  97                  FROM mantis_bug_table
  98                  WHERE project_id='$t_project_id' AND
  99                          status=80 AND
 100                          severity='$t_severity'";
 101          $result = db_query( $query );
 102          $count = db_result( $result, 0, 0 );
 103  
 104          switch ( $t_severity ) {
 105              case 20:$critical_count_arr[1] = $count;
 106                      break;
 107              case 30:$high_count_arr[1] = $count;
 108                      break;
 109              case 40:$medium_count_arr[1] = $count;
 110                      break;
 111              case 50:$low_count_arr[1] = $count;
 112                      break;
 113              case 60:$none_count_arr[1] = $count;
 114                      break;
 115              case 70:$duplicate_count_arr[1] = $count;
 116                      break;
 117          }
 118      }
 119      # GET CLOSED
 120      for ($i=0;$i<$severity_count;$i++) {
 121          $t_severity_arr = explode( ':', $severity_arr[$i] );
 122          $t_severity = $t_severity_arr[0];
 123          $query = "SELECT COUNT(*) as count
 124                  FROM mantis_bug_table
 125                  WHERE project_id='$t_project_id' AND
 126                          status=90 AND
 127                          severity='$t_severity'";
 128          $result = db_query( $query );
 129          $count = db_result( $result, 0, 0 );
 130  
 131          switch ( $t_severity ) {
 132              case 20:$critical_count_arr[2] = $count;
 133                      break;
 134              case 30:$high_count_arr[2] = $count;
 135                      break;
 136              case 40:$medium_count_arr[2] = $count;
 137                      break;
 138              case 50:$low_count_arr[2] = $count;
 139                      break;
 140              case 60:$none_count_arr[2] = $count;
 141                      break;
 142              case 70:$duplicate_count_arr[2] = $count;
 143                      break;
 144          }
 145      }
 146  
 147      $proj_name = project_get_field( $t_project_id, 'name' );
 148  
 149      # Setup Graph
 150      # ---
 151  
 152      $graph = new Graph( 800, 600, 'auto' );
 153      $graph->SetColor( "whitesmoke" );
 154      $graph->SetScale( "textlin" );
 155      $graph->SetShadow();
 156      $graph->img->SetMargin( 40, 30, 40, 40 );
 157  
 158      $graph->xaxis->SetTickLabels( array( 'Open', 'Resolved', 'Closed' ) );
 159      $graph->xaxis->title->Set( "Status" );
 160      $graph->xaxis->title->SetFont( FF_FONT1, FS_BOLD );
 161  
 162      $graph->title->Set( "Severity vs. Status Distribution: $proj_name" );
 163      $graph->title->SetFont( FF_FONT1, FS_BOLD );
 164  
 165      # Create graph
 166      $bplot1 = new BarPlot( $critical_count_arr );
 167      $bplot2 = new BarPlot( $high_count_arr );
 168      $bplot3 = new BarPlot( $medium_count_arr );
 169      $bplot4 = new BarPlot( $low_count_arr );
 170      $bplot5 = new BarPlot( $none_count_arr );
 171      $bplot6 = new BarPlot( $duplicate_count_arr );
 172  
 173      $bplot1->SetFillColor( "slateblue" );
 174      $bplot2->SetFillColor( "maroon" );
 175      $bplot3->SetFillColor( "lightgoldenrodyellow" );
 176      $bplot4->SetFillColor( "paleturquoise" );
 177      $bplot5->SetFillColor( "palegreen3" );
 178      $bplot6->SetFillColor( "sienna2" );
 179  
 180      $bplot1->SetShadow();
 181      $bplot2->SetShadow();
 182      $bplot3->SetShadow();
 183      $bplot4->SetShadow();
 184      $bplot5->SetShadow();
 185      $bplot6->SetShadow();
 186  
 187      $bplot1->SetLegend( 'Critical' );
 188      $bplot2->SetLegend( 'High' );
 189      $bplot3->SetLegend( 'Medium' );
 190      $bplot4->SetLegend( 'Low' );
 191      $bplot5->SetLegend( 'None' );
 192      $bplot6->SetLegend( 'Duplicate' );
 193  
 194      $bplot1->value->Show();
 195      $bplot2->value->Show();
 196      $bplot3->value->Show();
 197      $bplot4->value->Show();
 198      $bplot5->value->Show();
 199      $bplot6->value->Show();
 200  
 201      $bplot1->value->SetFont( FF_FONT1 );
 202      $bplot2->value->SetFont( FF_FONT1 );
 203      $bplot3->value->SetFont( FF_FONT1 );
 204      $bplot4->value->SetFont( FF_FONT1 );
 205      $bplot5->value->SetFont( FF_FONT1 );
 206      $bplot6->value->SetFont( FF_FONT1 );
 207  
 208      $bplot1->value->SetColor( "black", "darkred" );
 209      $bplot2->value->SetColor( "black", "darkred" );
 210      $bplot3->value->SetColor( "black", "darkred" );
 211      $bplot4->value->SetColor( "black", "darkred" );
 212      $bplot5->value->SetColor( "black", "darkred" );
 213      $bplot6->value->SetColor( "black", "darkred" );
 214  
 215      $bplot1->value->SetFormat( '%d' );
 216      $bplot2->value->SetFormat( '%d' );
 217      $bplot3->value->SetFormat( '%d' );
 218      $bplot4->value->SetFormat( '%d' );
 219      $bplot5->value->SetFormat( '%d' );
 220      $bplot6->value->SetFormat( '%d' );
 221  
 222      $gbarplot = new GroupBarPlot( array( $bplot1, $bplot2, $bplot3, $bplot4, $bplot5, $bplot6 ) );
 223  
 224      $gbarplot->SetWidth( 0.9 );
 225      $graph->Add( $gbarplot );
 226  
 227      $graph->Stroke();
 228  ?>


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