<?php | <?php |
include_once ("./lib/common.inc.php"); | include_once ("./lib/common.inc.php"); |
if ($_REQUEST['agency']) { | if ($_REQUEST['agency']) { |
include_header("Agency"); | |
$agency = htmlentities(strip_tags($_REQUEST['agency'])); | $agency = htmlentities(strip_tags($_REQUEST['agency'])); |
include_header($agency); | //MethodCountGraph($agency); |
echo '<center><h1>'.$agency.'</h1></center>'; | // CnCGraph($agency); |
// MethodCountGraph($agency); | //MethodValueGraph($agency); |
// CnCGraph($agency); | |
// MethodValueGraph($agency); | |
/* biggest contracts | /* biggest contracts |
spending by year | spending by year |
spending by industry/category | spending by industry/category |
spending by supplier | spending by supplier |
spread procurement methods (stacked bar graph) | spread procurement methods (stacked bar graph) |
+ percent consultancies + percent confidential (bar graph) | + percent consultancies + percent confidential (bar graph) |
Average value by procurement type | Average value by procurement type |
--- info | --- info |
website, procurement plan, annual reports | website, procurement plan, annual reports |
Breakdown of divisions/branches | Breakdown of divisions/branches |
Breakdown percentage,number,value by procurement type | Breakdown percentage,number,value by procurement type |
Histograph, overlaying number value reported per week over X years | Histograph, overlaying number value reported per week over X years |
Compliance statistics: amendments, delay in reporting average and number completely late */ | Compliance statistics: amendments, delay in reporting average and number completely late */ |
$query = 'SELECT "CNID", "description", "value", "agencyName", "category", | $query = 'SELECT "CNID", "description", "value", "agencyName", "category", |
"contractStart", "supplierName" | "contractStart", "supplierName" |
FROM contractnotice | FROM contractnotice |
WHERE "agencyName" = :agency | WHERE "agencyName" = :agency |
ORDER BY "value" DESC'; | ORDER BY "value" DESC limit 100'; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$query->bindParam(":agency", $agency); | $query->bindParam(":agency", $agency); |
$query->execute(); | $query->execute(); |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
echo "<table> <thead> | echo "<table> <thead> |
<tr> | <tr> |
<th>Contract Notice Number</th> | <th>Contract Notice Number</th> |
<th>Contract Description</th> | <th>Contract Description</th> |
<th>Total Contract Value</th> | <th>Total Contract Value</th> |
<th>Agency</th> | <th>Agency</th> |
<th>Contract Start Date</th> | <th>Contract Start Date</th> |
<th>Supplier</th> | <th>Supplier</th> |
</tr> | </tr> |
</thead>"; | </thead>"; |
foreach ($query->fetchAll() as $row) { | foreach ($query->fetchAll() as $row) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row['value']), 2); | $value = number_format(doubleval($row['value']), 2); |
echo ("<tr> | echo ("<tr> |
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> | <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> |
<td><b>{$row['description']}</b></a></td> | <td><b>{$row['description']}</b></a></td> |
<td>\$$value</td><td>{$row['agencyName']}</td> | <td>\$$value</td><td>{$row['agencyName']}</td> |
<td>{$row['contractStart']}</td> | <td>{$row['contractStart']}</td> |
<td>{$row['supplierName']}</td> | <td>{$row['supplierName']}</td> |
</tr>"); | </tr>"); |
} | } |
echo "</table>"; | echo "</table>"; |
} else { | } else { |
/* | /* |
split by portfolio | split by portfolio |
*/ | */ |
include_header("Agencies"); | include_header("Agencies"); |
agenciesGraph(); | agenciesGraph(); |
$query = 'SELECT SUM("value"), "agencyName" | $query = 'SELECT SUM("value"), "agencyName" |
FROM contractnotice | FROM contractnotice |
WHERE "childCN" is null | WHERE "childCN" is null |
GROUP BY "agencyName" '; | GROUP BY "agencyName" '; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$query->execute(); | $query->execute(); |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
echo "<table> <thead> | echo "<table> <thead> |
<tr> | <tr> |
<th>Agency</th> | <th>Agency</th> |
<th>Total Contracts Value</th> | <th>Total Contracts Value</th> |
</tr> | </tr> |
</thead>"; | </thead>"; |
foreach ($query->fetchAll() as $row) { | foreach ($query->fetchAll() as $row) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row[0]), 2); | $value = number_format(doubleval($row[0]), 2); |
$agency = stripslashes($row[1]); | $agency = stripslashes($row[1]); |
echo ("<tr><td><b><a href=\"displayAgency.php?agency={$agency}\">{$agency}</a></b></td><td>\$$value</td></tr>\n"); | echo ("<tr><td><b><a href=\"displayAgency.php?agency={$agency}\">{$agency}</a></b></td><td>\$$value</td></tr>\n"); |
} | } |
echo "</table>"; | echo "</table>"; |
} | } |
include_footer(); | include_footer(); |
?> | ?> |
<?php | <?php |
include_once("./lib/common.inc.php"); | include_once("./lib/common.inc.php"); |
include_header("Contract"); | |
$query = 'SELECT * | $query = 'SELECT * |
FROM contractnotice | FROM contractnotice |
WHERE "CNID" = :CNID LIMIT 1'; | WHERE "CNID" = :CNID LIMIT 1'; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$query->bindParam(":CNID", $_REQUEST['CNID']); | $query->bindParam(":CNID", $_REQUEST['CNID']); |
$query->execute(); | $query->execute(); |
$contractResult = $query->fetch(PDO::FETCH_ASSOC); | |
if (!$contractResult) { | |
header("Status: 404 Not Found"); | |
header("HTTP/1.0 404 Not Found"); | |
include_header("Contract Not Found"); | |
echo "<center><h1>No Contract Notice with that ID found</h1></center>"; | |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
} else { | foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { |
$description = ucsmart($contractResult["description"]); | |
include_header($description); | |
echo '<center><h1>'.$description.'</h1></center>'; | |
databaseError($conn->errorInfo()); | |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
foreach (array_filter($contractResult) as $key => $value) { | foreach (array_filter($row) as $key => $value) { |
echo "<b>$key</b> "; | echo "<b>$key</b> "; |
switch ($key) { | switch ($key) { |
case "supplierName": | case "supplierName": |
case "supplierABN": | case "supplierABN": |
echo '<a href="displaySupplier.php?supplier=' . $contractResult['supplierABN'] . '-' . urlencode($contractResult['supplierName']) . '">' . $value . "</a>"; | echo '<a href="displaySupplier.php?supplier=' . $row['supplierABN'] . '-' . urlencode($row['supplierName']) . '">' . $value . "</a>"; |
break; | break; |
case "agencyName": | case "agencyName": |
echo '<a href="displayAgency.php?agency=' . urlencode($value) . '">' . $value . "</a>"; | echo '<a href="displayAgency.php?agency=' . urlencode($value) . '">' . $value . "</a>"; |
break; | break; |
case "value": | case "value": |
echo "$" . number_format(doubleval($value), 2); | echo "$" . number_format(doubleval($value), 2); |
break; | break; |
default: | default: |
echo str_replace(" ", "<br>", ucsmart($value)); | echo str_replace(" ", "<br>", $value); |
} | } |
echo "<br>"; | echo "<br>"; |
} | } |
} | |
echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN' . $_REQUEST['CNID'] . '"> View original record @ tenders.gov.au</a><br>'; | echo '<br><a href="https://www.tenders.gov.au/?event=public.advancedsearch.keyword&keyword=CN' . $_REQUEST['CNID'] . '"> View original record @ tenders.gov.au</a><br>'; |
$query = 'SELECT * FROM heuristic_results where "CNID" = :CNID'; | $query = 'SELECT * FROM heuristic_results where "CNID" = :CNID'; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$agencyName = $input . '%'; | $agencyName = $input . '%'; |
$query->bindParam(":CNID", $_REQUEST['CNID']); | $query->bindParam(":CNID", $_REQUEST['CNID']); |
$query->execute(); | $query->execute(); |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
foreach ($query->fetchAll() as $r) { | foreach ($query->fetchAll() as $r) { |
echo "<b>{$r['heuristic_name']}</b>: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})<br>"; | echo "<b>{$r['heuristic_name']}</b>: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})<br>"; |
} | } |
} | |
include_footer(); | include_footer(); |
?> | ?> |
<?php | <?php |
include_once ("./lib/common.inc.php"); | include_once ("./lib/common.inc.php"); |
if ($_REQUEST['supplier']) { | if ($_REQUEST['supplier']) { |
include_header("Supplier"); | |
$supplierS = htmlentities(strip_tags($_REQUEST['supplier'])); | $supplierS = htmlentities(strip_tags($_REQUEST['supplier'])); |
include_header(str_replace("%","",$supplierName)); | |
echo '<center><h1>'.str_replace("%","",$supplierName).'</h1></center>'; | |
// MethodCountGraph($supplierS); | // MethodCountGraph($supplierS); |
// CnCGraph($supplierS); | // CnCGraph($supplierS); |
// MethodValueGraph($supplierS); | // MethodValueGraph($supplierS); |
/* lobbyist ties | /* lobbyist ties |
links to ABR/ASIC/Google News/ASX/Court records | links to ABR/ASIC/Google News/ASX/Court records |
total value to various agencies (bar graph) | total value to various agencies (bar graph) |
spread procurement methods + percent consultancies + percent confidential (bar graph) | spread procurement methods + percent consultancies + percent confidential (bar graph) |
spread of contract values | spread of contract values |
spread of industries (textual?) */ | spread of industries (textual?) */ |
$query = 'SELECT "CNID", "description", "value", "agencyName", "category", | $query = 'SELECT "CNID", "description", "value", "agencyName", "category", |
"contractStart", "supplierName" | "contractStart", "supplierName" |
FROM contractnotice WHERE ' . | FROM contractnotice WHERE ' . |
$supplierQ . ' ' . $standardQ | $supplierQ . ' ' . $standardQ |
. ' ORDER BY value DESC'; | . ' ORDER BY value DESC'; |
echo $query; | echo $query; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
if ($supplierParts[0] > 0) { | if ($supplierParts[0] > 0) { |
$query->bindParam(":supplierABN", $supplierABN); | $query->bindParam(":supplierABN", $supplierABN); |
} else { | } else { |
$query->bindParam(":supplierName", $supplierName); | $query->bindParam(":supplierName", $supplierName); |
} | } |
$query->execute(); | $query->execute(); |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
// echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">'; | // echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">'; |
// echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">'; | // echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">'; |
echo "<table> <thead> | echo "<table> <thead> |
<tr> | <tr> |
<th>Contract Notice Number</th> | <th>Contract Notice Number</th> |
<th>Contract Description</th> | <th>Contract Description</th> |
<th>Total Contract Value</th> | <th>Total Contract Value</th> |
<th>Agency</th> | <th>Agency</th> |
<th>Contract Start Date</th> | <th>Contract Start Date</th> |
<th>Supplier</th> | <th>Supplier</th> |
</tr> | </tr> |
</thead>"; | </thead>"; |
foreach ($query->fetchAll() as $row) { | foreach ($query->fetchAll() as $row) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row['value']), 2); | $value = number_format(doubleval($row['value']), 2); |
echo ("<tr> | echo ("<tr> |
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> | <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> |
<td><b>{$row['description']}</b></a></td> | <td><b>{$row['description']}</b></a></td> |
<td>\$$value</td><td>{$row['agencyName']}</td> | <td>\$$value</td><td>{$row['agencyName']}</td> |
<td>{$row['contractStart']}</td> | <td>{$row['contractStart']}</td> |
<td>{$row['supplierName']}</td> | <td>{$row['supplierName']}</td> |
</tr>"); | </tr>"); |
} | } |
echo "</table>"; | echo "</table>"; |
} else { | } else { |
/* | /* |
histograph of supplier size/value | histograph of supplier size/value |
*/ | */ |
include_header("Suppliers"); | include_header("Suppliers"); |
suppliersGraph(); | suppliersGraph(); |
$query = 'SELECT SUM("value") as val, MAX("supplierName") as supplierName, "supplierABN",( | $query = 'SELECT SUM("value") as val, MAX("supplierName") as supplierName, "supplierABN",( |
case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID | case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID |
FROM contractnotice | FROM contractnotice |
WHERE "childCN" is null | WHERE "childCN" is null |
GROUP BY supplierID,"supplierABN" | GROUP BY supplierID,"supplierABN" |
ORDER BY val DESC | ORDER BY val DESC |
LIMIT 100'; | LIMIT 100'; |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$query->execute(); | $query->execute(); |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
echo "<table> <thead> | echo "<table> <thead> |
<tr> | <tr> |
<th>Position</th> | <th>Position</th> |
<th>Supplier</th> | <th>Supplier</th> |
<th>Total Contract Value</th> | <th>Total Contract Value</th> |
</tr> | </tr> |
</thead>"; | </thead>"; |
$i = 1; | $i = 1; |
foreach ($query->fetchAll() as $row) { | foreach ($query->fetchAll() as $row) { |
setlocale(LC_MONETARY, 'en_US'); | setlocale(LC_MONETARY, 'en_US'); |
$value = number_format(doubleval($row['val']), 2); | $value = number_format(doubleval($row['val']), 2); |
$supplier = stripslashes($row['supplierABN'] . '-' . $row['suppliername']); | $supplier = stripslashes($row['supplierABN'] . '-' . $row['suppliername']); |
echo ("<tr><td>$i</td><td><b><a href=\"displaySupplier.php?supplier={$supplier}\">" . ucsmart($row['suppliername']) . "</a></b></td><td>\$$value</td></tr>\n"); | echo ("<tr><td>$i</td><td><b><a href=\"displaySupplier.php?supplier={$supplier}\">" . ucsmart($row['suppliername']) . "</a></b></td><td>\$$value</td></tr>\n"); |
$i++; | $i++; |
} | } |
echo "</table>"; | echo "</table>"; |
} | } |
include_footer(); | include_footer(); |
?> | ?> |
google-site-verification: google676a414ad086cefb.html | |
<?php | <?php |
date_default_timezone_set("Australia/ACT"); | date_default_timezone_set("Australia/ACT"); |
error_reporting(E_ALL ^ E_NOTICE); | error_reporting(E_ALL ^ E_NOTICE); |
$conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); | $conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); |
if (!$conn) { | if (!$conn) { |
die("A database error occurred.\n"); | die("A database error occurred.\n"); |
} | } |
define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME)); | define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME)); |
if (strstr($_SERVER['PHP_SELF'], "labs/")) { | if (strstr($_SERVER['PHP_SELF'], "labs/")) { |
$basePath = "../"; | $basePath = "../"; |
} | } |
require ROOT . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'openid.php'; | require ROOT . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'openid.php'; |
$openid = new LightOpenID($_SERVER['HTTP_HOST']); | $openid = new LightOpenID($_SERVER['HTTP_HOST']); |
function login() { | function login() { |
global $openid; | global $openid; |
if (!$openid->mode) { | if (!$openid->mode) { |
$openid->required = array('contact/email'); | $openid->required = array('contact/email'); |
$openid->identity = 'https://www.google.com/accounts/o8/id'; | $openid->identity = 'https://www.google.com/accounts/o8/id'; |
header('Location: ' . $openid->authUrl()); | header('Location: ' . $openid->authUrl()); |
} | } |
} | } |
function auth() { | function auth() { |
global $openid; | global $openid; |
if ($_SESSION['authed'] == true) { | if ($_SESSION['authed'] == true) { |
return true; | return true; |
} | } |
if ($openid->mode) { | if ($openid->mode) { |
$attr = $openid->getAttributes(); | $attr = $openid->getAttributes(); |
if ($attr['contact/email'] != 'maxious@gmail.com') { | if ($attr['contact/email'] != 'maxious@gmail.com') { |
die('Access Denied'); | die('Access Denied'); |
} else { | } else { |
$_SESSION['authed'] = true; | $_SESSION['authed'] = true; |
} | } |
} else { | } else { |
login(); | login(); |
} | } |
} | } |
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
function databaseError($errMsg) { | function databaseError($errMsg) { |
if ($errMsg[2] != "") { | if ($errMsg[2] != "") { |
echo '<div class="alert-message error">'; | echo '<div class="alert-message error">'; |
die(print_r($errMsg, true)); | die(print_r($errMsg, true)); |
echo "</div>"; | echo "</div>"; |
} | } |
} | } |
function ucsmart($str) { | function ucsmart($str) { |
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" | $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
, "Of", "On", "Or", "The", "To", "With"); | , "Of", "On", "Or", "The", "To", "With"); |
$strArray = explode(" ", preg_replace("/(?<=(?<!:|’s)\W) | $strArray = explode(" ", preg_replace("/(?<=(?<!:|’s)\W) |
(A|An|And|At|For|In|Of|On|Or|The|To|With) | (A|An|And|At|For|In|Of|On|Or|The|To|With) |
(?=\W)/e", 'strtolower("$1")', ucwords(strtolower($str)))); | (?=\W)/e", 'strtolower("$1")', ucwords(strtolower($str)))); |
foreach ($strArray as &$word) { | foreach ($strArray as &$word) { |