--- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -67,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("/(?<=(?"; + 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 "%
"; @@ -136,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; @@ -184,7 +212,7 @@ pcdt: http://purl.org/procurement/public-contracts-datatypes#"> <?php echo $title; ?> - Contract Dashboard - + @@ -335,10 +363,15 @@ } function include_footer() { - global $start; + global $start, $conn; $end = (float) array_sum(explode(' ', microtime())); - echo '