<div class="right_col" role="main">
	<div class="">
		<div class="page-title">
			<div class="title_left">
				<table>
					<tr>
						<td width="150px"><h3>Guest list</h3></td>
						<td><a href="index.php?pagecontent=guest"><button type="button" class="btn btn-dark">Add Guest</button></a></td>
				</table>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-12 col-sm-12 col-xs-12">
				<div class="x_panel">
					<div class="x_content">
						<table id="datatable" class="table table-striped table-bordered">
							<thead>
								<tr>
									<th>Name</th>
									<th>ID</th>
									<th>Gender</th>
									<th>Contact</th>
									<th>Status</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$result=mysqli_query($conn, "SELECT *FROM guest") or die (mysql_error());
									while($row = mysqli_fetch_array($result))
									{
								?>
								<tr>
									<td width="200"><b><u><a href="index.php?pagecontent=guestid&id=<?php echo $row['g_id'];?>"><?php echo $row['g_full_name'];?></a></u></b></td>
									<td width="110"><?php echo $row['g_id_no'];?></td>
									<td width="30"><?php echo $row['g_gendar'];?></td>
									<td><?php echo $row['g_contact'];?></td>
									<td><?php	switch($row['g_status'])
															{
																case 0: echo '<span style="color:green;font-weight:bold;">Unbarring</span>';
																break;
																default: echo '<span style="color:red;font-weight:bold;">Barring</span>';
															}
													;?></td></td>
									<td>
										<div class="btn-group">
											<button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button" aria-expanded="false">Default <span class="caret"></span>
											</button>
											<ul role="menu" class="dropdown-menu">
												<li><a href="index.php?pagecontent=guestlist&guestunbar=<?php echo $row['g_id'];?>">Unbarring</a></li>
												<li><a href="index.php?pagecontent=guestlist&guestbar=<?php echo $row['g_id'];?>">Barring</a></li>
												<li><a href="index.php?pagecontent=guestupdate&guestid=<?php echo $row['g_id'];?>">Update Guest</a></li>
												<li><a href="index.php?pagecontent=guestupload&guestid=<?php echo $row['g_id'];?>">Upload</a></li>
											</ul>
										</div>
									</td>
								</tr>
								<?php
									}
								?>
						</table>
					</div>
				</div>
			</div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['guestunbar'])){
		
		$id=$_REQUEST['guestunbar'];
		
		mysqli_query($conn,"UPDATE guest SET g_status=0 WHERE g_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=guestlist');  
	}
?>

<?php
	if(isset($_REQUEST['guestbar'])){
		
		$id=$_REQUEST['guestbar'];
		
		mysqli_query($conn,"UPDATE guest SET g_status=1 WHERE g_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=guestlist');  
	}
?>