[ Index ]

PHP Cross Reference of Eventum

title

Body

[close]

/reports/ -> workload_time_period_graph.php (source)

   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_time_period_graph.php 3437 2007-11-10 00:52:16Z 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.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 . "db_access.php");
  36  require_once(APP_JPGRAPH_PATH . "jpgraph.php");
  37  require_once(APP_JPGRAPH_PATH . "jpgraph_bar.php");
  38  
  39  Auth::checkAuthentication(APP_COOKIE);
  40  $usr_id = Auth::getUserID();
  41  
  42  if (Auth::getCurrentRole() <= User::getRoleID("Customer")) {
  43      echo "Invalid role";
  44      exit;
  45  }
  46  
  47  /**
  48   * Generates the workload by time period graph.
  49   */
  50  
  51  // get timezone of current user
  52  $user_prefs = Prefs::get($usr_id);
  53  
  54  if (@$_GET["type"] == "email") {
  55      $data = Report::getEmailWorkloadByTimePeriod(@$user_prefs["timezone"], true);
  56      $graph_title = ev_gettext("Email by Time Period");
  57      $event_type = ev_gettext("emails");
  58  } else {
  59      $data = Report::getWorkloadByTimePeriod(@$user_prefs["timezone"], true);
  60      $graph_title = ev_gettext("Workload by Time Period");
  61      $event_type = ev_gettext("actions");
  62  }
  63  
  64  $plots = array();
  65  foreach ($data as $performer => $values) {
  66      ksort($values);ksort($data[$performer]);
  67      
  68      // Create a bar pot 
  69      $bplot = new BarPlot(array_values($values));
  70      
  71      if ($performer == "customer") {
  72          $color = "#99ccff";
  73      } else {
  74          $color = "#ffcc00";
  75      }
  76      $bplot->SetFillColor($color);
  77      $bplot->setLegend(ucfirst($performer) . " " . $event_type);
  78      
  79      $plots[] = $bplot;
  80  }
  81  
  82  $graph = new Graph(800,350);
  83  $graph->SetScale("textlin");
  84  $graph->img->SetMargin(60,30,40,40);
  85  $graph->yaxis->SetTitleMargin(45);
  86  $graph->SetShadow();
  87  
  88  // Turn the tickmarks 
  89  $graph->xaxis->SetTickDirection(SIDE_DOWN);
  90  $graph->yaxis->SetTickDirection(SIDE_LEFT);
  91  $graph->xaxis->SetTickLabels(array_keys($data["developer"] + $data["customer"]));
  92  
  93  // group plots together
  94  $grouped = new GroupBarPlot($plots);
  95  $graph->Add($grouped);
  96  
  97  $graph->title->Set($graph_title);
  98  $graph->xaxis->title->Set("Hours (" . Date_API::getTimezoneShortNameByUser($usr_id) . ")");
  99  $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
 100  $graph->title->SetFont(FF_FONT1,FS_BOLD);
 101  $graph->yaxis->title->Set(ucfirst($event_type) . " (%)");
 102  $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
 103  $graph->legend->Pos(0.01,0.09,'left','bottom');
 104  $graph->legend->SetLayout(LEGEND_HOR); 
 105  $graph->Stroke();


Generated: Wed Dec 19 21:21:33 2007 Cross-referenced by PHPXref 0.7