Integrate supplier piechart
Integrate supplier piechart

<?php <?php
include_once ("../lib/common.inc.php"); include_once ("../lib/common.inc.php");
$query = 'SELECT c."CNID",c."parentCN",c."amendmentReason",p."childCN" FROM contractnotice as c LEFT OUTER JOIN contractnotice as p on c."parentCN" = p."CNID" $query = 'SELECT c."CNID",c."parentCN",c."amendmentReason",p."childCN" FROM contractnotice as c LEFT OUTER JOIN contractnotice as p on c."parentCN" = p."CNID"
WHERE WHERE
c."parentCN" > 0 AND p."childCN" IS NULL '; c."parentCN" > 0 AND p."childCN" IS NULL ';
$query = $conn->prepare($query); $query = $conn->prepare($query);
$query->execute(); $query->execute();
if (!$query) { if (!$query) {
databaseError($conn->errorInfo()); databaseError($conn->errorInfo());
} }
foreach ($query->fetchAll() as $row) { foreach ($query->fetchAll() as $row) {
$conn->exec('UPDATE contractnotice SET "childCN" = \'' . $conn->exec('UPDATE contractnotice SET "childCN" = \'' .
$row['CNID'] . '\', "amendmentReason" = \'' . $row['CNID'] . '\', "amendmentReason" = \'' .
$row['amendmentReason'] . '\' where "CNID" = \'' . $row['amendmentReason'] . '\' where "CNID" = \'' .
$row['parentCN'] . '\';'); $row['parentCN'] . '\';');
echo 'UPDATE contractnotice SET "childCN" = \'' . echo 'UPDATE contractnotice SET "childCN" = \'' .
$row['CNID'] . '\', "amendmentReason" = \'' . $row['CNID'] . '\', "amendmentReason" = \'' .
$row['amendmentReason'] . '\' where "CNID" = \'' . $row['amendmentReason'] . '\' where "CNID" = \'' .
$row['parentCN'] . '\';'; $row['parentCN'] . '\';';
$errors = $conn->errorInfo(); $errors = $conn->errorInfo();
if ($errors[1] == 7 || $errors[1] ==0) if ($errors[1] == 7 || $errors[1] ==0)
echo $row['CNID'] . " linked to parent " . $row['parentCN'] . echo $row['CNID'] . " linked to parent " . $row['parentCN'] .
"<br>\n"; "<br>\n";
else print_r($errors); else print_r($errors);
   
} }
  // also need to eliminate CN 100528/100529 - check for double parent CNs with no childCN, latest sequent CN id wins childCN = 0
?> ?>
<?php <?php
include_once("./lib/common.inc.php"); include_once("./lib/common.inc.php");
include_header("Months and Years"); include_header("Months and Years");
if ($_REQUEST['month']) { if ($_REQUEST['month']) {
echo "<center><h1>".$_REQUEST['month']."</h1></center>"; echo "<center><h1>".$_REQUEST['month']."</h1></center>";
$monthParts = explode("-",$_REQUEST['month']); $monthParts = explode("-",$_REQUEST['month']);
$query = "SELECT CNID, description, value, agencyName, category, contractStart, supplierName $query = 'SELECT "CNID", "description", "value", "agencyName", "category", "contractStart", "supplierName"
FROM `contractnotice` FROM contractnotice
WHERE childCN = 0 WHERE "childCN" = 0
AND YEAR(contractStart) = {$monthParts[1]} AND extract(year from "contractStart") = :year
AND MONTH(contractStart) = {$monthParts[0]} AND extract(month from "contractStart") = :month
ORDER BY value DESC"; ORDER BY value DESC';
$result = mysql_query($query); $query = $conn->prepare($query);
echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">'; $query->bindParam(":month", $monthParts[0]);
echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">';  
  $query->bindParam(":year", $monthParts[1]);
  $query->execute();
  if (!$query) {
  databaseError($conn->errorInfo());
  }
   
  MethodCountGraph($supplier);
  CnCGraph($supplier);
echo "<table> <thead> echo "<table> <thead>
<tr> <tr>
<th>Contract Notice Number</th> <th>Contract Notice Number</th>
<th>Contract Description</th> <th>Contract Description</th>
<th>Total Contract Value</th> <th>Total Contract Value</th>
<th>Agency</th> <th>Agency</th>
<th>Contract Start Date</th> <th>Contract Start Date</th>
<th>Supplier</th> <th>Supplier</th>
</tr> </tr>
</thead>"; </thead>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { foreach ($query->fetchAll() as $row) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row['value']) , 2); $value = number_format(doubleval($row['value']) , 2);
echo ("<tr> echo ("<tr>
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td>
<td><b>{$row['description']}</b></a></td> <td><b>{$row['description']}</b></a></td>
<td>\$$value</td><td>{$row['agencyName']}</td> <td>\$$value</td><td>{$row['agencyName']}</td>
<td>{$row['contractStart']}</td> <td>{$row['contractStart']}</td>
<td>{$row['supplierName']}</td> <td>{$row['supplierName']}</td>
</tr>"); </tr>");
} }
echo "</table>"; echo "</table>";
mysql_free_result($result); mysql_free_result($result);
} else { } else {
/* /*
split by year split by year
todo: todo:
Year/Month drilldown - largest contracts, agencies, suppliers Year/Month drilldown - largest contracts, agencies, suppliers
count per month count per month
big picture graphs?*/ big picture graphs?*/
echo '<img src="graphs/displayContractStartingGraph.php">'; echo '<img src="graphs/displayContractStartingGraph.php">';
echo '<img src="graphs/displayContractPublishedGraph.php">'; echo '<img src="graphs/displayContractPublishedGraph.php">';
$query = "SELECT YEAR(contractStart), MONTH(contractStart), $query = 'SELECT extract(year from "contractStart"), extract(month from "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) "; SUM(value) as val, count(1) as count FROM contractnotice WHERE "childCN" = 0 GROUP BY extract(year from "contractStart"), extract(month from "contractStart") ORDER BY extract(year from "contractStart"), extract(month from "contractStart") ';
  $query = $conn->prepare($query);
  $query->execute();
  if (!$query) {
  databaseError($conn->errorInfo());
  }
