<?php
|
<?php
|
include_once ("../lib/common.inc.php");
|
include_once ("../lib/common.inc.php");
|
// Width and height of the graph
|
// Width and height of the graph
|
$width = 800;
|
$width = 800;
|
$height = 300;
|
$height = 300;
|
$query = "select procurementMethod, count(1) as count, value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` |
$query = "select procurementMethod, count(1) as count, SUM(value) as val, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` |
where $agencyQ $supplierQ childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2009 group by procurementMethod,year,month order by procurementMethod,year,month"; |
where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month"; |
$result = mysql_query($query);
|
$result = mysql_query($query);
|
$methods = Array("Direct","Open","Select");
|
$methods = Array("Direct","Open","Select");
|
$dates = Array();
|
$dates = Array();
|
$methodCountsP = Array();
|
$methodCountsP = Array();
|
$methodCounts = Array();
|
$methodCounts = Array();
|
$maxValue = 0;
|
$maxValue = 0;
|
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
|
setlocale(LC_MONETARY, 'en_US');
|
setlocale(LC_MONETARY, 'en_US');
|
if ($row['value'] > $maxValue) $maxValue = $row['value']; |
if ($row['val'] > $maxValue) $maxValue = $row['val']; |
$date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"];
|
$date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"];
|
if (array_search($date,$dates) === false ) {
|
if (array_search($date,$dates) === false ) {
|
$dates[$row["year"]*100 + $row["month"]] = $date;
|
$dates[$row["year"]*100 + $row["month"]] = $date;
|
ksort($dates);
|
ksort($dates);
|
}
|
}
|
$methodCountsP[$row["procurementMethod"]][$date] = $row["count"];
|
$methodCountsP[$row["procurementMethod"]][$date] = $row["count"];
|
|
|
}
|
}
|
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
foreach($dates as $date) {
|
foreach($dates as $date) {
|
if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date];
|
if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date];
|
else $methodCounts[$method][] = 0;
|
else $methodCounts[$method][] = 0;
|
}
|
}
|
}
|
}
|
$dates = array_values($dates);
|
$dates = array_values($dates);
|
$totalRecords = array_sum_all($methodCounts);
|
$totalRecords = array_sum_all($methodCounts);
|
mysql_free_result($result);
|
mysql_free_result($result);
|
|
|
|
|
function formatCallback($aVal) {
|
function formatCallback($aVal) {
|
global $totalRecords;
|
global $totalRecords;
|
return percent($aVal, $totalRecords) . "%";
|
return percent($aVal, $totalRecords) . "%";
|
}
|
}
|
$attributes = Array();
|
$attributes = Array();
|
$attributeNames = Array(
|
$attributeNames = Array(
|
"Consultancies",
|
"Consultancies",
|
"Confidentialities"
|
"Confidentialities"
|
);
|
);
|
$query = "SELECT 'consultancy', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ consultancy='Yes' AND childCN = 0;";
|
$query = "SELECT 'consultancy', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ consultancy='Yes' AND childCN = 0;";
|
$result = mysql_query($query);
|
$result = mysql_query($query);
|
$row = mysql_fetch_array($result, MYSQL_BOTH);
|
$row = mysql_fetch_array($result, MYSQL_BOTH);
|
$attributes[0] = $row[1];
|
$attributes[0] = $row[1];
|
$query = "SELECT 'confidentiality', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ (confidentialityContract='Yes' OR confidentialityOutputs='Yes') AND childCN = 0;";
|
$query = "SELECT 'confidentiality', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ (confidentialityContract='Yes' OR confidentialityOutputs='Yes') AND childCN = 0;";
|
$result = mysql_query($query);
|
$result = mysql_query($query);
|
$row = mysql_fetch_array($result, MYSQL_BOTH);
|
$row = mysql_fetch_array($result, MYSQL_BOTH);
|
$attributes[1] = $row[1];
|
$attributes[1] = $row[1];
|
mysql_free_result($result);
|
mysql_free_result($result);
|
// Create a graph instance
|
// Create a graph instance
|
$graph2 = new Graph($width, $height);
|
$graph2 = new Graph($width, $height);
|
$graph2->SetScale('textlin',0,$totalRecords);
|
$graph2->SetScale('textlin',0,$totalRecords);
|
$graph2->Set90AndMargin(105, 45, 45, 45);
|
$graph2->Set90AndMargin(105, 45, 45, 45);
|
// Setup a title for the graph
|
// Setup a title for the graph
|
$graph2->title->Set($agency);
|
$graph2->title->Set($agency);
|
$graph2->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); |
$graph2->SetUserFont("liberation/LiberationSans-Regular.ttf"); |
$graph2->title->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
$graph2->title->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
// Setup font for axis
|
// Setup font for axis
|
$graph2->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10);
|
$graph2->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10);
|
$graph2->xaxis->SetTickLabels($attributeNames);
|
$graph2->xaxis->SetTickLabels($attributeNames);
|
$graph2->yaxis->hide();
|
$graph2->yaxis->hide();
|
$attb1plot = new BarPlot($attributes);
|
$attb1plot = new BarPlot($attributes);
|
$attb1plot->value->Show();
|
$attb1plot->value->Show();
|
$attb1plot->SetValuePos('top');
|
$attb1plot->SetValuePos('top');
|
$attb1plot->value->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
$attb1plot->value->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
$attb1plot->value->SetAngle(45);
|
$attb1plot->value->SetAngle(45);
|
$attb1plot->value->SetFormatCallback("formatCallback");
|
$attb1plot->value->SetFormatCallback("formatCallback");
|
$attb1plot->SetFillColor("orange");
|
$attb1plot->SetFillColor("orange");
|
// ...and add it to the graPH
|
// ...and add it to the graPH
|
$graph2->Add($attb1plot);
|
$graph2->Add($attb1plot);
|
$graph2->Stroke();
|
$graph2->Stroke();
|
?>
|
?>
|
|
|