From: root Date: Wed, 02 Jun 2010 09:24:49 +0000 Subject: fix value/sum X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=234da1061420d4a311d17af971929f38aa9fff9d --- fix value/sum --- --- a/displayCalendar.php +++ b/displayCalendar.php @@ -3,14 +3,19 @@ include_header("Months and Years"); -if ($_REQUEST['category']) { - echo "

".$_REQUEST['category']."

"; +if ($_REQUEST['month']) { + echo "

".$_REQUEST['month']."

"; +$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 ''; + echo ''; + echo ""; 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 ''; +echo ''; + + $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 "
"; 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 (""); + echo (""); } echo "
$month_name {$row[0]}\$$value
$month_name {$row[0]}\$$value({$row['count']} contracts)
"; 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 @@ = 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 @@ = 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 +