<div class="right_col" role="main">
	<div class="">
		<div class="page-title">
			<div class="title_left">
				<table>
					<tr>
						<td width="150px"><h3>Room list</h3></td>
						<td><a href="index.php?pagecontent=room_new"><button type="button" class="btn btn-dark">Add Room</button></a></td>
					</tr>
				</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>Onwer Name</th>
									<th>Room Type</th>
									<th>Room No</th>
									<th>No Pax</th>
									<th>Place</th>
									<th>Status</th>
									<th>Action</th>
								</tr>
							</thead>
							<tbody>
								<?php
									$result=mysqli_query($conn, "SELECT *FROM owner AS o INNER JOIN room AS r ON o.o_id=r.o_id") or die (mysql_error());
									while($row = mysqli_fetch_array($result))
									{
										$rid=$row['r_id'];
								?>
								<tr>
									<td width="150"><?php echo $row['o_name'];?></a></td>
									<td width="110"><?php echo $row['r_type'];?></td>
									<td width="30"><?php echo $row['r_no'];?></td>
									<td><?php echo $row['r_pax'];?></td>
									<td><?php echo $row['r_place'];?></td>
									<td><?php	switch($row['r_status'])
															{
																case 0: echo '<span style="color:green;font-weight:bold;">Ok</span>';
																break;
																case 1: echo '<span style="color:orange;font-weight:bold;">Dirty</span>';
																break;
																default: echo '<span style="color:red;font-weight:bold;">Problem</span>';
															}
													;?></td></td>
									<td><a href="index.php?pagecontent=roomlist&roomok=<?php echo $row['r_id'];?>"><button type="button" class="btn btn-success">OK</button>
									<a href="index.php?pagecontent=roomlist&roomdirty=<?php echo $row['r_id'];?>"><button type="button" class="btn btn-warning">Dirty</button>
									<a href="index.php?pagecontent=roomlist&roomproblem=<?php echo $row['r_id'];?>"><button type="button" class="btn btn-danger">Problem</button></td>
								</tr>
								<?php
									}
								?>
						</table>
					</div>
				</div>
			</div>
        </div>
    </div>
</div>

<?php
	if(isset($_REQUEST['roomok'])){
		
		$id=$_REQUEST['roomok'];
		
		mysqli_query($conn,"UPDATE room SET r_status=0 WHERE r_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=roomlist');  
	}
?>

<?php
	if(isset($_REQUEST['roomdirty'])){
		
		$id=$_REQUEST['roomdirty'];
		
		mysqli_query($conn,"UPDATE room SET r_status=1 WHERE r_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=roomlist');  
	}
?>

<?php
	if(isset($_REQUEST['roomproblem'])){
		
		$id=$_REQUEST['roomproblem'];
		
		mysqli_query($conn,"UPDATE room SET r_status=2 WHERE r_id=$id") or die (mysql_error());
		
		header('Location: index.php?pagecontent=roomlist');  
	}
?>