<?php
|
<?php
|
include_once ("../lib/common.inc.php");
|
include_once ("../lib/common.inc.php");
|
$agency = "AusAid";
|
$agency = "AusAid";
|
$topX = 15;
|
$topX = 15;
|
$startYear = 2007; |
|
$query = "SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 AND agencyName = '$agency'
|
$query = "SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 AND agencyName = '$agency'
|
GROUP BY lower(supplierName) ORDER BY val DESC limit $topX";
|
GROUP BY lower(supplierName) ORDER BY val DESC limit $topX";
|
$result = mysql_query($query);
|
$result = mysql_query($query);
|
$suppliers = Array();
|
$suppliers = Array();
|
$values = Array();
|
$values = Array();
|
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
$suppliers[] = ucsmart($row['supplierName']);
|
$suppliers[] = ucsmart($row['supplierName']);
|
$values[] = doubleval($row["val"]);
|
$values[] = doubleval($row["val"]);
|
}
|
}
|
mysql_free_result($result);
|
mysql_free_result($result);
|
|
|
$query = "SELECT sum(a.val) as value, count(1) as count from (SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 and agencyName = '$agency'
|
$query = "SELECT sum(a.val) as value, count(1) as count from (SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 and agencyName = '$agency'
|
GROUP BY lower(supplierName) ORDER BY val DESC LIMIT 18446744073709551610 OFFSET $topX) as a";
|
GROUP BY lower(supplierName) ORDER BY val DESC LIMIT 18446744073709551610 OFFSET $topX) as a";
|
$result = mysql_query($query);
|
$result = mysql_query($query);
|
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
|
if ($row['count'] > 0) {
|
if ($row['count'] > 0) {
|
$suppliers[] = $row['count'] . " other suppliers";
|
$suppliers[] = $row['count'] . " other suppliers";
|
$values[] = doubleval($row[0]);
|
$values[] = doubleval($row[0]);
|
}
|
}
|
}
|
}
|
mysql_free_result($result);
|
mysql_free_result($result);
|
|
|
// Width and height of the graph
|
// Width and height of the graph
|
$width = 800;
|
$width = 800;
|
$height = 800;
|
$height = 800;
|
// Create a graph instance
|
// Create a graph instance
|
$graph = new PieGraph($width, $height);
|
$graph = new PieGraph($width, $height);
|
$pieplot = new PiePlot($values);
|
$pieplot = new PiePlot($values);
|
$pieplot->SetCenter(400, 300);
|
$pieplot->SetCenter(400, 300);
|
$pieplot->SetGuideLines(true, false);
|
$pieplot->SetGuideLines(true, false);
|
$pieplot->SetLegends($suppliers);
|
$pieplot->SetLegends($suppliers);
|
// Add the plot to the graph
|
// Add the plot to the graph
|
$graph->Add($pieplot);
|
$graph->Add($pieplot);
|
$graph->legend->SetPos(0.01, 0.97, 'left', 'bottom');
|
$graph->legend->SetPos(0.01, 0.97, 'left', 'bottom');
|
$graph->legend->SetColumns(2);
|
$graph->legend->SetColumns(2);
|
// Display the graph
|
// Display the graph
|
$graph->Stroke();
|
$graph->Stroke();
|
?> |
?> |