<?php
session_start();

include "../functions.php";
checkAdmin(session_id());

if ($_POST["confirm"] == 1)
{
	$staffid = $_POST["staffid"];
	
	$query = "delete from staff where staffid='$staffid'";
	mysql_query($query) or die (mysql_error());
	mysql_query("delete from move, move_staff where move.moveid=move_staff.moveid and move_staff.staffid=$staffid");
	mysql_query("delete from move_staff where staffid=$staffid");
	mysql_query("delete from roombook where staffid=$staffid");
	header ("location: staff.php");
}
?>

<?php
include "header.php";
$staffid = $_POST["staffid"];

$query = "select firstname, lastname from staff where staffid='$staffid'";
//echo $query;
$result = mysql_query($query) or die (mysql_error());
if ($row = mysql_fetch_array($result))
{
	$firstname = $row[0];
	$lastname = $row[1];
}
?>
<center>
<table>
  <tr>
    <td align="center">Are you sure you want to delete the staff: <b><?php echo "$firstname, $lastname"; ?></b>?
  </tr>
  
  <tr>
    <td align="center"><form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"><input type="hidden" name="confirm" value="1"><input type="hidden" name="staffid" value="<?php echo $staffid; ?>"><input type="submit" value="Yes"></td></form>
  </tr>
  
  <tr>
    <td align="center"><form action="staff.php" method="get"><input type="submit" value=" No "></td></form>
  </tr>
</table>
</center>

<?php
include "footer.php";
?>