From: root Date: Thu, 26 Jan 2017 00:30:01 +0000 Subject: new stats box X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=ec65262ca2bad59466701a43b1ce9438df218855 --- 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
"; + echo "link amend
"; include ("linkAmendments.php"); echo "update UNSPSC
"; - include ("updateUNSPSC.php");*/ + include ("updateUNSPSC.php"); } // cn --- a/admin/importdatagov.php +++ b/admin/importdatagov.php @@ -1,7 +1,7 @@ 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("Error in data import; data mapping fields out of bounds or changed $num > ".count($datamapping0712)."
" . $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
\n"; + echo "dupe {$data[2]} row $row
\n"; } else { if ($errors[1] == 0) { - echo "success {$data[2]} row $row
\n"; + echo "success insert {$data[2]} row $row
\n"; $success++; } else { foreach ($contractNoticeFields as $key => $cnf) { @@ -158,8 +167,32 @@ } echo $data[2] . " failed CN insert.
" . print_r($errors, true) . "
row $row

\n"; } -} +}*/ + + + $contractNoticeUpdate = $contractNoticeInsert; + $contractNoticeUpdate[] = $data[2]; +#var_dump($contractNoticeUpdate); + /*$i =0; + while($i < 35) { + echo "{$contractNoticeFields[$i]} : {$contractNoticeUpdate[$i]}
"; + $i++; + }*/ + $contractNoticeUpdateQ->execute($contractNoticeUpdate); + $errors = $conn->errorInfo(); + + if ($errors[1] == 0) { + // echo "success update {$data[2]} row $row
\n"; + $success++; + } else { + foreach ($contractNoticeFields as $key => $cnf) { + echo var_dump($contractNoticeUpdate[$key]) . $cnf . "
"; + } + echo $data[2] . " failed CN update.
" . print_r($errors, true) . "
row $row

\n"; + } + flush(); + //die('endlol'); //echo "
\n"; } $row++; @@ -204,10 +237,10 @@ // if ($success > 0) { $conn->exec("update datasets set \"lastUpdated\" = NOW() where title = 'Contract Notices'"); - echo "link amend
"; + /*echo "link amend
"; include ("linkAmendments.php"); echo "update UNSPSC
"; - include ("updateUNSPSC.php"); + include ("updateUNSPSC.php");*/ } // cn --- a/admin/linkAmendments.php +++ b/admin/linkAmendments.php @@ -1,9 +1,6 @@ prepare($query); $query->execute(); --- a/displayAgency.php +++ b/displayAgency.php @@ -1,29 +1,120 @@

'.$agency.'

'; - agencySuppliersGraph($agency); -/* - * * Common categories and uncommon categories - * 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" - FROM contractnotice - WHERE ' .$yearQ . ' "agencyName" like :agency and "childCN" is null - ORDER BY "value" DESC limit 100'; + echo '

' . $agency . '

'; + $query = 'SELECT category, min("categoryUNSPSC") AS "categoryUNSPSC", count(*) AS count, sum(value) AS value FROM contractnotice + WHERE "agencyName" LIKE :agency AND ' . " " . $standardQ . ' ' . $yearQ . ' GROUP BY category ORDER BY count(*) DESC LIMIT 10'; $query = $conn->prepare($query); $query->bindParam(":agency", $agency); $query->execute(); databaseError($conn->errorInfo()); - echo " + $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 "

Categories

+ + + + + + "; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $category = urlencode($row['category']); + echo(" + + + + "); + } + echo "
CategoryContracts CountTotal Contract Value
{$row['category']}{$row['count']}\$$value

"; + + $query = 'SELECT contractnotice."SONID", min(title) AS title, count(*), sum(value) AS value FROM contractnotice INNER JOIN standingoffers ON contractnotice."SONID" = standingoffers."SONID" +WHERE "agencyName" LIKE :agency AND ' . " " . $standardQ . ' ' . $yearQ . 'AND contractnotice."SONID" != \'\' GROUP BY contractnotice."SONID"'; + $query = $conn->prepare($query); + $query->bindParam(":agency", $agency); + $query->execute(); + databaseError($conn->errorInfo()); + $sonrows = ""; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $sonrows .= " + {$row['title']} + {$row['count']} + \$$value + "; + } + if (strlen($sonrows) > 1) { + echo "

Standing Offers/Panels

+ + + + + + $sonrows
Standing OfferContracts CountTotal Contract Value

