<?php include("header.php"); ?>
<?php
$_GET['id'];
$user_id = $_GET['id'];
?>

<?php $users = mysql_query("SELECT * FROM users where user_id = '$user_id'") or die(mysql_error());  ?>

			<?php $mems = mysql_fetch_array($users);
				$id = $mems['user_id'];
				$first_name = $mems['first_name'];
				$middle_initial = $mems['middle_initial'];
				$last_name = $mems['last_name'];
				$username = $mems['username'];
				$password = $mems['password'];
				$user_type = $mems['user_type'];
				$photo = $mems['photo'];

			?>
<title>Modify User</title>
</head>
<body class="modify_user standard">
<div class="wrapper">

	<div class="header">
	<h1>Lifeguard Archangels Security Corporation</h1>
	</div>
<?php include("main_menu.php"); ?>
	<div class="right_nav">
	<h1>Profiles</h1>
<?php include("right_nav.php"); ?>
	</div>
	<div class="content">
	<div class="title_page">
	</div>
	
	<div class="actions">

	<div class="form label-inline uniform" id="shadow" style="width: 700px; margin:0 auto;" >
	<h2>Modify User</h2>
	<!--for history log-->
	<input type="hidden" class="action" value="modified user" name="action">

							
	<input class="id" value="<?php echo $mems['user_id']; ?>"  name="id" size="30" type="hidden"/>
	<div class="field"><label>Firstname</label> <input class="firstname" value="<?php echo $first_name; ?>" name="firstname" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Middle Initial </label>
		<select name="middle_initial" class="middle_initial" >
		<option>Choose Middle Initial</option>
		<option>A</option>
		<option>B</option>
		<option>C</option>
		<option>D</option>
		<option>E</option>
		<option>F</option>
		<option>G</option>
		<option>H</option>
		<option>I</option>
		<option>J</option>
		<option>K</option>
		<option>L</option>
		<option>M</option>
		<option>N</option>
		<option>O</option>
		<option>P</option>
		<option>Q</option>
		<option>R</option>
		<option>S</option>
		<option>T</option>
		<option>U</option>
		<option>V</option>
		<option>W</option>
		<option>X</option>
		<option>Y</option>
		<option>Z</option>
		</select></div>
	<div class="field"><label>User Type</label>
	<select class="lastname">
	<option value="<?php echo $user_type; ?>"><?php echo $user_type; ?></option>
	<option value="Administrator">Administrator</option>
	<option value="User">User</option>
	</select>
	</div>
	
	<div class="field"><label>Lastname</label> <input class="lastname" value="<?php echo $last_name; ?>" name="firstname" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Username</label> <input class="username" value="<?php echo $username; ?>" name="firstname" size="30" type="text" class="medium" /></div>
	<div class="field"><label>&nbsp;</label> <a href="#" id="change_pass">change password</a></div>
	
	<div class="change_pass" >
	<div class="field"><label>Old Password</label> <input class="firstname" value="" name="old_password" size="30" type="password" class="medium" /></div>
	<div class="field"><label>New Password</label> <input class="password" value="" name="password" size="30" type="password" class="medium" /></div>
	</div>
	<div class="field"><button id="updateuser" name="SubmitOne">Save Changes</button></div>
	</div>
	
	</div>

</div>
<?php include("footer.php"); ?>
<input type="hidden" class="pc_time" />
<input type="hidden" class="pc_date" />
</body>
</html>

<script type="text/javascript">
jQuery(document).ready( function () {

jQuery('.change_pass').hide();
jQuery('#change_pass').click( function(){
jQuery('.change_pass').slideToggle();
});

/* amo ni*/
var myDate = new Date();
var pc_date = (myDate.getMonth()+1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
var pc_time = myDate.getHours()+':'+myDate.getMinutes()+':'+myDate.getSeconds();
jQuery(".pc_date").val(pc_date);
jQuery(".pc_time").val(pc_time);
/*asta d*/	
jQuery('#updateuser').click( function(){
	
		var id = $(".id").val();
		var first_name = $(".firstname").val();
		var last_name = $(".lastname").val();
		var middle_initial = $(".middle_initial").val();
		var username = $(".username").val();
		var password = $(".password").val();
		var action = $(".action").val();
		var pc_date = $(".pc_date").val();
		var pc_time = $(".pc_time").val();
		jQuery.ajax({
		type: "POST",
		data: ({id:id,first_name: first_name,last_name: last_name,middle_initial: middle_initial, username: username,password: password, action:action,pc_date:pc_date, pc_time:pc_time}),
		url:"update_user.php",
		success: function(msg) {
		showNotification({
message: "User's Profile Successfully Updated",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
<!--redirection -->
		 var delay = 3000;
		setTimeout(function(){ window.location = 'view_user.php';}, delay);  
<!--redirection end -->	
}
});

});

});

</script>	