<?php include("header.php"); ?>
<script type="text/javascript" charset="utf-8">
jQuery(function($){
$(".permit_from").datepicker();
});
jQuery(function($){
$(".permit_to").datepicker();
});
</script>
<?php
$_POST['id'];

$equip_id = $_POST['id'];

?>

<?php $equips = mysql_query("SELECT * FROM equipments where equip_id = '$equip_id'") or die(mysql_error());  ?>

			<?php $equip = mysql_fetch_array($equips);
				$id = $equip['equip_id'];
				$name = $equip['name'];
				$brand = $equip['brand'];
				$model = $equip['model'];
				$cal = $equip['cal'];
				$type = $equip['type'];
				$serial = $equip['serial'];
				$qty = $equip['quantity'];
				$price = $equip['price'];
				$license = $equip['license'];
				$permit_from = $equip['permit_from'];
				$permit_to = $equip['permit_to'];
				$guards = $equip['guards'];
				$image = $equip['image'];
				$license_image = $equip['license_pic'];

			?>
<script type="text/javascript">

$(document).ready( function () {
<!-- add this if my serialize -->
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 -->
$("#append").click( function() {
		$(".inc").append('<div class="field"><label>&nbsp;</label><select class="guards" name="guards[]"><?php  guards(); ?></select><a href="#" class="remove_this">remove</a></div>');
		return false;
	});
	
$("#append_equip").click( function() {
		$(".inc2").append('<div class="field"><label>&nbsp;</label><select class="equipments" name="equipments[]"><?php  equips(); ?></select><a href="#" class="remove_this">remove</a></div>');
		return false;
	
	});		
	
// using live() will bind the event to all future
// elements as well as the existing ones
$('.remove_this').live('click', function() {
    $(this).parent().remove();
    return false;
});
	


jQuery('#update-equip').submit(function(e){
    e.preventDefault();
    var formData = jQuery(this).serialize();
    jQuery.ajax({
        type: 'POST',
        url:  'update_equip.php', /*  <--- diri na makadto ang time and date kung serialize <3 */
        data: formData,
        success: function(msg){
            showNotification({
message: "Equipment Successfully Updated",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
		var delay = 3000;
		setTimeout(function(){ window.location = 'view_equip_list.php';}, delay);  
       
        }
    });
});
});

</script>			
<title>Modify Equipment</title>
</head>
<body class="add_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>Records</h1>
<?php include("records_sidebar.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 Equipment</h2>
	<form id="update-equip">
	<!--diri na di makadto -->	
	<input type="hidden" class="pc_date" name="pc_date" >
	<input type="hidden" class="pc_time" name="pc_time" >
	<!-- call na lang daun sa saving -->
	<input type="hidden" value="<?php echo $_SESSION['user_name']; ?>" name="user">
	<input class="id" value="<?php echo $id; ?>"  name="id" size="30" type="hidden"/>
	<div class="field"><label>Name</label> <input class="name" value="<?php echo $name; ?>" name="name" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Type</label><select name="type" class="type" >
		<option>Office</option>
		<option>Biometrics</option>
		<option>FireArms</option></select>
	</div>
	<div class="field"><label>Serial Number</label> <input class="serial valid" value="<?php echo $serial; ?>"  name="serial" size="30" type="text" class="medium"  /></div>
	<div class="field"><label>Model</label> <input class="model" value="<?php echo $model; ?>"  name="model" size="30" type="text" class="medium"  /></div>
	<div class="field"><label>Kind</label> <input class="brand" value="<?php echo $brand; ?>" name="brand" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Caliber</label> <input class="cal" value="<?php echo $cal; ?>" name="cal" size="20" type="text" class="medium" /></div>
	<div class="field"><label>Quantity</label> <input class="quantity" value="<?php echo $qty; ?>" name="quantity" size="30" type="text" class="medium" />
	</div> 
	
	<div class="field"><label>Price</label> <input class="price" name="price" value="<?php echo $price; ?>"  size="30" type="text" class="medium" /></div>
	<div class="field"><label>License</label> <input class="license" value="<?php echo $license; ?>" name="license" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Permit Validity</label> <input class="permit_from " value="<?php echo $permit_from; ?>" name="permit_from" size="30" type="text" class="medium" />to<input class="permit_to" value="<?php echo $permit_to; ?>" name="permit_to" size="30" type="text" class="medium" /></div>
	
		<!--<div class="field"><label>Equipment Image</label><a href="update_image.php?id=<?php echo $id; ?>"><img src="images/uploads/<?php echo $image; ?>" width="150" height="150" /></a></div>
	-->
	<div class="field"><label></label><button id="updateequip" name="SubmitOne">Save Changes</button></div>
	</form>
	</div>
	
	</div>
	
	
<?php include("footer.php"); ?>
</div>
</body>
</html>