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

$r2 = mysql_query("select *
				from tbl_pnpm");
$n2 = mysql_num_rows($r2);
if($n2 > 0) $d2 = mysql_fetch_object($r2);
mysql_free_result($r2);

$r = mysql_query("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 a.id_booking = '".$_GET[idx]."' ");
$n = mysql_num_rows($r);
if($n > 0) $d = mysql_fetch_object($r);
mysql_free_result($r);

$id_room = getFromTable("select item_id from tbl_transaksi where jns_trans = 'ROOM' and status_trans = 1 and no_booking = '".$_GET[idx]."' ");
$no_room = getFromTable("select no_room from tbl_room where id = $id_room ");
$nama = getFromTable("select nm_lengkap from tbl_booking where id_booking = '".$_GET[idx]."' ");

if ($_GET[jns] == "RESTO" or $_GET[jns] == "SERVICE" ) {
	$kete = "Restauran Bill";
} elseif ($_GET[jns] == "LAUNDRY") {
	$kete = "Laundry Bill";
} elseif ($_GET[jns] == "BAR") {
	$kete = "Mini Bar Bill";
} elseif ($_GET[jns] == "EXTRABED") {
	$kete = "Extrabed Bill";
} elseif ($_GET[jns] == "BANQUET") {
	$kete = "Other Banquet Bill";
} elseif ($_GET[jns] == "KARAOKE") {
	$kete = "Karaoke Bill";
} elseif ($_GET[jns] == "LOUNGE") {
	$kete = "Launge Bill";
} elseif ($_GET[jns] == "DRUG") {
	$kete = "Drug Store Bill";
} else {
	$kete = "Laundry Bill";
}

$id = explode("-",$_GET[idx]);

if ($_GET[jns] == "RESTO" or $_GET[jns] == "SERVICE" ) {
?>
<table width="100%">
	<tr>
		<td class="judul_kw">DJ Inn Tegal</td>
	</tr>
	<!--tr>
		<td class="judul1_kw"><?php echo $d2->alamat1; ?></td>
	</tr>
	<tr>
		<td class="judul1_kw"><?php echo $d2->alamat2; ?></td>
	</tr-->
</table>
<hr class="line_kw"/>
<?php
}
	$r3 = mysql_query("select * from tbl_pos_out
					where no_id = '".$_GET[idx]."' ");
	$n3 = mysql_num_rows($r3);
	if($n3 > 0) $d3 = mysql_fetch_object($r3);
	mysql_free_result($r3);
	
	?>
	<table width="100%" class="tbl_kw" border="0px">
		<tr>
			<th width="40%">No. Trans</th>
			<td width="60%">: <?php echo $_GET[idx]; ?></td>
			
		</tr>
		<?php if($id[0] == "BO") { ?>
		<tr>
			<th >No. Room</th>
			<td >: <?php echo $no_room; ?></td>
		</tr>
		<tr>
			<th >Guest</th>
			<td >: <?php echo ucwords(strtolower($nama)); ?></td>
		<?php } else { ?>
			<tr>
			<th >Guest Name</th>
			<td >: <?php echo $d3->no_meja; ?></td>
		</tr>
		<?php } ?>
		<tr>
			<th >Type</th>
			<td >: <?php echo $kete; ?></td>
		</tr>
	</table>
	<br/>
	<table width="100%" class="rincian" >
		<tr>
			<th class="rincian_th" width="5%">No</th>
			<th class="rincian_th" colspan="2">Item</th>
			<th class="rincian_th">Qty</th>
			<th class="rincian_th">Total</th>
		</tr>
		<?php 
		
		$sql2 = "select a.*, b.nm_layanan from tbl_transaksi a 
				join tbl_layanan b on b.id = a.item_id 
				where a.jns_trans = '".$_GET[jns]."' and no_booking = '".$_GET[idx]."'
				and status_trans = 1 and a.no_kwitansi is NULL order by a.tgl_trans, a.wkt_entry";
		$r2 = mysql_query($sql2);
		$n2 = mysql_num_rows($r2);
		
		$no = 1;
		$jml = 0;	
		while ($row2 = mysql_fetch_array($r2)) { 
			$lay = $row2[nm_layanan];
		?>
			<tr>
				<td class="rincian_td" align="center"><?php echo $no++; ?></td>
				<td class="rincian_td" colspan="2"><?php echo $lay; ?> @<?php echo number_format($row2[harga],0,",","."); ?></td>
				<td class="rincian_td" align="center"><?php echo $row2[qty]; ?> </td>
				<td class="rincian_td" align="right"><?php echo number_format($row2[jumlah],0,",","."); ?></td>
			</tr>
		<?php $jml = $jml + $row2[jumlah]; } ?>
		<tr>
			<td align="right" class="rincian_total" colspan="4"><b>Total</b></td>
			<td align="right" class="rincian_total"><b><?php echo number_format($jml,0,",","."); ?></b></td>
		</tr>		
	</table>
	<table width="100%">
		<tr>
			<td align="center" class="judul1_kw">&nbsp;</td>
			<td align="center" class="judul1_kw"><?php echo ucwords(strtolower($d2->kota)); ?>, <?php echo date("d-m-Y"); ?></td>
		</tr>
		<tr>
			<td align="center" class="judul1_kw">Customer</td>
			<td align="center" class="judul1_kw">Cashier</td>
		</tr>
		<tr>
			<td align="center" class="judul1_kw">&nbsp;<br><br><br></td>
			<td align="center" class="judul1_kw">&nbsp;</td>
		</tr>
		<tr>
			<td align="center" class="judul1_kw"><b><?php echo ucwords(strtolower($d3->nm_pembayar)); ?></b></td>
			<td align="center" class="judul1_kw"><b><?php echo ucwords(strtolower($_SESSION[nama_usr])); ?></b></td>
		</tr>
	</table>
	<SCRIPT LANGUAGE="JavaScript">
	
	function printWindow() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) window.print();
	}
		
	printWindow();
	</script>
