<?php 
   
$PID = "cancel_booking";
$SC = $_SERVER["SCRIPT_NAME"];

require_once("lib/dbconn.php");
require_once("lib/form.php");
require_once("lib/functions.php");



if(isset($_GET[idx])){
	title("<img src='images/sales-report-icon.png' width='65' align='absmiddle' >  Cancel Reservation");
	include_once('keterangan.php');
	
	?>
	<br/>
	<div class="ui three column stackable grid" align="center">
		<div class="column"></div>
		<div class="column">
			<h4 class="ui top attached block header">Select Reason Cancel Reservation!</h4>
			<form action="actions/cancel_booking_insert.php" method="POST">
			<input type="hidden" name="p" value="<?php echo $PID;?>"/>
			<input type="hidden" name="idx" value="<?php echo $_GET["idx"];?>"/>
			<input type="hidden" name="down_paymen" value="<?php echo $downpay;?>"/>
			<table width="100%" class="gridtable_form" border="1px">						
				<tr>
					<td align="center"> <?php echo query_alasan("alasan", "001");?> </td>
				</tr>
				<tr>
					<td align="center"><input type="submit" value="Cancel Checkin" ></td>
				</tr>
			</table>
			</form>
		</div>
	</div>
	<div class="column"></div>
<script language='JavaScript'>
	function cari_kamar(tag) {
	    sWin = window.open('includes/cari_kamar.php?jns='+tag, 'xWin',
	 	'top=0,left=0,width=1200,height=550,menubar=no,scrollbars=yes');
	    sWin.focus();
	}
</script>
	<?php
} else {
	title("<img src='images/sales-report-icon.png' width='65' align='absmiddle' >  Cancel Reservation");
	
?>
<br/>
<form>
<input type="hidden" name="p" value="cancel_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. Reserv.</td>
		<td class="gridtable_th" align="center">Reserv.<br/>Date</td>
		<td class="gridtable_th" align="center">Check in<br/>Date</td>
		<td class="gridtable_th" align="center">Guest Name</td>
		<td class="gridtable_th" align="center">Address</td>
		<td class="gridtable_th" align="center">Hp & Email</td>
		<td class="gridtable_th" align="center">Room Type</td>
		<td class="gridtable_th" align="center">Down Payment</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>
		<td class="gridtable_th" align="center"><input type="text" name="alamat" value="<?php echo $_GET[alamat];?>"></td>
		<td class="gridtable_th">&nbsp;</td>
		<td class="gridtable_th">&nbsp;</td>
		<td class="gridtable_th">&nbsp;</td>
	</tr>
	<?php
	$sql = "select a.*, b.keterangan as inisial, c.*, d.keterangan as negara
			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'
			where status_booking = 'booking' and upper(id_booking) like '%".strtoupper($_GET[kd_book])."%' and
			upper(a.nm_lengkap) like '%".strtoupper($row[nm_lengkap])."%' and (upper(a.alamat) like '%".strtoupper($row[alamat])."%'
			or upper(a.kota) like '%".strtoupper($row[kota])."%' or upper(a.kd_pos) like '%".strtoupper($row[kd_pos])."%'
			or upper(d.keterangan) like '%".strtoupper($row[negara])."%')  ";
	$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?p=$PID&idx=$row[id_booking]";?>"><?php echo $row[id_booking]; ?></a></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[tgl_booking])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[tgl_cekin])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[inisial]." ".$row[nm_lengkap])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[alamat]." ".$row[kota]." ".$row[kd_pos]." ".$row[negara])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[no_hp]." / ".$row[email])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[keterangan])); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[down_paymen],2,",","."); ?></td>
	</tr>
	<?php } ?>
</table>
</form>
<?php } ?>