"; + } + + $query = 'SELECT SUM(value) AS value, count(*), text_mode("supplierName") "supplierName", min("supplierABN") AS "supplierABN", ( + CASE WHEN "supplierABN" != 0 THEN "supplierABN"::TEXT ELSE lower("supplierName") END) AS "supplierID" FROM contractnotice +WHERE ' . $yearQ . " " . $standardQ . ' AND "agencyName" LIKE :agency +GROUP BY "supplierID" ORDER BY "value" DESC'; + $query = $conn->prepare($query); + $query->bindParam(":agency", $agency); + $query->execute(); + databaseError($conn->errorInfo()); + echo "

Suppliers

+ + + + + + "; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $supplierID = $row['supplierABN'] . '-' . urlencode($row['supplierName']); + echo(" + + + + "); + } + echo "
SupplierContracts CountTotal Contract Value
{$row['supplierName']}{$row['count']}\$$value

"; + + $query = 'SELECT "CNID", "description", "value", "agencyName", "category", + "contractStart", "supplierName" + FROM contractnotice + WHERE ' . $yearQ . ' "agencyName" LIKE :agency AND "childCN" IS NULL + ORDER BY "value" DESC LIMIT 100'; + $query = $conn->prepare($query); + $query->bindParam(":agency", $agency); + $query->execute(); + databaseError($conn->errorInfo()); + + echo "

Contracts

@@ -36,7 +127,7 @@ foreach ($query->fetchAll() as $row) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value']), 2); - echo (" + echo(" @@ -53,7 +144,7 @@ agenciesGraph(); $query = 'SELECT SUM("value"), "agencyName" FROM contractnotice -WHERE ' .$yearQ . ' "childCN" is null +WHERE ' . $yearQ . ' "childCN" IS NULL GROUP BY "agencyName" '; $query = $conn->prepare($query); $query->execute(); @@ -68,7 +159,7 @@ setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row[0]), 2); $agency = stripslashes($row[1]); - echo ("\n"); + echo("\n"); } echo "
Contract Notice Number Contract Description
{$row['CNID']} {$row['description']} \$$value{$row['agencyName']}
{$agency}\$$value
{$agency}\$$value
"; } --- a/displayConsultancies.php +++ b/displayConsultancies.php @@ -11,7 +11,7 @@ include_header("Consultancies"); $query = ' -SELECT SUM(value) as value, count(*), min("supplierName"), unnest(string_to_array("consultancyReason",\';\')) reason +SELECT SUM(value) as value, count(*), text_mode("supplierName"), unnest(string_to_array("consultancyReason",\';\')) reason FROM contractnotice where ' .$yearQ . ' "consultancy" = \'Yes\' and "childCN" is null GROUP BY "supplierABN",reason order by value desc '; --- a/displayContract.php +++ b/displayContract.php @@ -39,8 +39,6 @@ break; case "CNID": echo ''.$value.''; - break; - case "categoryUNSPSC": break; case "category": echo ''.$value.''; --- a/displaySON.gexf.php +++ b/displaySON.gexf.php @@ -51,7 +51,7 @@ ' . PHP_EOL; $query = ' -SELECT "supplierABN", min("supplierName") AS "supplierName", contractnotice."SONID", count(*), sum(value) AS value +SELECT "supplierABN", text_mode("supplierName") AS "supplierName", contractnotice."SONID", count(*), sum(value) AS value FROM contractnotice WHERE "childCN" IS NULL AND extract(year from "publishDate") = \'2016\' --- a/displaySON.php +++ b/displaySON.php @@ -1,52 +1,73 @@ prepare($query); -$query->bindParam(":SONID", $_REQUEST['SONID']); - $query->execute(); - databaseError($conn->errorInfo()); - $title = reset($query->fetchAll())['title']; + $query = 'SELECT title FROM standingoffers WHERE "SONID" = :SONID'; + $query = $conn->prepare($query); + $query->bindParam(":SONID", $_REQUEST['SONID']); + $query->execute(); + databaseError($conn->errorInfo()); + $title = reset($query->fetchAll())['title']; include_header($title); - echo "

".$_REQUEST['SONID']." - ".$title."

