-
Notifications
You must be signed in to change notification settings - Fork 6
/
city_graph.php
48 lines (42 loc) · 1.67 KB
/
city_graph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @package city_graph.php
* @author John Doe <[email protected]>
* @since version
* @version 2013-10-05
*/
/*
10/5/2013 complete rewrite; simplification based on using SQL COUNT/GROUP-BY
*/
require_once './incs/functions.inc.php'; //7/28/10
extract($_GET);
$where = " WHERE `problemstart` > '{$p1}' AND `problemstart` < '{$p2}' ";
$query = "SELECT `city`, COUNT(*) AS `nr`
FROM `$GLOBALS[mysql_prefix]ticket` `t`
{$where}
AND `t`.`status` != {$GLOBALS['STATUS_RESERVED']}
GROUP BY `city`
ORDER BY `nr` DESC
LIMIT 5"; // limit is a BAACHART issue
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
if (mysql_num_rows($result) > 0) {
$temp = explode ("/", get_variable('pie_charts'));
$type_diam = (count($temp)> 0 )? intval($temp[2]) : "450"; //
$width = isset($img_width)? $img_width: $type_diam; // 3/21/10
include 'baaChart.php';
$mygraph = new baaChart($width);
$incidents_capt = get_text("incidents");
$mygraph->setTitle("{$incidents_capt} by City","");
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) { //
$row ['city'] = ( @strlen( @trim ( $row ['city'] ) )> 0 ) ? $row ['city'] : " ? " ; // possible null/empty
$mygraph->addDataSeries('P',PIE_CHART_PCENT + PIE_LEGEND_VALUE, $row ['nr'] , $row ['city'] );
}
$mygraph->setBgColor(0,0,0,1); //transparent background
$mygraph->setChartBgColor(0,0,0,1); //as background
$mygraph->drawGraph();
}
else { // a WTF situation?
$err_arg = basename(__FILE__) . "/" . __LINE__;
do_log ($GLOBALS['LOG_ERROR'], 0, 0, $err_arg); // log error message
}
?>