From: maxious Date: Wed, 24 Nov 2010 08:28:02 +0000 Subject: Prettier JQuery tables X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=2168524e9590a454062a4c432b1145dabc8002cb --- Prettier JQuery tables --- --- a/admin/google-example.htm +++ b/admin/google-example.htm --- a/admin/import.bat +++ b/admin/import.bat --- a/admin/import.php +++ b/admin/import.php @@ -1,120 +1,113 @@ "; -$dhandle = opendir($path); -// define an array to hold the files -$files = array(); - -if ($dhandle) { - // loop through all of the files - while (false !== ($fname = readdir($dhandle))) { - if (($fname != '.') && ($fname != '..')) { - echo "$fname".filesize($path.$fname)."
"; - } - } -} - -} else { -$success =0; -$fname = $_REQUEST["fname"]; -echo " ============== $fname ==============
"; -$row = 1; -$handle = fopen($path.$fname, "r"); -//"t" mode string translates windows line breaks to unix -$datamapping0709 = Array("Agency" => "agencyName", "Parent CN ID" => "parentCN", "CN ID" => "CNID", "Publish Date" => "publishDate", "Amendment Date" => "amendDate", "Status" => "", "StartDate" => "contractStart" , "EndDate" => "contractEnd", "Value" => "value", "Description" => "description", "Agency Ref Id" => "agencyID", "Category" => "category", "Procurement Method" => "procurementMethod", "ATM ID" => "atmID", "SON ID" => "SONID","Confidentiality - Contract" => "confidentialityContract", "Confidentiality - Contract Reason(s)" => "confidentialityContractReason", "Confidentiality - Outputs" => "confidentialityOutputs", "Confidentiality - Outputs Reason(s)" => "confidentialityOutputsReason", "Consultancy" => "consultancy", "Consultancy Reason(s)" => "consultancyReason", "Amendment Reason" => "amendmentReason", "Supplier Name" => "supplierName", "Supplier Address" => "supplierAddress", "Supplier City" => "supplierCity", "Supplier Postcode" => "supplierPostcode", "Supplier Country" => "supplierCountry" , "Supplier ABNExempt" => "supplierABNExempt", "Supplier ABN" => "supplierABN" , "Agency Branch" => "contactBranch","Agency Divison" => "contactDivision", "Agency Postcode" => "contactPostcode" , "" => ""); -$headers; -$contractNoticeFields = Array("agencyName", "parentCN", "CNID", "publishDate", "amendDate", "contractStart" , "contractEnd", "value", "description", "agencyID", "category", "procurementMethod", "atmID", "SONID", "confidentialityContract", "confidentialityContractReason", "confidentialityOutputs", "confidentialityOutputsReason", "consultancy", "consultancyReason", "amendmentReason", "supplierName", "supplierAddress", "supplierCity", "supplierPostcode", "supplierCountry" , "supplierABNExempt", "supplierABN", "contactBranch","contactDivision","contactPostcode" ); -$agencyFields = Array("agencyName"); -$supplierFields = Array("supplierName", "supplierAddress", "supplierCity", "supplierPostcode", "supplierCountry" , "supplierABNExempt", "supplierABN" ); - -while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) { - $num = count($data); - - if ($row == 3) - { - $headers = $data; - } - else if ($row > 3) - { - if ($num > count($datamapping0709)) - { - die ("Error in data import; data mapping fields out of bounds or changed
".$fname.print_r($data)); - } - $firstCN= false; - $firstSupplier= true; - $firstAgency= true; - $contractNoticeInsert = "INSERT INTO contractnotice (importFile, ".implode(" , ",$contractNoticeFields). ") VALUES ( \"$fname\" "; - $supplierInsert = "INSERT INTO supplierdetails (".implode(" , ",$supplierFields). ") VALUES ("; - $agencyInsert = "INSERT INTO agency (".implode(" , ",$agencyFields). ") VALUES ("; - - $keys = array_keys($datamapping0709); - for ($c=0; $c < $num; $c++) { - $data[$c] = trim($data[$c],"="); - $data[$c] = trim($data[$c], "\""); - - if (in_array(($datamapping0709[$headers[$c]]),$contractNoticeFields)) - { - if (($datamapping0709[$headers[$c]]) == "parentCN" || ($datamapping0709[$headers[$c]]) == "CNID") - { - $data[$c] = substr($data[$c],2); - if ($data[$c] >0) - { - $contractNoticeInsert .= ($firstCN ? "" : ","). mysql_real_escape_string($data[$c]); - } else - { - $contractNoticeInsert .= ($firstCN ? "" : ",")."''"; - } - } else if (($datamapping0709[$headers[$c]]) == "amendDate" || ($datamapping0709[$headers[$c]]) == "publishDate" || ($datamapping0709[$headers[$c]]) == "contractStart" || ($datamapping0709[$headers[$c]]) == "contractEnd") - { - $contractNoticeInsert .= ($firstCN ? "" : ","). "'".date( 'Y-m-d H:i:s', strtotime($data[$c])). "'"; - } else - { - if (strstr("\" =",$data[$c] > 0)) - { - die ("Invalid Description field" . $contractNoticeInsert); - } - $contractNoticeInsert .= ($firstCN ? "" : ",") . "'". mysql_real_escape_string($data[$c])."'"; - - } - $firstCN = false; - } - if (in_array(($datamapping0709[$headers[$c]]),$supplierFields)) - { - $supplierInsert .= ($firstSupplier ? "" : ",") . "'". mysql_real_escape_string($data[$c])."'"; - $firstSupplier = false; - } - if (in_array(($datamapping0709[$headers[$c]]),$agencyFields)) - { - $agencyInsert .= ($firstAgency ? "" : ",") . "'". mysql_real_escape_string($data[$c])."'"; - $firstAgency = false; - } - - } - $contractNoticeInsert .= ");"; - $supplierInsert .= ");"; - $agencyInsert .= ");"; - -$result = mysql_query($contractNoticeInsert); -if ($result) $success++; -else if (strpos(mysql_error(),"Duplicate entry") === false) echo $data[2] . " failed CN insert.
". mysql_error() ."
$contractNoticeInsert

\n"; - - $result = mysql_query($agencyInsert); -if ($result) $success++; -else if (strpos(mysql_error(),"Duplicate entry") === false) echo $data[2] . " failed agency insert.
". mysql_error() ."
$agencyInsert

\n"; - - $result = mysql_query($supplierInsert); -if ($result) $success++; -else if (strpos(mysql_error(),"Duplicate entry") === false) echo $data[2] . " failed supplier insert.
". mysql_error() ."
$supplierInsert

\n"; - -//echo "
\n"; - } - - $row++; -} -echo "
$success records successfully created"; -fclose($handle); -} + include_once("../lib/common.inc.php"); + $path = 'data/'; + if ($_REQUEST["fname"] == "") { + echo "Get files from: https://www.tenders.gov.au/?event=public.reports.list
"; + $dhandle = opendir($path); + // define an array to hold the files + $files = array(); + + if ($dhandle) { + // loop through all of the files + while (false !== ($fname = readdir($dhandle))) { + if (($fname != '.') && ($fname != '..')) { + echo "$fname" . filesize($path . $fname) . "
"; + } + } + } + } else { + $success = 0; + $fname = $_REQUEST["fname"]; + echo " ============== $fname ==============
"; + flush(); + $row = 1; + $handle = fopen($path . $fname, "r"); + //"t" mode string translates windows line breaks to unix + $datamapping0709 = array("Agency" => "agencyName", "Parent CN ID" => "parentCN", "CN ID" => "CNID", "Publish Date" => "publishDate", "Amendment Date" => "amendDate", "Status" => "", "StartDate" => "contractStart", "EndDate" => "contractEnd", "Value" => "value", "Description" => "description", "Agency Ref Id" => "agencyID", "Category" => "category", "Procurement Method" => "procurementMethod", "ATM ID" => "atmID", "SON ID" => "SONID", "Confidentiality - Contract" => "confidentialityContract", "Confidentiality - Contract Reason(s)" => "confidentialityContractReason", "Confidentiality - Outputs" => "confidentialityOutputs", "Confidentiality - Outputs Reason(s)" => "confidentialityOutputsReason", "Consultancy" => "consultancy", "Consultancy Reason(s)" => "consultancyReason", "Amendment Reason" => "amendmentReason", "Supplier Name" => "supplierName", "Supplier Address" => "supplierAddress", "Supplier City" => "supplierCity", "Supplier Postcode" => "supplierPostcode", "Supplier Country" => "supplierCountry", "Supplier ABNExempt" => "supplierABNExempt", "Supplier ABN" => "supplierABN", "Agency Branch" => "contactBranch", "Agency Divison" => "contactDivision", "Agency Postcode" => "contactPostcode", "" => ""); + $headers; + $contractNoticeFields = array("agencyName", "parentCN", "CNID", "publishDate", "amendDate", "contractStart", "contractEnd", "value", "description", "agencyID", "category", "procurementMethod", "atmID", "SONID", "confidentialityContract", "confidentialityContractReason", "confidentialityOutputs", "confidentialityOutputsReason", "consultancy", "consultancyReason", "amendmentReason", "supplierName", "supplierAddress", "supplierCity", "supplierPostcode", "supplierCountry", "supplierABNExempt", "supplierABN", "contactBranch", "contactDivision", "contactPostcode"); + $agencyFields = array("agencyName"); + $supplierFields = array("supplierName", "supplierAddress", "supplierCity", "supplierPostcode", "supplierCountry", "supplierABNExempt", "supplierABN"); + + while (($data = fgetcsv($handle, 1000, "\t")) !== false) { + $num = count($data); + + if ($row == 3) { + $headers = $data; + } elseif ($row > 3) { + if ($num > count($datamapping0709)) { + die("Error in data import; data mapping fields out of bounds or changed
" . $fname . print_r($data)); + } + $firstCN = false; + $firstSupplier = true; + $firstAgency = true; + $contractNoticeInsert = "INSERT INTO contractnotice (importFile, " . implode(" , ", $contractNoticeFields) . ") VALUES ( \"$fname\" "; + $supplierInsert = "INSERT INTO supplierdetails (" . implode(" , ", $supplierFields) . ") VALUES ("; + $agencyInsert = "INSERT INTO agency (" . implode(" , ", $agencyFields) . ") VALUES ("; + + $keys = array_keys($datamapping0709); + for ($c = 0; $c < $num; $c++) { + $data[$c] = trim($data[$c], "="); + $data[$c] = trim($data[$c], "\""); + + if (in_array(($datamapping0709[$headers[$c]]), $contractNoticeFields)) { + if (($datamapping0709[$headers[$c]]) == "parentCN" || ($datamapping0709[$headers[$c]]) == "CNID") { + $data[$c] = substr($data[$c], 2); + if ($data[$c] > 0) { + $contractNoticeInsert .= ($firstCN ? "" : ",") . mysql_real_escape_string($data[$c]); + } else { + $contractNoticeInsert .= ($firstCN ? "" : ",") . "''"; + } + } elseif (($datamapping0709[$headers[$c]]) == "amendDate" || ($datamapping0709[$headers[$c]]) == "publishDate" || ($datamapping0709[$headers[$c]]) == "contractStart" || ($datamapping0709[$headers[$c]]) == "contractEnd") { + $contractNoticeInsert .= ($firstCN ? "" : ",") . "'" . date('Y-m-d H:i:s', strtotime($data[$c])) . "'"; + } else { + if (strstr("\" =", $data[$c] > 0)) { + die("Invalid Description field" . $contractNoticeInsert); + } + $contractNoticeInsert .= ($firstCN ? "" : ",") . "'" . mysql_real_escape_string($data[$c]) . "'"; + } + $firstCN = false; + } + if (in_array(($datamapping0709[$headers[$c]]), $supplierFields)) { + $supplierInsert .= ($firstSupplier ? "" : ",") . "'" . mysql_real_escape_string($data[$c]) . "'"; + $firstSupplier = false; + } + if (in_array(($datamapping0709[$headers[$c]]), $agencyFields)) { + $agencyInsert .= ($firstAgency ? "" : ",") . "'" . mysql_real_escape_string($data[$c]) . "'"; + $firstAgency = false; + } + } + flush(); + $contractNoticeInsert .= ");"; + $supplierInsert .= ");"; + $agencyInsert .= ");"; + + $result = mysql_query($contractNoticeInsert); + if ($result) + $success++; + elseif (strpos(mysql_error(), "Duplicate entry") === false) + echo $data[2] . " failed CN insert.
" . mysql_error() . "
$contractNoticeInsert

\n"; + + $result = mysql_query($agencyInsert); + if ($result) + $success++; + elseif (strpos(mysql_error(), "Duplicate entry") === false) + echo $data[2] . " failed agency insert.
" . mysql_error() . "
$agencyInsert

\n"; + + $result = mysql_query($supplierInsert); + if ($result) + $success++; + elseif (strpos(mysql_error(), "Duplicate entry") === false) + echo $data[2] . " failed supplier insert.
" . mysql_error() . "
$supplierInsert

\n"; + flush(); + + //echo "
\n"; + } + + $row++; + } + echo "
$success records successfully created"; + flush(); + fclose($handle); + } ?> - --- a/admin/recordsperweek.txt +++ b/admin/recordsperweek.txt --- a/admin/setAgencyStatus.php +++ b/admin/setAgencyStatus.php @@ -1,16 +1,24 @@ \n"; else echo "error".mysql_error(); } foreach ($suspended as $agency) { + $agencyParts = explode("|",$agency); + $agency = $agencyParts[1]; + $agencyInsert = "INSERT INTO agency (agencyName) VALUES ('$agency')"; + $result = mysql_query($agencyInsert); $result = mysql_query("UPDATE agency SET status = 'suspended' where agencyName = '".mysql_real_escape_string($agency)."';") ; if ($result) echo $agency. " set to suspended in ". mysql_affected_rows() . " divisions/branches
\n"; else echo "error".mysql_error(); --- a/admin/setAgencyURLABN.php +++ b/admin/setAgencyURLABN.php @@ -26,9 +26,10 @@ $result = mysql_query("UPDATE agency SET website = 'http://" . $result->visibleUrl . "', abn = '{$abn[0]}' WHERE agencyName = '$agency';"); if ($result) echo $agency . " set in " . mysql_affected_rows() . "
\n"; } else { + echo "invalid ABN"; $result = mysql_query("UPDATE agency SET website = 'http://" . $result->visibleUrl . "' WHERE agencyName = '$agency';"); - if ($result) echo $agency . " set in " . mysql_affected_rows() . "
\n"; + if ($result) echo $agency . " set in " . mysql_affected_rows() . "
\n"; } // fi --- a/autosuggest_inquisitor.css +++ b/autosuggest_inquisitor.css --- a/contractDashboard.kpf +++ b/contractDashboard.kpf --- a/cutenews/LICENSE.txt +++ b/cutenews/LICENSE.txt --- a/cutenews/README.htm +++ b/cutenews/README.htm --- a/cutenews/data/.htaccess +++ b/cutenews/data/.htaccess --- a/cutenews/data/Default.tpl +++ b/cutenews/data/Default.tpl --- a/cutenews/data/Headlines.tpl +++ b/cutenews/data/Headlines.tpl --- a/cutenews/data/archives/index.htm +++ b/cutenews/data/archives/index.htm --- a/cutenews/data/backup/index.html +++ b/cutenews/data/backup/index.html --- a/cutenews/data/comments.txt +++ b/cutenews/data/comments.txt --- a/cutenews/data/emoticons/.htaccess +++ b/cutenews/data/emoticons/.htaccess --- a/cutenews/data/emoticons/index.html +++ b/cutenews/data/emoticons/index.html --- a/cutenews/data/index.html +++ b/cutenews/data/index.html --- a/cutenews/data/news.txt +++ b/cutenews/data/news.txt --- a/cutenews/data/postponed_news.txt +++ b/cutenews/data/postponed_news.txt --- a/cutenews/data/rss.tpl +++ b/cutenews/data/rss.tpl --- a/cutenews/data/unapproved_news.txt +++ b/cutenews/data/unapproved_news.txt --- a/cutenews/data/upimages/.htaccess +++ b/cutenews/data/upimages/.htaccess --- a/cutenews/data/upimages/index.html +++ b/cutenews/data/upimages/index.html --- a/cutenews/inc/.htaccess +++ b/cutenews/inc/.htaccess --- a/cutenews/inc/about.mdu +++ b/cutenews/inc/about.mdu --- a/cutenews/inc/addnews.mdu +++ b/cutenews/inc/addnews.mdu --- a/cutenews/inc/categories.mdu +++ b/cutenews/inc/categories.mdu --- a/cutenews/inc/debug.mdu +++ b/cutenews/inc/debug.mdu --- a/cutenews/inc/editcomments.mdu +++ b/cutenews/inc/editcomments.mdu --- a/cutenews/inc/editnews.mdu +++ b/cutenews/inc/editnews.mdu --- a/cutenews/inc/editusers.mdu +++ b/cutenews/inc/editusers.mdu --- a/cutenews/inc/help.mdu +++ b/cutenews/inc/help.mdu --- a/cutenews/inc/images.mdu +++ b/cutenews/inc/images.mdu --- a/cutenews/inc/ipban.mdu +++ b/cutenews/inc/ipban.mdu --- a/cutenews/inc/main.mdu +++ b/cutenews/inc/main.mdu --- a/cutenews/inc/massactions.mdu +++ b/cutenews/inc/massactions.mdu --- a/cutenews/inc/options.mdu +++ b/cutenews/inc/options.mdu --- a/cutenews/inc/preview.mdu +++ b/cutenews/inc/preview.mdu --- a/cutenews/inc/tools.mdu +++ b/cutenews/inc/tools.mdu --- a/cutenews/inc/wizards.mdu +++ b/cutenews/inc/wizards.mdu --- a/cutenews/remember.js +++ b/cutenews/remember.js --- a/cutenews/rte/blank.htm +++ b/cutenews/rte/blank.htm --- a/cutenews/rte/insert_link.htm +++ b/cutenews/rte/insert_link.htm --- a/cutenews/rte/insert_table.htm +++ b/cutenews/rte/insert_table.htm --- a/cutenews/rte/palette.htm +++ b/cutenews/rte/palette.htm --- a/cutenews/rte/richtext.js +++ b/cutenews/rte/richtext.js --- a/cutenews/rte/rte.css +++ b/cutenews/rte/rte.css --- a/cutenews/skins/cute.js +++ b/cutenews/skins/cute.js --- a/cutenews/skins/rss_style.css +++ b/cutenews/skins/rss_style.css --- a/displayAgency.php +++ b/displayAgency.php @@ -23,6 +23,37 @@ Breakdown percentage,number,value by procurement type Histograph, overlaying number value reported per week over X years Compliance statistics: amendments, delay in reporting average and number completely late*/ + + $query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName + FROM `contractnotice` + WHERE agencyName = '".mysql_real_escape_string($agency)."' + ORDER BY value DESC"; + echo $query; + $result = mysql_query($query); + + echo " + + + + + + + + + "; + while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']) , 2); + echo (" + + + + + + "); + } + echo "
Contract Notice NumberContract DescriptionTotal Contract ValueAgencyContract Start DateSupplier
{$row['CNID']}{$row['description']}\$$value{$row['agencyName']}{$row['contractStart']}{$row['supplierName']}
"; + mysql_free_result($result); } else { /* split by portfolio @@ -33,7 +64,12 @@ WHERE childCN = 0 GROUP BY agencyName "; $result = mysql_query($query); - echo ""; + echo "
+ + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row[0]) , 2); --- a/displayAmendments.php +++ b/displayAmendments.php @@ -1,9 +1,18 @@ 0) a where CNID = ccn order by diff DESC"; +$query = "select CNID, description, value, pvalue, (value - pvalue) as diff from contractnotice, (SELECT CNID as cn, childCN as ccn, value as pvalue FROM contractnotice where childCN > 0) a". +" where ".$agencyQ.$yearQ."CNID = ccn AND (value - pvalue) <> 0 order by diff DESC"; $result = mysql_query($query); -echo "
AgencyTotal Contracts Value
"; + echo "
+ + + + + + + "; +if ($result) { while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value']) , 2); @@ -13,6 +22,9 @@ echo ""; echo ""; } +} else { +echo mysql_error(); +} echo "
ContractOriginal ValueAmended ValueDifference
{$row['description']}\$$pvalue\$$value\$$diff
"; mysql_free_result($result); include_footer(); --- a/displayCalendar.php +++ b/displayCalendar.php @@ -3,15 +3,29 @@ include_header("Months and Years"); -if ($_REQUEST['category']) { - echo "

