<?php


include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Member Successfully Deleted";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}

// DELETE BEGIN
if($_REQUEST[delete]=="true")
{
	$ADMINID = $_REQUEST['ADMINID'];
	if (is_numeric($ADMINID))
	{
		$sql="DELETE FROM administrators WHERE ADMINID='".mysql_real_escape_string($ADMINID)."'";
		$conn->Execute($sql);
		header("location: listadmins.php?update=success");
	}
}
// DELETE END

// SORT BEGIN
if($_REQUEST['sortby']=="username")
{
	$sort =" order by username";
}
elseif($_REQUEST['sortby']=="email")
{
	$sort =" order by email";
}
else
{
	$sort =" order by ADMINID";
}

if($_REQUEST['sorthow']=="desc")
{
	$sorthow ="desc";
}
else
{
	$sorthow ="asc";
}
// SORT END

$query="SELECT * FROM administrators $sort $sorthow";
$executequery = $conn->Execute($query);
$total = $executequery->recordcount()+0;
$members = $executequery->getrows();

STemplate::assign('total',$total+0);
STemplate::assign('members',$members);

Stemplate::assign('error',$error);
STemplate::display("administrator/listadmins.tpl");
?>