<?php include("header.php"); ?>

<title>List of Users</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('#users').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>Profiles</h1>
<?php include("right_nav.php"); ?>
	</div>
	<div class="content">
	
	
	<div class="actions">
	<h2>Users List  
	
	<!-- hide actions for user access level-->
				<?php if($_SESSION['user_type'] != 'User'){ ?>
				<!-- hide actions for user access level-->| <a href="add_user.php"><img src="images/add-icon.png" height="28"></a>

			<?php } ?>
		</h2>
<div class="demo_jui">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="users" class="jtable">
	<thead>
		<tr>
			<th>Username</th>
			<th>User Type</th>
			<th>Photo</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 $members = mysql_query("SELECT * FROM users") or die(mysql_error());  ?>
			<?php WHILE($mems = mysql_fetch_array($members)){
				$id = $mems['user_id'];
				$user_type = $mems['user_type'];
				$photo = $mems['photo'];
				$name = $mems['first_name']. "&nbsp;" . $mems['middle_initial']. "&nbsp;" . $mems['last_name'];
				?>
			<tr class="gradeA del<?php echo $id;?>">
				<td><?php echo $name; ?></td>
				<td><?php echo $user_type; ?></td>
				<td><img src="images/uploads/<?php echo $photo;?>" width="50" height="50" /></td>
				<!-- hide actions for user access level-->
				<?php if($_SESSION['user_type'] != 'User'){ ?>
				<!-- hide actions for user access level-->
				<td ><a class="delete" id="<?php echo $id; ?>"><img src = "images/edit_delete.png" height="30" alt = "delete" title = "delete"/></a>
				<a href="modify_user.php<?php echo '?id='; echo $id; ?>"><img src = "images/edit-icon.png" height="30" alt = "edit" title = "edit"/></a></td>
			</tr>
			<?php } ?>
			<?php } ?>
	</tbody>
</table>
</div>
	</div>
	
	</div>
<?php include("footer.php"); ?>
</div>
<input type="hidden" class="pc_time" />
<input type="hidden" class="pc_date" />
</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 delete this member?")){
			
		
			$.ajax({
			type: "POST",
			url: "delete_user.php",
			data: ({id: id,pc_date:pc_date,pc_time:pc_time }),
			cache: false,
			success: function(html){
			$(".del"+id).fadeOut('slow', function(){ $(this).remove();}); 
			}
			}); 
			}else{
			return false;}
		});				
	});

</script>
