--- a/displaySON.gexf.php +++ b/displaySON.gexf.php @@ -1,1 +1,98 @@ +" : ">") + . ""; + echo "" . PHP_EOL; + $used_node_ids[] = $id; + } +} + +function add_edge($from, $to, $weight = '1.0') +{ + global $used_edge_ids, $included_panel_ids; + $id = urlencode($from . '-' . $to); + + if (!in_array($id, $used_edge_ids)) { + echo "" . PHP_EOL; + if ($weight != 0.1) { + echo ""; + } else { + echo ""; + } + echo "" . PHP_EOL; + $used_edge_ids[] = $id; + } +} + +$edges = Array(); +header('Content-Type: application/gexf+xml'); +echo ' + + + Gexf.net + A hello world! file + + + + ' . PHP_EOL; + +$query = ' +SELECT "supplierABN", min("supplierName") AS "supplierName", contractnotice."SONID", count(*), sum(value) AS value +FROM contractnotice +WHERE "childCN" IS NULL +AND extract(year from "publishDate") = \'2016\' +AND "supplierABN" in (select distinct "supplierABN" from contractnotice where (left("categoryUNSPSC"::text,2) = \'43\' or left("categoryUNSPSC"::text,2) = \'80\') ) +AND contractnotice."SONID" != \'\' AND contractnotice."SONID" IS NOT NULL GROUP BY "supplierABN", contractnotice."SONID"'; +$query = $conn->prepare($query); +$query->execute(); +databaseError($conn->errorInfo()); +foreach ($query->fetchAll() as $row) { + add_node($row['supplierABN'], $row['supplierName'], "",false); + $included_panel_ids[] = $row['SONID']; + $edges[] = array("head" => $row['SONID'], "tail" => $row['supplierABN'], "weight" => $row['count']); +} + +$query = 'SELECT "SONID", title FROM standingoffers'; +$query = $conn->prepare($query); +$query->execute(); +foreach ($query->fetchAll() as $row) { + // if (in_array($row['SONID'], $included_panel_ids)){ + add_node($row['SONID'], $row['title'], "", true); + // } +} + +$query = 'select "SONID", abn,name from standingoffer_suppliers'; +$query = $conn->prepare($query); +$query->execute(); +databaseError($conn->errorInfo()); +foreach ($query->fetchAll() as $row) { + add_node($row['abn'], $row['name']); + + $edges[] = array("head"=>$row['SONID'], "tail"=>$row['abn'], "weight"=> 0.1); +} + +echo ' + ' . PHP_EOL; +foreach ($edges as $edge) { + add_edge($edge['head'], $edge['tail']); +} +echo ' + +' . PHP_EOL; + +?> +