<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' >  Pilih Guest");


if (isset($_GET["e"])) {
	mysql_query("update tbl_pos_out set no_booking = '".$_GET[e]."' where no_id = '".$_GET[idx]."'")
    ?>
    <SCRIPT language="JavaScript">
        window.opener.location = window.opener.location;
        window.close();
    </SCRIPT>
    <?php
    exit;
}

if (strlen($_GET[no_booking])  > 0){
	mysql_query("update tbl_pos_out set no_booking = NULL where no_id = '".$_GET[idx]."'")
    ?>
    <SCRIPT language="JavaScript">
        window.opener.location = window.opener.location;
        window.close();
    </SCRIPT>
    <?php
    exit;
} else {
	
?>
<form>
<input type="hidden" name="idx" value="<?php echo $_GET[idx]; ?>"/>
<input type="hidden" name="no_booking" value="<?php echo $_GET[no_booking]; ?>"/>
<input type="submit" style="display: none;"/>
<table id='mytable' class="gridtable tableWithFloatingHeader" width="100%" border="1px">
	<tr>
		<td class="gridtable_th" align="center">No</td>
		<td class="gridtable_th" align="center">No. Guest</td>
		<td class="gridtable_th" align="center">Tgl. Cek-In</td>
		<td class="gridtable_th" align="center">Kamar</td>
		<td class="gridtable_th" align="center">Nama</td>
	</tr>
	<tr>
		<td class="gridtable_th">&nbsp;</td>
		<td class="gridtable_th" align="center"><input type="text" size="10" name="kd_book" value="<?php echo $_GET[kd_book];?>"></td>
		<td class="gridtable_th">&nbsp;</td>
		<td class="gridtable_th">&nbsp;</td>
		<td class="gridtable_th" align="center"><input type="text" name="nama" value="<?php echo $_GET[nama];?>"></td>
		
	</tr>
	<?php
	$sql = "select a.*, b.keterangan as inisial, c.*, d.keterangan as negara, e.tgl_trans, f.no_room
			from tbl_booking a 
			JOIN tbl_referensi b ON b.id = a.kd_inisial and b.kd = 'INS' 
			JOIN tbl_referensi c ON c.id = a.jns_room and c.kd = 'ROM' 
			join tbl_referensi d on d.id = a.kd_negara and d.kd = 'NGR'
			join tbl_transaksi e on e.no_booking = a.id_booking
			join tbl_room f on f.id = e.item_id 
			where e.jns_trans = 'ROOM' and e.status_trans = 1 and 
			status_booking = 'cekin' and upper(id_booking) like '%".strtoupper($_GET[kd_book])."%' and
			upper(a.nm_lengkap) like '%".strtoupper($_GET[nama])."%' and (upper(a.alamat) like '%".strtoupper($_GET[alamat])."%'
			or upper(a.kota) like '%".strtoupper($_GET[alamat])."%' or upper(a.kd_pos) like '%".strtoupper($_GET[alamat])."%'
			or upper(d.keterangan) like '%".strtoupper($_GET[alamat])."%')  ";
	$r = mysql_query($sql);
	$n = mysql_num_rows($r);
	
	$no = 1;
	
while ($row = mysql_fetch_array($r)) {
	?>
	<tr>
		<td class="gridtable_td"><?php echo $no++; ?></td>
		<td class="gridtable_td" align="center"><a href="<?php echo "$SC?idx=$_GET[idx]&e=$row[id_booking]";?>"><?php echo $row[id_booking]; ?></a></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[tgl_trans])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[no_room]." - ".$row[keterangan])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[inisial]." ".$row[nm_lengkap])); ?></td>
	</tr>
	<?php } ?>
</table>
</form>
<?php } ?>

