<?php include("header.php"); ?>
<title>List of Transactions</title>
<style type="text/css" title="currentStyle">
			@import "css/table/demo_page.css";
			@import "css/table/demo_table_jui.css";
			@import "css/table/jquery-ui-1.8.4.custom.css";
		</style>
		<script type="text/javascript" language="javascript" src="js/table/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="utf-8">
			jQuery(document).ready(function() {
				oTable = jQuery('#monitor').dataTable({
					"bJQueryUI": true,
					"sPaginationType": "full_numbers"
								} );
				});		
		</script>
</head>
<body class="view_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="actions">
			<h2>Transaction List
			
			<!-- hide actions for user access level-->
			<?php if($_SESSION['user_type'] != 'User'){ ?>
			
			<?php } ?>
			<!-- hide actions for user access level-->
		
			| <!-- call for pdf print --> <a href="mpdf51/examples/monitoring_pdf.php"><img src="images/printer.jpg"></a></h2>

		
		
		
		<div class="demo_jui">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="monitor" class="jtable">
	<thead>
		<tr>
			<th>Control Number</th>
			<th>Employee</th>
			<th>Status</th>
			<!-- hide actions for user access level-->
			<?php if($_SESSION['user_type'] != 'User'){ ?><th>Actions</th><?php } ?>
			<!-- hide actions for user access level -->
		</tr>
	</thead>
	<tbody>
			<?php $monitor = mysql_query("SELECT * FROM employees WHERE type='guard' ") or die(mysql_error());  ?>
			<?php WHILE($mon = mysql_fetch_array($monitor)){
				$id = $mon['emp_id'];
				$name = $mon['first_name'] ." ".$mon['middle_initial']." ".$mon['last_name'];
				$assignment = $mon['assignment'];
				$date = $mon['transact_from'] . " - <br />" . $mon['transact_to'];
				?>
				
			<tr class="gradeA del<?php echo $id;?>">
				<td><?php echo $id; ?></td>
				<td><?php echo $name; ?></td>
				<td class="change<?php  echo $id; ?>"><?php echo $assignment; ?></td>
				<!-- hide actions for user access level-->
				<?php if($_SESSION['user_type'] != 'User'){ ?>
				<!-- hide actions for user access level-->
				<td style="width:110px;">
				
				<div class="link">
				<input type="hidden" value="<?php  echo $id; ?>" name="id" />
				<a href="view_mon.php<?php echo '?id='; echo $id; ?>">
				View<height="30" alt = "view" title = "view"/></a> |
				
				
				<a id="<?php echo $id; ?>" class="delete">Open</a>
				</div>
				
				<div>
				
				<form action="add_monitoring.php" method="POST" >
				<input type="hidden" name="id" value="<?php echo $id; ?>" /> 
				<input type="hidden" name="name" value="<?php echo $name; ?>" /> 
				<input type="submit" value="Assign " name="submit" />
				<!--<input type="image" src ="" value="Assign" name="submit" /> -->
				</form>
				
			
				<form action="modify_mon.php" method="POST">
				<input type="hidden" name="id" value="<?php echo $id; ?>" /> 
				<input type="submit" value=" Modify " />
				</form>
				
				</div>
				
				<?php } ?>
				</td>
				</tr>
			<?php } ?>
	</tbody>
</table>
</div>
		</div>
	
	</div>
<?php include("footer.php"); ?>
</div>
			<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">
</body>
</html>
<script type="text/javascript">
	$(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*/	
		
		$('.delete').click( function() {
		
		var id = $(this).attr("id");
		
		if(confirm("Are you sure you want to set the status to Open Availability?")){
						
			var pc_date = jQuery('.pc_date').val();
			var pc_time = jQuery('.pc_time').val();
			var user = jQuery('.user').val();
		
			$.ajax({
			type: "POST",
			url: "delete_mon.php",
			data: ({id: id, pc_date:pc_date, pc_time:pc_time,user:user}),
			cache: false,
			success: function(html){
			$(".change"+id).html('');
			$(".change"+id).html('Opened Availabilty');
			}
			}); 
			}else{
			return false;}
		});				
	});

</script>