".$_REQUEST['category']."

"; +if ($_REQUEST['month']) { + echo "

".$_REQUEST['month']."

"; +$monthParts = explode("-",$_REQUEST['month']); $query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName FROM `contractnotice` WHERE childCN = 0 - AND category = '" . $_REQUEST['category'] . "' + AND YEAR(contractStart) = {$monthParts[1]} + AND MONTH(contractStart) = {$monthParts[0]} ORDER BY value DESC"; $result = mysql_query($query); - echo ""; +echo ''; + echo ''; + + echo "
+ + + + + + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value']) , 2); @@ -30,22 +44,34 @@ split by year todo: Year/Month drilldown - largest contracts, agencies, suppliers +count per month big picture graphs?*/ +echo ''; +echo ''; + + $query = "SELECT YEAR(contractStart), MONTH(contractStart), -value FROM `contractnotice` WHERE childCN = 0 GROUP BY MONTH(contractStart), YEAR(contractStart) ORDER BY YEAR(contractStart), MONTH(contractStart) "; +SUM(value) as val, count(1) as count FROM `contractnotice` WHERE childCN = 0 GROUP BY MONTH(contractStart), YEAR(contractStart) ORDER BY YEAR(contractStart), MONTH(contractStart) "; $result = mysql_query($query); -echo "
Contract Notice NumberContract DescriptionTotal Contract ValueAgencyContract Start DateSupplier
"; + echo "
+ + + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); -$value = number_format(doubleval($row["value"]),2); +$value = number_format(doubleval($row["val"]),2); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); - echo (""); + echo (""); } echo "
Month/YearTotal Contracts ValueNumber of Contracts
$month_name {$row[0]}\$$value
$month_name {$row[0]}\$$value({$row['count']} contracts)
"; mysql_free_result($result); } include_footer(); -?> +?> + --- a/displayCategory.php +++ b/displayCategory.php @@ -9,7 +9,16 @@ AND category = '" . $_REQUEST['category'] . "' ORDER BY value DESC"; $result = mysql_query($query); - echo ""; + echo "
+ + + + + + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['value']) , 2); @@ -33,7 +42,12 @@ WHERE childCN = 0 GROUP BY category ORDER BY sum(value) DESC "; $result = mysql_query($query); -echo "
Contract Notice NumberContract DescriptionTotal Contract ValueAgencyContract Start DateSupplier
"; + echo "
+ + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row[0]) , 2); --- a/displayProcurementMethod.php +++ b/displayProcurementMethod.php @@ -10,8 +10,9 @@ */ include_header("Procurement Methods"); -$query = "SELECT value, procurementMethod +$query = "SELECT SUM(value) as value, procurementMethod FROM `contractnotice` +WHERE childCN = 0 GROUP BY procurementMethod "; $result = mysql_query($query); --- a/displaySupplier.php +++ b/displaySupplier.php @@ -3,10 +3,10 @@ if ($_REQUEST['supplier']) { include_header("Supplier"); - $supplier = htmlentities(strip_tags($_REQUEST['supplier'])); - echo ''; - echo ''; - echo ''; + $supplierS = htmlentities(strip_tags($_REQUEST['supplier'])); + echo ''; + echo ''; + echo ''; /*lobbyist ties links to ABR/ASIC/Google News/ASX/Court records @@ -18,6 +18,38 @@ spread of contract values spread of industries (textual?)*/ + $query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName + FROM `contractnotice` WHERE + $supplierQ $standardQ + ORDER BY value DESC"; + echo $query; + $result = mysql_query($query); +echo ''; + echo ''; + + echo "
CategoryTotal Contracts Value
+ + + + + + + + + "; + while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { + setlocale(LC_MONETARY, 'en_US'); + $value = number_format(doubleval($row['value']) , 2); + echo (" + + + + + + "); + } + echo "
Contract Notice NumberContract DescriptionTotal Contract ValueAgencyContract Start DateSupplier
{$row['CNID']}{$row['description']}\$$value{$row['agencyName']}{$row['contractStart']}{$row['supplierName']}
"; + mysql_free_result($result); } else { /* histograph of supplier size/value @@ -30,7 +62,12 @@ ORDER BY val DESC LIMIT 100"; $result = mysql_query($query); - echo ""; + echo "
+ + + + + "; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); $value = number_format(doubleval($row['val']) , 2); --- a/graphs/displayAgenciesGraph.php +++ b/graphs/displayAgenciesGraph.php @@ -1,7 +1,6 @@ = $startYear) AND childCN = 0 GROUP BY agencyName ORDER BY val DESC limit $topX"; $result = mysql_query($query); --- a/graphs/displayAgencySuppliersGraph.php +++ b/graphs/displayAgencySuppliersGraph.php @@ -2,7 +2,6 @@ include_once ("../lib/common.inc.php"); $agency = "AusAid"; $topX = 15; -$startYear = 2007; $query = "SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 AND agencyName = '$agency' GROUP BY lower(supplierName) ORDER BY val DESC limit $topX"; $result = mysql_query($query); --- a/graphs/displayCnCGraph.php +++ b/graphs/displayCnCGraph.php @@ -3,8 +3,8 @@ // Width and height of the graph $width = 800; $height = 300; -$query = "select procurementMethod, count(1) as count, value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` -where $agencyQ $supplierQ childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2009 group by procurementMethod,year,month order by procurementMethod,year,month"; +$query = "select procurementMethod, count(1) as count, SUM(value) as val, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` +where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month"; $result = mysql_query($query); $methods = Array("Direct","Open","Select"); $dates = Array(); @@ -13,7 +13,7 @@ $maxValue = 0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { setlocale(LC_MONETARY, 'en_US'); - if ($row['value'] > $maxValue) $maxValue = $row['value']; + if ($row['val'] > $maxValue) $maxValue = $row['val']; $date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"]; if (array_search($date,$dates) === false ) { $dates[$row["year"]*100 + $row["month"]] = $date; @@ -57,7 +57,7 @@ $graph2->Set90AndMargin(105, 45, 45, 45); // Setup a title for the graph $graph2->title->Set($agency); -$graph2->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph2->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph2->title->SetFont(FF_USERFONT, FS_NORMAL, 12); // Setup font for axis $graph2->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10); --- a/graphs/displayContractPublishedGraph.php +++ b/graphs/displayContractPublishedGraph.php @@ -1,7 +1,7 @@ = 2008) AND childCN = 0 GROUP BY MONTH(publishDate), YEAR(publishDate) @@ -12,11 +12,11 @@ $values = Array(); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); -$value = number_format(doubleval($row["value"]),2); +$value = number_format(doubleval($row["val"]),2); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); $dates[] = $month_name." {$row[0]}"; $counts[] = doubleval($row["count"]); - $values[] = doubleval($row["value"]); + $values[] = doubleval($row["val"]); } mysql_free_result($result); @@ -31,8 +31,8 @@ $graph->SetScale('textlog'); // Setup a title for the graph -$graph->title->Set('Contracts Starting - All Agencies since July 2008'); -$graph->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph->title->Set('Contracts Published - All Agencies since July 2008'); +$graph->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph->title->SetFont(FF_USERFONT,FS_NORMAL,12); // Setup font for axis --- a/graphs/displayContractStartingGraph.php +++ b/graphs/displayContractStartingGraph.php @@ -1,7 +1,7 @@ = 2008) AND childCN = 0 GROUP BY MONTH(contractStart), YEAR(contractStart) @@ -12,11 +12,11 @@ $values = Array(); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { setlocale(LC_MONETARY, 'en_US'); -$value = number_format(doubleval($row["value"]),2); +$value = number_format(doubleval($row["val"]),2); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); $dates[] = $month_name." {$row[0]}"; $counts[] = doubleval($row["count"]); - $values[] = doubleval($row["value"]); + $values[] = doubleval($row["val"]); } mysql_free_result($result); @@ -32,7 +32,7 @@ // Setup a title for the graph $graph->title->Set('Contracts Starting - All Agencies since July 2008'); -$graph->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph->title->SetFont(FF_USERFONT,FS_NORMAL,12); // Setup font for axis --- a/graphs/displayMethodCountGraph.php +++ b/graphs/displayMethodCountGraph.php @@ -3,8 +3,8 @@ // Width and height of the graph $width = 800; $height = 300; -$query = "select procurementMethod, count(1) as count, value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` -where $agencyQ $supplierQ childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2009 group by procurementMethod,year,month order by procurementMethod,year,month"; +$query = "select procurementMethod, count(1) as count, SUM(value) as value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` +where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month"; $result = mysql_query($query); $methods = Array("Direct","Open","Select"); $dates = Array(); @@ -37,7 +37,7 @@ $graph->SetMargin(95, 145, 45, 100); // Setup a title for the graph $graph->title->Set($agencyQ.$supplierQ); -$graph->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph->title->SetFont(FF_USERFONT, FS_NORMAL, 12); // Setup font for axis $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10); @@ -80,7 +80,7 @@ $graph2->Set90AndMargin(105, 45, 45, 45); // Setup a title for the graph $graph2->title->Set($agency); -$graph2->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph2->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph2->title->SetFont(FF_USERFONT, FS_NORMAL, 12); // Setup font for axis $graph2->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10); --- a/graphs/displayMethodValueGraph.php +++ b/graphs/displayMethodValueGraph.php @@ -3,8 +3,8 @@ // Width and height of the graph $width = 800; $height = 300; -$query = "select procurementMethod, value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` -where $agencyQ $supplierQ childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2009 group by procurementMethod,year,month order by procurementMethod,year,month"; +$query = "select procurementMethod, SUM(value) as value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` +where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month"; $result = mysql_query($query); $methods = Array("Direct","Open","Select"); $dates = Array(); @@ -37,7 +37,7 @@ $graph->SetMargin(95, 145, 45, 100); // Setup a title for the graph $graph->title->Set($agencyQ.$supplierQ); -$graph->SetUserFont("ttf-liberation/LiberationSans-Regular.ttf"); +$graph->SetUserFont("liberation/LiberationSans-Regular.ttf"); $graph->title->SetFont(FF_USERFONT, FS_NORMAL, 12); // Setup font for axis $graph->xaxis->SetFont(FF_USERFONT, FS_NORMAL, 10); --- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -1,4 +1,6 @@ 0) $supplierQ = "supplierABN = '" . $supplierParts[0] . "' AND"; - else $supplierQ = "supplierName LIKE '%" . $supplierParts[1] . "%' AND"; + if ($supplierParts[0] > 0) $supplierQ = "supplierABN = '" . $supplierParts[0] . "' AND "; + else $supplierQ = "supplierName LIKE '%" . $supplierParts[1] . "%' AND "; } +$startYear = 2007; $year = mysql_real_escape_string(stripslashes($_REQUEST['year'])); -if ($year != "") $yearQ = "agencyName = '" . $agency . "' AND"; - +if ($year != "") $yearQ = "YEAR(publishDate) = " . $year . " AND "; +$standardQ = "childCN = 0 AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010"; $start =0.0; function include_header($title) { @@ -55,9 +60,8 @@ Contract Dashboard - <?=$title?> - + - + + + + +
@@ -86,7 +101,7 @@ procurement method contractual confidentiality consultancies - consultancies + amendments postcodes
SupplierTotal Contract Value