-
-
-
-
-
-
- Filter by:
-
-
- year
-
- 2008 -
-
--- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -7,208 +7,228 @@ $conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); if (!$conn) { - die("A database error occurred.\n"); -} - - // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -function databaseError($errMsg) -{ + die("A database error occurred.\n"); +} + +// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +function databaseError($errMsg) { if ($errMsg[2] != "") { - die(print_r($errMsg,true)); + echo '
"; } } function ucsmart($str) { - $shortWords = Array("The","Pty","Ltd","Inc","Red","Oil","A","An","And","At","For","In" - ,"Of","On","Or","The","To","With"); - $strArray = explode(" ",preg_replace("/(?<=(?$value) - $totale += array_sum_all($value); - return $totale; - } + $count1 = $num_amount / $num_total; + $count2 = $count1 * 100; + $count = number_format($count2, 2); + return $count; +} + +function array_sum_all($a) { + if (!is_array($a)) + return $a; + foreach ($a as $key => $value) + $totale += array_sum_all($value); + return $totale; +} + // magic query modifiers $agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); -if ($agency != "") $agencyQ = "agencyName = '" . $agency . "' AND "; +if ($agency != "") + $agencyQ = "agencyName = '" . $agency . "' AND "; $supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); if ($supplier != "") { - $supplierParts = explode("-", $supplier); - $supplierName = "%".$supplierParts[1]."%"; - $supplierABN = $supplierParts[0]; - if ($supplierParts[0] > 0) $supplierQ = ' "supplierABN" = :supplierABN AND '; - else $supplierQ = ' "supplierName" LIKE :supplierName AND '; + $supplierParts = explode("-", $supplier); + $supplierName = "%" . $supplierParts[1] . "%"; + $supplierABN = $supplierParts[0]; + if ($supplierParts[0] > 0) + $supplierQ = ' "supplierABN" = :supplierABN AND '; + else + $supplierQ = ' "supplierName" LIKE :supplierName AND '; } $startYear = 2007; $year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); -if ($year != "") $yearQ = "YEAR(publishDate) = " . $year . " AND "; +if ($year != "") + $yearQ = "YEAR(publishDate) = " . $year . " AND "; $standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; -$start =0.0; +$start = 0.0; function include_header($title) { global $start; -?> - - - -'."Processing time: ". sprintf("%.4f", ($end-$start))." seconds".'