--- a/displayAgency.php +++ b/displayAgency.php @@ -1,42 +1,106 @@

'.$agency.'

'; -// MethodCountGraph($agency); - // CnCGraph($agency); - // MethodValueGraph($agency); - /* biggest contracts - spending by year - spending by industry/category - spending by supplier - - spread procurement methods (stacked bar graph) - + percent consultancies + percent confidential (bar graph) - - Average value by procurement type - - --- info - website, procurement plan, annual reports - Breakdown of divisions/branches - Breakdown percentage,number,value by procurement type - Histograph, overlaying number value reported per week over X years - Compliance statistics: amendments, delay in reporting average and number completely late */ - - $query = 'SELECT "CNID", "description", "value", "agencyName", "category", - "contractStart", "supplierName" - FROM contractnotice - WHERE "agencyName" like :agency - 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 " + + 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

"; + /* + * 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'; + $query = $conn->prepare($query); + $query->bindParam(":agency", $agency); + $query->execute(); + databaseError($conn->errorInfo()); + + echo "

Contracts

@@ -49,7 +113,7 @@ foreach ($query->fetchAll() as $row) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value']), 2); - echo (" + echo(" @@ -66,7 +130,7 @@ agenciesGraph(); $query = 'SELECT SUM("value"), "agencyName" FROM contractnotice -WHERE "childCN" is null +WHERE ' . $yearQ . ' "childCN" IS NULL GROUP BY "agencyName" '; $query = $conn->prepare($query); $query->execute(); @@ -81,7 +145,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
"; }