lotta updates
lotta updates

--- a/admin/data/CN3414909.1a4721f289580354dea4cd202ee60400.xls
+++ b/admin/data/CN3414909.1a4721f289580354dea4cd202ee60400.xls
@@ -790,7 +790,7 @@
 ="Department of Defence"	=""	="CN3415740"	12-Apr-17 01:14 PM	 	="published"	31-Mar-17	18-Aug-17	13112.22	"Purchase of RAST equipment."	="DNMULQ"	="Military watercraft"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="BEAK ENGINEERING (AUST) PTY LTD"	="7 WALKER ST BRAESIDE VIC AUSTRALIA"	="BRAESIDE VIC"	="3195"	="AUSTRALIA"	="No"	="90604585417"	=""	="CASG"	="2173"	

 ="Department of Defence"	=""	="CN3415741"	12-Apr-17 01:14 PM	 	="published"	31-Mar-17	11-Jul-17	154426.03	"WEAPON SPARES"	="DNMULF"	="Light weapons and ammunition"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="MILSPEC SERVICES PTY LIMITED"	="UNIT 2 / 99 SPENCER ROAD CARRARA QLD AUSTRALIA"	="CARRARA QLD"	="4211"	="AUSTRALIA"	="No"	="12071999132"	=""	="CASG"	="2173"	

 ="Department of Defence"	=""	="CN3415742"	12-Apr-17 01:14 PM	 	="published"	31-Mar-17	16-Jun-17	14203.20	"Gage Pressure Dial"	="DNMULB"	="Marine craft systems and subassemblies"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="CONSILIUM NOVAMARINE PTY LIMITED"	="30 DOWNIE ST WICKHAM NSW AUSTRALIA"	="WICKHAM  NSW"	="2293"	="AUSTRALIA"	="No"	="36001704070"	=""	="CASG"	="2173"	

-="Department of Defence"	=""	="CN3415743"	12-Apr-17 01:14 PM	 	="published"	30-Mar-17	28-Jul-17	18216.00	"Switch pressure 9""	="DNMUK1"	="Hardware"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="PLATYPUS OUTDOORS GROUP PTY LTD"	="6 WESTPOOL DR HALLAM VIC AUSTRALIA"	="HALLAM VIC"	="3803"	="AUSTRALIA"	="No"	="25850258719"	=""	="CASG"	="2173"	

+="Department of Defence"	=""	="CN3415743"	12-Apr-17 01:14 PM	 	="published"	30-Mar-17	28-Jul-17	18216.00	"Switch pressure 9''"	="DNMUK1"	="Hardware"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="PLATYPUS OUTDOORS GROUP PTY LTD"	="6 WESTPOOL DR HALLAM VIC AUSTRALIA"	="HALLAM VIC"	="3803"	="AUSTRALIA"	="No"	="25850258719"	=""	="CASG"	="2173"	

 ="Department of Defence"	=""	="CN3415744"	12-Apr-17 01:14 PM	 	="published"	30-Mar-17	29-May-17	14968.80	"Driver picket tubular"	="DNMUKX"	="Tools and General Machinery"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="JESTOMIC PTY LTD"	="7 TROON COURT ROBINA QLD AUSTRALIA"	="ROBINA QLD"	="4226"	="AUSTRALIA"	="No"	="27791312647"	=""	="CASG"	="2173"	

 ="Department of Defence"	=""	="CN3415745"	12-Apr-17 01:14 PM	 	="published"	30-Mar-17	27-Jul-17	55840.40	"Purchase of ships spares."	="DNMUKV"	="Military watercraft"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="THYSSENKRUPP MARINE SYSTEMS AUST"	="LEVEL 2, 355 SPENCER ST WEST MELBOURNE VIC AUSTRALIA"	="WEST MELBOURNE VIC"	="3003"	="AUSTRALIA"	="No"	="40083122507"	=""	="CASG"	="2173"	

 ="Department of Defence"	=""	="CN3415746"	12-Apr-17 01:14 PM	 	="published"	31-Mar-17	17-May-17	107497.50	"Distress light markers"	="DNMUKT"	="Water safety"	="Limited tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="SURVITEC GROUP"	="2 BURILDA CLOSE WETHERILL PARK NSW AUSTRALIA"	="WETHERILL PARK NSW"	="2164"	="AUSTRALIA"	="No"	="55050242601"	=""	="CASG"	="2173"	

