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

$equip_id = $_GET['id'];

?>

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

			<?php $equip = mysql_fetch_array($clients);
				$id = $equip['equip_id'];
				$name = $equip['name'];
				$brand = $equip['brand'];
				$model = $equip['model'];
				$type = $equip['type'];
				$qty = $equip['quantity'];
				$price = $equip['price'];
				$license = $equip['license'];
				$permit_from = $equip['permit_from'];
				$permit_to = $equip['permit_to'];
				$guards = $equip['guards'];

			?>
<script type="text/javascript">
$(document).ready( function () {
$("#append").click( function() {
		$(".inc").append('<div class="field"><label>&nbsp;</label><input class="guards" name="guards[]" size="30" type="text" class="medium" />'
						+'<a href="#" class="remove_this" border="2">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',
        data: formData,
        success: function(msg){
            showNotification({
message: "Client Successfully Updated",
type: "success", // type of notification is error/success/warning/information,
autoClose: true, // auto close to true
duration: 5 // message display duration
});
        }
    });
});
});

</script>			
<title>Modify Client</title>
</head>
<body class="add_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>Modify Client</h2>
	<form id="update-equip">						
	<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> <input class="type" value="<?php echo $type; ?>"  name="type" size="30" type="text" class="medium"  /></div>
	<div class="field"><label>brand</label> <input class="brand" value="<?php echo $brand; ?>" name="brand" size="30" 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" /></div>
	<div class="field"><label>Contact Number</label> <input class="permit_to" value="<?php echo $permit_to; ?>" name="permit_to" size="30" type="text" class="medium" /></div>
	<div class="field"><label>Assigned Guard(s)</label></div>
	<div class="inc">
	<?php $wordChunks = explode(",", $guards);
for($i = 0; $i < count($wordChunks); $i++){
	echo "<div class='field'><label>&nbsp;</label><input class='guards' type='text' name='guards[]' value='$wordChunks[$i]' size='30' class='medium' /><a href='#' class='remove_this' border='2'>remove</a></div>";
}
?>
</div>
<div class="field"><button type="submit" id="append" name="append">Add Guard</button><button id="updateclient" name="SubmitOne">Save Changes</button></div>
	</form>
	</div>
	
	</div>
	
	</div>
<?php include("footer.php"); ?>
</div>
</body>
</html>