fix value/sum
--- a/displayCalendar.php
+++ b/displayCalendar.php
@@ -3,14 +3,19 @@
include_header("Months and Years");
-if ($_REQUEST['category']) {
- echo "<center><h1>".$_REQUEST['category']."</h1></center>";
+if ($_REQUEST['month']) {
+ echo "<center><h1>".$_REQUEST['month']."</h1></center>";
+$monthParts = explode("-",$_REQUEST['month']);
$query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName
FROM `contractnotice`
WHERE childCN = 0
- AND category = '" . $_REQUEST['category'] . "'
+ AND YEAR(contractStart) = {$monthParts[1]}
+ AND MONTH(contractStart) = {$monthParts[0]}
ORDER BY value DESC";
$result = mysql_query($query);
+echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">';
+ echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">';
+
echo "<table>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
setlocale(LC_MONETARY, 'en_US');
@@ -30,22 +35,28 @@
split by year
todo:
Year/Month drilldown - largest contracts, agencies, suppliers
+count per month
big picture graphs?*/
+echo '<img src="graphs/displayContractStartingGraph.php">';
+echo '<img src="graphs/displayContractPublishedGraph.php">';
+
+
$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);
echo "<table>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
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]) );
- 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>";
mysql_free_result($result);
}
include_footer();
-?>
+?>
+
--- a/displayProcurementMethod.php
+++ b/displayProcurementMethod.php
@@ -10,8 +10,9 @@
*/
include_header("Procurement Methods");
-$query = "SELECT value, procurementMethod
+$query = "SELECT SUM(value) as value, procurementMethod
FROM `contractnotice`
+WHERE childCN = 0
GROUP BY procurementMethod ";
$result = mysql_query($query);
--- a/graphs/displayCnCGraph.php
+++ b/graphs/displayCnCGraph.php
@@ -3,7 +3,7 @@
// Width and height of the graph
$width = 800;
$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";
$result = mysql_query($query);
$methods = Array("Direct","Open","Select");
@@ -13,7 +13,7 @@
$maxValue = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
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"];
if (array_search($date,$dates) === false ) {
$dates[$row["year"]*100 + $row["month"]] = $date;
--- a/graphs/displayContractPublishedGraph.php
+++ b/graphs/displayContractPublishedGraph.php
@@ -1,7 +1,7 @@
<?php
include_once("../lib/common.inc.php");
$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)
AND childCN = 0
GROUP BY MONTH(publishDate), YEAR(publishDate)
@@ -12,11 +12,11 @@
$values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
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]) );
$dates[] = $month_name." {$row[0]}";
$counts[] = doubleval($row["count"]);
- $values[] = doubleval($row["value"]);
+ $values[] = doubleval($row["val"]);
}
mysql_free_result($result);
@@ -31,7 +31,7 @@
$graph->SetScale('textlog');
// 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->title->SetFont(FF_USERFONT,FS_NORMAL,12);
--- a/graphs/displayContractStartingGraph.php
+++ b/graphs/displayContractStartingGraph.php
@@ -1,7 +1,7 @@
<?php
include_once("../lib/common.inc.php");
$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)
AND childCN = 0
GROUP BY MONTH(contractStart), YEAR(contractStart)
@@ -12,11 +12,11 @@
$values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
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]) );
$dates[] = $month_name." {$row[0]}";
$counts[] = doubleval($row["count"]);
- $values[] = doubleval($row["value"]);
+ $values[] = doubleval($row["val"]);
}
mysql_free_result($result);
--- a/graphs/displayMethodCountGraph.php
+++ b/graphs/displayMethodCountGraph.php
@@ -3,7 +3,7 @@
// Width and height of the graph
$width = 800;
$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";
$result = mysql_query($query);
$methods = Array("Direct","Open","Select");
--- a/graphs/displayMethodValueGraph.php
+++ b/graphs/displayMethodValueGraph.php
@@ -3,7 +3,7 @@
// Width and height of the graph
$width = 800;
$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";
$result = mysql_query($query);
$methods = Array("Direct","Open","Select");
--- a/todo.txt
+++ b/todo.txt
@@ -6,4 +6,7 @@
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
+