<link rel="stylesheet" type="text/css" href="../css/semantic.css">
<LINK rel="stylesheet" type="text/css" href="../css/default.css">
<?php
@session_start();
require_once("../lib/dbconn.php");
require_once("../lib/form.php");
require_once("../lib/functions.php");

title("<img src='../images/sales-report-icon.png' width='65' align='absmiddle' >  Select No. Room");

unset($_SESSION["SELECT_KAMAR_CEKIN"]);
unset($_SESSION["SELECT_NOMOR_CEKIN"]);


if (isset($_GET["idx"])) {
    $_SESSION["SELECT_KAMAR_CEKIN"] = $_GET["idx"];
    $_SESSION["SELECT_NOMOR_CEKIN"] = $_GET["nomor"];
    ?>
    <SCRIPT language="JavaScript">
        window.opener.location = window.opener.location;
        window.close();
    </SCRIPT>
    <?php
    exit;
}

?>
 <div class="ui column relaxed grid">

<table class="ui inverted blue selectable celled left aligned table">
	<thead>
		<tr>
			<th class="center aligned" width="5%">&nbsp;</th>
			<th class="center aligned">NO.ROOM</th>
			<th class="center aligned">ROOM TYPE</th>
			<th class="center aligned">ROOM BED TYPE</th>
			<th class="center aligned">ROOM STATUS</th>
			<th class="center aligned">STATUS SERVICE</th>
		</tr>
	</thead>
	<tbody>
<?php
$SQL = "select a.*,
		case when a.stat_isi = 0 then 'Available' 
		when a.stat_isi = 1 then 'Use'
		else 'Use' end as status_isi, b.keterangan
		from tbl_room a
		join tbl_referensi b on b.id = a.kd_jenis and b.kd = 'ROM'
		where a.kd_jenis =  '".$_GET[jns]."' order by a.no_room ";
$r = mysql_query($SQL);

while ($row = mysql_fetch_array($r)) { 
	if ($row[stat_isi] == 0 ){
		if ($row[status_kmr] == "kotor"){
			$class = " class='negative'";
		} elseif ($row[status_kmr] == "dibersihkan"){
			$class = " class='info'";
		} else {
			$class = " class='positive'";
		}
		
	} else {
		if ($row[status_kmr] == "kotor"){
			$class = " class='negative'";
		} elseif ($row[status_kmr] == "dibersihkan"){
			$class = " class='info'";
		} else {
			$class = " class='negative'";
		}
		
	}
	
	if ($row[status_kmr] == "kotor"){
		$ket = "Vacant Dirty";
	} elseif ($row[status_kmr] == "dibersihkan"){
		$ket = "Vacant Cleaning";
	}elseif ($row[status_kmr] == "rusak"){
		$ket = "Out of order";
	} else {
		$ket = "Vacant Ready";
	}
 ?>
	<tr <?php echo $class;?> >
		<?php if ($row[stat_isi] == 0 && $row[status_kmr]!='rusak'){ ?>
		<td class="center aligned"><a href="cari_kamar.php?idx=<?php echo $row[id]; ?>&nomor=<?php echo $row[no_room]; ?>"><img src="../images/icon-ok.png" /></a></td>
		<?php } else { ?>
		<td class="center aligned">&nbsp;</td>
		<?php } ?>
		<td class="center aligned"><?php echo ucwords(strtolower($row[no_room])); ?></td>
		<td><?php echo ucwords(strtolower($row[keterangan])); ?></td>
		<td class="center aligned"><?php echo ucwords(strtolower($row['tipe_bed'])); ?></td>
		<td><?php echo ucwords(strtolower($row[status_isi])); ?></td>
		<td><?php echo ucwords(strtolower($ket)); ?></td>
	</tr>
    <?php } ?>

	</tbody>
</table>
</div>
