[ 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_daily_delta.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_daily_delta.php,v 1.10.2.1 2007-10-13 22:35:52 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      $g_start_date = date( 'Y-m-d', strtotime("-1 Month"));
  38  
  39      $query = "SELECT status, date_submitted, last_updated
  40              FROM mantis_bug_table
  41              WHERE project_id='$t_project_id' AND
  42                      date_submitted>='$g_start_date'
  43              ORDER BY date_submitted ASC";
  44      $result = db_query( $query );
  45      $bug_count = db_num_rows( $result );
  46  
  47      $data_date_arr = array();
  48  
  49      # usort function
  50  	function tmpcmp ($a, $b) {
  51          if ($a == $b) return 0;
  52          return ($a < $b) ? -1 : 1;
  53      }
  54  
  55      # get total bugs before a date
  56  	function get_total_count_by_date( $p_date ) {
  57          $t_project_id = helper_get_current_project();
  58  
  59          $d_arr = explode( '/', $p_date );
  60          $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1];
  61          $query = "SELECT COUNT(*)
  62                  FROM mantis_bug_table
  63                  WHERE date_submitted<='$p_date' AND
  64                      project_id='$t_project_id'";
  65          $result = db_query ( $query );
  66          return db_result( $result, 0, 0 );
  67      }
  68  
  69      # get resolved bugs before a date
  70  	function get_resolved_count_by_date( $p_date ) {
  71          $t_project_id = helper_get_current_project();
  72  
  73          $d_arr = explode( '/', $p_date );
  74          $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1];
  75          $query = "SELECT COUNT(*)
  76                  FROM mantis_bug_table
  77                  WHERE last_updated<='$p_date' AND
  78                      status='80' AND
  79                      project_id='$t_project_id'";
  80          $result = db_query ( $query );
  81          return db_result( $result, 0, 0 );
  82      }
  83  
  84      # get closed bugs before a date
  85  	function get_closed_count_by_date( $p_date ) {
  86          $t_project_id = helper_get_current_project();
  87  
  88          $d_arr = explode( '/', $p_date );
  89          $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1];
  90          $query = "SELECT COUNT(*)
  91                  FROM mantis_bug_table
  92                  WHERE last_updated<='$p_date' AND
  93                      status='90' AND
  94                      project_id='$t_project_id'";
  95          $result = db_query ( $query );
  96          return db_result( $result, 0, 0 );
  97      }
  98  
  99      # -- start --
 100  
 101      while( $row = db_fetch_array( $result ) ) {
 102          extract( $row );
 103  
 104          if ( $status < 80 ) {
 105              $date_str = date( 'm/d/Y', db_unixtimestamp( $date_submitted ) );
 106          } else {
 107              $date_str = date( 'm/d/Y', db_unixtimestamp( $last_updated ) );
 108          }
 109  
 110          $data_date_arr[] = $date_str;
 111      }
 112  
 113      $counter = 0;
 114      while( $row = db_fetch_array( $result ) ) {
 115          extract( $row );
 116      }
 117  
 118      $data_date_arr_temp = array_unique( $data_date_arr );
 119      $data_date_arr = array();
 120      foreach( $data_date_arr_temp as $key => $val ) {
 121          $data_date_arr[] = $val;
 122      }
 123      usort( $data_date_arr, 'tmpcmp' );
 124  
 125  
 126      # total up open
 127      $data_open_count_arr_temp = array();
 128      foreach( $data_date_arr as $val ) {
 129          $data_open_count_arr_temp[] = get_total_count_by_date( $val );
 130      }
 131  
 132      $data_open_count_arr = array();
 133      for ($i=1;$i<count($data_open_count_arr_temp);$i++) {
 134          $data_open_count_arr[] = $data_open_count_arr_temp[$i]-$data_open_count_arr_temp[$i-1];
 135      }
 136      $data_open_count_arr[] = 0;
 137  
 138      # total up resolved
 139      $data_resolved_count_arr_temp = array();
 140      foreach( $data_date_arr as $val ) {
 141          $data_resolved_count_arr_temp[] = get_resolved_count_by_date( $val );
 142      }
 143      $data_resolved_count_arr = array();
 144      for ($i=1;$i<count($data_resolved_count_arr_temp);$i++) {
 145          $data_resolved_count_arr[] = $data_resolved_count_arr_temp[$i]-$data_resolved_count_arr_temp[$i-1];
 146      }
 147      $data_resolved_count_arr[] = 0;
 148  
 149      # total up closed
 150      $data_closed_count_arr_temp = array();
 151      foreach( $data_date_arr as $val ) {
 152          $data_closed_count_arr_temp[] = get_closed_count_by_date( $val );
 153      }
 154      $data_closed_count_arr = array();
 155      for ($i=1;$i<count($data_closed_count_arr_temp);$i++) {
 156          $data_closed_count_arr[] = $data_closed_count_arr_temp[$i]-$data_closed_count_arr_temp[$i-1];
 157      }
 158      $data_closed_count_arr[] = 0;
 159  
 160      foreach( $data_date_arr as $key => $val ) {
 161          $data_date_arr[$key] = substr( $val, 0, 5 ).' ';
 162      }
 163  
 164      $proj_name = project_get_field( $t_project_id, 'name' );
 165  
 166      # Setup Graph
 167      # ---
 168  
 169      $graph = new Graph(800,600,"auto");
 170      $graph->img->SetMargin(40,20,40,90);
 171  
 172      if ( ON == config_get_global( 'jpgraph_antialias' ) ) {
 173          $graph->img->SetAntiAliasing("white");
 174      }
 175      $graph->SetScale("textlin");
 176      $graph->SetShadow();
 177      $graph->SetColor('gray');
 178      $graph->SetMarginColor('white');
 179      $graph->title->Set( "Daily Delta Chart: $proj_name" );
 180      $graph->title->SetFont( FF_FONT1, FS_BOLD );
 181  
 182      $graph->xaxis->SetFont( FF_FONT1 );
 183      $graph->xaxis->SetTickLabels( $data_date_arr );
 184      $graph->xaxis->SetLabelAngle( 90 );
 185  
 186      $graph->legend->Pos( 0.75, 0.2 );
 187  
 188      # OPEN
 189      $p1 = new LinePlot( $data_open_count_arr );
 190      $p1->mark->SetType( MARK_FILLEDCIRCLE );
 191      $p1->mark->SetFillColor( "blue" );
 192      $p1->mark->SetWidth( 3 );
 193      $p1->SetColor( "blue" );
 194      $p1->SetCenter();
 195      $p1->SetLegend( "Open" );
 196      $graph->Add( $p1 );
 197  
 198      # RESOLVED
 199      $p2 = new LinePlot($data_resolved_count_arr);
 200      $p2->mark->SetType(MARK_SQUARE);
 201      $p2->mark->SetFillColor("hotpink");
 202      $p2->mark->SetWidth(5);
 203      $p2->SetColor("hotpink");
 204      $p2->SetCenter();
 205      $p2->SetLegend("Resolved");
 206      $graph->Add($p2);
 207  
 208      # CLOSED
 209      $p3 = new LinePlot($data_closed_count_arr);
 210      $p3->mark->SetType(MARK_UTRIANGLE);
 211      $p3->mark->SetFillColor("yellow1");
 212      $p3->mark->SetWidth(6);
 213      $p3->SetColor("yellow1");
 214      $p3->SetCenter();
 215      $p3->SetLegend("Closed");
 216      $graph->Add($p3);
 217  
 218      $p1->value->Show();
 219      $p2->value->Show();
 220      $p3->value->Show();
 221  
 222      $p1->value->SetFont(FF_FONT1,FS_NORMAL,8);
 223      $p2->value->SetFont(FF_FONT1,FS_NORMAL,8);
 224      $p3->value->SetFont(FF_FONT1,FS_NORMAL,8);
 225  
 226      $p1->value->SetColor("black","darkred");
 227      $p2->value->SetColor("black","darkred");
 228      $p3->value->SetColor("black","darkred");
 229  
 230      $p1->value->SetFormat('%d');
 231      $p2->value->SetFormat('%d');
 232      $p3->value->SetFormat('%d');
 233  
 234      // Output line
 235      $graph->Stroke();
 236  ?>


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