<div class="right_col" role="main">
    <div class="">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
					<div class="x_title">
						<h2>Room Detail</h2>
						<div class="clearfix"></div>
					</div>
					<div class="x_content">

						<form class="form-horizontal form-label-left" method="post">

							<div class="form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12">Owner Name</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input list="ownername" name="ownername" class="form-control">
									<datalist id="ownername">
										<?php
											$result=mysqli_query($conn, "SELECT * FROM owner") or die (mysql_error());
											while($row = mysqli_fetch_array($result))
											{
										?>
										<option value="<?php echo $row['o_id']; ?>"><?php echo $row['o_name'];?></option>
										<?php
											}
										?>
									</datalist id="ownername">
								</div>
							</div>
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomtype">Room Type <span class="required">*</span></label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select class="form-control" name="roomtype">
										<option>Choose option</option>
										<option value="1">Studio Bedroom</option>
										<option value="2">One Bedroom</option>
										<option value="3">Two Bedroom</option>
										<option value="4">Three Bedroom</option>
										<option value="5">Duplex Bedroom</option>
									</select>
								</div>
							</div>
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomno">Room No <span class="required">*</span></label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input id="roomno" class="form-control col-md-7 col-xs-12" name="roomno" type="text">
								</div>
							</div>
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="nopax">No pax <span class="required">*</span></label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<input id="nopax" class="form-control col-md-7 col-xs-12" name="nopax" type="number">
								</div>
							</div>
							<div class="item form-group">
								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="roomplace">Property <span class="required">*</span>
								</label>
								<div class="col-md-6 col-sm-6 col-xs-12">
									<select class="form-control" name="listproperty">
										<option>Choose option</option>
										<option value="1">Solstice</option>
										<option value="2">Kanvas Soho</option>
										<option value="3">Hyve Soho</option>
										<option value="4">Eclipse</option>
										<option value="5">Skypark</option>
									</select>
								</div>
							</div>
							<div class="ln_solid"></div>
							<div class="form-group">
								<div class="col-md-6 col-md-offset-3">
									<button id="send" type="submit" name="submit" class="btn btn-success">Submit</button>
									<button type="submit" class="btn btn-primary" onclick="javascript:window.location='index.php?pagecontent=dashboard'">Cancel</button>
								</div>
							</div>
						</form>
					</div>
                </div>
            </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');  
	}
?>

<?php
	if(isset($_POST['submit']))
	{
		$oid=$_POST['ownername'];
		$roomtype=$_POST['roomtype'];
		$roomno=$_POST['roomno'];
		$nopax=$_POST['nopax'];
		$roomplace=$_POST['roomplace'];
		$status=$_POST['roomstatus'];
		
		mysqli_query($conn, "INSERT INTO room (o_id, r_type, r_no, r_pax, r_place, r_status)
		VALUES ($oid, '$roomtype', '$roomno', $nopax,'$roomplace', '$status')") or die (mysql_error());
		
		header('Location: index.php?pagecontent=roomlist');
	}
?>