<?php
include("../include/session.php");  
include("permission.class.php");
require_once("../include/accessCheck.php");

if(!$session->logged_in || $session->userlevel!=1)     //Not logged in or not Super Admin
{
    echo accessDeniedMsg;
    exit;
}

if (isset($_GET['page'])){ //find out what the sub page is
	$page = $_GET['page'];
	}
else{$page = 'display';}

global $pageNum;
if(isset($_GET['pageNum']))
        $pageNum=$_GET['pageNum']; //Get the current page number
    else
        $pageNum=1;
		

function displayPermission(){
	global $pageNum;
$result=permission::showAllAdmins();
$nrResults = mysql_numrows($result);
//paging code below
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     
$limit=20; // Limit of result per page 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  

$result =permission::showAllAdmins($pageNum,$limit);
$num_rows = mysql_numrows($result);

if(!$result || ($num_rows < 0)){
echo "Error displaying info";
return;
}
if($num_rows == 0){
echo "Database table empty";
return;
}

/* Display table contents */
echo "<table  cellspacing=\"3\" cellpadding=\"2\">";
echo "<tr><th><b>Administrator Name</b></th><th><b>Action</b></th></tr>\n";
for($i=0; $i<$num_rows; $i++){
    
$AdminID  = mysql_result($result,$i,"AdminID");
$AdminFName  = mysql_result($result,$i,"firstName");
$AdminLName  = mysql_result($result,$i,"lastName");

echo '<tr><td class="'.($i%2? "c1":"c2").'">'.$AdminLName. "  " .$AdminFName. '</td>';

echo '<td class="'.($i%2? "c1":"c2").'"><a href="organizationPermission.php?id='.$AdminID.'"> Organization Permission</a> / 
		<a href="applicationPermission.php?id='.$AdminID.'">Application Permission </td>';    
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    

permission::displayPageNav($nrResults,$limit,$pageNum,$_SERVER['PHP_SELF']);

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="../style.css"/>       


</head>
<body >

<div id="layout">
	<?php require('../include/header.php');   ?>
	 <P class=veryLargeBlue>Manage Permission</P>
	<?php
		displayPermission();

	?>
	
	
<?php require('../include/footer.php'); ?>
</div>
<?php
 unset($_SESSION['error_array']); 
?>
</body>
</html>
