Add standing offers
[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
@@ -4,7 +4,7 @@
 error_reporting(E_ALL ^ E_NOTICE);
 
 
-$conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost");
+$conn = new PDO("pgsql:dbname=contractdashboard;user=postgres;password=snmc;host=localhost");
 
 if (!$conn) {
     die("A database error occurred.\n");
@@ -15,6 +15,24 @@
     $basePath = "../";
 }
 require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php';
+require(ROOT.'/solarium/vendor/autoload.php');
+require(ROOT.'/solarium/library/Solarium/Autoloader.php');
+Solarium\Autoloader::register();
+// check solarium version available
+//echo 'Solarium library version: ' . Solarium\Client::VERSION . ' - ';
+$config = array(
+    'endpoint' => array(
+        'localhost' => array(
+            'host' => '127.0.0.1',
+            'port' => 8983,
+            'path' => '/solr/contracts/',
+        )
+    )
+);
+// create a client instance
+$solr_client = new Solarium\Client($config);
+
+
 $openid = new LightOpenID($_SERVER['HTTP_HOST']);
 // you have to open the session to be able to modify or remove it
 session_start();
@@ -57,9 +75,10 @@
 function ucsmart($str) {
     $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In"
         , "Of", "On", "Or", "The", "To", "With");
-    $strArray = explode(" ", preg_replace("/(?<=(?<!:|’s)\W)
+    $strArray = explode(" ",  preg_replace_callback("/(?<=(?<!:|’s)\W)
             (A|An|And|At|For|In|Of|On|Or|The|To|With)
-            (?=\W)/e", 'strtolower("$1")', ucwords(strtolower($str))));
+            (?=\W)/",
+function($matches) { return strtolower($matches[1]); } , ucwords(strtolower($str))));
     foreach ($strArray as &$word) {
         if (strlen($word) <= 4 && !in_array($word, $shortWords))
             $word = strtoupper($word);
@@ -232,11 +251,9 @@
                         <ul class="nav">
                             <li><a href="displayAgency.php">agencies</a></li>
                             <li><a href="displaySupplier.php">suppliers</a></li>
+                            <li><a href="displaySON.php">standing offers</a></li>
                             <li><a href="displayCategory.php">categories</a></li>
-                            <li><a href="displayCalendar.php">time periods</a></li>
-                            <!--  <li class="dropdown">
-                                  <a href="#" class="dropdown-toggle">metrics</a>
-                                  <ul class="dropdown-menu">-->
+                            <li><a href="displayCalendar.php">dates</a></li>
                             <li><a href="displayProcurementMethod.php">tenderm</a></li>
                             <li><a href="displayConfidentialities.php">confidentiality</a></li>
                             <li><a href="displayConsultancies.php">consultancies</a></li>
@@ -245,7 +262,7 @@
                         </ul>  
 
 
-                        <form method="post" action="search.php" class="pull-right">
+                        <form method="get" action="search.php" class="pull-right">
                             <input type="text" id="searchKeyword" name="searchKeyword"  value="" placeholder="Search" />
                             <input type="hidden" id="searchID" name="searchID" value=""/>
                         </form>
@@ -270,7 +287,7 @@
                 	<div class="well sidebar-nav">
                     		<li class="nav-header">Year</li>
 <?php
-foreach (range(2008,2015) as $year) {
+foreach (range(2007,2016) as $year) {
 $get = $_GET;
 $get['year'] = $year;
 $query = http_build_query($get);