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