<?php include("header.php"); ?>
<title>List of Expense Activities</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('#emp').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>Expense List 
			
		<!-- hide actions for user access level-->
		<?php if($_SESSION['user_type'] != 'User'){ ?>
		|  <a href="add_expense.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/expenses_pdf.php"><img src="images/printer.jpg"></a></h2>
		<form action="mpdf51/examples/custom_expenses.php" method="POST">
		<div class="color2"><label>View by month :</label></div>
		<select name="month">
		<option value="1">January</option>
		<option value="2">February</option>
		<option value="3">March</option>
		<option value="4">April</option>
		<option value="5">May</option>
		<option value="6">June</option>
		<option value="7">July</option>
		<option value="8">August</option>
		<option value="9">September</option>
		<option value="10">October</option>
		<option value="11">November</option>
		<option value="12">December</option>
		</select>
		<select name="year">
		<option value="2011">2011</option>
		<option value="2012">2012</option>
		<option value="2013">2013</option>
		<option value="2013">2014</option>
		<option value="2014">2014</option>
		<option value="2015">2015</option>
		</select>
		<input type="submit" name="submit" value="Proceed" />
		</form>
		<br />
<div class="demo_jui">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="emp" class="jtable">
	<thead>
		<tr>
			<th>Control Number</th>
			<th>Date</th>
			<th>Expense Acitvity</th>
			<th>Expense Type</th>
			<th>Quantity</th>
			<th>Cost</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 $exp = mysql_query("SELECT * FROM expenses WHERE trash = '0' ORDER BY date ASC") or die(mysql_error());  ?>
			<?php WHILE($exps = mysql_fetch_array($exp)){
				$id = $exps['exp_id'];
				$control = $exps['exp_id'];
				$exp_name = $exps['exp_name'];
				$exp_type = $exps['exp_type'];
				$quantity = $exps['quantity'];
				$cost = $exps['cost'];
				$date = $exps['date'];
				?>
			<tr class="gradeA del<?php echo $id;?>">
			<form action="modify_exp.php" method="POST">
				<td><?php echo $control; ?></td>
				<td><?php echo $date; ?></td>
				<td><?php echo $exp_name; ?></td>
				<td><?php echo $exp_type; ?></td>
				<td><?php echo $quantity; ?></td>
				<td><?php echo $cost; ?></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; ?>">
					<input type="hidden" value="<?php echo $id; ?>" name="id">
					<img src = "images/edit_delete.png" height="30" alt = "delete" title = "delete"/></a>
					<input type="image" src="images/edit-icon.png" height="30" />
					<a href="view_exp.php<?php echo '?id='; echo $id; ?>">
					<img src= "images/view-icon.png" height="30" alt = "view" title = "view"/></a> 
					
					</form>
					<?php } ?>
				</td>
				
				</tr>
			<?php } ?>
	</tbody>
</table>
</div>
		</div>
	
	</div>
<?php include("footer.php"); ?>
</div>

</body>
</html>
<script type="text/javascript">
	$(document).ready( function() {
		
		$('.delete').click( function() {
		
		var id = $(this).attr("id");
	   var myDate = new Date();
var date = (myDate.getMonth()+1) + '/' + (myDate.getDate()) + '/' + myDate.getFullYear();
var time = myDate.getHours()+':'+myDate.getMinutes()+':'+myDate.getSeconds();		
/* 		$(".change").val(change); */
		
		if(confirm("Are you sure you want to delete this expense activity?")){
			
		
			$.ajax({
			type: "POST",
			url: "del_exp.php",
			data: ({id: id,date:date, time:time}),
			cache: false,
			success: function(html){
			$(".del"+id).fadeOut('slow', function(){ $(this).remove();}); 
			} 
			}); 
			}else{
			return false;}
		});				
	});

</script>
