<!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-reset password";
include ("../navigation/access.php");


$table_name = $_SESSION['db_prefix']."_users";
$select_query = "SELECT userid, username FROM $table_name WHERE username <> 'system_manager' ";
	$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++;
	}


?>

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>

<script language="JavaScript">
<!--
function confirmRefresh() {
var okToRefresh = confirm("Do you really want to cancel this entry?");
var url='user_list.php'
if (okToRefresh)
	{
			window.location=url;
	}
}
// -->
</script>

<script language="JavaScript">
  var needToConfirm = true;
  window.onbeforeunload = confirmExit;
   function confirmExit()
  {
    if (needToConfirm)
      return "You did not finish the wizard.\nIf you leave now your data will not be saved.";
  }
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>

<script type="text/javascript">
        function removeWhitespaces() {
            var txtbox = document.getElementById('user_password_text');
            txtbox.value = txtbox.value.replace(/\s/g, "");
        }
    </script>
</head>
<?php
if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>

<body>
<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">Reset password</label></td>
        <td align="right">&nbsp;</td>
      </tr>
    </table>
  </div>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <div class="standard_frame">
    <form id="form1" name="form1" method="post" action="save_reset_password.php">
      <label class="label_std">Select a user to reset password for &nbsp;&nbsp;&nbsp;&nbsp;</label>
      <select name="user_select" class="select_light">
        <option value=""></option>
        <?php
        	for ($i = 0; $i < count($arrId); $i++) {
    		echo "<option value=" . "\"" . $arrId[$i] . "\"" . ">" . $arrName[$i] . "</option>";
	   ?>
       
       <?php }
?>
      </select>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <label class="label_std"><br />
        
        <br />
        Enter new password here:</label>
      <br />
      <table width="300" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="127" height="40"><label class="label_std">password:</label>
            <br /></td>
          <td width="173"><input type="password" name="user_password_text" id="user_password_text" onkeyup="MM_callJS('removeWhitespaces()')"/></td>
        </tr>
        <tr>
          <td height="40"><label class="label_std">confirm password:</label>
            &nbsp;<br /></td>
          <td><input type="password" name="user_password_text2" id="user_password_text2" /></td>
        </tr>
        <tr>
          <td colspan="2" align="center"><br />
            <br />
            <input name="button" type="submit" class="std_button" id="button" value="Change password" onclick="needToConfirm = false; "/>
            <input name="button2" type="reset" class="std_button" id="button2" value="Cancel" onClick="needToConfirm = false; confirmRefresh();"/></td>
        </tr>
      </table>
    </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.");
  frmvalidator.addValidation("user_password_text","req","Please enter a password.");
  frmvalidator.addValidation("user_password_text2","req","Please re-type the password.");
  frmvalidator.addValidation("user_password_text","minlen=6","Mininum length for a password is 6 characters.");
  frmvalidator.addValidation("user_password_text","eqelmnt=user_password_text2","The confirmed password is not same as password");
  
  </script>
  </div></td>
</tr>
</table>  <!--end of tableMain--><p>&nbsp;</p>
  
</div>
</body>

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

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