graph.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:3k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: graph.php,v $
- // | $Date: 2004/02/10 01:34:30 $
- // | $Revision: 1.20 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Generate graphs for technician reports page.
- // +-------------------------------------------------------------+
- error_reporting(E_ALL ^ E_NOTICE);
- include "./../global.php";
- require_once(INCLUDE_PATH.'functions/calendar_functions.php');
- require_once(INCLUDE_PATH.'graph/jpgraph.php');
- require_once(INCLUDE_PATH.'graph/jpgraph_pie.php');
- require_once(INCLUDE_PATH.'graph/jpgraph_pie3d.php');
- $graph = 0;
- if ($_REQUEST['type'] == 'category') {
- $db->query("
- SELECT COUNT(*) AS total, ticket_cat.name AS category FROM ticket
- LEFT JOIN ticket_cat ON ticket.category = ticket_cat.id
- WHERE tech = '$user[id]'
- AND ticket.is_open
- AND ticket.awaiting_tech
- GROUP BY category
- ");
- while ($res = $db->row_array()) {
- if (!$res['category']) {
- $res['category'] = "No category";
- }
- if (strlen($res['category']) > 20) {
- $res['category'] = substr($res['category'], 0, 20);
- }
- $data[$res['category']] = $res['total'];
- $graph = 1;
- }
- } else {
- $db->query("
- SELECT COUNT(*) AS total, ticket_pri.name AS priority FROM ticket
- LEFT JOIN ticket_pri ON ticket.priority = ticket_pri.id
- WHERE tech = '$user[id]'
- AND ticket.is_open
- AND ticket.awaiting_tech
- GROUP BY priority
- ");
- while ($res = $db->row_array()) {
- if (!$res['priority']) {
- $res['priority'] = "No priority";
- }
- if (strlen($res['priority']) > 20) {
- $res['priority'] = substr($res['priority'], 0, 20);
- }
- $data[$res['priority']] = $res['total'];
- $graph = 1;
- }
- }
- if (!$graph) {
- exit;
- }
- $graph = new PieGraph(350, 175);
- $piegraph = new PiePlot3D(array_values($data));
- $piegraph->SetCenter(0.35,0.5);
- $piegraph->value->SetFont(FF_VERDANA,FS_NORMAL,8);
- $graph->legend->SetFont(FF_VERDANA,FS_NORMAL,7);
- $piegraph->SetLegends(array_keys($data));
- $piegraph->SetLabelType(PIE_VALUE_ABS);
- $piegraph->value->SetFormat('%d');
- $piegraph->SetSize(0.40);
- $graph->Add($piegraph);
- $graph->legend->Pos(0.02,0.02);
- $graph->SetMarginColor('silver');
- $graph->Stroke();