"; - $query = 'select category, min("categoryUNSPSC") as "categoryUNSPSC" from contractnotice where "SONID" = :SONID group by category'; -$query = $conn->prepare($query); -$query->bindParam(":SONID", $_REQUEST['SONID']); - $query->execute(); - databaseError($conn->errorInfo()); -echo "Categories: "; -foreach ($query->fetchAll() as $row) { -echo "{$row['category']}  "; -} -echo "
"; - $query = 'select "supplierABN", min("supplierName") as "supplierName", count(*), sum(value) as value from contractnotice - WHERE '.$yearQ.' "childCN" is null AND "SONID" = :SONID group by "supplierABN" - union select abn as "supplierABN",name as "supplierName",0 as sum,0 as value from standingoffer_suppliers - where "SONID" = :SONID and abn not in (select distinct "supplierABN" as abn from contractnotice where "SONID" = :SONID)'; -$query = $conn->prepare($query); -$query->bindParam(":SONID", $_REQUEST['SONID']); - $query->execute(); - databaseError($conn->errorInfo()); + echo "

" . $_REQUEST['SONID'] . " - " . $title . "

"; echo '
View original record @ tenders.gov.au
'; + /* + * Procurement method in text, seperate Open via SON from Open + * Consultancies, Confidentialities percentage + */ + $query = 'SELECT category, min("categoryUNSPSC") AS "categoryUNSPSC", count(*) AS count, sum(value) AS value +FROM contractnotice +WHERE "SONID" = :SONID +GROUP BY category'; + $query = $conn->prepare($query); + $query->bindParam(":SONID", $_REQUEST['SONID']); + $query->execute(); + databaseError($conn->errorInfo()); + echo "

Categories

+ + + + + + "; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $category = urlencode($row['category']); + echo(" + + + + "); + } + echo "
CategoryContracts CountTotal Contract Value
{$row['category']}{$row['count']}\$$value

"; - echo " + $query = 'SELECT "supplierABN", text_mode("supplierName") AS "supplierName", count(*), sum(value) AS value FROM contractnotice + WHERE ' . $yearQ . ' "childCN" IS NULL AND "SONID" = :SONID GROUP BY "supplierABN" + UNION SELECT abn AS "supplierABN",name AS "supplierName",0 AS sum,0 AS value FROM standingoffer_suppliers + WHERE "SONID" = :SONID AND abn NOT IN (SELECT DISTINCT "supplierABN" AS abn FROM contractnotice WHERE "SONID" = :SONID)'; + $query = $conn->prepare($query); + $query->bindParam(":SONID", $_REQUEST['SONID']); + $query->execute(); + databaseError($conn->errorInfo()); + + echo "

Suppliers

"; -foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['value']) , 2); - $supplier = stripslashes($row['supplierABN'] . '-' . $row['supplierName']); - echo (" + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $supplier = stripslashes($row['supplierABN'] . '-' . $row['supplierName']); + echo(""); - } - echo "
Supplier Contracts Count Total Contract Value
{$row['supplierName']} {$row['count']} \$$value
+ } + echo "

Contracts

@@ -56,52 +77,53 @@ "; - $query = 'SELECT "CNID", description, value, "agencyName", contractnotice."SONID", "contractStart", "supplierName" - FROM contractnotice - WHERE '.$yearQ.' "childCN" is null + $query = 'SELECT "CNID", title, description, value, "agencyName", contractnotice."SONID", "contractStart", "supplierName" + FROM contractnotice INNER JOIN standingoffers ON contractnotice."SONID" = standingoffers."SONID" + WHERE ' . $yearQ . ' "childCN" IS NULL AND contractnotice."SONID" = :SONID - ORDER BY value DESC'; -$query = $conn->prepare($query); -$query->bindParam(":SONID", $_REQUEST['SONID']); - $query->execute(); - databaseError($conn->errorInfo()); - foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['value']) , 2); - echo (" + ORDER BY VALUE DESC'; + $query = $conn->prepare($query); + $query->bindParam(":SONID", $_REQUEST['SONID']); + $query->execute(); + databaseError($conn->errorInfo()); + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + echo(""); - } - echo "
Contract Notice Number Contract DescriptionSupplier
{$row['CNID']} {$row['description']} \$$value{$row['agencyName']} {$row['contractStart']} {$row['supplierName']}
"; + } + echo ""; } else { - /* - split by main categories - */ + include_header("Standing Offers"); -$query = 'SELECT sum(value), count(*), contractnotice."SONID", min(title) as title -FROM contractnotice inner join standingoffers on contractnotice."SONID" = standingoffers."SONID" -WHERE '.$yearQ.' "childCN" is null and contractnotice."SONID" != \'\' -GROUP BY contractnotice."SONID" ORDER BY sum(value) DESC '; -$query = $conn->prepare($query); - $query->execute(); - databaseError($conn->errorInfo()); - echo " + $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" +WHERE ' . $yearQ . ' "childCN" IS NULL AND contractnotice."SONID" != \'\' +GROUP BY contractnotice."SONID" ORDER BY sum(VALUE) DESC '; + $query = $conn->prepare($query); + $query->execute(); + databaseError($conn->errorInfo()); + echo "
+ "; - foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['sum']) , 2); - echo (""); -} -echo "
SONIDMain category Total Contracts Value Number of Contracts
{$row['title']}\$$value{$row['count']}
"; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['sum']), 2); + $title = $row['SONID']; + if (strlen($row['title']) > 1) $title = $row['title']; + echo("$title{$row['category']}\$$value{$row['count']}"); + } + echo ""; } include_footer(); --- a/displaySupplier.php +++ b/displaySupplier.php @@ -1,57 +1,150 @@ prepare($query); + $query->bindParam(":supplierABN", $supplierABN); + $query->execute(); + databaseError($conn->errorInfo()); + $title = reset($query->fetchAll())['supplierName']; + } + include_header(str_replace("%", "", $title)); + echo '

