<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<?php
include ("../navigation/header.php");
$page_name = "AD-remove user";
include ("../navigation/access.php");

$s= $_GET["s"];

if ($s==1) {
	$userid= $_GET["user_select"];
}
else {
	$userid="";
}


$table_name = $_SESSION['db_prefix']."_users";
$select_query = "SELECT userid, username FROM $table_name ORDER BY username";
	$arrId = array ();
	$arrName = array ();
	$select_result = execsql($select_query);
	$select_num = mysql_num_rows($select_result);
	$a = 0;
	while ($a < $select_num) {
		$arrId[$a] = mysql_result($select_result, $a, "userid");
		$arrName[$a] = mysql_result($select_result, $a, "username");
		$a++;
	}
if ($s==1) {	
$table_name = $_SESSION['db_prefix']."_users";
$name_query = "SELECT  username FROM $table_name WHERE userid='".$userid."' ";
	$name_result = execsql($name_query);
	$user_name = mysql_result($name_result, 0, "username");
}
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>

</head>
<body>
<?php 
if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>


<div class="main_frame">
<table id="tableMain" > <!--begin of tableMain-->
    <tr>
      <td width="830" height="125" valign="top" >
  <div class="page_head_frame">
    <table width="809" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="385"><label class="label_page_head">Remove user</label></td>
        <td align="right">&nbsp;</td>
      </tr>
    </table>
  </div><br />
<br />

  <div class="page_middle_frame">
  <table width="650" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="62" height="52"></td>
      <td width="645" height="52"><div class="page_inside_frame">
        <form name="form1" id="form1" action="remove_user.php" method="get">
          <label class="std">Select a user to remove:&nbsp;&nbsp;&nbsp;&nbsp;</label>
          <select name="user_select" class="selectbox120" onchange="window.location.href= this.form.user_select.options[this.form.user_select.selectedIndex].value" >
            <option value=""></option>
            <?php
        	for ($i = 0; $i < count($arrId); $i++) {
    		  echo "<option value=remove_user.php?user_select=".$arrId[$i]."&s=1>".$arrName[$i]."</option>";
	}
?>
          </select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </form>
        <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("user_select","req","Please select user.");
      </script>
      </div>
        <br />
        <br />
        <br /><br />
<br />
<?php if ($s==1) { ?>
        <div class="page_inside_frame">
            <label class="label_std">If you remove the user, the user will be permantly be removed from the system. This action cannot be undone.<br />
            </label>
            <br /><br />


            <label class="label_std">To remove user:&nbsp;<font size="3"><b>"<?php echo $user_name ?>"</b></font> &nbsp;&nbsp;&nbsp;&nbsp;click </label>&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="remove_button" type="button" class="imagebutton" id="remove_button" value="Remove" onclick="MM_goToURL('parent','save_remove_user.php?userid=<?php echo $userid ?>');return document.MM_returnValue"/>
            <input name="cancele_button" type="button" class="imagebutton" id="cancel_button" value="Cancel" onclick="MM_goToURL('parent','remove_user.php?user_select=&s=0;');return document.MM_returnValue"/>
          
        </div>
        <?php } ?></td>
      <td width="43" height="52"></td>
    </tr>
  </table>
  </div>
  </td> 
      <!--center of tableMain-->
</tr>
<tr>
<td> <!--center of tableMain-->


  <p>&nbsp;</p>
</td>
</tr>
</table>  <!--end of tableMain-->  
</div>


<?php include ('../navigation/side_bar.php'); ?>
</body>

<?php } else {
    $_SESSION['denied_return'] = "admin_module/user_list.php";	
    include ("../navigation/admin_sidebar.php");
	include ('../navigation/side_bar.php');?>
	<body onLoad="needToConfirm = false; accessdenied(); return false">	
	</body>
<?php }
?>
</html>