<?php | <?php |
include_once("./lib/common.inc.php"); | include_once("./lib/common.inc.php"); |
include_header("Months and Years"); | include_header("Months and Years"); |
if ($_REQUEST['category']) { | if ($_REQUEST['month']) { |
echo "<center><h1>".$_REQUEST['category']."</h1></center>"; | echo "<center><h1>".$_REQUEST['month']."</h1></center>"; |
$monthParts = explode("-",$_REQUEST['month']); | |
$query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName | $query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName |
FROM `contractnotice` | FROM `contractnotice` |
WHERE childCN = 0 | WHERE childCN = 0 |
AND category = '" . $_REQUEST['category'] . "' | AND YEAR(contractStart) = {$monthParts[1]} |
AND MONTH(contractStart) = {$monthParts[0]} | |
ORDER BY value DESC"; | ORDER BY value DESC"; |
$result = mysql_query($query); | $result = mysql_query($query); |
echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">'; | |
echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">'; | |
echo "<table>"; | echo "<table>"; |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { | while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row['value']) , 2); | $value = number_format(doubleval($row['value']) , 2); |
echo ("<tr> | echo ("<tr> |
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> | <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> |
<td><b>{$row['description']}</b></a></td> | <td><b>{$row['description']}</b></a></td> |
<td>\$$value</td><td>{$row['agencyName']}</td> | <td>\$$value</td><td>{$row['agencyName']}</td> |
<td>{$row['contractStart']}</td> | <td>{$row['contractStart']}</td> |
<td>{$row['supplierName']}</td> | <td>{$row['supplierName']}</td> |
</tr>"); | </tr>"); |
} | } |
echo "</table>"; | echo "</table>"; |
mysql_free_result($result); | mysql_free_result($result); |
} else { | } else { |
/* | /* |
split by year | split by year |
todo: | todo: |
Year/Month drilldown - largest contracts, agencies, suppliers | Year/Month drilldown - largest contracts, agencies, suppliers |
count per month | |
big picture graphs?*/ | big picture graphs?*/ |
echo '<img src="graphs/displayContractStartingGraph.php">'; | |
echo '<img src="graphs/displayContractPublishedGraph.php">'; | |
$query = "SELECT YEAR(contractStart), MONTH(contractStart), | $query = "SELECT YEAR(contractStart), MONTH(contractStart), |
value FROM `contractnotice` WHERE childCN = 0 GROUP BY MONTH(contractStart), YEAR(contractStart) ORDER BY YEAR(contractStart), MONTH(contractStart) "; | SUM(value) as val, count(1) as count FROM `contractnotice` WHERE childCN = 0 GROUP BY MONTH(contractStart), YEAR(contractStart) ORDER BY YEAR(contractStart), MONTH(contractStart) "; |
$result = mysql_query($query); | $result = mysql_query($query); |
echo "<table>"; | echo "<table>"; |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { | while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row["value"]),2); | $value = number_format(doubleval($row["val"]),2); |
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); | $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); |
echo ("<tr><td><b>$month_name {$row[0]}</b></td><td>\$$value</td></tr>"); | echo ("<tr><td><b><a href=\"?month=$row[1]-$row[0]\">$month_name {$row[0]}</a></b></td><td>\$$value</td><td>({$row['count']} contracts)</td></tr>"); |
} | } |
echo "</table>"; | echo "</table>"; |
mysql_free_result($result); | mysql_free_result($result); |
} | } |
include_footer(); | include_footer(); |
?> | ?> |
<?php | <?php |
include_once("./lib/common.inc.php"); | include_once("./lib/common.inc.php"); |
/* | /* |
biggest suppliers in each method | biggest suppliers in each method |
biggest agencies in each method (weighted for size? percentage of total expenditure) | biggest agencies in each method (weighted for size? percentage of total expenditure) |
largest Average value by procurement type? | largest Average value by procurement type? |
*/ | */ |
include_header("Procurement Methods"); | include_header("Procurement Methods"); |
$query = "SELECT value, procurementMethod | $query = "SELECT SUM(value) as value, procurementMethod |
FROM `contractnotice` | FROM `contractnotice` |
WHERE childCN = 0 | |
GROUP BY procurementMethod "; | GROUP BY procurementMethod "; |
$result = mysql_query($query); | $result = mysql_query($query); |
echo "<table>"; | echo "<table>"; |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { | while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row[0]),2); | $value = number_format(doubleval($row[0]),2); |
echo ("<tr><td><b>{$row[1]}</b></td><td>\$$value</td></tr>"); | echo ("<tr><td><b>{$row[1]}</b></td><td>\$$value</td></tr>"); |
} | } |
echo "</table>"; | echo "</table>"; |
mysql_free_result($result); | mysql_free_result($result); |
include_footer(); | include_footer(); |
?> | ?> |
<?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 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(); |
$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("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(); |
?> | ?> |
<?php | <?php |
include_once("../lib/common.inc.php"); | include_once("../lib/common.inc.php"); |
$query = "SELECT YEAR(publishDate), MONTH(publishDate), | $query = "SELECT YEAR(publishDate), MONTH(publishDate), |
value, count(1) as count FROM `contractnotice` | SUM(value) as val, count(1) as count FROM `contractnotice` |
WHERE (YEAR(publishDate) >= 2008) | WHERE (YEAR(publishDate) >= 2008) |
AND childCN = 0 | AND childCN = 0 |
GROUP BY MONTH(publishDate), YEAR(publishDate) | GROUP BY MONTH(publishDate), YEAR(publishDate) |
ORDER BY YEAR(publishDate), MONTH(publishDate)"; | ORDER BY YEAR(publishDate), MONTH(publishDate)"; |
$result = mysql_query($query); | $result = mysql_query($query); |
$dates = Array(); | $dates = Array(); |
$values = Array(); | $values = Array(); |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { | while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row["value"]),2); | $value = number_format(doubleval($row["val"]),2); |
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); | $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); |
$dates[] = $month_name." {$row[0]}"; | $dates[] = $month_name." {$row[0]}"; |
$counts[] = doubleval($row["count"]); | $counts[] = doubleval($row["count"]); |
$values[] = doubleval($row["value"]); | $values[] = doubleval($row["val"]); |
} | } |
mysql_free_result($result); | mysql_free_result($result); |
// Width and height of the graph | // Width and height of the graph |
$width = 1000; $height = 400; | $width = 1000; $height = 400; |
// Create a graph instance | // Create a graph instance |
$graph = new Graph($width,$height); | $graph = new Graph($width,$height); |
$graph->SetMargin(85,45,45,115); | $graph->SetMargin(85,45,45,115); |
// Specify what scale we want to use, | // Specify what scale we want to use, |
$graph->SetScale('textlog'); | $graph->SetScale('textlog'); |
// Setup a title for the graph | // Setup a title for the graph |
$graph->title->Set('Contracts Starting - All Agencies since July 2008'); | $graph->title->Set('Contracts Published - All Agencies since July 2008'); |
$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->yaxis->SetFont(FF_USERFONT,FS_NORMAL,10); | $graph->yaxis->SetFont(FF_USERFONT,FS_NORMAL,10); |
// Setup titles and X-axis labels | // Setup titles and X-axis labels |
$graph->xaxis->SetTickLabels($dates); | $graph->xaxis->SetTickLabels($dates); |
$graph->xaxis->SetLabelAngle(50); | $graph->xaxis->SetLabelAngle(50); |
// Create the linear plot | // Create the linear plot |
$valueplot=new LinePlot($values); | $valueplot=new LinePlot($values); |
$valueplot->SetFillColor('orange@0.5'); | $valueplot->SetFillColor('orange@0.5'); |
$valueplot->SetLegend("Total Value"); | $valueplot->SetLegend("Total Value"); |
$countplot=new LinePlot($counts); | $countplot=new LinePlot($counts); |
$countplot->SetFillColor('red@0.5'); | $countplot->SetFillColor('red@0.5'); |
$countplot->SetLegend("Number of Contracts"); | $countplot->SetLegend("Number of Contracts"); |
// Add the plot to the graph | // Add the plot to the graph |
$graph->Add($valueplot); | $graph->Add($valueplot); |
$graph->SetYScale(0,'lin'); | $graph->SetYScale(0,'lin'); |
$graph->ynaxis[0]->SetColor('red'); | $graph->ynaxis[0]->SetColor('red'); |
$graph->AddY(0,$countplot); | $graph->AddY(0,$countplot); |
// Display the graph | // Display the graph |
$graph->Stroke(); | $graph->Stroke(); |
?> | ?> |
<?php | <?php |
include_once("../lib/common.inc.php"); | include_once("../lib/common.inc.php"); |
$query = "SELECT YEAR(contractStart), MONTH(contractStart), | $query = "SELECT YEAR(contractStart), MONTH(contractStart), |
value, count(1) as count FROM `contractnotice` | SUM(value) as val, count(1) as count FROM `contractnotice` |
WHERE (YEAR(contractStart) >= 2008) | WHERE (YEAR(contractStart) >= 2008) |
AND childCN = 0 | AND childCN = 0 |
GROUP BY MONTH(contractStart), YEAR(contractStart) | GROUP BY MONTH(contractStart), YEAR(contractStart) |
ORDER BY YEAR(contractStart), MONTH(contractStart)"; | ORDER BY YEAR(contractStart), MONTH(contractStart)"; |
$result = mysql_query($query); | $result = mysql_query($query); |
$dates = Array(); | $dates = Array(); |
$values = Array(); | $values = Array(); |
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { | while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row["value"]),2); | $value = number_format(doubleval($row["val"]),2); |
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); | $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); |
$dates[] = $month_name." {$row[0]}"; | $dates[] = $month_name." {$row[0]}"; |
$counts[] = doubleval($row["count"]); | $counts[] = doubleval($row["count"]); |
$values[] = doubleval($row["value"]); | $values[] = doubleval($row["val"]); |
} | } |
mysql_free_result($result); | mysql_free_result($result); |
// Width and height of the graph | // Width and height of the graph |
$width = 1000; $height = 400; | $width = 1000; $height = 400; |
// Create a graph instance | // Create a graph instance |
$graph = new Graph($width,$height); | $graph = new Graph($width,$height); |
$graph->SetMargin(85,45,45,115); | $graph->SetMargin(85,45,45,115); |
// Specify what scale we want to use, | // Specify what scale we want to use, |
$graph->SetScale('textlog'); | $graph->SetScale('textlog'); |
// Setup a title for the graph | // Setup a title for the graph |
$graph->title->Set('Contracts Starting - All Agencies since July 2008'); | $graph->title->Set('Contracts Starting - All Agencies since July 2008'); |
$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->yaxis->SetFont(FF_USERFONT,FS_NORMAL,10); | $graph->yaxis->SetFont(FF_USERFONT,FS_NORMAL,10); |
// Setup titles and X-axis labels | // Setup titles and X-axis labels |
$graph->xaxis->SetTickLabels($dates); | $graph->xaxis->SetTickLabels($dates); |
$graph->xaxis->SetLabelAngle(50); | $graph->xaxis->SetLabelAngle(50); |
// Create the linear plot | // Create the linear plot |
$valueplot=new LinePlot($values); | $valueplot=new LinePlot($values); |
$valueplot->SetFillColor('orange@0.5'); | $valueplot->SetFillColor('orange@0.5'); |
$valueplot->SetLegend("Total Value"); | $valueplot->SetLegend("Total Value"); |
$countplot=new LinePlot($counts); | $countplot=new LinePlot($counts); |
$countplot->SetFillColor('red@0.5'); | $countplot->SetFillColor('red@0.5'); |
$countplot->SetLegend("Number of Contracts"); | $countplot->SetLegend("Number of Contracts"); |
// Add the plot to the graph | // Add the plot to the graph |
$graph->Add($valueplot); | $graph->Add($valueplot); |
$graph->SetYScale(0,'lin'); | $graph->SetYScale(0,'lin'); |
$graph->ynaxis[0]->SetColor('red'); | $graph->ynaxis[0]->SetColor('red'); |
$graph->AddY(0,$countplot); | $graph->AddY(0,$countplot); |
// Display the graph | // Display the graph |
$graph->Stroke(); | $graph->Stroke(); |
?> | ?> |
<?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 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(); |
$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['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); |
} | } |
$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); |
// 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($methodCounts[$methods[$i]]); | $lplot[$i] = new LinePlot($methodCounts[$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(); |
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("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); |
//----------------------- | //----------------------- |
// Create a multigraph | // Create a multigraph |
//---------------------- | //---------------------- |
$mgraph = new MGraph(); | $mgraph = new MGraph(); |
$mgraph->SetMargin(2, 2, 2, 2); | $mgraph->SetMargin(2, 2, 2, 2); |
$mgraph->Add($graph, 0, 0); | $mgraph->Add($graph, 0, 0); |
$mgraph->Add($graph2, 0, ($height) + 5); | $mgraph->Add($graph2, 0, ($height) + 5); |
$mgraph->Stroke(); | $mgraph->Stroke(); |
?> | ?> |
<?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(); |
?> | ?> |
can we merge accountablity-avoiding contract notices (ie sequential/similar agencyInternalID/description to same vendor, same publish date) | can we merge accountablity-avoiding contract notices (ie sequential/similar agencyInternalID/description to same vendor, same publish date) |
can we merge ABN splitting companies like PWC/Dell Finance? | can we merge ABN splitting companies like PWC/Dell Finance? |
can we add google news? lobbyist officers? | can we add google news? lobbyist officers? |
compile database of file lists | compile database of file lists |
compile database of employees | compile database of employees |
show metrics about agencies/suppliers eg. extent of contract variations, level of reg 10 commitments, reporting speedyness | |