<?php include("header.php"); ?>
<!--for the datepicker-->
<script type="text/javascript" charset="utf-8">
jQuery(function($){
$(".birthdate").datepicker(
{
yearRange: '1950:1993',
changeYear: true

});
});
</script>

<?php
$emp_id = $_POST['id'];
?>
<?php $emps = mysql_query("SELECT * FROM employees where emp_id = '$emp_id'") or die(mysql_error());  ?>

			<?php $emp = mysql_fetch_array($emps);
				$id = $emp['emp_id'];
				$first_name = $emp['first_name'];
				$middle_initial = $emp['middle_initial'];
				$gender = $emp['gender'];
				$last_name = $emp['last_name'];
				$street = $emp['street'];
				$city = $emp['city'];
				$province = $emp['province'];
				$birthdate = $emp['birthdate'];
				$status = $emp['status'];
				$philhealth = $emp['philhealth'];
				$sss = $emp['sss'];
				$control = $emp['control'];
				$position = $emp['position'];
				$email = $emp['email'];
				$contact = $emp['contact'];
				$contact_per = $emp['contact_per'];
				$assignment = $emp['assignment'];
				$skills = $emp['skills'];
				$image = $emp['image'];
				$ranking = $emp['ranking'];

			?>
<title>Modify Employee</title>
</head>
<body class="add_employee 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 Employee</h2>
	<!--for history log-->
	<input type="hidden" value="modified employee" name="action">
	<!--begin form-->
	
	
	<input class="id" value="<?php echo $id; ?>" type="hidden"/>
	<!--<div class="field"><label>Image </label> <a href="update_emp_photo.php?id=<?php echo $id ?>"><img src="images/uploads/<?php echo $image; ?>" height="150" width="150" /></a></div>	
	-->
	<div class="field"><label>Firstname </label> <input class="first_name" value="<?php echo $first_name; ?>"  name="firstname" size="30=" value="<?php echo $first_name; ?>" name="firtname" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Middle Initial </label><select name="middle_initial" class="middle_initial" >
		<option><?php echo $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="last_name" value="<?php echo $last_name; ?>" name="last_name" size="30" type="text" class="medium" /></div>

	<div class="field"><label>Gender </label>
		<select name="gender" class="gender" >
		<option>Female</option>
		<option>Male</option></select></div>
	<div class="field"><label>Street</label> <input class="street" value="<?php echo $street; ?>" name="street" size="30" type="text" class="medium" /></div>
	<div class="field"><label>City </label> <input class="city" value="<?php echo $city; ?>" name="city" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Province </label> <input class="province" value="<?php echo $province; ?>" name="province" size="30" type="text" class="medium" /></div>	
	<div class="field"><label>Date of Birth </label><input class="birthdate" value="<?php echo $birthdate; ?>" name="birthdate" size="30" type="text" class="medium" /><img src="images/calendar.png"></div>
	<div class="field"><label>Status </label> 
		<select name="status" class="status" ><option>Single</option>
		<option>Married</option>
		<option>Widowed</option>
		<option>Divorced</option></select></div>
	<div class="field"><label>Philhealth </label> <input class="philhealth" value="<?php echo $philhealth; ?>" name="philhealth" size="30" type="text" class="medium" /></div>
	<div class="field"><label>SSS Number </label> <input class="sss" value="<?php echo $sss; ?>" name="sss" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Control Number </label> <input class="control" value="<?php echo $control; ?>" name="control" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Position </label> 
		<select name="position" class="position" >
		<option>Administrator</option>
		<option>Janitorial Staff</option>
		<option>Manager</option>
		<option>Office Staff</option>
		<option>Security Guard</option>
		<option>Supervisor</option>
		<option>Technical Staff</option></select></div>
	<div class="field"><label>Email Address </label> <input class="email" value="<?php echo $email; ?>" name="email" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Contact Number </label> <input class="contact" value="<?php echo $contact; ?>" name="contact" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Contact Person </label> <input class="contact_per" value="<?php echo $contact_per; ?>" name="contact_per" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Skills </label> 
	<select name="skills" class="skills">
	<option>Choose Skill</Option>
	<option>Airports</Option>
	<option>Banks</Option>
	<option>Escorts</Option>
	<option>Homes</Option>
	<option>Malls</Option>
	<option>Private Firms</Option>
	<option>Restaurants</Option>
	<option>Schools</Option>
	<option>Supermarkets</Option></select></div>
	
	
	
	
	<div class="field"><label>Rating</label>
	<input class="ranking" name="ranking" value="<?php echo $ranking; ?>" type="hidden" id="backing6">
            <div id="rateit" class="rateit bigstars" data-rateit-starwidth="32" data-rateit-starheight="32" >
            </div>
			<script type="text/javascript">
                $(function () { $('#rateit').rateit({ max: 5, step: 0.25, backingfld: '#backing6' }); });
            </script>
			</div>	
	<div class="field"><button id="updateemp" name="SubmitOne">Save Changes</button></div>
	</div>
	
	</div>
	
	</div>
<?php include("footer.php"); ?>
</div>
<input type="hidden" class="pc_date">
<input type="hidden" class="pc_time">
</body>
</html>
<script type="text/javascript">
jQuery(document).ready( function () {

/*  validation
	var first_name = jQuery('.first_name').val();
	var last_name = jQuery('.last_name').val();		
	
	if(first_name && last_name){
	
	 */
			/* 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*/	

$(".email").change( function() {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var email = jQuery('.email').val();
		if(!emailReg.test(email)){
					alert('Please enter a valid email adderess.');
				}
		return false;
	});


jQuery('#updateemp').click( function(){
	
		var id = $(".id").val();
		var first_name = $(".first_name").val();
		var last_name = $(".last_name").val();
		var middle_initial = $(".middle_initial").val();
		var gender = $(".gender").val();
		var street = $(".street").val();
		var city = $(".city").val();
		var province = $(".province").val();
		var birthdate = $(".birthdate").val();
		var status = $(".status").val();
		var philhealth = $(".philhealth").val();
		var sss = $(".sss").val();
		var control = $(".control").val();
		var position = $(".position").val();
		var email = $(".email").val();
		var contact = $(".contact").val();
		var contact_per = $(".contact_per").val();
		var skills = $(".skills").val();
		var ranking = $(".ranking").val();
if (first_name && last_name && middle_initial && gender && street && city && province && birthdate && status && philhealth && sss && control && position && email && contact && contact_per && skills && ranking)
{		
		jQuery.ajax({
		type: "POST",
		data: ({id:id,first_name: first_name,last_name: last_name,middle_initial: middle_initial,gender: gender, 
				street: street,city: city, province: province,birthdate: birthdate,status:status, 
				philhealth: philhealth, sss: sss,control:control, position: position, email: email, 
				contact: contact, contact_per: contact_per, skills: skills,ranking:ranking,pc_date:pc_date,pc_time:pc_time}),
		url:"update_emp.php",
		success: function(msg) {
		showNotification({
message: "Employee'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_emp_list.php';}, delay);
<!--redirection end -->	
}
});
} else {
alert('All fields are required!');
return false;
}
});

});

</script>