<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");
include("../lib/function_query.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;
}

?>
<form name="form1">
	<table width="30%" class="gridtable_form" border="1px" align="center">						
		<tr>
			<td>Room Type</td>
			<td>: <?php echo query_jnskamar("jns",$_GET[jns]," onChange=this.form.submit();"); ?>
			</td>
		</tr>
	</table>
</form>
<br/>
 <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 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 = "Dirty";
	} elseif ($row[status_kmr] == "dibersihkan"){
		$ket = "Cleaned";
	} else {
		$ket = "Clean";
	}
	
 ?>
	<tr <?php echo $class;?> >
		<td class="center aligned"><a href="cari_kamar.php?idx=<?php echo $row[id]; ?>&nomor=<?php echo $row[no_room]; ?>&jnis=<?php echo $_GET[jns]; ?>"><img src="../images/icon-ok.png" /></a></td>
		<td class="center aligned"><?php echo ucwords(strtolower($row[no_room])); ?></td>
		<td><?php echo ucwords(strtolower($row[keterangan])); ?></td>
		<td><?php echo ucwords(strtolower($row[status_isi])); ?></td>
		<td><?php echo ucwords(strtolower($ket)); ?></td>
	</tr>
    <?php } ?>

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