| [ Index ] |
|
Code source de Mantis 1.1.0rc3 |
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_cumulative.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 $g_start_date = date( 'Y-m-d', strtotime("-1 Month")); 36 37 # usort function 38 function tmpcmp ($a, $b) { 39 if ($a == $b) return 0; 40 return ($a < $b) ? -1 : 1; 41 } 42 43 # get total bugs before a date 44 function get_total_count_by_date( $p_date ) { 45 $t_project_id = helper_get_current_project(); 46 47 $d_arr = explode( '/', $p_date ); 48 $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1]; 49 $query = "SELECT COUNT(*) 50 FROM mantis_bug_table 51 WHERE date_submitted<='$p_date' AND 52 project_id='$t_project_id'"; 53 $result = db_query ( $query ); 54 return db_result( $result, 0, 0 ); 55 } 56 57 # get resolved bugs before a date 58 function get_resolved_count_by_date( $p_date ) { 59 $t_project_id = helper_get_current_project(); 60 61 $d_arr = explode( '/', $p_date ); 62 $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1]; 63 $query = "SELECT COUNT(*) 64 FROM mantis_bug_table 65 WHERE last_updated<='$p_date' AND 66 status='80' AND 67 project_id='$t_project_id'"; 68 $result = db_query ( $query ); 69 return db_result( $result, 0, 0 ); 70 } 71 72 # get closed bugs before a date 73 function get_closed_count_by_date( $p_date ) { 74 $t_project_id = helper_get_current_project(); 75 76 $d_arr = explode( '/', $p_date ); 77 $p_date = $d_arr[2].'-'.$d_arr[0].'-'.$d_arr[1]; 78 $query = "SELECT COUNT(*) 79 FROM mantis_bug_table 80 WHERE last_updated<='$p_date' AND 81 status='90' AND 82 project_id='$t_project_id'"; 83 $result = db_query ( $query ); 84 return db_result( $result, 0, 0 ); 85 } 86 87 # -- start -- 88 89 $t_project_id = helper_get_current_project(); 90 91 $query = "SELECT status, date_submitted, last_updated 92 FROM mantis_bug_table 93 WHERE project_id='$t_project_id' AND 94 date_submitted>='$g_start_date' 95 ORDER BY date_submitted ASC"; 96 $result = db_query( $query ); 97 $bug_count = db_num_rows( $result ); 98 99 $data_date_arr = array(); 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 = array(); 128 foreach( $data_date_arr as $val ) { 129 $data_open_count_arr[] = get_total_count_by_date( $val ); 130 } 131 132 # total up resolved 133 $data_resolved_count_arr = array(); 134 foreach( $data_date_arr as $val ) { 135 $data_resolved_count_arr[] = get_resolved_count_by_date( $val ); 136 } 137 138 # total up closed 139 $data_closed_count_arr = array(); 140 foreach( $data_date_arr as $val ) { 141 $data_closed_count_arr[] = get_closed_count_by_date( $val ); 142 } 143 144 foreach( $data_date_arr as $key => $val ) { 145 $data_date_arr[$key] = $val.' '; 146 } 147 148 $proj_name = project_get_field( $t_project_id, 'name' ); 149 150 # Setup Graph 151 # --- 152 153 $graph = new Graph(800,600,"auto"); 154 $graph->img->SetMargin(40,20,40,90); 155 156 if ( ON == config_get_global( 'jpgraph_antialias' ) ) { 157 $graph->img->SetAntiAliasing("white"); 158 } 159 $graph->SetScale("textlin"); 160 $graph->SetShadow(); 161 $graph->SetColor('whitesmoke'); 162 $graph->title->Set("Cumulative - New, Resolved and Closed: $proj_name"); 163 $graph->title->SetFont(FF_FONT1,FS_BOLD); 164 165 $graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,5); 166 $graph->xaxis->SetTickLabels( $data_date_arr ); 167 $graph->xaxis->SetLabelAngle(90); 168 169 $graph->legend->Pos(0.75, 0.2); 170 171 # OPEN 172 $p1 = new LinePlot($data_open_count_arr); 173 $p1->mark->SetType(MARK_FILLEDCIRCLE); 174 $p1->mark->SetFillColor("blue"); 175 $p1->mark->SetWidth(3); 176 $p1->SetColor("blue"); 177 $p1->SetCenter(); 178 $p1->SetLegend("Total"); 179 $graph->Add($p1); 180 181 # RESOLVED 182 $p2 = new LinePlot($data_resolved_count_arr); 183 $p2->mark->SetType(MARK_SQUARE); 184 $p2->mark->SetFillColor("hotpink"); 185 $p2->mark->SetWidth(5); 186 $p2->SetColor("hotpink"); 187 $p2->SetCenter(); 188 $p2->SetLegend("Resolved"); 189 $graph->Add($p2); 190 191 # CLOSED 192 $p3 = new LinePlot($data_closed_count_arr); 193 $p3->mark->SetType(MARK_UTRIANGLE); 194 $p3->mark->SetFillColor("yellow1"); 195 $p3->mark->SetWidth(6); 196 $p3->SetColor("yellow1"); 197 $p3->SetCenter(); 198 $p3->SetLegend("Closed"); 199 $graph->Add($p3); 200 201 $p1->value->Show(); 202 $p2->value->Show(); 203 $p3->value->Show(); 204 205 $p1->value->SetFont(FF_FONT1,FS_NORMAL,8); 206 $p2->value->SetFont(FF_FONT1,FS_NORMAL,8); 207 $p3->value->SetFont(FF_FONT1,FS_NORMAL,8); 208 209 $p1->value->SetColor("black","darkred"); 210 $p2->value->SetColor("black","darkred"); 211 $p3->value->SetColor("black","darkred"); 212 213 $p1->value->SetFormat('%d'); 214 $p2->value->SetFormat('%d'); 215 $p3->value->SetFormat('%d'); 216 217 // Output line 218 $graph->Stroke(); 219 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
|