<?
session_start();
session_unregister('aF');
session_unregister('aF1');


require("DB.php");
require("asstHeader.php");


$dbVar = new DB("andromeda", "gradinfo");
$dbVar->connect();



if(isset($actionflag) && isset($event_id)){

			if($actionflag == 1){		
				deleteUser($event_id);
			  $actionflag = 0;
			}
//	printStudents();
}
printUsers();
function printUsers()
{
	print"<h1>Users of GPA</h1>";

	global $dbVar;
	$listOfUsers = ($dbVar->getListUsers());
	print"<table border = 1><tr>\n";
	print"<tr><td>First Name</td><td>Last Name</td><td>User Name</td><td>User Type</td>";
	foreach($listOfUsers as $row)
	{
	   if($row[userType]=='a')
	     $t = "Applicant";
	   else if($row[userType]=='s')
	     $t = "Student";
	   else if($row[userType]=='f')
	     $t = "Faculty";
	   else if($row[userType]=='v')
	     $t = "Advisor";
	   else if($row[userType]=='c')
	     $t = "Graduate Committee";
	   else if($row[userType]=='d')
	     $t = "Graduate Director";
	   else if($row[userType]=='m')
	     $t = "Management Assistant";
	   else 
	     $t = " ";

		//print $row["firstName"]." ";
		//print $row["GRE"];
		print"<tr>\n";
		print"<td>$row[first]</td><td>$row[last]</td>
			<td>$row[username]</td>
		        <td>$t</td>
			<td><a href=\"updateU.php?event_id=$row[username]\">
			Update / View </a></td>
			<td><a href=\"javascript: if (window.confirm('Delete User from database?')) 
			document.location = '$GLOBALS[PHP_SELF]?event_id=$row[username]&actionflag=1';\">";
		print "delete</a></td>";
		print "<tr>\n";

	}
	print"</table>";
	print"<form action = \"newUser.php\" method= \"post\">
	      <input type=\"submit\", value=\"Add a new user\"></form>";
	print"<hr>";
}

function deleteUser($id){
	global $dbVar;
	$dbVar->deleteUser($id);

}
?>