[ 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: workload_date_range_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.template.php"); 32 require_once (APP_INC_PATH . "class.auth.php"); 33 require_once (APP_INC_PATH . "class.report.php"); 34 require_once (APP_INC_PATH . "class.custom_field.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 require_once(APP_JPGRAPH_PATH . "jpgraph_pie.php"); 40 require_once(APP_JPGRAPH_PATH . "jpgraph_line.php"); 41 42 Auth::checkAuthentication(APP_COOKIE); 43 44 if (Auth::getCurrentRole() <= User::getRoleID("Customer")) { 45 echo "Invalid role"; 46 exit; 47 } 48 49 /** 50 * Generates a graph for workload by date range report 51 */ 52 $data = Session::get("workload_date_range_data"); 53 if (empty($data)) { 54 echo "Unable to load data"; 55 exit; 56 } 57 58 switch ($_REQUEST["interval"]) { 59 case "dow": 60 $x_title = "Day of Week"; 61 break; 62 case "week": 63 $x_title = "Week"; 64 break; 65 case "dom": 66 $x_title = "Day of Month"; 67 break; 68 case "day": 69 $x_title = "Day"; 70 break; 71 case "month": 72 $x_title = "Month"; 73 break; 74 } 75 76 if ($_REQUEST["graph"] == "issue") { 77 $plots = array_values($data["issues"]["points"]); 78 $graph_title = "Issues by created date"; 79 $labels = array_keys($data["issues"]["points"]); 80 $y_label = "Issues"; 81 } elseif ($_REQUEST["graph"] == "email") { 82 $plots = array_values($data["emails"]["points"]); 83 $graph_title = "Emails by sent date"; 84 $labels = array_keys($data["emails"]["points"]); 85 $y_label = "Emails"; 86 }elseif ($_REQUEST["graph"] == "note") { 87 $plots = array_values($data["notes"]["points"]); 88 $graph_title = "Notes by sent date"; 89 $labels = array_keys($data["notes"]["points"]); 90 $y_label = "Notes"; 91 } elseif ($_REQUEST["graph"] == "phone") { 92 $plots = array_values($data["phone"]["points"]); 93 $graph_title = "Phone calls by date"; 94 $labels = array_keys($data["phone"]["points"]); 95 $y_label = "Phone Calls"; 96 } elseif ($_REQUEST["graph"] == "time_spent") { 97 $plots = array_values($data["time_spent"]["points"]); 98 $graph_title = "Time spent (hrs)"; 99 $labels = array_keys($data["time_spent"]["points"]); 100 $y_label = "Hours"; 101 } elseif ($_REQUEST["graph"] == "avg_time_per_issue") { 102 $plots = array_values($data["avg_time_per_issue"]["points"]); 103 $graph_title = "Avg. Time spent per issue (min)"; 104 $labels = array_keys($data["avg_time_per_issue"]["points"]); 105 $y_label = "Minutes"; 106 } 107 $graph_title .= " " . $_REQUEST["start_date"] . " through " . $_REQUEST["end_date"]; 108 109 if (count($plots) < 1) { 110 Header("Location: ../images/no_data.gif"); 111 exit; 112 } 113 114 if (@$_REQUEST["type"] == "pie") { 115 116 // A new graph 117 $graph = new PieGraph(500,300,"auto"); 118 119 // The pie plot 120 $plot = new PiePlot($plots); 121 $plot->SetTheme('pastel'); 122 123 // Move center of pie to the left to make better room 124 // for the legend 125 $plot->SetCenter(0.26,0.55); 126 127 // Label font and color setup 128 $plot->SetFont(FF_FONT1, FS_BOLD); 129 $plot->SetFontColor("black"); 130 131 // Use percentages 132 $plot->SetLabelType(0); 133 134 // Size of pie in fraction of the width of the graph 135 $plot->SetSize(0.3); 136 137 // Legends 138 $plot->SetLegends($labels); 139 $graph->legend->SetFont(FF_FONT1); 140 $graph->legend->Pos(0.06,0.27); 141 142 } else { 143 144 // bar chart 145 $plot = new BarPlot($plots); 146 $plot->showValue(true); 147 $plot->SetValueFont(FF_FONT2, FS_NORMAL, 9); 148 149 //$plot->setLegend("Issues"); 150 151 // figure out the best size for this graph. 152 $width = 75; 153 if (count($labels) > 3) { 154 foreach ($labels as $label) { 155 $label_width = imagefontwidth(FF_FONT1) * strlen($label) + 15; 156 if ($label_width < 50) { 157 $label_width = 50; 158 } 159 $width += $label_width; 160 } 161 } 162 if ($width < 500) { 163 $width = 500; 164 } 165 166 $plot->showValue(true); 167 $plot->SetFillColor("#0000ff"); 168 169 $graph = new Graph($width,350); 170 $graph->SetScale("textlin"); 171 $graph->img->SetMargin(50,30,40,40); 172 $graph->yaxis->SetTitleMargin(30); 173 $graph->SetShadow(); 174 175 // Turn the tickmarks 176 $graph->xaxis->SetTickDirection(SIDE_DOWN); 177 $graph->yaxis->SetTickDirection(SIDE_LEFT); 178 $graph->xaxis->SetTickLabels($labels); 179 180 $graph->xaxis->title->Set($x_title); 181 $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD); 182 $graph->title->SetFont(FF_FONT1,FS_BOLD); 183 $graph->yaxis->scale->setGrace(15,0); 184 $graph->yaxis->title->Set($y_label); 185 $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD); 186 187 } 188 189 $graph->title->Set($graph_title); 190 $graph->title->SetFont(FF_FONT1,FS_BOLD); 191 192 $graph->Add($plot); 193 $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 |