code style/openspending
[contractdashboard.git] / lib / common.inc.php
blob:a/lib/common.inc.php -> blob:b/lib/common.inc.php
--- a/lib/common.inc.php
+++ b/lib/common.inc.php
@@ -14,12 +14,6 @@
 if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) {
     $basePath = "../";
 }
-require $basePath."lib/amon-php/amon.php";
-Amon::config(array('address'=> 'http://127.0.0.1:2464', 
-		'protocol' => 'http', 
-		'secret_key' => "JBcSUdFOi5lK0vCjLjbHDpQamcBnRA4iV7QLaTADeDQ"));
-Amon::setup_exception_handler();
-
 require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php';
 $openid = new LightOpenID($_SERVER['HTTP_HOST']);
 // you have to open the session to be able to modify or remove it
@@ -55,7 +49,6 @@
 function databaseError($errMsg) {
     if ($errMsg[2] != "") {
         echo '<div class="alert-message error">';
-        Amon::log(print_r($errMsg, true).print_r($_REQUEST, true).print_r($_SERVER, true), array('error'));
         die(print_r($errMsg, true));
         echo "</div>";
     }
@@ -102,13 +95,13 @@
     if ($supplierParts[0] > 0)
         $supplierQ = ' "supplierABN" = :supplierABN AND ';
     else
-        $supplierQ = ' "supplierName" LIKE :supplierName AND ';
+        $supplierQ = ' "supplierName" ILIKE :supplierName AND ';
 }
 
 $startYear = 2007;
 $year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT);
 if ($year != "") {
-    $yearQ = "YEAR(publishDate) = " . $year . " AND ";
+    $yearQ = 'extract(year from "contractStart") = ' . $year . " AND ";
 }
 $standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010';
 $start = 0.0;
@@ -273,9 +266,21 @@
         <div class="container-fluid">
             <div class="row-fluid">
 		<div class="span3">
+<h3> Filter by: </h3>
                 	<div class="well sidebar-nav">
-                    		<li class="nav-header">Filter by:</li>
-                    		<li>2008</li>
+                    		<li class="nav-header">Year</li>
+<?php
+foreach (range(2008,2015) as $year) {
+$get = $_GET;
+$get['year'] = $year;
+$query = http_build_query($get);
+echo "<li><A href='?$query'>";
+if ($_GET['year'] == $year) echo "<b>";
+echo "$year";
+if ($_GET['year'] == $year) echo "</b>";
+echo "</a></li>";
+}
+?>
                 	</div> 
 		</div>
             	<div class="span9">
@@ -312,6 +317,3 @@
             include ("graphs.inc.php");
 
 
-
-            
-