graph.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:3k
源码类别:

电子政务应用

开发平台:

Java

  1. <?php
  2. // +-------------------------------------------------------------+
  3. // | DeskPRO v [2.0.1 Production]
  4. // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
  5. // | Supplied by WTN-WDYL
  6. // | Nullified by WTN-WDYL
  7. // | Distribution via WebForum, ForumRU and associated file dumps
  8. // +-------------------------------------------------------------+
  9. // | DESKPRO IS NOT FREE SOFTWARE
  10. // +-------------------------------------------------------------+
  11. // | License ID : Full Enterprise License =) ...
  12. // | License Owner : WTN-WDYL Team
  13. // +-------------------------------------------------------------+
  14. // | $RCSfile: graph.php,v $
  15. // | $Date: 2004/02/10 01:34:30 $
  16. // | $Revision: 1.20 $
  17. // +-------------------------------------------------------------+
  18. // | File Details:
  19. // | - Generate graphs for technician reports page.
  20. // +-------------------------------------------------------------+
  21. error_reporting(E_ALL ^ E_NOTICE);
  22. include "./../global.php";
  23. require_once(INCLUDE_PATH.'functions/calendar_functions.php');
  24. require_once(INCLUDE_PATH.'graph/jpgraph.php');
  25. require_once(INCLUDE_PATH.'graph/jpgraph_pie.php');
  26. require_once(INCLUDE_PATH.'graph/jpgraph_pie3d.php');
  27. $graph = 0;
  28. if ($_REQUEST['type'] == 'category') {
  29. $db->query("
  30. SELECT COUNT(*) AS total, ticket_cat.name AS category FROM ticket
  31. LEFT JOIN ticket_cat ON ticket.category = ticket_cat.id
  32. WHERE tech = '$user[id]'
  33. AND ticket.is_open 
  34. AND ticket.awaiting_tech
  35. GROUP BY category
  36. ");
  37. while ($res = $db->row_array()) {
  38. if (!$res['category']) {
  39. $res['category'] = "No category";
  40. }
  41. if (strlen($res['category']) > 20) {
  42. $res['category'] = substr($res['category'], 0, 20);
  43. }
  44. $data[$res['category']] = $res['total'];
  45. $graph = 1;
  46. }
  47. } else {
  48. $db->query("
  49. SELECT COUNT(*) AS total, ticket_pri.name AS priority FROM ticket
  50. LEFT JOIN ticket_pri ON ticket.priority = ticket_pri.id
  51. WHERE tech = '$user[id]'
  52. AND ticket.is_open 
  53. AND ticket.awaiting_tech
  54. GROUP BY priority
  55. ");
  56. while ($res = $db->row_array()) {
  57. if (!$res['priority']) {
  58. $res['priority'] = "No priority";
  59. }
  60. if (strlen($res['priority']) > 20) {
  61. $res['priority'] = substr($res['priority'], 0, 20);
  62. }
  63. $data[$res['priority']] = $res['total'];
  64. $graph = 1;
  65. }
  66. }
  67. if (!$graph) {
  68. exit;
  69. }
  70. $graph = new PieGraph(350, 175);
  71. $piegraph = new PiePlot3D(array_values($data));
  72. $piegraph->SetCenter(0.35,0.5);
  73. $piegraph->value->SetFont(FF_VERDANA,FS_NORMAL,8);
  74. $graph->legend->SetFont(FF_VERDANA,FS_NORMAL,7);
  75. $piegraph->SetLegends(array_keys($data));
  76. $piegraph->SetLabelType(PIE_VALUE_ABS);
  77. $piegraph->value->SetFormat('%d');
  78. $piegraph->SetSize(0.40);
  79. $graph->Add($piegraph);
  80. $graph->legend->Pos(0.02,0.02);
  81. $graph->SetMarginColor('silver');
  82. $graph->Stroke();