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