$result = mysql_query($query);  
echo "<table> <thead> echo "<table> <thead>
<tr> <tr>
<th>Month/Year</th> <th>Month/Year</th>
<th>Total Contracts Value</th> <th>Total Contracts Value</th>
<th>Number of Contracts</th> <th>Number of Contracts</th>
</tr> </tr>
</thead>"; </thead>";
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { foreach ($query->fetchAll() as $row) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row["val"]),2); $value = number_format(doubleval($row["val"]),2);
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) );
echo ("<tr><td><b><a href=\"?month=$row[1]-$row[0]\">$month_name {$row[0]}</a></b></td><td>\$$value</td><td>({$row['count']} contracts)</td></tr>"); echo ("<tr><td><b><a href=\"?month=$row[1]-$row[0]\">$month_name {$row[0]}</a></b></td><td>\$$value</td><td>({$row['count']} contracts)</td></tr>");
} }
echo "</table>"; echo "</table>";
mysql_free_result($result); mysql_free_result($result);
} }
include_footer(); include_footer();
?> ?>
   
<?php <?php
include('../lib/common.inc.php'); include('lib/common.inc.php');
$year = 2006; $year = 2006;
$ZeroX = 112.5; $ZeroX = 112.5;
$MaxX = 157; $MaxX = 157;
$ZeroY = -9; $ZeroY = -9;
$MaxY = -45; $MaxY = -45;
$XRange = $MaxX - $ZeroX; $XRange = $MaxX - $ZeroX;
$YRange = abs($MaxY) - abs($ZeroY); $YRange = abs($MaxY) - abs($ZeroY);
$xdivs = 250; $xdivs = 250;
$xdivlength = $XRange / $xdivs; $xdivlength = $XRange / $xdivs;
$ydivs = 250; $ydivs = 250;
$ydivheight = $YRange / $ydivs; $ydivheight = $YRange / $ydivs;
$borderLeft = 100; $borderLeft = 100;
$borderTop = 35; $borderTop = 35;
$width = 497; $width = 497;
$height = 457; $height = 457;
//echo "http://dev.openstreetmap.org/~pafciu17/?module=map&bbox=".$ZeroX.",".$ZeroY.",".$MaxX.",".$MaxY."&width=".$width."&height=".$height; //echo "http://dev.openstreetmap.org/~pafciu17/?module=map&bbox=".$ZeroX.",".$ZeroY.",".$MaxX.",".$MaxY."&width=".$width."&height=".$height;
//$handle = ImageCreate ($width, $height) or die ("Cannot Create image"); //$handle = ImageCreate ($width, $height) or die ("Cannot Create image");
$handle = imagecreatefrompng('../images/australia.png'); $handle = imagecreatefrompng('images/australia.png');
$white = imagecolorallocate($handle, 0, 0, 0); $white = imagecolorallocate($handle, 0, 0, 0);
imagecolortransparent($handle, $white); imagecolortransparent($handle, $white);
$query = "SELECT supplierPostcode, sum(value) as value, lat, lon FROM `contractnotice`,`postcodes` where childCN = 0 AND supplierCountry = 'Australia' AND YEAR(contractStart) >= '$year' AND supplierPostcode = postcode GROUP BY supplierPostcode"; $query = 'SELECT "supplierPostcode", sum("value") as value, max(lat) as lat, max(lon) as lon FROM contractnotice inner join postcodes on "supplierPostcode" = postcode::text where "childCN" = 0 AND "supplierCountry" = \'Australia\' GROUP BY "supplierPostcode"';
$result = mysql_query($query); $query = $conn->prepare($query);
  $query->execute();
  if (!$query) {
  databaseError($conn->errorInfo());
  }
   
