<?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"); |
include('db.inc.php'); |
|
|
if (!$conn) { |
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME)); |
die("A database error occurred.\n"); |
if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) { |
} |
$basePath = "../"; |
|
} |
define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME)); |
/*require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; |
if (strstr($_SERVER['PHP_SELF'], "labs/")) { |
require(ROOT.'/solarium/vendor/autoload.php'); |
$basePath = "../"; |
require(ROOT.'/solarium/library/Solarium/Autoloader.php'); |
} |
Solarium\Autoloader::register(); |
|
// check solarium version available |
require ROOT . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'openid.php'; |
//echo 'Solarium library version: ' . Solarium\Client::VERSION . ' - '; |
$openid = new LightOpenID($_SERVER['HTTP_HOST']); |
$config = array( |
|
'endpoint' => array( |
function login() { |
'localhost' => array( |
global $openid; |
'host' => '127.0.0.1', |
if (!$openid->mode) { |
'port' => 8983, |
$openid->required = array('contact/email'); |
'path' => '/solr/contracts/', |
$openid->identity = 'https://www.google.com/accounts/o8/id'; |
) |
header('Location: ' . $openid->authUrl()); |
) |
} |
); |
} |
// create a client instance |
|
$solr_client = new Solarium\Client($config); |
function auth() { |
|
global $openid; |
|
if ($_SESSION['authed'] == true) { |
$openid = new LightOpenID($_SERVER['HTTP_HOST']); |
return true; |
// you have to open the session to be able to modify or remove it |
} |
session_start(); |
|
function login() { |
if ($openid->mode) { |
global $openid; |
$attr = $openid->getAttributes(); |
if (!$openid->mode) { |
if ($attr['contact/email'] != 'maxious@gmail.com') { |
$openid->required = array('contact/email'); |
die('Access Denied'); |
$openid->identity = 'https://www.google.com/accounts/o8/id'; |
} else { |
header('Location: ' . $openid->authUrl()); |
$_SESSION['authed'] = true; |
} |
} |
} |
} else { |
|
login(); |
function auth() { |
} |
global $openid; |
} |
if ($_SESSION['authed'] == true) { |
|
return true; |
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
} |
function databaseError($errMsg) { |
|
if ($errMsg[2] != "") { |
if ($openid->mode) { |
echo '<div class="alert-message error">'; |
$attr = $openid->getAttributes(); |
die(print_r($errMsg, true)); |
if ($attr['contact/email'] != 'maxious@gmail.com') { |
echo "</div>"; |
die('Access Denied'); |
} |
} else { |
} |
$_SESSION['authed'] = true; |
|
} |
function ucsmart($str) { |
} else { |
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
login(); |
, "Of", "On", "Or", "The", "To", "With"); |
} |
$strArray = explode(" ", preg_replace("/(?<=(?<!:|’s)\W) |
}*/ |
(A|An|And|At|For|In|Of|On|Or|The|To|With) |
|
(?=\W)/e", 'strtolower("$1")', ucwords(strtolower($str)))); |
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
foreach ($strArray as &$word) { |
function databaseError($errMsg) { |
if (strlen($word) <= 4 && !in_array($word, $shortWords)) |
if ($errMsg[2] != "") { |
$word = strtoupper($word); |
echo '<div class="alert-message error">'; |
} |
die(print_r($errMsg, true)); |
return implode(" ", $strArray); |
echo "</div>"; |
} |
} |
|
} |
function percent($num_amount, $num_total) { |
function cleanseName($input) { |
$count1 = $num_amount / $num_total; |
|
$count2 = $count1 * 100; |
return trim(join(" ",array_filter(explode(" ",strtolower($input)), function($v, $k) { |
$count = number_format($count2, 2); |
$cleanseNamesCorp = Array( |
return $count; |
"ltd", |
} |
"limited", |
|
"australia", |
function array_sum_all($a) { |
"australian", |
if (!is_array($a)) |
"australasia", |
return $a; |
"(aus)", |
foreach ($a as $key => $value) |
"(aust)", |
$totale += array_sum_all($value); |
"(australia)", |
return $totale; |
"the", |
} |
"pty", |
|
"contractors", |
// magic query modifiers |
"p/l", |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
"inc.", |
if ($agency != "") |
"inc", |
$agencyQ = "agencyName = '" . $agency . "' AND "; |
"incorporated" |
|
); |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
return !in_array($v,$cleanseNamesCorp) ; |
if ($supplier != "") { |
}, ARRAY_FILTER_USE_BOTH))); |
$supplierParts = explode("-", $supplier); |
} |
$supplierName = "%" . $supplierParts[1] . "%"; |
function ucsmart($str) { |
$supplierABN = $supplierParts[0]; |
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
if ($supplierParts[0] > 0) |
, "Of", "On", "Or", "The", "To", "With"); |
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
$strArray = explode(" ", preg_replace_callback("/(?<=(?<!:|’s)\W) |
else |
(A|An|And|At|For|In|Of|On|Or|The|To|With) |
$supplierQ = ' "supplierName" LIKE :supplierName AND '; |
(?=\W)/", |
} |
function($matches) { return strtolower($matches[1]); } , ucwords(strtolower($str)))); |
|
foreach ($strArray as &$word) { |
$startYear = 2007; |
if (strlen($word) <= 4 && !in_array($word, $shortWords)) |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
$word = strtoupper($word); |
if ($year != "") |
} |
$yearQ = "YEAR(publishDate) = " . $year . " AND "; |
return implode(" ", $strArray); |
|
} |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
|
$start = 0.0; |
function percent($num_amount, $num_total) { |
|
$count1 = $num_amount / $num_total; |
function include_header($title) { |
$count2 = $count1 * 100; |
global $start; |
$count = number_format($count2, 2); |
?> |
return $count; |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
} |
"http://www.w3.org/TR/html4/strict.dtd"> |
|
<html> |
function array_sum_all($a) { |
<head> |
if (!is_array($a)) |
<title>Contract Dashboard - <?php echo $title; ?></title> |
return $a; |
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
$totale = 0; |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
foreach ($a as $key => $value) |
<!--[if lt IE 9]> |
$totale += array_sum_all($value); |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
return $totale; |
<![endif]--> |
} |
<script type="text/javascript" src="lib/bsn.AutoSuggest_2.1.3_comp.js" charset="utf-8"></script> |
|
<link rel="stylesheet" href="autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> |
function show_stats($stats) { |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
setlocale(LC_MONETARY, 'en_US'); |
<script type="text/javascript"> |
$value = number_format(doubleval($stats['total_value']) , 2); |
$(document).ready(function() |
echo "<br/> {$stats['total']} contracts, total value $$value <br/>"; |
{ |
if ($stats['consultancy'] > 0) { |
//hide the all of the element with class msg_body |
echo "<b>Consultancies:</b> {$stats['consultancy']} contracts, ".percent($stats['consultancy'],$stats['total']); |
$(".msg_body").hide(); |
echo "%<br/>"; |
//toggle the componenet with class msg_body |
} |
$(".msg_head").click(function() |
if ($stats['confidentialityContract']+$stats['confidentialityOutputs'] > 0) { |
{ |
$confidentialities = $stats['confidentialityContract']+$stats['confidentialityOutputs']; |
$(this).next(".msg_body").slideToggle(600); |
echo "<b>Confidentialities:</b> $confidentialities contracts, ".percent( $confidentialities,$stats['total'])."%"; |
}); |
echo "( {$stats['confidentialityContract']} on the contract, {$stats['confidentialityOutputs']} on the outputs)"; |
}); |
echo "<br/>"; |
</script> |
} |
|
echo "<b>Procurement methods:</b> "; |
<style type="text/css" title="currentStyle"> |
if ($stats['open'] > 0) { |
@import "media/css/demo_table.css"; |
echo "Open {$stats['open']} contracts, ".percent($stats['open'],$stats['total']); |
</style> |
echo "%, "; |
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script> |
} |
<script type="text/javascript" language="javascript" src="lib/bootstrap-dropdown.js"></script> |
if ($stats['openSON'] > 0) { |
<script type="text/javascript" charset="utf-8"> |
echo "Open via SON {$stats['openSON']} contracts, ".percent($stats['openSON'],$stats['total']); |
jQuery.fn.dataTableExt.aTypes.unshift( |
echo "%, "; |
function ( sData ) |
} |
{ |
if ($stats['prequalified'] > 0) { |
var sValidChars = "0123456789.-,"; |
echo "Prequalified {$stats['prequalified']} contracts, ".percent($stats['prequalified'],$stats['total']); |
var Char; |
echo "%, "; |
|
} |
/* Check the numeric part */ |
if ($stats['limited'] > 0) { |
for ( i=1 ; i<sData.length ; i++ ) |
echo "limited {$stats['limited']} contracts, ".percent($stats['limited'],$stats['total']); |
{ |
echo "%, "; |
Char = sData.charAt(i); |
} |
if (sValidChars.indexOf(Char) == -1) |
} |
{ |
|
return null; |
// magic query modifiers |
} |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
} |
if ($agency != "") |
|
$agencyQ = "agencyName = '" . $agency . "' AND "; |
/* Check prefixed by currency */ |
|
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
{ |
if ($supplier != "") { |
return 'currency'; |
if ($supplier[0] !== '-') { |
} |
$supplierParts = explode("-", $supplier); |
return null; |
|
} |
$supplierABN = array_shift($supplierParts); |
); |
$supplierName = "%" . implode('-',$supplierParts) . "%"; |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
|
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
} else { |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
$supplierName = "%" . substr($supplier,1) . "%"; |
|
$supplierQ = ' "supplierName" ILIKE :supplierName AND '; |
/* Remove the currency sign */ |
} |
x = x.substring( 1 ); |
} |
y = y.substring( 1 ); |
|
|
$startYear = 2007; |
/* Parse and return */ |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
x = parseFloat( x ); |
if ($year != "") { |
y = parseFloat( y ); |
$yearQ = 'extract(year from "contractStart") = ' . $year . " AND "; |
return x - y; |
} |
}; |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
|
$start = 0.0; |
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
|
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
function local_url() { |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
} |
|
|
/* Remove the currency sign */ |
function include_header($title) { |
x = x.substring( 1 ); |
global $start; |
y = y.substring( 1 ); |
?> |
|
<!DOCTYPE html> |
/* Parse and return */ |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" version="XHTML+RDFa 1.1" |
x = parseFloat( x ); |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
y = parseFloat( y ); |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
return y - x; |
xmlns:gr="http://purl.org/goodrelations/v1#" |
}; |
xmlns:dc="http://purl.org/dc/terms/" |
$(document).ready(function() { |
xmlns:pc="http://purl.org/procurement#" |
$('table').dataTable(); |
xmlns:unspsc="http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml#" |
} ); |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
</script> |
xmlns:pcdt="http://purl.org/procurement/public-contracts-datatypes#" |
<link type="text/css" rel="stylesheet" href="style.css"> |
prefix="rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# |
</head> |
rdfs: http://www.w3.org/2000/01/rdf-schema# |
<body> |
gr: http://purl.org/goodrelations/v1# |
<div class="topbar"> |
dcterms: http://purl.org/dc/terms/ |
<div class="topbar-inner"> |
pc: http://purl.org/procurement/public-contracts# |
<div class="container-fluid"> |
cpv: http://purl.org/weso/pscs/cpv/2008/resource/ |
<a class="brand" href="#">contract dashboard</a> |
unspsc: http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml# |
<ul class="nav"> |
v: http://www.w3.org/2006/vcard/ns# |
<li><a href="displayAgency.php">agencies</a></li> |
payment: http://reference.data.gov.uk/def/payment# |
<li><a href="displaySupplier.php">suppliers</a></li> |
br: http://purl.org/business-register# |
<li><a href="displayCategory.php">categories</a></li> |
xsd: http://www.w3.org/2001/XMLSchema# |
<li><a href="displayCalendar.php">time periods</a></li> |
pcdt: http://purl.org/procurement/public-contracts-datatypes#"> |
<!-- <li class="dropdown"> |
<head> |
<a href="#" class="dropdown-toggle">metrics</a> |
<title><?php echo $title; ?> - Contract Dashboard</title> |
<ul class="dropdown-menu">--> |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
<li><a href="displayProcurementMethod.php">tenderm</a></li> |
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
<li><a href="displayConfidentialities.php">confidentiality</a></li> |
<link rel="stylesheet" type="text/css" href="bootstrap-responsive.css"> |
<li><a href="displayConsultancies.php">consultancies</a></li> |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
<li><a href="displayAmendments.php">amendments</a></li> |
<!--[if lt IE 9]> |
<li><a href="displayMap.php">geo</a></li> |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
<!-- </ul> |
<![endif]--> |
</li>--> |
<script type="text/javascript" src="lib/bsn.AutoSuggest_2.1.3_comp.js" charset="utf-8"></script> |
</ul> |
<link rel="stylesheet" href="autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> |
|
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
|
<script type="text/javascript"> |
<form method="post" action="search.php" class="pull-right"> |
$(document).ready(function() |
<input type="text" id="searchKeyword" name="searchKeyword" value="" placeholder="Search" /> |
{ |
<input type="hidden" id="searchID" name="searchID" value=""/> |
//hide the all of the element with class msg_body |
</form> |
$(".msg_body").hide(); |
|
//toggle the componenet with class msg_body |
</div> |
$(".msg_head").click(function() |
</div><!-- /topbar-inner --> |
{ |
</div><!-- /topbar --> |
$(this).next(".msg_body").slideToggle(600); |
</div><!-- /topbar-wrapper --> |
}); |
<script type="text/javascript"> |
}); |
|
</script> |
var options_xml = { |
|
script: function (input) { return "search_autosuggest.php?input="+input; }, |
<style type="text/css" title="currentStyle"> |
varname:"input", |
@import "media/css/demo_table.css"; |
callback: function (obj) { document.getElementById('searchID').value = obj.id; } |
</style> |
}; |
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script> |
var as_xml = new bsn.AutoSuggest('searchKeyword', options_xml); |
<script type="text/javascript" language="javascript" src="lib/bootstrap-dropdown.js"></script> |
</script> |
<script type="text/javascript" charset="utf-8"> |
<div class="container-fluid"> |
jQuery.fn.dataTableExt.aTypes.unshift( |
<div class="sidebar"> |
function ( sData ) |
<div class="well"> |
{ |
Filter by:<li> |
var sValidChars = "0123456789.-,"; |
<li>year |
var Char; |
<li><li>2008</li> |
|
</li> |
/* Check the numeric part */ |
</li> |
for ( i=1 ; i<sData.length ; i++ ) |
</li> <br> |
{ |
</div> </div> |
Char = sData.charAt(i); |
<div class="content"> |
if (sValidChars.indexOf(Char) == -1) |
<?php |
{ |
$start = (float) array_sum(explode(' ', microtime())); |
return null; |
} |
} |
|
} |
function include_footer() { |
|
global $start; |
/* Check prefixed by currency */ |
$end = (float) array_sum(explode(' ', microtime())); |
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
|
{ |
echo ' <footer>' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . ' <footer>'; |
return 'currency'; |
echo '</div> </div></body> </html>'; |
} |
} |
return null; |
|
} |
include ("graphs.inc.php"); |
); |
?> |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
|
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
|
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
|
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
|
|
|
/* Remove the currency sign */ |
|
x = x.substring( 1 ); |
|
y = y.substring( 1 ); |
|
|
|
/* Parse and return */ |
|
x = parseFloat( x ); |
|
y = parseFloat( y ); |
|
return x - y; |
|
}; |
|
|
|
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
|
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
|
var x = a == & |