new stats box
--- a/admin/import.php
+++ b/admin/import.php
@@ -109,13 +109,13 @@
if (in_array(($datamapping0712[$headers[$c]]), $contractNoticeFields)) {
if (($datamapping0712[$headers[$c]]) == "parentCN" || ($datamapping0712[$headers[$c]]) == "CNID") {
$data[$c] = substr($data[$c], 2); // take off the "CN" prefix
- if ($data[$c] > 0 && $data[$c] != '0') {
+ if ($data[$c] > 0 && $data[$c] != '0' && $data[$c] != '') {
$contractNoticeInsert[] = $data[$c];
} else {
$contractNoticeInsert[] = null;
}
- } elseif (($datamapping0712[$headers[$c]]) == "supplierABN") {
- if ($data[$c] > 0 && $data[$c] != '0') {
+ } elseif (($datamapping0712[$headers[$c]]) == "supplierABN" || ($datamapping0712[$headers[$c]]) == "SONID") {
+ if ($data[$c] > 0 && $data[$c] != '0' && $data[$c] != '') {
$contractNoticeInsert[] = $data[$c];
} else {
$contractNoticeInsert[] = null;
@@ -191,10 +191,10 @@
//
if ($success > 0) {
$conn->exec("update datasets set \"lastUpdated\" = NOW() where title = 'Contract Notices'");
-/* echo "link amend<br>";
+ echo "link amend<br>";
include ("linkAmendments.php");
echo "update UNSPSC<br>";
- include ("updateUNSPSC.php");*/
+ include ("updateUNSPSC.php");
}
// cn
--- a/admin/importdatagov.php
+++ b/admin/importdatagov.php
@@ -1,7 +1,7 @@
<?php
include_once ("../lib/common.inc.php");
-auth();
+
/* todo gaps
Contract ID,Department,Portfolio,Division,Branch,Agency Ref,Contract Date,End Date,Value,Office PCode,Description,Procurement Desc,Confidentiality Reason,Consultancy,ANZSCC Code,ANSCC Desc,Supplier,Supplier Postal Addr,Supplier Suburb,Supplier State,Supplier Country,Supplier PCode,Supplier ABN,Supplier DUNS,Supplier ACN,S/O Reference Num
1694570,Department of Defence,Defence,NEW SOUTH WALES,RAN HMAS WATSON,1906458734 ,30-Jun-2007,30-Jun-2007,16083.96,2612,AIRLINE TICKETS,direct source,,No,731,Passenger transportation by air,QANTAS AIRWAYS LTD,PO Box PB 747,MASCOT,NSW,Australia,2020,16009661901,750512642,009661901 ,
@@ -24,6 +24,7 @@
"procurementMethod",
"atmID",
"SONID",
+ "SONPanelArrangement",
"confidentialityContract",
"confidentialityContractReason",
"confidentialityOutputs",
@@ -50,8 +51,15 @@
$contractNoticeInsertQ.= ");";
$contractNoticeInsertQ = $conn->prepare($contractNoticeInsertQ);
+$contractNoticeUpdateQ = 'UPDATE contractnotice SET ("' . implode('" , "', $contractNoticeFields) . '") = ( ';
+foreach ($contractNoticeFields as $key => $f) {
+ $contractNoticeUpdateQ.= ($key == 0 ? "" : ", ") . "?";
+}
+$contractNoticeUpdateQ.= ') where "CNID" = ?;';
+$contractNoticeUpdateQ = $conn->prepare($contractNoticeUpdateQ);
+
function processFile($fpath) {
- global $conn, $contractNoticeFields, $contractNoticeInsertQ;
+ global $conn, $contractNoticeFields, $contractNoticeInsertQ, $contractNoticeUpdateQ;
$row = 1;
$success = 0;
ini_set('auto_detect_line_endings',TRUE);
@@ -64,17 +72,18 @@
"Parent Contract ID" => "parentCN",
"Contract ID" => "CNID",
"Publish Date" => "publishDate",
- "AmendmentDate" => "amendDate",
+ "Amendment Date" => "amendDate",
"Start Date" => "contractStart",
"End Date" => "contractEnd",
"Value" => "value",
"Description" => "description",
"Agency Ref ID" => "agencyID",
"UNSPSC Code" => "categoryUNSPSC",
- "Title" => "category",
+ "UNSPSC Title" => "category",
"Procurement Method" => "procurementMethod",
- "TenderNumber" => "atmID",
+ "ATM ID" => "atmID",
"SON ID" => "SONID",
+ "Panel Arrangement" => "SONPanelArrangement",
"Confidentiality Contract Flag" => "confidentialityContract",
"Confidentiality Contract Reason" => "confidentialityContractReason",
"Confidentiality Outputs Flag" => "confidentialityOutputs",
@@ -83,12 +92,12 @@
"Consultancy Reason" => "consultancyReason",
"Amendment Reason" => "amendmentReason",
"Supplier Name" => "supplierName",
- "SupplierAddress" => "supplierAddress",
- "SupplierSuburb" => "supplierCity",
+ "Supplier Address" => "supplierAddress",
+ "Supplier Suburb" => "supplierCity",
"Supplier Postcode" => "supplierPostcode",
"Supplier Country" => "supplierCountry",
"Supplier ABN Exempt" => "supplierABNExempt",
- "ABN" => "supplierABN",
+ "Supplier ABN" => "supplierABN",
"Contact Name" => "",
"Contact Phone" => "",
"Branch" => "contactBranch",
@@ -103,7 +112,7 @@
$num = count($data);
if ($row == 1) {
$headers = $data;
- } elseif ($row > 1) {
+ } elseif ($row >30000 && $row < 59000) {
if ($num > count($datamapping0712)) {
die("<font color=red>Error in data import; data mapping fields out of bounds or changed $num > ".count($datamapping0712)."</font><br>" . $fpath . print_r($data));
}
@@ -144,13 +153,13 @@
}
flush();
// print_r($contractNoticeInsert);
- $contractNoticeInsertQ->execute($contractNoticeInsert);
+ /* $contractNoticeInsertQ->execute($contractNoticeInsert);
$errors = $conn->errorInfo();
if ($errors[1] == 7 && strpos($errors[2], "duplicate key")) {
-// echo "dupe {$data[2]} row $row <br>\n";
+ echo "dupe {$data[2]} row $row <br>\n";
} else {
if ($errors[1] == 0) {
- echo "success {$data[2]} row $row <br>\n";
+ echo "success insert {$data[2]} row $row <br>\n";
$success++;
} else {
foreach ($contractNoticeFields as $key => $cnf) {
@@ -158,8 +167,32 @@
}
echo $data[2] . " failed CN insert.<br>" . print_r($errors, true) . "<br> row $row <br><br>\n";
}
-}
+}*/
+
+
+ $contractNoticeUpdate = $contractNoticeInsert;
+ $contractNoticeUpdate[] = $data[2];
+#var_dump($contractNoticeUpdate);
+ /*$i =0;
+ while($i < 35) {
+ echo "{$contractNoticeFields[$i]} : {$contractNoticeUpdate[$i]}<br/>";
+ $i++;
+ }*/
+ $contractNoticeUpdateQ->execute($contractNoticeUpdate);
+ $errors = $conn->errorInfo();
+
+ if ($errors[1] == 0) {
+ // echo "success update {$data[2]} row $row <br>\n";
+ $success++;
+ } else {
+ foreach ($contractNoticeFields as $key => $cnf) {
+ echo var_dump($contractNoticeUpdate[$key]) . $cnf . "<br>";
+ }
+ echo $data[2] . " failed CN update.<br>" . print_r($errors, true) . "<br> row $row <br><br>\n";
+ }
+
flush();
+ //die('endlol');
//echo "<hr>\n";
}
$row++;
@@ -204,10 +237,10 @@
//
if ($success > 0) {
$conn->exec("update datasets set \"lastUpdated\" = NOW() where title = 'Contract Notices'");
- echo "link amend<br>";
+ /*echo "link amend<br>";
include ("linkAmendments.php");
echo "update UNSPSC<br>";
- include ("updateUNSPSC.php");
+ include ("updateUNSPSC.php");*/
}
// cn
--- a/admin/linkAmendments.php
+++ b/admin/linkAmendments.php
@@ -1,9 +1,6 @@
<?php
include_once ("../lib/common.inc.php");
-if (php_sapi_name() != "cli") {
-
-//auth();
-}
+
$query = 'update contractnotice set "parentCN" = null where "parentCN" = \'0\'';
$query = $conn->prepare($query);
$query->execute();
--- a/displayAgency.php
+++ b/displayAgency.php
@@ -12,6 +12,24 @@
$query->bindParam(":agency", $agency);
$query->execute();
databaseError($conn->errorInfo());
+
+ $query = '
+ SELECT
+sum((consultancy = \'Yes\')::int) AS consultancy,
+sum(("confidentialityContract" = \'Yes\')::int) AS "confidentialityContract",
+sum(("confidentialityOutputs" = \'Yes\')::int) AS "confidentialityOutputs",
+sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS null)::int) AS open,
+sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS NOT null)::int) AS "openSON",
+sum(("procurementMethod" = \'Prequalified tender\' OR "procurementMethod" = \'Select\')::INT) AS prequalified,
+sum(("procurementMethod" = \'Direct\' OR "procurementMethod" = \'Limited tender\')::int) AS limited,
+COUNT(*) AS total
+FROM contractnotice
+WHERE "supplierABN" = \'51194660183\'
+ ';
+ /*
+ * Procurement method in text, seperate Open via SON from Open
+ * Consultancies, Confidentialities percentage
+ Compliance statistics: amendments, delay in reporting average and number completely late */
echo "<h3>Categories</h3><table> <thead>
@@ -85,10 +103,6 @@
</tr>");
}
echo "</table><br/>";
- /*
- * Procurement method in text, seperate Open via SON from Open
- * Consultancies, Confidentialities percentage
- Compliance statistics: amendments, delay in reporting average and number completely late */
$query = 'SELECT "CNID", "description", "value", "agencyName", "category",
"contractStart", "supplierName"
--- a/displaySON.php
+++ b/displaySON.php
@@ -99,9 +99,7 @@
}
echo "</table>";
} else {
- /*
- split by main categories
- */
+
include_header("Standing Offers");
$query = 'SELECT sum(value), count(*), contractnotice."SONID", min(title) AS title, text_mode(category) as category
FROM contractnotice INNER JOIN standingoffers ON contractnotice."SONID" = standingoffers."SONID"
--- a/displaySupplier.php
+++ b/displaySupplier.php
@@ -20,12 +20,33 @@
$query->bindParam(":supplierABN", $supplierABN);
$query->execute();
databaseError($conn->errorInfo());
- echo "Also known as: ".implode(', ', $query->fetchAll(PDO::FETCH_COLUMN, 0));
+ echo "<b>Also known as:</b> ".implode(', ', $query->fetchAll(PDO::FETCH_COLUMN, 0));
}
- /*
- * Procurement method in text, seperate Open via SON from Open
- * Consultancies, Confidentialities percentage
- */
+
+ $query = '
+ SELECT
+sum((consultancy = \'Yes\')::int) AS consultancy,
+sum(("confidentialityContract" = \'Yes\')::int) AS "confidentialityContract",
+sum(("confidentialityOutputs" = \'Yes\')::int) AS "confidentialityOutputs",
+sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS null)::int) AS open,
+sum((("procurementMethod" = \'Open\' OR "procurementMethod" = \'Open tender\') AND "SONID" IS NOT null)::int) AS "openSON",
+sum(("procurementMethod" = \'Prequalified tender\' OR "procurementMethod" = \'Select\')::INT) AS prequalified,
+sum(("procurementMethod" = \'Direct\' OR "procurementMethod" = \'Limited tender\')::int) AS limited,
+COUNT(*) AS total
+FROM contractnotice
+WHERE' . $supplierQ . " " . $standardQ ;
+ $query = $conn->prepare($query);
+ if ($supplierParts[0] > 0) {
+ $query->bindParam(":supplierABN", $supplierABN);
+ } else {
+ $query->bindParam(":supplierName", $supplierName);
+ }
+ $query->execute();
+ databaseError($conn->errorInfo());
+
+ $stats = reset($query->fetchAll());
+ show_stats($stats);
+
$query = 'SELECT category, min("categoryUNSPSC") AS "categoryUNSPSC", count(*) AS count, sum(value) AS value FROM contractnotice
WHERE ' . $supplierQ . " " . $standardQ . ' GROUP BY category ORDER BY count(*) DESC LIMIT 10';
$query = $conn->prepare($query);