
<SCRIPT type='text/javascript' language="JavaScript" src='js/jquery-ui-timepicker-addon.js'></SCRIPT>
<link rel="stylesheet" type="text/css" href='js/jquery-ui-timepicker-addon.css'/>
        
<script>
	$(function() {
		var startDateTextBox  = $('.wkt1');
		var endDateTextBox = $('.wkt2');

		$.timepicker.datetimeRange(
			startDateTextBox,
			endDateTextBox,
			{
				minInterval: (1000*60*60), // 1hr
				dateFormat: 'yy-mm-dd', 
				timeFormat: 'HH:mm:ss',
				start: {}, // start picker options
				end: {} // end picker options					
			}
		);
	});
</script>
<?php    
$PID = "lap_changeroom";
$SC = $_SERVER["SCRIPT_NAME"];

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


if (!isset($GLOBALS['print'])) {
	title_print("Change Room Guest Report");
	$tgl = date("d-m-Y");
	$jam = date("H:i:s");	
?>
<form>
<input type="hidden" name="p" value="<?php echo $PID;?>"/>

<table class="gridtable_form" width="40%">
	<tr>
		<td><b>Date From</b></td>
		<td><input type="text" name="tgl1" class="wkt1" value="<?php echo $_GET["tgl1"]; ?>" ></td>
	</tr>
	<tr>
		<td><b>To</b></td>
		<td><input type="text" name="tgl2" class="wkt2" value="<?php echo $_GET["tgl2"]; ?>" ></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" value="Tampilkan"/></td>
	</tr>
</table>
</form>
<?php } else { ?>
<table class="gridtable_form" width="50%">
	<tr>
		<td><b>Report Name</b></td>
		<td> : Cancel Reservation Report </td>
	</tr>
	<tr>
		<td><b>Date From</b></td>
		<td> : <?php echo $_GET["tgl1"]; ?> <b>to</b> <?php echo $_GET["tgl2"]; ?></td>
	</tr>
	<tr>
		<td><b>Date Print</b></td>
		<td> : <?php echo $tgl; ?> &nbsp; <?php echo $jam; ?></td>
	</tr>
	<tr>
		<td><b>User Print</b></td>
		<td> : <?php echo $_SESSION[nama_usr];?>  </td>
	</tr>
</table>
<?php } ?>
<br/>
<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">Guest ID</td>
		<td class="gridtable_th" align="center">Date Trans</td>
		<td class="gridtable_th" align="center">Time Trans</td>		
		<td class="gridtable_th" align="center">Name</td>
		<td class="gridtable_th" align="center">Address</td>
		<td class="gridtable_th" align="center">From Room</td>
		<td class="gridtable_th" align="center">To Room</td>
		<td class="gridtable_th" align="center">User Entry</td>
	</tr>
	<?php
	$sql = "select a.*, c.keterangan as inisial, d.*, d.keterangan as negara, f.no_room, b.*
			from tbl_booking a 
			join tbl_transaksi b on b.no_booking = a.id_booking
			join tbl_referensi c ON c.id = a.kd_inisial and c.kd = 'INS'
			join tbl_referensi e on e.id = a.kd_negara and e.kd = 'NGR'
			join tbl_room f on f.id = b.item_id
			join tbl_referensi d ON d.id = f.kd_jenis and d.kd = 'ROM'
			where b.jns_trans = 'ROOM' and b.status_trans = 0 and (b.tgl_trans between '".$_GET[tgl1]."' and '".$_GET[tgl2]."' )
			 ";
	$r = mysql_query($sql);
	$n = mysql_num_rows($r);
	
	$no = 1;

while ($row = mysql_fetch_array($r)) {
	$r1 = mysql_query("SELECT a.item_id, b.no_room, b.kd_jenis, c.keterangan
						FROM tbl_transaksi a
						join tbl_room b on b.id = a.item_id
						join tbl_referensi c on c.id = b.kd_jenis and c.kd = 'ROM'
						WHERE a.jns_trans = 'ROOM' AND a.status_trans = 1 and a.no_booking = '".$row[id_booking]."'");
	$n1 = mysql_num_rows($r1);
	if($n1 > 0) $d = mysql_fetch_object($r1);
	mysql_free_result($r1);
	?>
	<tr>
		<td class="gridtable_td"><?php echo $no++; ?></td>
		<td class="gridtable_td" align="center"><?php echo $row[id_booking]; ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[tgl_trans])); ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[wkt_entry])); ?></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[negara])); ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[no_room]." - ".$row[keterangan])); ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($d->no_room." - ".$d->keterangan)); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[user_entry])); ?></td>
	</tr>
	<?php } ?>
</table>