<?php
session_start();
include "../functions.php";

$userID = checkAdmin(session_id());

//echo "<$userID>";
//include "adminHeader.php";

$query = "select firstName, lastName from theusers where userID='$userID'";
$result = mysql_query($query);

while ($row = mysql_fetch_array($result))
{
	$firstName = $row[0];
	$lastName = $row[1];
}


//include "adminFooter.php";
?>

<html>
<head>
<title>Administration Area</title>
</head>

<body>

<center>
<table width=80% border=0>
  <tr>
    <td width=1>
     <img src="../img/logo.jpg">
    </td>
    
    <td valign="bottom">
      <table border=0 width=100% height=100% cellpadding=13>
        <tr>
          <td align="center"><h2><b>Administration Module</b></h2></td>
        </tr>
        
        <tr>
          <td align="center"><a href="logoff.php">Log out</a>&nbsp;&nbsp;&nbsp;
          <a href="index.php">Main Menu</a></td>
        </tr>
      </table>
    </td>
    
    <td align="right" valign="bottom">
      <?php echo "<b>Welcome! $firstName, $lastName</b>"; ?>
    </td>
    
  </tr>
</table>
</center>

<center>
<table width=80% border=0 cellpadding=5 cellspacing=1>
<tr bgcolor="#a0a0a0"><th>Access Name</th><th>Name</th><th colspan=2>Options</th></tr>
<?php
$query = "select userID, firstName, lastName, userName from theusers";
$result = mysql_query($query);

$lastColor = 1;

while ($row = mysql_fetch_array($result))
{
	$userID = $row[0];
	$name = $row[1] . "," . $row[2];
	$userName = $row[3];
	
	$lastColor = ($lastColor + 1) % 2;
	
	if ($lastColor == 1)
	{
		echo "<tr bgcolor=\"#c9c9c9\">";
	}
	else
	{
		echo "<tr bgcolor=\"#e9e9e9\">";
	}
	
	echo "<td>$userName</td>";
	echo "<td>$name</td>";
	echo "<td align=right><form action=modAdmin.php method=post><input type=hidden name=userID value=$userID><input type=submit value=Modify></td></form>";
	echo "<td><form action=delAdmin.php method=post><input type=hidden name=userID value=$userID><input type=submit value=Delete></td></form>";
}
?>
<tr>
<td align="center" colspan=4><form action="addAdmin.php" method="post"><input type="submit" value="Add New Admin User"></td></form>
</tr>
</table>
</center>

</body>
</html>