--- a/lib/common.inc.php
+++ b/lib/common.inc.php
@@ -4,17 +4,13 @@
error_reporting(E_ALL ^ E_NOTICE);
-$conn = new PDO("pgsql:dbname=contractdashboard;user=postgres;password=snmc;host=localhost");
-
-if (!$conn) {
- die("A database error occurred.\n");
-}
+include('db.inc.php');
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME));
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 +57,7 @@
} else {
login();
}
-}
+}*/
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function databaseError($errMsg) {
@@ -71,10 +67,32 @@
echo "";
}
}
-
+function cleanseName($input) {
+
+ return trim(join(" ",array_filter(explode(" ",strtolower($input)), function($v, $k) {
+ $cleanseNamesCorp = Array(
+ "ltd",
+ "limited",
+ "australia",
+ "australian",
+ "australasia",
+ "(aus)",
+ "(aust)",
+ "(australia)",
+ "the",
+ "pty",
+ "contractors",
+ "p/l",
+ "inc.",
+ "inc",
+ "incorporated"
+ );
+ return !in_array($v,$cleanseNamesCorp) ;
+}, ARRAY_FILTER_USE_BOTH)));
+}
function ucsmart($str) {
$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", "Use", "No", "Yes");
$strArray = explode(" ", preg_replace_callback("/(?<=(? $value)
$totale += array_sum_all($value);
return $totale;
+}
+
+function show_stats($stats) {
+ setlocale(LC_MONETARY, 'en_US');
+ $value = number_format(doubleval($stats['total_value']) , 2);
+ echo "
{$stats['total']} contracts, total value $$value
";
+ if ($stats['consultancy'] > 0) {
+ echo "Consultancies: {$stats['consultancy']} contracts, ".percent($stats['consultancy'],$stats['total']);
+ echo "%
";
+ }
+ if ($stats['confidentialityContract']+$stats['confidentialityOutputs'] > 0) {
+ $confidentialities = $stats['confidentialityContract']+$stats['confidentialityOutputs'];
+ echo "Confidentialities: $confidentialities contracts, ".percent( $confidentialities,$stats['total'])."%";
+ echo "( {$stats['confidentialityContract']} on the contract, {$stats['confidentialityOutputs']} on the outputs)";
+ echo "
";
+ }
+ echo "Procurement methods: ";
+ if ($stats['open'] > 0) {
+ echo "Open {$stats['open']} contracts, ".percent($stats['open'],$stats['total']);
+ echo "%, ";
+ }
+ if ($stats['openSON'] > 0) {
+ echo "Open via SON {$stats['openSON']} contracts, ".percent($stats['openSON'],$stats['total']);
+ echo "%, ";
+ }
+ if ($stats['prequalified'] > 0) {
+ echo "Prequalified {$stats['prequalified']} contracts, ".percent($stats['prequalified'],$stats['total']);
+ echo "%, ";
+ }
+ if ($stats['limited'] > 0) {
+ echo "limited {$stats['limited']} contracts, ".percent($stats['limited'],$stats['total']);
+ echo "%, ";
+ }
}
// magic query modifiers
@@ -108,13 +160,17 @@
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING);
if ($supplier != "") {
+ if ($supplier[0] !== '-') {
$supplierParts = explode("-", $supplier);
- $supplierName = "%" . $supplierParts[1] . "%";
- $supplierABN = $supplierParts[0];
- if ($supplierParts[0] > 0)
- $supplierQ = ' "supplierABN" = :supplierABN AND ';
- else
- $supplierQ = ' "supplierName" ILIKE :supplierName AND ';
+
+ $supplierABN = array_shift($supplierParts);
+ $supplierName = "%" . implode('-',$supplierParts) . "%";
+
+ $supplierQ = ' "supplierABN" = :supplierABN AND ';
+ } else {
+ $supplierName = "%" . substr($supplier,1) . "%";
+ $supplierQ = ' "supplierName" ILIKE :supplierName AND ';
+ }
}
$startYear = 2007;
@@ -156,6 +212,7 @@
pcdt: http://purl.org/procurement/public-contracts-datatypes#">