$left = "FFFF50"; $left = "FFFF50";
$right= "EF0050"; $right= "EF0050";
$leftR = hexdec(substr($left,0,2)); $leftR = hexdec(substr($left,0,2));
$leftG = hexdec(substr($left,2,2)); $leftG = hexdec(substr($left,2,2));
$leftB = hexdec(substr($left,4,2)); $leftB = hexdec(substr($left,4,2));
$rightR = hexdec(substr($right,0,2)); $rightR = hexdec(substr($right,0,2));
$rightG = hexdec(substr($right,2,2)); $rightG = hexdec(substr($right,2,2));
$rightB = hexdec(substr($right,4,2)); $rightB = hexdec(substr($right,4,2));
for($i=0;$i<250;$i++) { for($i=0;$i<250;$i++) {
$colorset[$i] = imagecolorallocatealpha($handle, $leftR + ($i*(($rightR-$leftR)/250)), $leftG + ($i*(($rightG-$leftG)/250)), $leftB + ($i*(($rightB-$leftB)/250)),117 - ($i/250)*40); $colorset[$i] = imagecolorallocatealpha($handle, $leftR + ($i*(($rightR-$leftR)/250)), $leftG + ($i*(($rightG-$leftG)/250)), $leftB + ($i*(($rightB-$leftB)/250)),117 - ($i/250)*40);
} }
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) foreach ($query->fetchAll() as $row) {
{  
$xpage = round((($XRange - ($MaxX - $row['lon'])) / $xdivlength)); $xpage = round((($XRange - ($MaxX - $row['lon'])) / $xdivlength));
if ($row['lat'] < -40.25) $row['lat']-= 0.75; if ($row['lat'] < -40.25) $row['lat']-= 0.75;
$ypage = round(($YRange - (abs($MaxY) - abs($row['lat']))) / $ydivheight); $ypage = round(($YRange - (abs($MaxY) - abs($row['lat']))) / $ydivheight);
@$pagevalues[$xpage][$ypage] += $row['value']; @$pagevalues[$xpage][$ypage] += $row['value'];
//echo $ypage." ".$xpage."<br>"; //echo $ypage." ".$xpage."<br>";
} }
$max = 0; $max = 0;
$min = 0; $min = 0;
for ($i = 0;$i < $xdivs; $i++ ) { for ($i = 0;$i < $xdivs; $i++ ) {
for ($j = 0;$j < $ydivs; $j++ ) { for ($j = 0;$j < $ydivs; $j++ ) {
if (@$pagevalues[$i][$j]) if (@$pagevalues[$i][$j])
{ {
if (@$pagevalues[$i][$j] > $max) $max = @$pagevalues[$i][$j]; if (@$pagevalues[$i][$j] > $max) $max = @$pagevalues[$i][$j];
if ($min == 0 || @$pagevalues[$i][$j] < $min) $min = @$pagevalues[$i][$j]; if ($min == 0 || @$pagevalues[$i][$j] < $min) $min = @$pagevalues[$i][$j];
} else { } else {
@$pagevalues[$i][$j] = ((@$pagevalues[$i][$j] + (@$pagevalues[$i+1][$j] + @$pagevalues[$i][$j+1] @$pagevalues[$i][$j] = ((@$pagevalues[$i][$j] + (@$pagevalues[$i+1][$j] + @$pagevalues[$i][$j+1]
+ @$pagevalues[$i-1][$j] + @$pagevalues[$i][$j-1])/4) /2)-9; + @$pagevalues[$i-1][$j] + @$pagevalues[$i][$j-1])/4) /2)-9;
@$pagevalues[$i-1][$j] = ((@$pagevalues[$i-1][$j] + (@$pagevalues[$i][$j] + @$pagevalues[$i-1][$j+1] @$pagevalues[$i-1][$j] = ((@$pagevalues[$i-1][$j] + (@$pagevalues[$i][$j] + @$pagevalues[$i-1][$j+1]
+ @$pagevalues[$i-2][$j] + @$pagevalues[$i-1][$j-1])/4) /2)-9; + @$pagevalues[$i-2][$j] + @$pagevalues[$i-1][$j-1])/4) /2)-9;
@$pagevalues[$i][$j-1] = ((@$pagevalues[$i][$j-1] + (@$pagevalues[$i+1][$j-1] + @$pagevalues[$i][$j] @$pagevalues[$i][$j-1] = ((@$pagevalues[$i][$j-1] + (@$pagevalues[$i+1][$j-1] + @$pagevalues[$i][$j]
+ @$pagevalues[$i-1][$j-1] + @$pagevalues[$i][$j-2])/4) /2)-9; + @$pagevalues[$i-1][$j-1] + @$pagevalues[$i][$j-2])/4) /2)-9;
} }
} }
} }
//echo $max." ".$min; //echo $max." ".$min;
//echo "<table width='100%'>"; //echo "<table width='100%'>";
for ($i = 0;$i < $xdivs; $i++ ) { for ($i = 0;$i < $xdivs; $i++ ) {
// echo "<tr>"; // echo "<tr>";
for ($j = 0; $j < $ydivs; $j++ ) { for ($j = 0; $j < $ydivs; $j++ ) {
// echo ("<td>". log10(@$pagevalues[$i][$j])/log10($max) ."</td>"); // echo ("<td>". log10(@$pagevalues[$i][$j])/log10($max) ."</td>");
if ((@$pagevalues[$i][$j]) > $min) { if ((@$pagevalues[$i][$j]) > $min) {
$x = $i*($width/$xdivs); $x = $i*($width/$xdivs);
$x1 = $borderLeft + $x -($width/$xdivs); $x1 = $borderLeft + $x -($width/$xdivs);
$x2 = $borderLeft + $x +($width/$xdivs); $x2 = $borderLeft + $x +($width/$xdivs);
$y = $j*($height/$ydivs); $y = $j*($height/$ydivs);
$y1 = $borderTop + $y - ($height/$ydivs); $y1 = $borderTop + $y - ($height/$ydivs);
$y2 = $borderTop + $y + ($height/$ydivs); $y2 = $borderTop + $y + ($height/$ydivs);
imagefilledrectangle ($handle, $x1, $y1, $x2, $y2, $colorset[(int)((log10(@$pagevalues[$i][$j])/log10($max))*249)]); imagefilledrectangle ($handle, $x1, $y1, $x2, $y2, $colorset[(int)((log10(@$pagevalues[$i][$j])/log10($max))*249)]);
} }
} }
//echo "</tr>"; //echo "</tr>";
} }
//echo "</table>" //echo "</table>"
header ("Content-type: image/png"); header ("Content-type: image/png");
ImagePng ($handle); ImagePng ($handle);
?> ?>
<?php <?php
include_once ("./lib/common.inc.php"); include_once ("./lib/common.inc.php");
if ($_REQUEST['supplier']) { if ($_REQUEST['supplier']) {
include_header("Supplier"); include_header("Supplier");
$supplierS = htmlentities(strip_tags($_REQUEST['supplier'])); $supplierS = htmlentities(strip_tags($_REQUEST['supplier']));
echo '<img src="graphs/displayMethodCountGraph.php?supplier=' . stripslashes($supplierS) . '">'; MethodCountGraph($supplierS);
echo '<img src="graphs/displayCnCGraph.php?supplier=' . stripslashes($supplierS) . '">'; CnCGraph($supplierS);
echo '<img src="graphs/displayMethodValueGraph.php?supplier=' . stripslashes($supplierS) . '">'; MethodValueGraph($supplierS);
/*lobbyist ties /*lobbyist ties
links to ABR/ASIC/Google News/ASX/Court records links to ABR/ASIC/Google News/ASX/Court records
total value to various agencies (bar graph) total value to various agencies (bar graph)
spread procurement methods + percent consultancies + percent confidential (bar graph) spread procurement methods + percent consultancies + percent confidential (bar graph)
spread of contract values spread of contract values
spread of industries (textual?)*/ spread of industries (textual?)*/
$query = 'SELECT "CNID", "description", "value", "agencyName", "category", $query = 'SELECT "CNID", "description", "value", "agencyName", "category",
"contractStart", "supplierName" "contractStart", "supplierName"
FROM contractnotice WHERE '. FROM contractnotice WHERE '.
$supplierQ.' '.$standardQ $supplierQ.' '.$standardQ
.' ORDER BY value DESC'; .' ORDER BY value DESC';
echo $query; echo $query;
$query = $conn->prepare($query); $query = $conn->prepare($query);
   
//$query->bindParam(":supplierName", $supplierName); //$query->bindParam(":supplierName", $supplierName);
$query->bindParam(":supplierABN", $supplierABN); $query->bindParam(":supplierABN", $supplierABN);
$query->execute(); $query->execute();
if (!$query) { if (!$query) {
databaseError($conn->errorInfo()); databaseError($conn->errorInfo());
} }
echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">'; echo '<img src="graphs/displayMethodCountGraph.php?month=' . stripslashes($supplier) . '">';
echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">'; echo '<img src="graphs/displayCnCGraph.php?month=' . stripslashes($supplier) . '">';
   
echo "<table> <thead> echo "<table> <thead>
<tr> <tr>
<th>Contract Notice Number</th> <th>Contract Notice Number</th>
<th>Contract Description</th> <th>Contract Description</th>
<th>Total Contract Value</th> <th>Total Contract Value</th>
<th>Agency</th> <th>Agency</th>
<th>Contract Start Date</th> <th>Contract Start Date</th>
<th>Supplier</th> <th>Supplier</th>
</tr> </tr>
</thead>"; </thead>";
foreach ($query->fetchAll() as $row) { foreach ($query->fetchAll() as $row) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row['value']) , 2); $value = number_format(doubleval($row['value']) , 2);
echo ("<tr> echo ("<tr>
<td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td> <td><a href=\"displayContract.php?CNID={$row['CNID']}\">{$row['CNID']}</a></td>
<td><b>{$row['description']}</b></a></td> <td><b>{$row['description']}</b></a></td>
<td>\$$value</td><td>{$row['agencyName']}</td> <td>\$$value</td><td>{$row['agencyName']}</td>
<td>{$row['contractStart']}</td> <td>{$row['contractStart']}</td>
<td>{$row['supplierName']}</td> <td>{$row['supplierName']}</td>
</tr>"); </tr>");
} }
echo "</table>"; echo "</table>";
} else { } else {
/* /*
histograph of supplier size/value histograph of supplier size/value
*/ */
include_header("Suppliers"); include_header("Suppliers");
  suppliersGraph();
$query = 'SELECT SUM("value") as val, MAX("supplierName") as supplierName, "supplierABN",( $query = 'SELECT SUM("value") as val, MAX("supplierName") as supplierName, "supplierABN",(
case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID
FROM contractnotice FROM contractnotice
WHERE "childCN" = 0 WHERE "childCN" = 0
GROUP BY supplierID,"supplierABN" GROUP BY supplierID,"supplierABN"
ORDER BY val DESC ORDER BY val DESC
LIMIT 100'; LIMIT 100';
$query = $conn->prepare($query); $query = $conn->prepare($query);
$query->execute(); $query->execute();
if (!$query) { if (!$query) {
databaseError($conn->errorInfo()); databaseError($conn->errorInfo());
} }
echo "<table> <thead> echo "<table> <thead>
<tr> <tr>
<th>Position</th> <th>Position</th>
<th>Supplier</th> <th>Supplier</th>
<th>Total Contract Value</th> <th>Total Contract Value</th>
</tr> </tr>
</thead>"; </thead>";
$i = 1; $i = 1;
foreach ($query->fetchAll() as $row) { foreach ($query->fetchAll() as $row) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row['val']) , 2); $value = number_format(doubleval($row['val']) , 2);
$supplier = stripslashes($row['supplierABN'].'-'.$row['suppliername']); $supplier = stripslashes($row['supplierABN'].'-'.$row['suppliername']);
echo ("<tr><td>$i</td><td><b><a href=\"displaySupplier.php?supplier={$supplier}\">".ucsmart($row['suppliername'])."</a></b></td><td>\$$value</td></tr>\n"); echo ("<tr><td>$i</td><td><b><a href=\"displaySupplier.php?supplier={$supplier}\">".ucsmart($row['suppliername'])."</a></b></td><td>\$$value</td></tr>\n");
$i++; $i++;
} }
echo "</table>"; echo "</table>";
} }
include_footer(); include_footer();
?> ?>
   
