fix value/sum
[contractdashboard.git] / graphs / displayCnCGraph.php
blob:a/graphs/displayCnCGraph.php -> blob:b/graphs/displayCnCGraph.php
--- 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;