<?php include("header.php"); ?>
<!--for the datepicker-->
<script type="text/javascript" charset="utf-8">
jQuery(function($){
$(".transact_from").datepicker();
});
jQuery(function($){
$(".transact_to").datepicker();
});
</script>

<?php
$mon_id = $_POST['id'];

?>

<?php $monitoring = mysql_query("SELECT * FROM monitoring where guards = '$mon_id'") or die(mysql_error());  ?>

			<?php $mon = mysql_fetch_array($monitoring);
				$id = $mon['trans_id'];
				$transact_from = $mon['transact_from'];
				$transact_to = $mon['transact_to'];
				$guards = $mon['guards'];
				$client = $mon['client'];
				$equipments = $mon['equipments'];
			?>
<title>Modify Transaction</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>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 Monitoring</h2>
	<form id="update-mon">
	<!--for history log-->
			<input type="hidden" class="pc_date" name="pc_date"/>
			<input type="hidden" class="pc_time" name="pc_time"/>
			<input type="hidden" class="user" 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>Transaction Period</label>
		<input class="transact_from" value="<?php echo $transact_from; ?>" name="transact_from" size="30" type="text" class="medium" /><img src="images/calendar.png">
		<input class="transact_to" value="<?php echo $transact_to; ?>" name="transact_to" size="30" type="text" class="medium" /><img src="images/calendar.png"></div>

	<div class="field"><label>Assigned Guard</label><input type="text" class="guards" name="guards" value="<?php echo $guards; ?>" /></div>


	<div class="field"><label>Client-in-Authority </label><input type="text" class="client" name="client" value="<?php echo $client; ?>" /></div>	
	<div class="inc2">
	<div class="field"><label>Equipments</label>
	<input type="text" class="equipments" name="equipments" value="<?php echo $equipments; ?>" />
	<!--<button type="submit" id="append_equip" name="add_equip">Add Equipment</button></div>
	<?php $wordChunks = explode(",", $equipments);
	for($i = 0; $i < count($wordChunks); $i++){
	echo "<div class='field'><label>&nbsp;</label><select class='equipments' name='equipments[]'><option value ='$wordChunks[$i]'>$wordChunks[$i]</option>"; equips(); echo "</select><a href='#' class='remove_this' border='2'>remove</a></div>";
	}
	?>
	</div> -->
<!-- 	<div class="field"><label>Ranking</label>
	<input class="ranking" name="ranking" value="<?php echo $ranking; ?>" type="hidden" id="backing6">
            <div id="rateit6">
            </div>
			<script type="text/javascript">
                $(function () { $('#rateit6').rateit({ max: 5, step: 0.25, backingfld: '#backing6' }); });
            </script>
			</div>	 -->
	
	<div class="field"><button id="update-mon" name="SubmitOne">Save Changes</button></div>
	</form>
	</div>
	
	</div>
	
	</div>
<?php include("footer.php"); ?>
</div>

</body>
</html>
<script type="text/javascript">
jQuery(document).ready( function () {
			/* local time*/
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-mon').submit(function(e){
var transact_from = jQuery('.transact_from').val();
var transact_to = jQuery('.transact_to').val();
var client = jQuery('.client').val();
var type = jQuery('.type').val();
var type = jQuery('.type').val();

    e.preventDefault();
if (guards && transact_from && transact_to && client && type)	{	
    var formData = jQuery(this).serialize();
    jQuery.ajax({
        type: 'POST',
        url:  'update_mon.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
});
<!--redirection -->
	 var delay = 3000;
		setTimeout(function(){ window.location = 'view_monitoring_list.php';}, delay); 
<!--redirection end -->	
        }
    });
} else {
alert('All fields are required!');
return false;
}		
});

});

</script>