' . str_replace("%", "", $title) . '

'; if ($supplierABN) { - $query = 'SELECT text_mode("supplierName") as "supplierName" from contractnotice where "supplierABN" = :supplierABN group by "supplierABN"'; -$query = $conn->prepare($query); -$query->bindParam(":supplierABN", $supplierABN); - $query->execute(); - databaseError($conn->errorInfo()); - $title = reset($query->fetchAll())['supplierName']; + $query = 'SELECT distinct on (lower("supplierName")) "supplierName" from contractnotice where "supplierABN" = :supplierABN'; + $query = $conn->prepare($query); + $query->bindParam(":supplierABN", $supplierABN); + $query->execute(); + databaseError($conn->errorInfo()); + echo "Also known as: ".implode(', ', $query->fetchAll(PDO::FETCH_COLUMN, 0)); } - include_header(str_replace("%","",$title)); -echo '

'.str_replace("%","",$title).'

'; - agenciesGraph(); - /* - * Make supplier name the most common name for this ABN - * Common names and uncommon names - * Common categories and uncommon categories - * Procurement method in text, seperate Open via SON from Open - * Consultancies, Confidentialities percentage - */ -$query = 'select contractnotice."SONID", min(title) as title, count(*), sum(value) as value from contractnotice inner join standingoffers on contractnotice."SONID" = standingoffers."SONID" WHERE ' .$yearQ . ' ' . - $supplierQ . ' ' . $standardQ - . ' and contractnotice."SONID" != \'\' group by contractnotice."SONID"'; -$query = $conn->prepare($query); - - - if ($supplierParts[0] > 0) { - $query->bindParam(":supplierABN", $supplierABN); - } else { - $query->bindParam(":supplierName", $supplierName); - } - $query->execute(); - databaseError($conn->errorInfo()); -echo "

Standing Offers/Panels

- - + + $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); + if ($supplierParts[0] > 0) { + $query->bindParam(":supplierABN", $supplierABN); + } else { + $query->bindParam(":supplierName", $supplierName); + } + $query->execute(); + databaseError($conn->errorInfo()); + + + echo "

Categories

Standing Offer
+ + "; foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['value']), 2); - echo (" + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $category = urlencode($row['category']); + echo(" + + + + "); + } + echo "
Category Contracts Count Total Contract Value
{$row['category']}{$row['count']}\$$value

"; + + + $query = 'SELECT SUM("value") AS "value", count(*), MAX(contractnotice."agencyName") AS agencyname FROM contractnotice JOIN agency_nametoabn ON contractnotice."agencyName"=agency_nametoabn."agencyName" +WHERE ' . $yearQ . ' ' . $supplierQ . ' "childCN" IS NULL +GROUP BY abn ORDER BY SUM("value") DESC'; + $query = $conn->prepare($query); + if (count($supplierParts) > 0) { + if ($supplierParts[0] > 0) { + $query->bindParam(":supplierABN", $supplierABN); + } else { + $query->bindParam(":supplierName", $supplierName); + } + } + $query->execute(); + databaseError($conn->errorInfo()); + + echo "

Agencies

+ + + + + + "; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $agency =urlencode($row['agencyname']); + echo(" + + + + "); + } + echo "
AgencyContracts CountTotal Contract Value
{$row['agencyname']}{$row['count']}\$$value

