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

$s=1;
$e = $_GET["e"];
if ($e==0) {
	$message = "Enter a new user.";
}
else {
	$message = "<font color=red>User already registered, use a different name</font>";
}





?>

<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_name_text');
            txtbox.value = txtbox.value.replace(/\s/g, "");
			var txtbox2 = document.getElementById('user_password_text');
            txtbox2.value = txtbox2.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">New user</label></td>
        <td align="right">&nbsp;</td>
      </tr>
    </table>
  </div>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="right" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="right" valign="top">
      <div class="page_middle_frame">
      <?php if ($s==1) { ?> <div class="page_inside_frame">
        <form id="form1" name="form1" method="get" action="save_user.php">
          <br />
          <table width="300" border="0" cellspacing="0" cellpadding="0">
            <tr >
              <td height="40" colspan="2" align="left"><label class="label_std">Enter a user name and password for the new user.</label></td>
              </tr>
            <tr>
              <td width="127" height="40" align="left" ><label class="label_std">user name:<br /></label></td>
              <td width="173" ><input name="user_name_text" type="text" class="text150" id="user_name_text" onkeyup="ToLower(this);MM_callJS('removeWhitespaces()')" autocomplete="off"/>
                <br /></td>
              </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">password:<br /></label></td>
              <td ><input name="user_password_text" type="password" class="text150" id="user_password_text" onkeyup="MM_callJS('removeWhitespaces()')" autocomplete="off"/></td>
              </tr>
            <tr>
              <td height="40" align="left" ><label class="label_std">confirm password: &nbsp;</label><br /></td>
              <td ><input name="user_password_text2" type="password" class="text150" id="user_password_text2" autocomplete="off"/></td>
              </tr>
            <tr>
              <td colspan="2" align="center"><br />
                <br />
                <input name="button" type="submit" class="imagebutton" id="button" value="Add new user" onClick="needToConfirm = false; "/>
                <input name="button2" type="reset" class="imagebutton" id="button2" value="Cancel" onClick="needToConfirm = false; confirmRefresh();"/></td>
              </tr>
            </table>
         
        </form>
        </div>
        <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("user_name_text","req","Please enter a user name.");
  frmvalidator.addValidation("user_name_text","minlen=6","Mininum length for a user name is 6 characters.");
  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");
  frmvalidator.addValidation("user_password_text","neelmnt=user_name_text","The password should not be same as user name");
  </script>
      </div>
      <?php } ?><br />
<br />


   <?php    
   if ($s==2) { ?>
   <div class="standard_frame">
   The employee &nbsp;<font size="3"><b>"&nbsp;<?php echo $emp_name ?>&nbsp;"</b></font>&nbsp;is allready registered as a user under the name &nbsp;<font size="3"><b>"&nbsp;<?php echo $username ?>&nbsp;"</b></font>&nbsp;. <br /><br />

   Make a new selection to add an user to the system.
   </div><?php } ?>
   </td>
      </tr>
  </table>
  </td> 
      <!--center of tableMain-->
</tr>
<tr>
<td> <!--center of tableMain-->


  <p>&nbsp;</p>
</td>
</tr>
</table>  <!--end of tableMain-->  
</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>