<?php <?php
$includedFlot = false; $includedFlot = false;
function includeFlot() { function includeFlot() {
if (!$includedFlot) { if (!$includedFlot) {
echo ' <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="lib/flot/excanvas.min.js"></script><![endif]--> echo ' <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="lib/flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="lib/flot/jquery.flot.js"></script> <script language="javascript" type="text/javascript" src="lib/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="lib/flot/jquery.flot.pie.js"></script> <script language="javascript" type="text/javascript" src="lib/flot/jquery.flot.pie.js"></script>
   
'; ';
$includedFlot = true; $includedFlot = true;
} }
} }
   
function CNDistributionGraph() { function CNDistributionGraph() {
global $conn; global $conn;
includeFlot(); includeFlot();
?> ?>
<center><div id="cndist" style="width:900px;height:550px"></div></center> <center><div id="cndist" style="width:900px;height:550px"></div></center>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
   
var d1 = []; var d1 = [];
<?php <?php
$query = 'select cnid, count(*) from (select ("CNID" - MOD("CNID",100)) as cnid from contractnotice where "CNID" < 999999) as a group by cnid order by cnid'; $query = 'select cnid, count(*) from (select ("CNID" - MOD("CNID",100)) as cnid from contractnotice where "CNID" < 999999) as a group by cnid order by cnid';
$query = $conn->prepare($query); $query = $conn->prepare($query);
$query->execute(); $query->execute();
if (!$query) { if (!$query) {
databaseError($conn->errorInfo()); databaseError($conn->errorInfo());
return Array(); return Array();
} }
   
foreach ($query->fetchAll() as $delta) { foreach ($query->fetchAll() as $delta) {
   
echo "d1.push([ ".intval($delta['cnid']).", ".intval($delta['count'])."]); \n"; echo "d1.push([ ".intval($delta['cnid']).", ".intval($delta['count'])."]); \n";
}; };
?> ?>
   
var placeholder = $("#cndist"); var placeholder = $("#cndist");
   
var plot = $.plot(placeholder, [ var plot = $.plot(placeholder, [
{ {
data: d1, data: d1,
bars: { show: true } bars: { show: true }
}, },
], ],
{ {
   
grid: { hoverable: true, clickable: true, labelMargin: 17 }, grid: { hoverable: true, clickable: true, labelMargin: 17 },
}); });
   
}); });
   