"; + + $query = 'SELECT contractnotice."SONID", min(title) AS title, count(*), sum(value) AS value FROM contractnotice INNER JOIN standingoffers ON contractnotice."SONID" = standingoffers."SONID" WHERE ' . $yearQ . ' ' . + $supplierQ . ' ' . $standardQ + . ' AND contractnotice."SONID" != \'\' GROUP BY contractnotice."SONID"'; + $query = $conn->prepare($query); + + + if ($supplierParts[0] > 0) { + $query->bindParam(":supplierABN", $supplierABN); + } else { + $query->bindParam(":supplierName", $supplierName); + } + $query->execute(); + databaseError($conn->errorInfo()); +$sonrows = ""; + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + $sonrows .= " {$row['title']} {$row['count']} \$$value - "); - } - echo "

Contracts

+ "; + } + if (strlen($sonrows) > 1) { + echo "

Standing Offers/Panels

+ + + + + + $sonrows
Standing OfferContracts CountTotal Contract Value

"; + } + echo "

Contracts

@@ -63,24 +156,24 @@ "; $query = 'SELECT "CNID", "description", "value", "agencyName", "category", "contractStart", "supplierName" - FROM contractnotice WHERE ' .$yearQ . ' ' . - $supplierQ . ' ' . $standardQ - . ' ORDER BY value DESC'; - - $query = $conn->prepare($query); - - - if ($supplierParts[0] > 0) { - $query->bindParam(":supplierABN", $supplierABN); - } else { - $query->bindParam(":supplierName", $supplierName); - } - $query->execute(); - databaseError($conn->errorInfo()); - foreach ($query->fetchAll() as $row) { - setlocale(LC_MONETARY, 'en_US'); - $value = number_format(doubleval($row['value']), 2); - echo (" + FROM contractnotice WHERE ' . $yearQ . ' ' . + $supplierQ . ' ' . $standardQ + . ' ORDER BY VALUE DESC'; + + $query = $conn->prepare($query); + + + if ($supplierParts[0] > 0) { + $query->bindParam(":supplierABN", $supplierABN); + } else { + $query->bindParam(":supplierName", $supplierName); + } + $query->execute(); + databaseError($conn->errorInfo()); + foreach ($query->fetchAll() as $row) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']), 2); + echo(" @@ -95,16 +188,16 @@ */ include_header("Suppliers"); suppliersGraph(); - $query = 'SELECT SUM("value") as val, text_mode("supplierName") as supplierName, "supplierABN",( - case when "supplierABN" != 0 THEN lower("supplierABN"::text) ELSE lower("supplierName") END) as supplierID + $query = 'SELECT SUM("value") AS val, text_mode("supplierName") AS supplierName, "supplierABN",( + CASE WHEN "supplierABN" != 0 THEN lower("supplierABN"::TEXT) ELSE lower("supplierName") END) AS supplierID FROM contractnotice -WHERE ' .$yearQ . ' "childCN" is null +WHERE ' . $yearQ . ' "childCN" IS NULL GROUP BY supplierID,"supplierABN" ORDER BY val DESC LIMIT 100'; $query = $conn->prepare($query); $query->execute(); - databaseError($conn->errorInfo()); + databaseError($conn->errorInfo()); echo "
Contract Notice Number Contract Description
{$row['CNID']} {$row['description']} \$$value{$row['agencyName']}
@@ -117,7 +210,7 @@ setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['val']), 2); $supplier = stripslashes($row['supplierABN'] . '-' . $row['suppliername']); - echo ("\n"); + echo("\n"); $i++; } echo "
Position
$i" . ucsmart($row['suppliername']) . "\$$value
$i" . ucsmart($row['suppliername']) . "\$$value
"; --- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -14,7 +14,7 @@ if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) { $basePath = "../"; } -require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; +/*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(); @@ -61,7 +61,7 @@ } else { login(); } -} +}*/ // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); function databaseError($errMsg) { @@ -96,6 +96,7 @@ function array_sum_all($a) { if (!is_array($a)) return $a; + $totale = 0; foreach ($a as $key => $value) $totale += array_sum_all($value); return $totale; @@ -273,12 +274,12 @@
@@ -309,7 +310,7 @@ global $start; $end = (float) array_sum(explode(' ', microtime())); - echo '
Incorporates AusTender materials under a Creative Commons Attribution 3.0 Australia licence (CC BY 3.0 AU) https://creativecommons.org/licenses/by/3.0/au/
AusTender materials are released by the Department of Finance.
AusTender materials are subject to change and should be verified on the AusTender website to ensure the information is up to date and correct: www.tenders.gov.au.
' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '
'; + echo '