@@ -1298,4 +1298,5 @@
 ="Department of Veterans' Affairs"	=""	="CN3414845"	10-Apr-17 10:07 AM	 	="published"	30-Mar-17	17-Apr-17	19362.20	"P03328 MPHE news Vol 16"	="CNA002581/0"	="Printed publications"	="Prequalified tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="BLUE STAR AUSTRALIA"	="BLUE STAR PRINT, LOCKED BAG 255"	="CLAYTON SOUTH"	="3169"	="AUSTRALIA"	="No"	="53004125231"	="Community and Aged Care Policy"	="Services"	="2606"	

 ="Digital Transformation Agency"	=""	="CN3415211"	11-Apr-17 11:11 AM	 	="published"	01-Mar-17	30-Jun-17	20000.00	" Legal Services "	="DTA-534"	="Legal services"	="Prequalified tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="Ashurst"	=""	="Canberra"	="2600"	="AUSTRALIA"	="No"	="75304286095"	=""	=""	="2600"	

 ="Digital Transformation Agency"	=""	="CN3415217"	11-Apr-17 11:36 AM	 	="published"	29-Mar-17	30-Apr-17	26400.00	" Legal Services "	="DTA-528"	="Legal services"	="Prequalified tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="Clayton Utz"	=""	="Canberra"	="2600"	="AUSTRALIA"	="No"	="35740217343"	=""	=""	="2600"	

-="Digital Transformation Agency"	=""	="CN3415605"	12-Apr-17 08:38 AM	 	="published"	23-Mar-17	30-Jun-17	12000.00	" Legal Advice "	="DTA-515"	="Legal services"	="Prequalified tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="Australian Government Solicitor"	=""	="Canberra"	="2600"	="AUSTRALIA"	="No"	="69405937639"	=""	=""	="2600" 
+="Digital Transformation Agency"	=""	="CN3415605"	12-Apr-17 08:38 AM	 	="published"	23-Mar-17	30-Jun-17	12000.00	" Legal Advice "	="DTA-515"	="Legal services"	="Prequalified tender"	=""	=""	="No"	=""	="No"	=""	="No"	=""	""	="Australian Government Solicitor"	=""	="Canberra"	="2600"	="AUSTRALIA"	="No"	="69405937639"	=""	=""	="2600" 

+

--- a/admin/import.php
+++ b/admin/import.php
@@ -114,7 +114,7 @@
                         } else {
                             $contractNoticeInsert[] = null;
                         }