</script> </script>
<?php <?php
} }
   
function agenciesGraph() { function agenciesGraph() {
global $conn; global $conn;
includeFlot(); includeFlot();
$query = 'SELECT SUM("value") as val, MAX(contractnotice."agencyName") as agencyname FROM contractnotice join agency on contractnotice."agencyName"=agency."agencyName" WHERE "childCN" = 0 $query = 'SELECT SUM("value") as val, MAX(contractnotice."agencyName") as agencyname FROM contractnotice join agency on contractnotice."agencyName"=agency."agencyName" WHERE "childCN" = 0
GROUP BY abn ORDER BY SUM("value") DESC'; GROUP BY abn ORDER BY SUM("value") DESC';
$query = $conn->prepare($query); $query = $conn->prepare($query);
$query->execute(); $query->execute();
if (!$query) { if (!$query) {
databaseError($conn->errorInfo()); databaseError($conn->errorInfo());
return Array(); return Array();
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
// data // data
var data = [ var data = [
<?php <?php
foreach ($query->fetchAll() as $row) { foreach ($query->fetchAll() as $row) {
echo '{ label: "'.$row['agencyname'].'", data: '.doubleval($row["val"]).'},'; echo '{ label: "'.$row['agencyname'].'", data: '.doubleval($row["val"]).'},';
} }
?> ?>
]; ];
// GRAPH 7 // GRAPH 7
$.plot($("#graph7"), data, $.plot($("#graph7"), data,
{ {
series: { series: {
pie: { pie: {
show: true, show: true,
radius: 1, radius: 1,
tilt: 0.75, tilt: 0.75,
label: { label: {
show: true, show: true,
radius: 1, radius: 1,
formatter: function(label, series){ formatter: function(label, series){
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+': '+Math.round(series.percent)+'%</div>'; return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+': '+Math.round(series.percent)+'%</div>';
}, },
background: { background: {
opacity: 0.5, opacity: 0.5,
color: '#000' color: '#000'
} }
}, },
combine: { combine: {
color: '#999', color: '#999',
threshold: 0.012 threshold: 0.012
} }
} }
}, },
legend: { legend: {
show: false show: false
} }
}); });
}); });
</script> </script>
<div id="graph7" style="width:900px;height:550px"></div> <div id="graph7" style="width:900px;height:550px"></div>
   
<?php <?php
}; };
   
function agencySuppliersGraph($agency) { function agencySuppliersGraph($agency) {
$agency = "AusAid"; $agency = "AusAid";
$topX = 15; $topX = 15;
$query = "SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 AND agencyName = '$agency' $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"; GROUP BY lower(supplierName) ORDER BY val DESC limit $topX";
$result = mysql_query($query); $result = mysql_query($query);
$suppliers = Array(); $suppliers = Array();
$values = Array(); $values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$suppliers[] = ucsmart($row['supplierName']); $suppliers[] = ucsmart($row['supplierName']);
$values[] = doubleval($row["val"]); $values[] = doubleval($row["val"]);
} }
mysql_free_result($result); mysql_free_result($result);
   
$query = "SELECT sum(a.val) as value, count(1) as count from (SELECT SUM(value) as val, supplierName FROM `contractnotice` WHERE (YEAR(contractStart) >= $startYear) AND childCN = 0 and agencyName = '$agency' $query = "SELECT sum(a.val) as value, count(1) as count from (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 18446744073709551610 OFFSET $topX) as a"; GROUP BY lower(supplierName) ORDER BY val DESC LIMIT 18446744073709551610 OFFSET $topX) as a";
$result = mysql_query($query); $result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
if ($row['count'] > 0) { if ($row['count'] > 0) {
$suppliers[] = $row['count'] . " other suppliers"; $suppliers[] = $row['count'] . " other suppliers";
$values[] = doubleval($row[0]); $values[] = doubleval($row[0]);
} }
} }
mysql_free_result($result); mysql_free_result($result);
} }
   
