
<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_uang_muka";
$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("Down Payment 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><b>Payment Method</b></td>
		<td><?php echo query_carabayar2("cab",$_GET[cab],"");?></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" value="Show"/></td>
	</tr>
</table>
</form>
<?php } else { ?>
<table class="gridtable_form" width="50%">
	<tr>
		<td><b>Report Name</b></td>
		<td> : Down Payment 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/>
<h4 class="ui top attached block header">Guest in House</h4>
<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">Date Trans</td>
		<td class="gridtable_th" align="center">Time Trans</td>
		<td class="gridtable_th" align="center">No. Check</td>
		<td class="gridtable_th" align="center">Guest ID</td>
		<td class="gridtable_th" align="center">Name</td>
		<td class="gridtable_th" align="center">Address</td>
		<td class="gridtable_th" align="center">User Entry</td>
		<td class="gridtable_th" align="center">Payment Method</td>
		<td class="gridtable_th" align="center">Materai</td>
		<td class="gridtable_th" align="center">Amount</td>
		<td class="gridtable_th" align="center">Total</td>
	</tr>
	<?php
	$sql = "select a.*, b.keterangan as cara_byr, c.*
			from tbl_pembayaran a
			join tbl_referensi b on b.id = a.cara_bayar and b.kd = 'CAB'
			join tbl_booking c on c.id_booking = a.no_booking
			where a.cara_bayar like '%".$_GET[cab]."%' and a.jns_bayar = 'DEPOSIT' and (CONCAT(a.tgl_bayar,' ',a.wkt_bayar) between '".$_GET[tgl1]."' and '".$_GET[tgl2]."' ) ";
	$r = mysql_query($sql);
	$n = mysql_num_rows($r);
	
	$no = 1;
	$tot = 0;
while ($row = mysql_fetch_array($r)) {
	?>
	<tr>
		<td class="gridtable_td"><?php echo $no++; ?></td>		
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[tgl_bayar])); ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[wkt_bayar])); ?></td>
		<td class="gridtable_td" align="center"><?php echo $row[no_kwitansi]; ?></td>
		<td class="gridtable_td" align="center"><?php echo $row[no_booking]; ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[nm_pembayar])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[alamat]." ".$row[kota])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[user_input])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[cara_byr])); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[materai], 2, ',','.'); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[jml_bayar] - $row[materai], 2, ',','.'); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[jml_bayar], 2, ',','.'); ?></td>
	</tr>
	<?php 
		$tot = $tot + $row[jml_bayar];	
	} ?>
	<tr>
		<td class="gridtable_total" align="right" colspan="11">TOTAL</td>
		<td class="gridtable_total" align="right"><?php echo number_format($tot, 2, ',','.'); ?></td>
	</tr>
</table>

<h4 class="ui top attached block header">Banquet</h4>
<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">Date Trans</td>
		<td class="gridtable_th" align="center">Time Trans</td>
		<td class="gridtable_th" align="center">No. Check</td>
		<td class="gridtable_th" align="center">Guest ID</td>
		<td class="gridtable_th" align="center">Name</td>
		<td class="gridtable_th" align="center">Address</td>
		<td class="gridtable_th" align="center">User Entry</td>
		<td class="gridtable_th" align="center">Payment Method</td>
		<td class="gridtable_th" align="center">Materai</td>
		<td class="gridtable_th" align="center">Amount</td>
		<td class="gridtable_th" align="center">Total</td>
	</tr>
	<?php
	$sql = "select a.*, b.keterangan as cara_byr, c.*
			from tbl_pembayaran a
			join tbl_referensi b on b.id = a.cara_bayar and b.kd = 'CAB'
			join tbl_banquet c on c.no_banquet = a.no_booking
			where a.cara_bayar like '%".$_GET[cab]."%' and a.jns_bayar = 'DEPOSIT' and (CONCAT(a.tgl_bayar,' ',a.wkt_bayar) between '".$_GET[tgl1]."' and '".$_GET[tgl2]."' ) ";
	$r = mysql_query($sql);
	$n = mysql_num_rows($r);
	
	$no = 1;
	$tot = 0;
while ($row = mysql_fetch_array($r)) {
	?>
	<tr>
		<td class="gridtable_td"><?php echo $no++; ?></td>		
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[tgl_bayar])); ?></td>
		<td class="gridtable_td" align="center"><?php echo ucwords(strtolower($row[wkt_bayar])); ?></td>
		<td class="gridtable_td" align="center"><?php echo $row[no_kwitansi]; ?></td>
		<td class="gridtable_td" align="center"><?php echo $row[no_booking]; ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[nm_pembayar])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[alamat]." ".$row[kota])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[user_input])); ?></td>
		<td class="gridtable_td"><?php echo ucwords(strtolower($row[cara_byr])); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[materai], 2, ',','.'); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[jml_bayar] - $row[materai], 2, ',','.'); ?></td>
		<td class="gridtable_td" align="right"><?php echo number_format($row[jml_bayar], 2, ',','.'); ?></td>
	</tr>
	<?php $tot = $tot + $row[jml_bayar];} ?>
	<tr>
		<td class="gridtable_total" align="right" colspan="11">TOTAL</td>
		<td class="gridtable_total" align="right"><?php echo number_format($tot, 2, ',','.'); ?></td>
	</tr>
</table>