[ Index ] |
PHP Cross Reference of Eventum |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */ 3 // +----------------------------------------------------------------------+ 4 // | Eventum - Issue Tracking System | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB | 7 // | | 8 // | This program is free software; you can redistribute it and/or modify | 9 // | it under the terms of the GNU General Public License as published by | 10 // | the Free Software Foundation; either version 2 of the License, or | 11 // | (at your option) any later version. | 12 // | | 13 // | This program is distributed in the hope that it will be useful, | 14 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 // | GNU General Public License for more details. | 17 // | | 18 // | You should have received a copy of the GNU General Public License | 19 // | along with this program; if not, write to: | 20 // | | 21 // | Free Software Foundation, Inc. | 22 // | 59 Temple Place - Suite 330 | 23 // | Boston, MA 02111-1307, USA. | 24 // +----------------------------------------------------------------------+ 25 // | Authors: Bryan Alsdorf <bryan@mysql.com> | 26 // +----------------------------------------------------------------------+ 27 // 28 // @(#) $Id: customer_stats_graph.php 3206 2007-01-24 20:24:35Z glen $ 29 // 30 require_once(dirname(__FILE__) . "/../init.php"); 31 require_once (APP_INC_PATH . "class.auth.php"); 32 require_once (APP_INC_PATH . "class.customer_stats_report.php"); 33 require_once (APP_INC_PATH . "class.prefs.php"); 34 require_once (APP_INC_PATH . "class.date.php"); 35 require_once (APP_INC_PATH . "class.session.php"); 36 require_once (APP_INC_PATH . "db_access.php"); 37 require_once(APP_JPGRAPH_PATH . "jpgraph.php"); 38 require_once(APP_JPGRAPH_PATH . "jpgraph_bar.php"); 39 40 Auth::checkAuthentication(APP_COOKIE); 41 42 if (Auth::getCurrentRole() <= User::getRoleID("Customer")) { 43 echo "Invalid role"; 44 exit; 45 } 46 47 /** 48 * Customer Statistics Graphs. Will Graph different items, depending on what is passed to this page. 49 */ 50 51 $data = Session::get("customer_stats_data"); 52 if (empty($data)) { 53 echo "Unable to load data"; 54 exit; 55 } 56 57 $colors = array( 58 "#c0c0c0", 59 "#0033ff", 60 "#99ccff", 61 "#00ff66", 62 "#33ffcc", 63 "#ffff66", 64 "#ffffcc", 65 "#ff3333", 66 "#ff9191" 67 ); 68 $color_index = 0; 69 70 $graph_types = Customer_Stats_Report::getGraphTypes(); 71 72 $graph_id = $_GET["graph_id"]; 73 74 $plots = array(); 75 $max_title_len = 0; 76 foreach ($data as $index => $info) { 77 78 if (strlen($info["title"]) > $max_title_len) { 79 $max_title_len = strlen($info["title"]); 80 } 81 82 // go through data and convert into something plottable 83 $plottable = array(); 84 switch ($graph_id) { 85 case 1: 86 $plottable["Customer Count"] = $info["customer_counts"]["customer_count"]; 87 $plottable["Issues"] = $info["issue_counts"]["total"]; 88 $plottable["Emails by Staff"] = $info["email_counts"]["developer"]["total"]; 89 $plottable["Emails by Customers"] = $info["email_counts"]["customer"]["total"]; 90 break; 91 case 2: 92 $plottable["Issues"] = $info["issue_counts"]["avg"]; 93 $plottable["Emails by Staff"] = $info["email_counts"]["developer"]["avg"]; 94 $plottable["Emails by Customers"] = $info["email_counts"]["customer"]["avg"]; 95 break; 96 case 3: 97 $plottable["Avg Time to Close"] = $info["time_stats"]["time_to_close"]["avg"] / (60 * 24); 98 $plottable["Median Time to Close"] = $info["time_stats"]["time_to_close"]["median"] / (60 * 24); 99 break; 100 case 4: 101 $plottable["Avg Time to First Response"] = $info["time_stats"]["time_to_first_response"]["avg"] / 60; 102 $plottable["Median Time to First Response"] = $info["time_stats"]["time_to_first_response"]["median"] / 60; 103 break; 104 } 105 106 // Create a bar pot 107 $bplot = new BarPlot(array_values($plottable)); 108 $bplot->showValue(true); 109 $bplot->SetValueFont(FF_FONT2, FS_NORMAL, 9); 110 if (!empty($graph_types[$graph_id]["value_format"])) { 111 $value_format = $graph_types[$graph_id]["value_format"]; 112 } else { 113 $value_format = '%d'; 114 } 115 $bplot->SetValueFormat($value_format, 90); 116 117 $bplot->setLegend($info["title"]); 118 if (isset($colors[$color_index])) { 119 $color = $colors[$color_index]; 120 } else { 121 $color_index = 0; 122 $color = $colors[$color_index]; 123 } 124 $color_index++; 125 $bplot->SetFillColor($color); 126 $plots[] = $bplot; 127 $labels = array_keys($plottable); 128 } 129 130 // figure out width of legend to propery set margin. 131 $legend_width = (imagefontwidth(FF_FONT1) * $max_title_len) + 30; 132 133 if (!empty($graph_types[$graph_id]["size"]["group"])) { 134 $width = ($graph_types[$graph_id]["size"]["group"] * count($data)) + 200; 135 } else { 136 $width = $graph_types[$graph_id]["size"]["x"]; 137 } 138 139 if (!empty($graph_types[$graph_id]["y_label"])) { 140 $y_label = $graph_types[$graph_id]["y_label"]; 141 } else { 142 $y_label = "Count"; 143 } 144 145 $graph = new Graph($width, $graph_types[$graph_id]["size"]["y"]); 146 $graph->SetScale("textlin"); 147 $graph->img->setMargin(60,($legend_width + 20),25,25); 148 $graph->yaxis->SetTitleMargin(45); 149 $graph->yaxis->scale->setGrace(15,0); 150 $graph->SetShadow(); 151 152 // Turn the tickmarks 153 $graph->xaxis->SetTickDirection(SIDE_DOWN); 154 $graph->yaxis->SetTickDirection(SIDE_LEFT); 155 $graph->xaxis->SetTickLabels($labels); 156 157 // group plots together 158 $grouped = new GroupBarPlot($plots); 159 $graph->Add($grouped); 160 161 $graph->title->Set($graph_types[$graph_id]["title"]); 162 //$graph->xaxis->title->Set("Support Level"); 163 //$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); 164 $graph->title->SetFont(FF_FONT1,FS_BOLD); 165 $graph->yaxis->title->Set($y_label); 166 $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); 167 $graph->legend->Pos(.015,.5,'right','center'); 168 $graph->Stroke();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 19 21:21:33 2007 | Cross-referenced by PHPXref 0.7 |