<?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) { |
|
$count1 = $num_amount / $num_total; |
function ucsmart($str) { |
$count2 = $count1 * 100; |
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
$count = number_format($count2, 2); |
, "Of", "On", "Or", "The", "To", "With"); |
return $count; |
$strArray = explode(" ", preg_replace_callback("/(?<=(?<!:|’s)\W) |
} |
(A|An|And|At|For|In|Of|On|Or|The|To|With) |
|
(?=\W)/", |
function array_sum_all($a) { |
function($matches) { return strtolower($matches[1]); } , ucwords(strtolower($str)))); |
if (!is_array($a)) |
foreach ($strArray as &$word) { |
return $a; |
if (strlen($word) <= 4 && !in_array($word, $shortWords)) |
foreach ($a as $key => $value) |
$word = strtoupper($word); |
$totale += array_sum_all($value); |
} |
return $totale; |
return implode(" ", $strArray); |
} |
} |
|
|
// magic query modifiers |
function percent($num_amount, $num_total) { |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
$count1 = $num_amount / $num_total; |
if ($agency != "") |
$count2 = $count1 * 100; |
$agencyQ = "agencyName = '" . $agency . "' AND "; |
$count = number_format($count2, 2); |
|
return $count; |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
} |
if ($supplier != "") { |
|
$supplierParts = explode("-", $supplier); |
function array_sum_all($a) { |
$supplierName = "%" . $supplierParts[1] . "%"; |
if (!is_array($a)) |
$supplierABN = $supplierParts[0]; |
return $a; |
if ($supplierParts[0] > 0) |
$totale = 0; |
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
foreach ($a as $key => $value) |
else |
$totale += array_sum_all($value); |
$supplierQ = ' "supplierName" LIKE :supplierName AND '; |
return $totale; |
} |
} |
|
|
$startYear = 2007; |
function show_stats($stats) { |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
setlocale(LC_MONETARY, 'en_US'); |
if ($year != "") |
$value = number_format(doubleval($stats['total_value']) , 2); |
$yearQ = "YEAR(publishDate) = " . $year . " AND "; |
echo "<br/> {$stats['total']} contracts, total value $$value <br/>"; |
|
if ($stats['consultancy'] > 0) { |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
echo "<b>Consultancies:</b> {$stats['consultancy']} contracts, ".percent($stats['consultancy'],$stats['total']); |
$start = 0.0; |
echo "%<br/>"; |
|
} |
function local_url() { |
if ($stats['confidentialityContract']+$stats['confidentialityOutputs'] > 0) { |
return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; |
$confidentialities = $stats['confidentialityContract']+$stats['confidentialityOutputs']; |
} |
echo "<b>Confidentialities:</b> $confidentialities contracts, ".percent( $confidentialities,$stats['total'])."%"; |
|
echo "( {$stats['confidentialityContract']} on the contract, {$stats['confidentialityOutputs']} on the outputs)"; |
function include_header($title) { |
echo "<br/>"; |
global $start; |
} |
?> |
echo "<b>Procurement methods:</b> "; |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
if ($stats['open'] > 0) { |
"http://www.w3.org/TR/html4/strict.dtd"> |
echo "Open {$stats['open']} contracts, ".percent($stats['open'],$stats['total']); |
<html> |
echo "%, "; |
<head> |
} |
<title><?php echo $title; ?> - Contract Dashboard</title> |
if ($stats['openSON'] > 0) { |
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
echo "Open via SON {$stats['openSON']} contracts, ".percent($stats['openSON'],$stats['total']); |
<link rel="stylesheet" type="text/css" href="bootstrap-responsive.css"> |
echo "%, "; |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
} |
<!--[if lt IE 9]> |
if ($stats['prequalified'] > 0) { |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
echo "Prequalified {$stats['prequalified']} contracts, ".percent($stats['prequalified'],$stats['total']); |
<![endif]--> |
echo "%, "; |
<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" /> |
if ($stats['limited'] > 0) { |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
echo "limited {$stats['limited']} contracts, ".percent($stats['limited'],$stats['total']); |
<script type="text/javascript"> |
echo "%, "; |
$(document).ready(function() |
} |
{ |
} |
//hide the all of the element with class msg_body |
|
$(".msg_body").hide(); |
// magic query modifiers |
//toggle the componenet with class msg_body |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
$(".msg_head").click(function() |
if ($agency != "") |
{ |
$agencyQ = "agencyName = '" . $agency . "' AND "; |
$(this).next(".msg_body").slideToggle(600); |
|
}); |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
}); |
if ($supplier != "") { |
</script> |
if ($supplier[0] !== '-') { |
|
$supplierParts = explode("-", $supplier); |
<style type="text/css" title="currentStyle"> |
|
@import "media/css/demo_table.css"; |
$supplierABN = array_shift($supplierParts); |
</style> |
$supplierName = "%" . implode('-',$supplierParts) . "%"; |
<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> |
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
<script type="text/javascript" charset="utf-8"> |
} else { |
jQuery.fn.dataTableExt.aTypes.unshift( |
$supplierName = "%" . substr($supplier,1) . "%"; |
function ( sData ) |
$supplierQ = ' "supplierName" ILIKE :supplierName AND '; |
{ |
} |
var sValidChars = "0123456789.-,"; |
} |
var Char; |
|
|
$startYear = 2007; |
/* Check the numeric part */ |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
for ( i=1 ; i<sData.length ; i++ ) |
if ($year != "") { |
{ |
$yearQ = 'extract(year from "contractStart") = ' . $year . " AND "; |
Char = sData.charAt(i); |
} |
if (sValidChars.indexOf(Char) == -1) |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
{ |
$start = 0.0; |
return null; |
|
} |
function local_url() { |
} |
return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; |
|
} |
/* Check prefixed by currency */ |
|
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
function include_header($title) { |
{ |
global $start; |
return 'currency'; |
?> |
} |
<!DOCTYPE html> |
return null; |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" version="XHTML+RDFa 1.1" |
} |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
); |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
xmlns:gr="http://purl.org/goodrelations/v1#" |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
xmlns:dc="http://purl.org/dc/terms/" |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
xmlns:pc="http://purl.org/procurement#" |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
xmlns:unspsc="http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml#" |
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
/* Remove the currency sign */ |
xmlns:pcdt="http://purl.org/procurement/public-contracts-datatypes#" |
x = x.substring( 1 ); |
prefix="rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# |
y = y.substring( 1 ); |
rdfs: http://www.w3.org/2000/01/rdf-schema# |
|
gr: http://purl.org/goodrelations/v1# |
/* Parse and return */ |
dcterms: http://purl.org/dc/terms/ |
x = parseFloat( x ); |
pc: http://purl.org/procurement/public-contracts# |
y = parseFloat( y ); |
cpv: http://purl.org/weso/pscs/cpv/2008/resource/ |
return x - y; |
unspsc: http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml# |
}; |
v: http://www.w3.org/2006/vcard/ns# |
|
payment: http://reference.data.gov.uk/def/payment# |
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
br: http://purl.org/business-register# |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
xsd: http://www.w3.org/2001/XMLSchema# |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
pcdt: http://purl.org/procurement/public-contracts-datatypes#"> |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
<head> |
|
<title><?php echo $title; ?> - Contract Dashboard</title> |
/* Remove the currency sign */ |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
x = x.substring( 1 ); |
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
y = y.substring( 1 ); |
<link rel="stylesheet" type="text/css" href="bootstrap-responsive.css"> |
|
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
/* Parse and return */ |
<!--[if lt IE 9]> |
x = parseFloat( x ); |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
y = parseFloat( y ); |
<![endif]--> |
return y - x; |
<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" /> |
$(document).ready(function() { |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
$('table').dataTable(); |
<script type="text/javascript"> |
} ); |
$(document).ready(function() |
</script> |
{ |
<link type="text/css" rel="stylesheet" href="style.css"> |
//hide the all of the element with class msg_body |
</head> |
$(".msg_body").hide(); |
<body> |
//toggle the componenet with class msg_body |
<div class="navbar"> |
$(".msg_head").click(function() |
<div class="navbar-inner"> |
{ |
<div class="container-fluid"> |
$(this).next(".msg_body").slideToggle(600); |
<a class="brand" href="#">contract dashboard</a> |
}); |
<ul class="nav"> |
}); |
<li><a href="displayAgency.php">agencies</a></li> |
</script> |
<li><a href="displaySupplier.php">suppliers</a></li> |
|
<li><a href="displayCategory.php">categories</a></li> |
<style type="text/css" title="currentStyle"> |
<li><a href="displayCalendar.php">time periods</a></li> |
@import "media/css/demo_table.css"; |
<!-- <li class="dropdown"> |
</style> |
<a href="#" class="dropdown-toggle">metrics</a> |
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script> |
<ul class="dropdown-menu">--> |
<script type="text/javascript" language="javascript" src="lib/bootstrap-dropdown.js"></script> |
<li><a href="displayProcurementMethod.php">tenderm</a></li> |
<script type="text/javascript" charset="utf-8"> |
<li><a href="displayConfidentialities.php">confidentiality</a></li> |
jQuery.fn.dataTableExt.aTypes.unshift( |
<li><a href="displayConsultancies.php">consultancies</a></li> |
function ( sData ) |
<li><a href="displayAmendments.php">amendments</a></li> |
{ |
<li><a href="displayMap.php">geo</a></li> |
var sValidChars = "0123456789.-,"; |
</ul> |
var Char; |
|
|
|
/* Check the numeric part */ |
<form method="post" action="search.php" class="pull-right"> |
for ( i=1 ; i<sData.length ; i++ ) |
<input type="text" id="searchKeyword" name="searchKeyword" value="" placeholder="Search" /> |
{ |
<input type="hidden" id="searchID" name="searchID" value=""/> |
Char = sData.charAt(i); |
</form> |
if (sValidChars.indexOf(Char) == -1) |
|
{ |
</div> |
return null; |
</div><!-- /topbar-inner --> |
} |
</div><!-- /topbar --> |
} |
</div><!-- /topbar-wrapper --> |
|
<script type="text/javascript"> |
/* Check prefixed by currency */ |
|
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
var options_xml = { |
{ |
script: function (input) { return "search_autosuggest.php?input="+input; }, |
return 'currency'; |
varname:"input", |
} |
callback: function (obj) { document.getElementById('searchID').value = obj.id; } |
return null; |
}; |
} |
var as_xml = new bsn.AutoSuggest('searchKeyword', options_xml); |
); |
</script> |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
<div class="container-fluid"> |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
<div class="row-fluid"> |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
<div class="span3"> |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
<div class="well sidebar-nav"> |
|
<li class="nav-header">Filter by:</li> |
/* Remove the currency sign */ |
<li>2008</li> |
x = x.substring( 1 ); |
</div> |
y = y.substring( 1 ); |
</div> |
|
<div class="span9"> |
/* Parse and return */ |
<?php |
x = parseFloat( x ); |
$start = (float) array_sum(explode(' ', microtime())); |
y = parseFloat( y ); |
} |
return x - y; |
|
}; |
function include_footer() { |
|
global $start; |
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
$end = (float) array_sum(explode(' ', microtime())); |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
|
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
echo '</div> <footer>' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . ' <footer>'; |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
|
|
if (strpos($_SERVER['SERVER_NAME'], ".gs")) { |
/* Remove the currency sign */ |
?> |
x = x.substring( 1 ); |
<script type="text/javascript"> |
y = y.substring( 1 ); |
|
|
var _gaq = _gaq || []; |
/* Parse and return */ |
_gaq.push(['_setAccount', 'UA-12341040-3']); |
x = parseFloat( x ); |
_gaq.push(['_trackPageview']); |
y = parseFloat( y ); |
|
return y - x; |
(function() { |
}; |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
$(document).ready(function() { |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
$('table').dataTable(); |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
} ); |
})(); |
</script> |