function CnCGraph() { function CnCGraph() {
$query = "select procurementMethod, count(1) as count, SUM(value) as val, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` $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"; where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month";
$result = mysql_query($query); $result = mysql_query($query);
$methods = Array("Direct","Open","Select"); $methods = Array("Direct","Open","Select");
$dates = Array(); $dates = Array();
$methodCountsP = Array(); $methodCountsP = Array();
$methodCounts = Array(); $methodCounts = Array();
$maxValue = 0; $maxValue = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
if ($row['val'] > $maxValue) $maxValue = $row['val']; if ($row['val'] > $maxValue) $maxValue = $row['val'];
$date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"]; $date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"];
if (array_search($date,$dates) === false ) { if (array_search($date,$dates) === false ) {
$dates[$row["year"]*100 + $row["month"]] = $date; $dates[$row["year"]*100 + $row["month"]] = $date;
ksort($dates); ksort($dates);
} }
$methodCountsP[$row["procurementMethod"]][$date] = $row["count"]; $methodCountsP[$row["procurementMethod"]][$date] = $row["count"];
   
} }
foreach ($methods as $method) { foreach ($methods as $method) {
foreach($dates as $date) { foreach($dates as $date) {
if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date]; if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date];
else $methodCounts[$method][] = 0; else $methodCounts[$method][] = 0;
} }
} }
$dates = array_values($dates); $dates = array_values($dates);
$totalRecords = array_sum_all($methodCounts); $totalRecords = array_sum_all($methodCounts);
mysql_free_result($result); mysql_free_result($result);
   
   
function formatCallback($aVal) { function formatCallback($aVal) {
global $totalRecords; global $totalRecords;
return percent($aVal, $totalRecords) . "%"; return percent($aVal, $totalRecords) . "%";
} }
$attributes = Array(); $attributes = Array();
$attributeNames = Array( $attributeNames = Array(
"Consultancies", "Consultancies",
"Confidentialities" "Confidentialities"
); );
$query = "SELECT 'consultancy', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ consultancy='Yes' AND childCN = 0;"; $query = "SELECT 'consultancy', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ consultancy='Yes' AND childCN = 0;";
$result = mysql_query($query); $result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_BOTH); $row = mysql_fetch_array($result, MYSQL_BOTH);
$attributes[0] = $row[1]; $attributes[0] = $row[1];
$query = "SELECT 'confidentiality', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ (confidentialityContract='Yes' OR confidentialityOutputs='Yes') AND childCN = 0;"; $query = "SELECT 'confidentiality', count(1) FROM `contractnotice` WHERE $agencyQ $supplierQ (confidentialityContract='Yes' OR confidentialityOutputs='Yes') AND childCN = 0;";
$result = mysql_query($query); $result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_BOTH); $row = mysql_fetch_array($result, MYSQL_BOTH);
$attributes[1] = $row[1]; $attributes[1] = $row[1];
mysql_free_result($result); mysql_free_result($result);
} }
function ContractPublishedGraph() { function ContractPublishedGraph() {
$query = "SELECT YEAR(publishDate), MONTH(publishDate), $query = "SELECT YEAR(publishDate), MONTH(publishDate),
SUM(value) as val, count(1) as count FROM `contractnotice` SUM(value) as val, count(1) as count FROM `contractnotice`
WHERE (YEAR(publishDate) >= 2008) WHERE (YEAR(publishDate) >= 2008)
AND childCN = 0 AND childCN = 0
GROUP BY MONTH(publishDate), YEAR(publishDate) GROUP BY MONTH(publishDate), YEAR(publishDate)
ORDER BY YEAR(publishDate), MONTH(publishDate)"; ORDER BY YEAR(publishDate), MONTH(publishDate)";
   
$result = mysql_query($query); $result = mysql_query($query);
$dates = Array(); $dates = Array();
$values = Array(); $values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row["val"]),2); $value = number_format(doubleval($row["val"]),2);
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) );
$dates[] = $month_name." {$row[0]}"; $dates[] = $month_name." {$row[0]}";
$counts[] = doubleval($row["count"]); $counts[] = doubleval($row["count"]);
$values[] = doubleval($row["val"]); $values[] = doubleval($row["val"]);
} }
mysql_free_result($result); mysql_free_result($result);
   
} }
function ContractStartingGraph() { function ContractStartingGraph() {
$query = "SELECT YEAR(contractStart), MONTH(contractStart), $query = "SELECT YEAR(contractStart), MONTH(contractStart),
SUM(value) as val, count(1) as count FROM `contractnotice` SUM(value) as val, count(1) as count FROM `contractnotice`
WHERE (YEAR(contractStart) >= 2008) WHERE (YEAR(contractStart) >= 2008)
AND childCN = 0 AND childCN = 0
GROUP BY MONTH(contractStart), YEAR(contractStart) GROUP BY MONTH(contractStart), YEAR(contractStart)
ORDER BY YEAR(contractStart), MONTH(contractStart)"; ORDER BY YEAR(contractStart), MONTH(contractStart)";
   
$result = mysql_query($query); $result = mysql_query($query);
$dates = Array(); $dates = Array();
$values = Array(); $values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
$value = number_format(doubleval($row["val"]),2); $value = number_format(doubleval($row["val"]),2);
$month_name = date( 'F', mktime(0, 0, 0, $row[1]) ); $month_name = date( 'F', mktime(0, 0, 0, $row[1]) );
$dates[] = $month_name." {$row[0]}"; $dates[] = $month_name." {$row[0]}";
$counts[] = doubleval($row["count"]); $counts[] = doubleval($row["count"]);
$values[] = doubleval($row["val"]); $values[] = doubleval($row["val"]);
} }
mysql_free_result($result); mysql_free_result($result);
} }
function MethodCountGraph() { function MethodCountGraph() {
$query = "select procurementMethod, count(1) as count, SUM(value) as value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` $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"; where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month";
$result = mysql_query($query); $result = mysql_query($query);
$methods = Array("Direct","Open","Select"); $methods = Array("Direct","Open","Select");
$dates = Array(); $dates = Array();
$methodCountsP = Array(); $methodCountsP = Array();
$methodCounts = Array(); $methodCounts = Array();
$maxValue = 0; $maxValue = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
if ($row['value'] > $maxValue) $maxValue = $row['value']; if ($row['value'] > $maxValue) $maxValue = $row['value'];
$date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"]; $date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"];
if (array_search($date,$dates) === false ) { if (array_search($date,$dates) === false ) {
$dates[$row["year"]*100 + $row["month"]] = $date; $dates[$row["year"]*100 + $row["month"]] = $date;
ksort($dates); ksort($dates);
} }
$methodCountsP[$row["procurementMethod"]][$date] = $row["count"]; $methodCountsP[$row["procurementMethod"]][$date] = $row["count"];
   
} }
foreach ($methods as $method) { foreach ($methods as $method) {
foreach($dates as $date) { foreach($dates as $date) {
if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date]; if ($methodCountsP[$method][$date] > 0) $methodCounts[$method][] = $methodCountsP[$method][$date];
else $methodCounts[$method][] = 0; else $methodCounts[$method][] = 0;
} }
} }
$dates = array_values($dates); $dates = array_values($dates);
$totalRecords = array_sum_all($methodCounts); $totalRecords = array_sum_all($methodCounts);
mysql_free_result($result); mysql_free_result($result);
} }
function MethodValueGraph() { function MethodValueGraph() {
$query = "select procurementMethod, SUM(value) as value, MONTH(contractStart) as month, YEAR(contractStart) as year from `contractnotice` $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"; where $agencyQ $supplierQ $standardQ group by procurementMethod,year,month order by procurementMethod,year,month";
$result = mysql_query($query); $result = mysql_query($query);
$methods = Array("Direct","Open","Select"); $methods = Array("Direct","Open","Select");
$dates = Array(); $dates = Array();
$methodValuesP = Array(); $methodValuesP = Array();
$methodValues = Array(); $methodValues = Array();
$maxValue = 0; $maxValue = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
if ($row['value'] > $maxValue) $maxValue = $row['value']; if ($row['value'] > $maxValue) $maxValue = $row['value'];
$date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"]; $date = date( 'F ', mktime(0, 0, 0, $row["month"]) ). $row["year"];
if (array_search($date,$dates) === false ) { if (array_search($date,$dates) === false ) {
$dates[$row["year"]*100 + $row["month"]] = $date; $dates[$row["year"]*100 + $row["month"]] = $date;
ksort($dates); ksort($dates);
} }
$methodValuesP[$row["procurementMethod"]][$date] = $row["value"]; $methodValuesP[$row["procurementMethod"]][$date] = $row["value"];
   
} }
foreach ($methods as $method) { foreach ($methods as $method) {
foreach($dates as $date) { foreach($dates as $date) {
if ($methodValuesP[$method][$date] > 0) $methodValues[$method][] = $methodValuesP[$method][$date]; if ($methodValuesP[$method][$date] > 0) $methodValues[$method][] = $methodValuesP[$method][$date];
else $methodValues[$method][] = 0; else $methodValues[$method][] = 0;
} }
} }
$dates = array_values($dates); $dates = array_values($dates);
$totalRecords = array_sum_all($methodValues); $totalRecords = array_sum_all($methodValues);
mysql_free_result($result); mysql_free_result($result);
   
} }
function SuppliersGraph() { function SuppliersGraph() {
   
  global $conn;
  includeFlot();
$topX = 10; $topX = 10;
$query = "SELECT value, supplierName  
FROM `contractnotice` WHERE (YEAR(contractStart) >= 2009) AND childCN = 0  
GROUP BY supplierABN ORDER BY value DESC limit $topX";  
$result = mysql_query($query);  
$suppliers = Array(); $suppliers = Array();
$values = Array(); $values = Array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {  
   
  $query = 'SELECT SUM("value") as value, MAX("supplierName") as supplierName, (
  case when "supplierABN" != 0 THEN "supplierABN"::text ELSE "supplierName" END) as supplierID
  FROM contractnotice
  WHERE "childCN" = 0
  GROUP BY supplierID
  ORDER BY value DESC
  LIMIT '.$topX;
  $query = $conn->prepare($query);
  $query->execute();
  if (!$query) {
  databaseError($conn->errorInfo());
  }
  foreach ($query->fetchAll() as $row) {
setlocale(LC_MONETARY, 'en_US'); setlocale(LC_MONETARY, 'en_US');
// $value = number_format(doubleval($row["value"]) , 2); // $value = number_format(doubleval($row["value"]) , 2);
$suppliers[] = ucsmart($row[1]); $suppliers[] = ucsmart($row[1]);
$values[] = doubleval($row["value"]); $values[] = doubleval($row["value"]);
} }
mysql_free_result($result);  
  $query = 'SELECT sum(a.svalue) as val, suppliercountry from (SELECT sum("value") as svalue, max("supplierCountry") as suppliercountry
$query = "SELECT sum(a.value) as val, supplierCountry from (SELECT value, supplierName, supplierCountry FROM contractnotice WHERE "childCN" = 0 and "supplierCountry" NOT ILIKE \'Australia\'
FROM `contractnotice` WHERE (YEAR(contractStart) >= 2009) AND childCN = 0 GROUP BY "supplierName" ORDER BY svalue LIMIT 18446744073 OFFSET 10) as a group by suppliercountry order by val DESC limit 10 ';
GROUP BY supplierName ORDER BY value LIMIT 18446744073709551610 OFFSET $topX) as a group by supplierCountry order by val DESC limit 5 offset 1"; $query = $conn->prepare($query);
$result = mysql_query($query); $query->execute();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { if (!$query) {
$suppliers[] = "Other suppliers in ".ucsmart($row["supplierCountry"]); databaseError($conn->errorInfo());
  }
   
  foreach ($query->fetchAll() as $row) {
  $suppliers[] = "Other suppliers in ".ucsmart($row["suppliercountry"]);
$values[] = doubleval($row[0]); $values[] = doubleval($row[0]);
} }
   
