<?php
// Geographically Dispersed Work Teams measures for all
include("config.php");
include($baseDir . "common/_func.php");
include($baseDir . "common/_gdwt.php");
// for testing purposes, gdwt or workteams data is used
$sql="SELECT * FROM user WHERE username=\"workteams\"";
$result = mysql_query($sql) or die(sqlError($sql));
$row = mysql_fetch_array($result);
session_register("uID");
$uID=$row['uID'];
$username="workteams";
include($baseDir . "common/_javascript.php");
include($baseDir . "common/_header.php");
echo "<center>";
echo "<table width=\"700\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">";
echo "<tr bgcolor=\"#CCCCCC\" align=\"center\">";
echo "<td nowrap bgcolor=\"#FFFFFF\" height=\"16\">";
echo "<div align=\"left\"><a href=\"index.php\">";
echo "<font color=#006699>Home</font></a> > ";
echo "<a href=\"socialnetworks.php\">";
echo "<font color=#006699>Social Networks</font></a>";
echo " > <a href=\"gdwt.php\"><font color=#006699>Geographic Dispersion</font></a> ";
echo "</div></td>";
echo "<td nowrap bgcolor=\"#FFFFFF\" height=\"16\" colspan=\"2\">";
echo "<div align=\"right\">";
include($baseDir . "common/_options.php");
echo "</div>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</center>";
#echo "<br><center>";
// grab the fields in networks table
$sql="SELECT * FROM networks WHERE uID=$uID ORDER BY ID";
$result = mysql_query($sql) or die(sqlError($sql));
// display the netname field in a pull-down menu
session_register("stat");
while($row=mysql_fetch_array($result)){
$net = $row['netname'];
#echo "Team = $net<br>";
// stat is the variable used for the class GDWT
$stat= new GDWT($uID,$net);
// triangle function to display matrix values
$stat->createTriangle();
#echo "raw data (upper-right triangle)=<br>$stat->data<br><br>";
// create site function to determine how many different sites
$sites = $stat->createSites();
for($c=0; $c<count($stat->sites); $c++){
#echo "Site $c contains people: {$stat->sites[$c]}<br>";
}
#echo "<br>";
$miles = $stat->computeMiles();
$minutes = $stat->computeMinutes();
$shared = $stat->computeShared();
#$sites = $stat->computeSites();
#$isolation = $stat->computeIsolation();
$separation = $stat->computeSeparation($miles);
$deviation = $stat->computeDeviation($miles);
$overlap = $stat->computeOverlap($shared);
// compute the five indices - Sites, Isolation, Separation, Deviation, Overlap
$sqlNetwork="SELECT * FROM networks WHERE uID=$uID AND netname=\"$net\"";
$resultnet = mysql_query($sqlNetwork) or die(sqlError($sqlNetwork));
$rowNetwork = mysql_fetch_array($resultNetwork);
#echo "Site Index=$rowNetwork[site]<br>";
#echo "Isolation Index=$rowNetwork[isolation]<br>";
#echo "Separation Index=$rowNetwork[separation]<br>";
#echo "Deviation Index=$rowNetwork[deviation]<br>";
#echo "Overlap Index=$rowNetwork[overlap]<br>";
#echo "<br>";
}
include($baseDir . "common/_footer.php");
?>