<?php 
include_once 'includes/processes.php';
$Process = new Login_Process;

$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);

$addEmployee = $Process->addEmployee($_POST,$_POST['add-user']);
$updateEmployee = $Process->updateEmployee($_POST,$_POST['update-user']);
$deleteEmployee = $Process->deleteEmployee($_POST,$_POST['delete-user']);
?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <title>Manage Users - APL Portal</title>

  <meta charset="utf-8">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width">

  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,400,600,700">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,300,700">
  <link rel="stylesheet" href="./css/font-awesome.min.css">
  <link rel="stylesheet" href="./js/libs/css/ui-lightness/jquery-ui-1.9.2.custom.min.css">
  <link rel="stylesheet" href="./css/bootstrap.min.css">

  <!-- Plugin CSS -->
  <link rel="stylesheet" href="./js/plugins/magnific/magnific-popup.css">

  <!-- App CSS -->
  <link rel="stylesheet" href="./css/target-admin.css">
  <link rel="stylesheet" href="./css/custom.css">


  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
  <![endif]-->
</head>

<body>

<?php include'includes/header.php'; ?>

<div class="container">

  <div class="content">

    <div class="content-container">

      

      <div class="content-header">
        <h2 class="content-header-title">Manage Users</h2>
        <ol class="breadcrumb">
          <li><a href="./">Home</a></li>
          <li class="active">Manage Users</li>
        </ol>
      </div> <!-- /.content-header -->

      

      <div class="row">
		 
        <div class="col-md-12">
			<?php echo $addEmployee; ?>
			<?php echo $updateEmployee; ?>
			<?php echo $deleteEmployee; ?>
		</div>
		
        <div class="col-md-12">
		
		 <div class="portlet">

            <div class="portlet-header">

              <h3>
                <i class="fa fa-ticket"></i>
                Manage Users
              </h3>
			  
			   <ul class="portlet-tools pull-right">
                <li>
                  <a data-toggle="modal" href="#newUserModal" class="btn btn-sm btn-default">
                    New User
                  </a>
                </li>
              </ul>

            </div> <!-- /.portlet-header -->

            <div class="portlet-content" style="font-size:11px">           
				<?php $Process->getUsers(); ?>
            </div> <!-- /.portlet-content -->

          </div> <!-- /.portlet -->

		  
        </div> <!-- /.col -->

      </div> <!-- /.row -->



      




    </div> <!-- /.content-container -->
      
  </div> <!-- /.content -->

</div> <!-- /.container -->
	<?php include"includes/footer.php"; ?>
	
	

   <div id="newUserModal" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3 class="modal-title"><i class="fa fa-user"></i> New User</h3>
      </div>
	  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		<div class="modal-body">
			<div class="row">
				<div class="form-group col-sm-12 col-sm-6">
					<label for="first-name">First name</label>
					<input type="text" id="first-name" name="first-name" class="form-control" required />
				</div>
				<div class="form-group col-sm-12 col-sm-6">
					<label for="last-name">Last name</label>
					<input type="text" id="last-name" name="last-name" class="form-control" required />
				</div>
				<div class="form-group col-md-6 col-sm-12">
					<label for="gender">Gender</label>
					<select class="form-control" id="gender" name="gender" required>
						<option value="">-- gender --</option>
						<option value="Male">Male</option>
						<option value="Female">Female</option>
					</select>
				</div>
				<div class="form-group col-sm-6">
					<label for="user-email">Email Address</label>
					<input type="email" id="user-email" name="user-email" class="form-control" required />
				</div>
				<div class="form-group col-sm-6">
					<label for="user-dept">User Department</label>
					<select class="form-control" id="user-dept" name="user-dept" required>
						<option value="">-- department --</option>
						<?php $Process->listDepartment(); ?>
					</select>
				</div>
				<div class="form-group col-sm-6">
					<label for="user-station">User Station</label>
					<select class="form-control" id="user-station" name="user-station" required>
						<option value="">-- station --</option>
						<?php $Process->listStation(); ?>
					</select>
				</div>
				<div class="form-group col-sm-6">
					<label for="user-phone">Phone Number</label>
					<input type="text" id="user-phone" name="user-phone" class="form-control" autocomplete="false" />
				</div>
				<div class="form-group col-sm-6">
					<label for="user-pass">Password</label>
					<input type="password" id="user-pass" name="user-pass" class="form-control" required />
				</div>
				<div class="form-group col-sm-6">
					<label for="role">User Access Role</label>
					<select class="form-control" id="role" name="role" required>
						<option value="">-- role --</option>
						<?php $Process->listRoles(); ?>
					</select>
				</div>
				<div class="form-group col-sm-6">
					<label for="send_details">Send Details to user</label>
					<select class="form-control" id="send_details" name="send_details">
						<option value="No">No, don't send details</option>
						<option value="Yes">Yes, send details</option>
					</select>
					<label class="checkbox-inline">
					  <input type="checkbox" id="inlineCheckbox1" name="send_me_copy" value="send_me_copy"> Send a copy to me
					</label>
				</div>
			</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			<button type="submit" name="add-user" class="btn btn-primary">Add User</button>
		</div>
	  </form>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>



<div id="editUserModal" class="modal fade">
	<div class="modal-dialog">
		<div class="modal-content">
		   
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
</div>

<div id="deleteUserModal" class="modal fade">
	<div class="modal-dialog">
		<div class="modal-content">
		   
		</div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
</div>

 <script src="./js/libs/jquery-1.10.1.min.js"></script>
  <script src="./js/libs/jquery-ui-1.9.2.custom.min.js"></script>
  <script src="./js/libs/bootstrap.min.js"></script>

  <!--[if lt IE 9]>
  <script src="./js/libs/excanvas.compiled.js"></script>
  <![endif]-->
  
  <!-- Plugin JS -->
  <script src="./js/plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="./js/plugins/datatables/DT_bootstrap.js"></script>
  <script src="./js/plugins/tableCheckable/jquery.tableCheckable.js"></script>
  <script src="./js/plugins/icheck/jquery.icheck.min.js"></script>

  <!-- App JS -->
  <script src="./js/target-admin.js"></script>
  <script>
  $(document).on("hidden.bs.modal", function (e) {
    $(e.target).removeData("bs.modal").find(".modal-content").empty();
	});
</script>
</body>
</html>
