<?
session_start();
session_unregister('aF');
session_unregister('aF1');
/**********************************************************************************
*Name: display.php
*Purpose: 1)Display a list of students and applicants to the management assistants staff
* 	  2)Allow staff members to update, delete, add a student or an applicant
*	  3)Allow staff members to update, delete, add a user through links in the header
*Version information
*Date: December 2, 2001
*Copyright notice
***********************************************************************************/
 
require("DB.php");
if($userType != 'm')
	header("Location: logout.php");


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

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

			if($actionflag == 1){
				deleteApplicant($event_id);
				deleteUser($event_id);
			}
			else if($actionflag == 2){
				$dbVar->appToStud($event_id);
				header("Location: gradStud.php");
				exit;
			}

		}
	
require("asstHeader.php");
	
		printApplicants();


function Applicant_To_Student($id){
	global $dbVar;
	$dbVar->appToStud($id);
}


function printApplicants()
{
	global $dbVar;
	print"<h1>Graudate Applicants in Computer Science</h1>";
	print"<table border = 1><tr>\n";
	print"<tr><td>First Name</td><td>Last Name</td><td>User ID</td>";
	
	$listOfApplicants = ($dbVar->getListApplicants());
	foreach($listOfApplicants as $row){
		print"<tr>\n";
		print"<td>$row[firstName]</td><td>$row[lastName]</td>
			<td>$row[rNumber]</td>
			<td><a href=\"viewA.php?event_id=$row[rNumber]\">Update / View </a></td>
			<td><a href=\"javascript: if (window.confirm('Delete Applicant from database?')) 
			document.location = '$GLOBALS[PHP_SELF]?event_id=$row[rNumber]&actionflag=1';\">";
		print "delete</a></td>";
		print "<td><a href=\"javascript: if (window.confirm('Change applicant to student?')) 
			document.location = '$GLOBALS[PHP_SELF]?event_id=$row[rNumber]&actionflag=2';\">";	
		print "Change Applicant to Student</a></td>";
		print "<tr>\n";

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



function deleteApplicant($id)
{
	global $dbVar;
	$dbVar->deleteApplicant($id);
}

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

}

?>

