add amendments metric
[contractdashboard.git] / displayAmendments.php
blob:a/displayAmendments.php -> blob:b/displayAmendments.php
--- a/displayAmendments.php
+++ b/displayAmendments.php
@@ -1,9 +1,18 @@
 <?php

 include_once ("./lib/common.inc.php");

     include_header("Amendments");

-$query = "select CNID, description, value, pvalue, (value - pvalue) as diff from contractnotice, (SELECT CNID as cn, childCN as ccn, value as pvalue FROM contractnotice where childCN > 0) a where CNID = ccn order by diff DESC";

+$query = "select CNID, description, value, pvalue, (value - pvalue) as diff from contractnotice, (SELECT CNID as cn, childCN as ccn, value as pvalue FROM contractnotice where childCN > 0) a".

+" where ".$agencyQ.$yearQ."CNID = ccn AND (value - pvalue) <> 0 order by diff DESC";

 $result = mysql_query($query);

-echo "<table>";

+  echo "<table>  <thead>

+    <tr>

+      <th>Contract</th>

+      <th>Original Value</th>

+    <th>Amended Value</th>

+    <th>Difference</th>

+    </tr>

+  </thead>";

+if ($result) {

 while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {

   setlocale(LC_MONETARY, 'en_US');

   $value = number_format(doubleval($row['value']) , 2);

@@ -13,6 +22,9 @@
   echo "<td><A href=\"displayContract.php?CNID={$row['CNID']}\"><b>{$row['description']}</b></a></td>";

   echo "<td>\$$pvalue</td><td>\$$value</td><td>\$$diff</td></tr>";

 }

+} else {

+echo mysql_error();

+}

 echo "</table>";

 mysql_free_result($result);

 include_footer();