-                    } elseif (($datamapping0712[$headers[$c]]) == "supplierABN" || ($datamapping0712[$headers[$c]]) == "SONID") {
+                    } elseif ($datamapping0712[$headers[$c]] == "supplierABN") {
                         if ($data[$c] > 0 && $data[$c] != '0' && $data[$c] != '') {
                             $contractNoticeInsert[] = $data[$c];
                         } else {

--- a/admin/importSON.php
+++ b/admin/importSON.php
@@ -3,7 +3,7 @@
 function fetchSON($SONID)
 {
     global $conn;
-    echo $SONID;
+    echo $SONID."\n";
 
 # Create a search parser object
     $search = new DOMDocument();
@@ -18,14 +18,19 @@
     foreach ($search->getElementsByTagName('a') as $link) {
         # Show the <a href>
         if (strpos($link->getAttribute('href'), 'UUID')) {
-            echo $link->getAttribute('href');
+            echo $link->getAttribute('href')."\n";
             @$doc->loadHTML(file_get_contents("https://www.tenders.gov.au".$link->getAttribute('href')));
+	   break;
         }
     }
 
-    //TODO update title from $x("//p[@class='lead']/text()")
-
-
+    //update title from $x("//p[@class='lead']/text()")
+$xpath = new DOMXpath($doc);
+$elements = $xpath->query("//p[@class='lead']/text()");
+echo ($elements[0]->wholeText)."\n";
+if ($title[0]->wholeText != "") {
+$conn->exec('insert into standingoffers ("SONID",title) values (\''.$SONID."','".$title[0]->wholeText."') ON CONFLICT DO UPDATE;");
+}
     $sql='insert into standingoffer_suppliers("SONID",name,abn,state,postcode) values(?,?,?,?,?)';
     $q=$conn->prepare($sql);
 
@@ -47,4 +52,16 @@
 }
 if ($_REQUEST['SONID']) {
     fetchSON($_REQUEST['SONID']);
+} else {
+
+$sons = Array(
+"SON1200402",
+"SON1209932",
+"SON98624");
+
+foreach ($sons as $son) {
+fetchSON($son);
+
 }
+}
+

--- a/displayAgency.php
+++ b/displayAgency.php
@@ -113,12 +113,16 @@
     "contractStart", "supplierName"
     FROM contractnotice
     WHERE ' . $yearQ . ' "agencyName" LIKE :agency AND "childCN" IS NULL
-    ORDER BY "value" DESC LIMIT 100';
+    ORDER BY "value" DESC';
+if ($yearQ == '') $query .=' LIMIT 1000';
     $query = $conn->prepare($query);
     $query->bindParam(":agency", $agency);
     $query->execute();
     databaseError($conn->errorInfo());
-
+if ($query->rowCount() > 999 && $yearQ == '') {
+// if 1000 records warn too many results
+print "<b> More than 1000 results found so only first 1000 shown. Please filter by year to see all results </b>";
+}
     echo "<h3>Contracts</h3><table>  <thead>
     <tr>
       <th>Contract Notice Number</th>

--- a/displayAmendments.php
+++ b/displayAmendments.php
@@ -2,7 +2,7 @@
 
 include_once ("./lib/common.inc.php");
 if ($year == "") {
-    $year = 2016;
+    $year = 2017;
     $yearQ = 'extract(year from "contractStart") = ' . $year . " AND ";
 }
 

--- a/displaySupplier.php
+++ b/displaySupplier.php
@@ -226,11 +226,15 @@
 FROM contractnotice
 WHERE ' . $yearQ . ' "childCN" IS NULL
 GROUP BY supplierID,"supplierABN"
-ORDER BY val DESC
-LIMIT 100';
-    $query = $conn->prepare($query);
-    $query->execute();
-    databaseError($conn->errorInfo());
+ORDER BY val DESC';
+if ($yearQ == '') $query .=' LIMIT 1000';
+    $query = $conn->prepare($query);
+    $query->execute();
+    databaseError($conn->errorInfo());
+if ($query->rowCount() > 999 && $yearQ == '') {
+// if 1000 records warn too many results
+print "<b> More than 1000 results found so only first 1000 shown. Please filter by year to see all results </b>";
+}
     echo "<table>  <thead>
     <tr>
        <th>Position</th>

--- a/lib/common.inc.php
+++ b/lib/common.inc.php
@@ -92,7 +92,7 @@
 }
 function ucsmart($str) {
     $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In"
-        , "Of", "On", "Or", "The", "To", "With");
+        , "Of", "On", "Or", "The", "To", "With", "Use", "No", "Yes");
     $strArray = explode(" ",  preg_replace_callback("/(?<=(?<!:|’s)\W)
             (A|An|And|At|For|In|Of|On|Or|The|To|With)
             (?=\W)/",
@@ -363,10 +363,15 @@
             }
 
             function include_footer() {
-                global $start;
+                global $start, $conn;
                 $end = (float) array_sum(explode(' ', microtime()));
 
-                echo '</div>  <footer>' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '  <footer>';
+        $query = 'SELECT DATE("importDate") FROM contractnotice ORDER BY "importDate" DESC limit 1';
+        $query = $conn->prepare($query);
+        $query->execute();
+        databaseError($conn->errorInfo());
+        $last_update = reset($query->fetchAll())[0];
+                echo '</div>  <footer>' . "Last updated: ".$last_update." Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '  <footer>';
 
                     if (strpos($_SERVER['SERVER_NAME'], ".gs")) {
                     ?>