Improve OS validation
--- a/exportData.csv.php
+++ b/exportData.csv.php
@@ -16,10 +16,9 @@
EXTRACT(EPOCH FROM "publishDate") as "publishDate",
EXTRACT(EPOCH FROM "contractStart") as "contractStart",
EXTRACT(EPOCH FROM "contractEnd") as "contractEnd",
-value,description,"procurementMethod",category,"categoryUNSPSC",
-(substr( "categoryUNSPSC"::text, 0, 2 ) || \'000000\'::text) as "cat1",
- (substr( "categoryUNSPSC"::text, 0, 4 ) || \'0000\'::text) as "cat2",
- (substr( "categoryUNSPSC"::text, 0, 6 ) || \'00\'::text) as "cat3",
+value,description,"procurementMethod",category as cat3,
+(substr( "categoryUNSPSC"::text, 0, 3 ) || \'000000\'::text) as "cat1",
+(substr( "categoryUNSPSC"::text, 0, 5 ) || \'0000\'::text) as "cat2",
"supplierABN","supplierName",
(
case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID,
@@ -29,7 +28,6 @@
where "childCN" is null'
, array(PDO::ATTR_CURSOR => PDO::FETCH_ORI_NEXT));
// "supplierCity","supplierPostcode","supplierCountry","contactPostcode",
-//
$query->execute();
$errors = $conn->errorInfo();
if ($errors[2] != "") {
@@ -57,6 +55,9 @@
|| $headers[$key] == "contractEnd") {
$colvalue = date("Y-m-d", $colvalue);
}
+ if ($headers[$key] == "CNID") {
+ $colvalue = str_replace("A","", $colvalue);
+}
if ($headers[$key] == "cat1" || $headers[$key] == "cat2"
|| $headers[$key] == "cat3") {
$colvalue = $unspsc[$colvalue];