<?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, value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` |
$query = "select procurementMethod, SUM(value) as value, 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 childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2009 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();
|
$methodValuesP = Array();
|
$methodValuesP = Array();
|
$methodValues = Array();
|
$methodValues = 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['value'] > $maxValue) $maxValue = $row['value'];
|
$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);
|
}
|
}
|
$methodValuesP[$row["procurementMethod"]][$date] = $row["value"];
|
$methodValuesP[$row["procurementMethod"]][$date] = $row["value"];
|
|
|
}
|
}
|
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
foreach($dates as $date) {
|
foreach($dates as $date) {
|
if ($methodValuesP[$method][$date] > 0) $methodValues[$method][] = $methodValuesP[$method][$date];
|
if ($methodValuesP[$method][$date] > 0) $methodValues[$method][] = $methodValuesP[$method][$date];
|
else $methodValues[$method][] = 0;
|
else $methodValues[$method][] = 0;
|
}
|
}
|
}
|
}
|
$dates = array_values($dates);
|
$dates = array_values($dates);
|
$totalRecords = array_sum_all($methodValues);
|
$totalRecords = array_sum_all($methodValues);
|
mysql_free_result($result);
|
mysql_free_result($result);
|
// Create a graph instance
|
// Create a graph instance
|
$graph = new Graph($width, $height);
|
$graph = new Graph($width, $height);
|
$graph->SetScale('datint');
|
$graph->SetScale('datint');
|
$graph->SetMargin(95, 145, 45, 100);
|
$graph->SetMargin(95, 145, 45, 100);
|
// Setup a title for the graph
|
// Setup a title for the graph
|
$graph->title->Set($agencyQ.$supplierQ);
|
$graph->title->Set($agencyQ.$supplierQ);
|
$graph->SetUserFont("liberation/LiberationSans-Regular.ttf");
|
$graph->SetUserFont("liberation/LiberationSans-Regular.ttf");
|
$graph->title->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
$graph->title->SetFont(FF_USERFONT, FS_NORMAL, 12);
|
// Setup font for axis
|
// Setup font for axis
|
$graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10);
|
$graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10);
|
$graph->xaxis->SetTickLabels($dates);
|
$graph->xaxis->SetTickLabels($dates);
|
$graph->xaxis->SetLabelAngle(50);
|
$graph->xaxis->SetLabelAngle(50);
|
$colors = Array ("orange","red","blue");
|
$colors = Array ("orange","red","blue");
|
for ($i = 0; $i <= 2;$i++) {
|
for ($i = 0; $i <= 2;$i++) {
|
$lplot[$i] = new LinePlot($methodValues[$methods[$i]]);
|
$lplot[$i] = new LinePlot($methodValues[$methods[$i]]);
|
$lplot[$i]->SetLegend($methods[$i]);
|
$lplot[$i]->SetLegend($methods[$i]);
|
$lplot[$i]->SetFillColor($colors[$i]);
|
$lplot[$i]->SetFillColor($colors[$i]);
|
}
|
}
|
|
|
// Create the grouped bar plot
|
// Create the grouped bar plot
|
$alplot = new AccLinePlot($lplot);
|
$alplot = new AccLinePlot($lplot);
|
// ...and add it to the graPH
|
// ...and add it to the graPH
|
$graph->Add($alplot);
|
$graph->Add($alplot);
|
|
|
$graph->Stroke();
|
$graph->Stroke();
|
?>
|
?>
|
|
|