<?php

session_start();
include "../config.php";
include "../header.php";
include "../style.php";
if( isset($_SESSION["alogin"]) ) {
$sort = dbget($_GET['sortby']);

	if($sort == "id")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`id` ASC";
	}
	else if($sort == "ip")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`ip` ASC";
	}
	else if($sort == "name")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`name` ASC";
	}
	else if($sort == "username")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`username` ASC";
	}
	else if($sort == "memtype")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`memtype` ASC";
	}
	else if($sort == "contact_email")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`contact_email` ASC";
	}
	else if($sort == "joindate")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`joindate` ASC";
	}
	else if($sort == "deleted")
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`deleted` ASC";
	}
	else
	{
		$query = "SELECT * FROM `leaves` ORDER BY `leaves`.`deleted` ASC";
	}
	
	$result = mysql_query ($query)
	     or die ("Query failed");
       $num_rows = mysql_num_rows($result);
    	?><table>
      	<tr>
        <td width="15%" valign=top><br>
        <? include("adminnavigation.php"); ?>
        </td>
        <td valign="top" align="center"><br><br> <?
	echo "<font size=3 face='$fonttype' color='$fontcolour'><p><center>";
	echo "<center>The Deleted Members Area</center>";
    echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
    echo "<center><p><b>";
    echo "$num_rows Results found<br><br>";
	
	echo mysql_result(mysql_query("SELECT COUNT(*) FROM leaves WHERE memtype = 'PRO'"),0). " Pro Members<br>";
	echo mysql_result(mysql_query("SELECT COUNT(*) FROM leaves WHERE memtype = 'JV Member'"),0). " JV Members<br>";
	echo mysql_result(mysql_query("SELECT COUNT(*) FROM leaves WHERE memtype = 'SUPER JV'"),0). " Super JV Members<br>";
	
    echo "</center></p></b>";
    ?>
    <table width=70% border=0 cellpadding=2 cellspacing=2>


  		<tr>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=name">Name</a> </font></center></td>
		  <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=username">UserName</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=userid">Userid</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=memtype">Membership</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=email">E-mail</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> Reason </font></center></td>
		  <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=ip">IP</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=joindate">Join Date</a> </font></center></td>
          <td bgcolor="<? echo $contrastcolour; ?>"><center><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"> <a href="deleted_members.php?sortby=deleted">Delete Date</a> </font></center></td>
        </tr>
    <?

    while ($line = mysql_fetch_array($result)) {
		$name = $line["name"];
		$username = $line["username"];
        $userid = $line["id"];
		$memtype = $line["memtype"];
		$reason = dbget($line["reason"]);
	    $contactemail = dbget($line["contact_email"]);
		$ip = $line["ip"];
        $joindate = $line["joindate"];
        $deletedate = $line["deleted"];
        
        ?>
  		<tr>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $name; ?></font></center></td>
		  <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $username; ?></font></center></td>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $userid; ?></font></center></td>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $memtype; ?></font></center></td>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $contactemail; ?></font></center></td>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $reason; ?></font></center></td>
          <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $ip; ?></font></center></td>
		  <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $joindate; ?></font></center></td>
		  <td bgcolor="<? echo $basecolour; ?>"><font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><center><? echo $deletedate; ?></font></center></td>
          <!--<td valign="middle" bgcolor="<?// echo $basecolour; ?>"><center><br>
          <form method=POST action=edit.php>
          <input type="hidden" name="userid" value="<?// echo $userid; ?>">
          <input type="submit" value="Edit">
          </form> </center>
          </td>-->


          	<td bgcolor="<? echo $basecolour; ?>" valign="middle"><center><br>
          	<form method="POST" action="deleteds/delete_deleteds.php">
          	<input type="hidden" name="userid" value="<? echo $userid; ?>">
          	<input type="submit" value="Delete">
          	</form> </center>
          	</td>
        	</tr>
        <? 
     }
     echo "</table></td></tr></table>";
  	}
else  {
	echo "Unauthorised Access!";
    }

include "../footer.php";
mysql_close($dblink);
?>