From: Alexander Sadleir Date: Sat, 03 Sep 2011 08:34:14 +0000 Subject: Support partial data amendments with multi line descriptions X-Git-Url: https://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=6e86e6da7bcc1f52ac12efc673e13322072732b8 --- Support partial data amendments with multi line descriptions --- --- a/admin/import.php +++ b/admin/import.php @@ -261,10 +261,10 @@ } // run post import data processing // cn -//include ("linkAmendments.php"); +include ("linkAmendments.php"); include ("updateUNSPSC.php"); // agency -include ("setAgencyStatus.php"); -include ("setAgencyURLABN.php"); +//include ("setAgencyStatus.php"); +//include ("setAgencyURLABN.php"); ?> --- a/admin/partialdata/importamendments.php +++ b/admin/partialdata/importamendments.php @@ -17,6 +17,8 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 45); +curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); +curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $page = curl_exec($ch); if (curl_errno($ch)) { echo " Database temporarily unavailable: "; @@ -219,6 +221,10 @@ $cnFields[$fieldName] = $fieldValue; } } +if (isset($cnFields[""])) { + $cnFields["description"] .= $cnFields[""]; + unset($cnFields[""]); +} $cnFields["importFile"] = $url; $contractNoticeInsertQ = 'INSERT INTO contractnotice ("' . implode('" , "', array_keys($cnFields)) . '") VALUES ( '; for($key = 0; $key < sizeof($cnFields); $key++) { @@ -304,7 +310,7 @@ if ($dhandle) { // loop through all of the files while (false !== ($fname = readdir($dhandle))) { - if (($fname != '.') && ($fname != '..')) { + if (($fname != '.') && ($fname != '..') && (strpos($fname,".xls")>0)) { echo "$fname " . filesize($path . $fname) . " " . date("c", filemtime($path . $fname)) . "
"; processFile($path . $fname, "contractnotice"); } --- a/exportData.csv.php +++ b/exportData.csv.php @@ -5,12 +5,14 @@ // source: http://stackoverflow.com/questions/81934/easy-way-to-export-a-sql-table-without-access-to-the-server-or-phpmyadmin#81951 $query = $conn->prepare(' SELECT "CNID",contractnotice."agencyName",agency.abn as "agencyABN",EXTRACT(EPOCH FROM "publishDate") as "publishDate",EXTRACT(EPOCH FROM "contractStart") as "contractStart",EXTRACT(EPOCH FROM "contractEnd") as "contractEnd",value,description,"procurementMethod",category,"categoryUNSPSC", - "supplierABN","supplierName","supplierCity","supplierPostcode","supplierCountry","contactPostcode", + "supplierABN","supplierName", ( case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID, (\'https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN\'::text || "CNID"::text) as sourceURL -FROM contractnotice join agency on contractnotice."agencyName"=agency."agencyName" where "childCN" = 0'); +FROM contractnotice join agency on contractnotice."agencyName"=agency."agencyName" where "childCN" = 0' +, array(PDO::ATTR_CURSOR => PDO::FETCH_ORI_NEXT)); +// "supplierCity","supplierPostcode","supplierCountry","contactPostcode", // (substr( "categoryUNSPSC"::text, 0, 2 ) || \'0000000\'::text) as "categoryUNSPSClv1", "categoryUNSPSC", (substr( "categoryUNSPSC"::text, 0, 3 ) || \'000000\'::text) as "categoryUNSPSClv2" "categoryUNSPSC", (substr( "categoryUNSPSC"::text, 0, 4 ) || \'00000\'::text as "categoryUNSPSClv3") $query->execute(); if (!$query) { @@ -31,7 +33,7 @@ header('Pragma: no-cache'); header('Expires: 0'); fputcsv($fp, $headers); -foreach ($query->fetchAll(PDO::FETCH_NUM) as $row) { + while ($row = $query->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) { foreach ($row as $key => &$colvalue) { $colvalue = preg_replace( '/[^[:print:]]/', '', --- a/lib/graphs.inc.php +++ b/lib/graphs.inc.php @@ -7,6 +7,7 @@ + '; $includedFlot = true; @@ -23,8 +24,9 @@ $(function () { var d1 = []; + var d2 = []; prepare($query); $query->execute(); if (!$query) { @@ -35,6 +37,18 @@ foreach ($query->fetchAll() as $delta) { echo "d1.push([ ".intval($delta['cnid']).", ".intval($delta['count'])."]); \n"; +}; +$query = 'select cnid, count(*) from (select ("CNID" - MOD("CNID",100)) as cnid from contractnotice where "CNID" < 999999 and "parentCN" is not null) as a group by cnid order by cnid'; +$query = $conn->prepare($query); +$query->execute(); +if (!$query) { + databaseError($conn->errorInfo()); + return Array(); +} + +foreach ($query->fetchAll() as $delta) { + + echo "d2.push([ ".intval($delta['cnid']).", ".intval($delta['count'])."]); \n"; }; ?> @@ -47,10 +61,20 @@ }, bars: { show: true } }, + { + data: d2, +series: { + lines: { show: true }, + points: { show: true } + }, + bars: { show: true } + }, ]; var options = { - +series: { + stack: true, + }, grid: { hoverable: true, clickable: true, labelMargin: 17 }, selection: { mode: "x" } };