mysql_free_result($result);  
  $query = 'SELECT sum(a.value) as val, substring(
$query = "SELECT sum(a.value) as val, TRUNCATE(supplierPostcode,-2) as postcode from (SELECT value, supplierName, supplierPostcode, supplierCountry supplierpostcode from 0 for 2) as postcode from (SELECT sum(value) as value, max("supplierPostcode") as supplierpostcode, max("supplierCountry") as suppliercountry
FROM `contractnotice` WHERE (YEAR(contractStart) >= 2009) AND childCN = 0 FROM contractnotice WHERE "childCN" = 0
GROUP BY supplierName ORDER BY value LIMIT 18446744073709551610 OFFSET $topX) as a GROUP BY "supplierABN" ORDER BY sum(value) LIMIT 1844674 OFFSET 10) as a
WHERE (supplierCountry LIKE 'Australia' OR supplierCountry LIKE 'AUSTRALIA') AND supplierPostcode < 10000 WHERE (suppliercountry ILIKE \'Australia\')
group by TRUNCATE(supplierPostcode,-2) group by substring(
order by val DESC"; supplierpostcode from 0 for 2)
$result = mysql_query($query); order by val DESC;';
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { $query = $conn->prepare($query);
  $query->execute();
  if (!$query) {
  databaseError($conn->errorInfo());
  }
   
  foreach ($query->fetchAll() as $row) {
if ($row['postcode'][0] == 2 && $row['postcode'][1] == 6) $ACTvalue += $row[0]; if ($row['postcode'][0] == 2 && $row['postcode'][1] == 6) $ACTvalue += $row[0];
else if ($row['postcode'][0] == 2 || $row['postcode'][0] == 1) $NSWvalue += $row[0]; else if ($row['postcode'][0] == 2 || $row['postcode'][0] == 1) $NSWvalue += $row[0];
else if ($row['postcode'][0] == 3 || $row['postcode'][0] == 8) $Vicvalue += $row[0]; else if ($row['postcode'][0] == 3 || $row['postcode'][0] == 8) $Vicvalue += $row[0];
else if ($row['postcode'][0] == 4 || $row['postcode'][0] == 9) $QLDvalue += $row[0]; else if ($row['postcode'][0] == 4 || $row['postcode'][0] == 9) $QLDvalue += $row[0];
else if ($row['postcode'][0] == 5) $SAvalue += $row[0]; else if ($row['postcode'][0] == 5) $SAvalue += $row[0];
else if ($row['postcode'][0] == 6) $WAvalue += $row[0]; else if ($row['postcode'][0] == 6) $WAvalue += $row[0];
else if ($row['postcode'][0] == 7) $Tasvalue += $row[0]; else if ($row['postcode'][0] == 7) $Tasvalue += $row[0];
else if ($row['postcode'][0] == 0) $NTvalue += $row[0]; else if ($row['postcode'][0] == 0) $NTvalue += $row[0];
} }
mysql_free_result($result);  
$suppliers[] = "Other suppliers in Australia - ACT"; $suppliers[] = "Other suppliers in Australia - ACT";
$values[] = doubleval($ACTvalue); $values[] = doubleval($ACTvalue);
$suppliers[] = "Other suppliers in Australia - NSW"; $suppliers[] = "Other suppliers in Australia - NSW";
$values[] = doubleval($NSWvalue); $values[] = doubleval($NSWvalue);
$suppliers[] = "Other suppliers in Australia - Victoria"; $suppliers[] = "Other suppliers in Australia - Victoria";
$values[] = doubleval($Vicvalue); $values[] = doubleval($Vicvalue);
$suppliers[] = "Other suppliers in Australia - Queensland"; $suppliers[] = "Other suppliers in Australia - Queensland";
$values[] = doubleval($QLDvalue); $values[] = doubleval($QLDvalue);
$suppliers[] = "Other suppliers in Australia - NT"; $suppliers[] = "Other suppliers in Australia - NT";
$values[] = doubleval($NTvalue); $values[] = doubleval($NTvalue);
$suppliers[] = "Other suppliers in Australia - West Australia"; $suppliers[] = "Other suppliers in Australia - West Australia";
$values[] = doubleval($WAvalue); $values[] = doubleval($WAvalue);
$suppliers[] = "Other suppliers in Australia - South Australia"; $suppliers[] = "Other suppliers in Australia - South Australia";
$values[] = doubleval($SAvalue); $values[] = doubleval($SAvalue);
$suppliers[] = "Other suppliers in Australia - Tasmania"; $suppliers[] = "Other suppliers in Australia - Tasmania";
$values[] = doubleval($Tasvalue); $values[] = doubleval($Tasvalue);
   
}  
   
?> ?>
  <script type="text/javascript">
  $(function () {
  // data
  var data = [
  <?php
  foreach ($suppliers as $key => $supplier) {
  echo '{ label: "'.$supplier.'", data: '.doubleval($values[$key]).'},';
  }
  ?>
  ];
  // GRAPH 7
  $.plot($("#graph7"), data,
  {
  series: {
  pie: {
  show: true,
  radius: 1,
  tilt: 0.75,
  label: {
  show: true,
  radius: 1,
  formatter: function(label, series){
  return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+': '+Math.round(series.percent)+'%</div>';
  },
  background: {
  opacity: 0.5,
  color: '#000'
  }
  },
  combine: {
  color: '#999',
  threshold: 0.012
  }
  }
  },
  legend: {
  show: false
  }
  });
  });
  </script>
  <div id="graph7" style="width:900px;height:550px"></div>
   
  <?php
  }
   
  ?>