<?php include("header.php"); ?>
<!-- upload -->
<script type="text/javascript" src="js/upload/jquery.form.js"></script>
<!-- upload -->
<title>Add User</title>
</head>
<body class="modify_user standard">
<div class="wrapper">

	<div class="header">
	<h1>Lifeguard Archangels Security Corportion</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>Add User</h2>
	<!--for history log-->
		<input type="hidden" value="added user" name="action">
		<input type="hidden" class="pc_date" name="date">
		<input type="hidden" class="pc_time" name="time">
		<input type="hidden" value="<?php echo $_SESSION['user_name']; ?>" name="user">
								
	<div class="field"><label>Firstname </label> <input class="firstname" 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>Lastname </label> <input class="lastname" name="lastname" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Username </label> <input class="username" name="username" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Password </label> <input class="password" name="password" size="30" type="password" class="medium" /></div>
	<div class="field"><label>User Type</label><select name="user_type" class="user_type" >
	<option>Administrator</option>
	<option>User</option>
	</select></div>
	<div class="field"><button id="save" name="SubmitOne">Save</button></div>
	</div>
	<form id="imageform" class="uploadthis" method="post" enctype="multipart/form-data" action='upload_user.php'>
Upload user image <input type="file" name="photoimg" id="photoimg" />
</form>
<div id='preview'>
</div>
	</div>

</div>
<?php include("footer.php"); ?>
</body>
</html>
<script type="text/javascript">
jQuery(document).ready( function () {
/* 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('#imageform').hide();
jQuery('#save').click( function(){


		/*  
	var first_name = jQuery('.first_name').val();
	var last_name = jQuery('.last_name').val();
	var username = jQuery('.username').val();
	var password = jQuery('.password').val();			
	
	
	if(first_name && last_name && username && password){
	 */
	
		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 user_type = $(".user_type").val();
		var user = $(".user").val();
		var pc_time = $(".pc_time").val();
		var pc_date = $(".pc_date").val();
if (first_name && last_name && middle_initial && username && password && user_type && user)	{	
		jQuery.ajax({
		type: "POST",
		data: ({first_name: first_name,last_name: last_name,middle_initial: middle_initial, username: username, password: password,user_type: user_type, user:user, pc_time:pc_time, pc_date:pc_date}),
		url:"save_user.php",
		success: function(msg) {
		showNotification({
message: "User Successfully Added",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
jQuery('#shadow').fadeOut();
jQuery('#imageform').fadeIn();
}
});
} else {
alert('All fields are required!');
return false;
}	

});

});

</script>	
<!-- upload -->
<script type="text/javascript" >
jQuery(document).ready(function() { 
		
            jQuery('#photoimg').live('change', function()			{ 
			           jQuery("#preview").html('');
			   jQuery("#preview").html('<img src="images/loader.gif" alt="Uploading...."/>');
			jQuery("#imageform").ajaxForm({
						target: '#preview'
		}).submit();
				 var delay = 3000;
		setTimeout(function(){ window.location = 'view_user.php';}, delay);  
			});
        }); 
</script>
<!-- upload end -->
