<?php include("header.php"); ?>
<title>List of Equipments</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() {
	/* bwesit nga 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);
/* bwesit nga local time*/
				oTable = jQuery('#equip').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>Equipment List 
			
		<!-- hide actions for user access level-->
		<?php if($_SESSION['user_type'] != 'User'){ ?>
		| <a href="add_equip.php"><img src="images/add-icon.png" height="28"></a>
		<?php } ?>
		<!-- hide actions for user access level-->
		| <!-- call for pdf print --> <a href="mpdf51/examples/equipments_pdf.php"> <img src="images/printer.jpg"></a></h2>
		
		<!--for print by equipment type-->
		<form action="mpdf51/examples/equip_type.php" method="POST">
		<br><div class="color2">Print By Type:<select name="type">
				<option value="Office">Office</option>
				<option value="Biometrics">Biometrics</option>
				<option value="Firearms">FireArms</option>
				</select>
				<input type="submit" value="Print">
		</select></div></br>
		</form>
		
		<!--for print by equipment type-->
		<form action="mpdf51/examples/equip_status.php" method="POST">
		<div class="color2">Print Accdg. To Status:<select name="status">
				<option value="available">Available</option>
				<option value="used">Used</option>
				</select>
				<input type="submit" value="Print">
		</select></div></br>
		</form>
		
		
<div class="demo_jui">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="equip" class="jtable">
	<thead>
		<tr>
			<th>Serial Number</th>
			<th>Name</th>
			<th>Type</th>
			<th>Brand</th>
			<th>Kind</th>
			<th>Caliber</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 $emp = mysql_query("SELECT * FROM equipments") or die(mysql_error());  ?>
			<?php WHILE($emps = mysql_fetch_array($emp)){
				$id = $emps['equip_id'];
				$serial = $emps['serial'];
				$name = $emps['name'];
				$type = $emps['type'];
				$brand = $emps['brand'];
				$model = $emps['model'];
				$cal = $emps['cal'];
				$status = $emps['status'];
				?>
			<tr class="gradeA del<?php echo $id;?>">
			<form action="modify_equip.php" method="POST">

			<input type="hidden" value="<?php echo $id; ?>" name="id" />
				<td style="width:20px;"><?php echo $serial; ?></td>
				<td><?php echo $name; ?></td>
				<td><?php echo $type; ?></td>
				<td><?php echo $brand; ?></td>
				<td><?php echo $model; ?></td>
				<td><?php echo $cal; ?></td>
				<td><?php echo $status; ?></td>
				
				<!-- hide actions for user access level-->
				<?php if($_SESSION['user_type'] != 'User'){ ?>
				<!-- hide actions for user access level-->
				<td style="width:110px;"><a class="delete" id="<?php echo $id; ?>">
					<img src = "images/edit_delete.png" height="30" alt = "delete" title = "delete"/></a>
					<input type="image" src= "images/edit-icon.png" height="30" alt = "view" title = "view"/> 
					<a href="view_equip.php<?php echo '?id='; echo $id; ?>">
					<img src= "images/view-icon.png" height="30" alt = "view" title = "view"/></a> 
				</td>
			</form>
			
			<?php } ?>
			</tr>
			<?php } ?>
	</tbody>
</table>
		
</div>
		</div>
	
	</div>
<?php include("footer.php"); ?>
</div>
			<input type="hidden" class="pc_date" name="pc_date"/>
			<input type="pc_time" 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() {
		
		$('.delete').click( function() {
		
		var id = $(this).attr("id");

		
		if(confirm("Are you sure you want to delete this equipment?")){
			
			var pc_date = jQuery('.pc_date').val();
			var pc_time = jQuery('.pc_time').val();
			var user = jQuery('.user').val();
		
			$.ajax({
			type: "POST",
			url: "del_equip.php",
			data: ({id: id,pc_date:pc_date,user:user,pc_time:pc_time}),
			cache: false,
			success: function(html){
			$(".del"+id).fadeOut('slow', function(){ $(this).remove();}); 
			}
			}); 
			}else{
			return false;}
		});				
	});

</script>
