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

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' >  Room Reservation");
?>
<br/>
<div class="ui three column stackable grid">
  <div class="column">
		<h4 class="ui top attached block header">Check Available</h4>
		<form>
		<input type="hidden" name="p" value="<?php echo $PID;?>"/>
		<input type="hidden" name="cek" value="ceking"/>
		<table width="100%" class="gridtable_form" border="1px">						
			<tr>
				<td>Date From</td>
				<td><input type="text" name="tgl1" id="tgl1" class="tgl1" value="<?php echo $_SESSION["SELECT_TGL1"]; ?>" ></td>
			</tr>
			<tr>
				<td>To</td>
				<td><input type="text" name="tgl2" id="tgl2" class="tgl2" value="<?php echo $_SESSION["SELECT_TGL2"]; ?>" ></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td><input type="button" value="Check" onclick="javascript:cek_kamar();" class="blue ui mini button" ></td>
			</tr>
		</table>
		</form>
		
	</div>	
	<div class="column">
	
	<?php
		if ($_SESSION["SELECT_KAMAR"]){
			$r = mysql_query("select * from tbl_referensi where id = '".$_SESSION["SELECT_KAMAR"]."' and kd = 'ROM'");
		    $n = mysql_num_rows($r);
		    if($n > 0) $d = mysql_fetch_object($r);
		    mysql_free_result($r);
		?>
		<h4 class="ui top attached block header">Room Type</h4>
		<div class="ui one cards">
			<div class="ui card">
				<div class="image dimmable">
					
				<img src="images/<?php echo $d->gambar;?>" >
				</div>
			<div class="content">
				<div class="header"><?php echo $d->keterangan; ?></div>					
				<div class="description"><?php echo $d->keterangan2;?></div>
			</div>
			<div class="extra content">
				<a class="friends"><font color="#3959c6"> Price /Night : Rp. <?php echo number_format($d->harga,2,',','.'); ?></font></a>
			</div>
			</div>
		</div>
		<?php
		}
		?>
	</div>
	<div class="column">
		<?php
		if ($_SESSION["SELECT_KAMAR"]){
			$lama_inap = getFromtable("select date('".$_SESSION[SELECT_TGL2]."') - date('".$_SESSION[SELECT_TGL1]."') ");
		?>
		<h4 class="ui top attached block header">Detail Reservation</h4>
		<form action="actions/booking_insert.php" method="POST">
		<input type="hidden" name="p" value="booking"/>		
		<input type="hidden" name="jns" value="<?php echo $_SESSION["SELECT_KAMAR"];?>"/>		
		<input type="hidden" name="tgl1" value="<?php echo $_SESSION["SELECT_TGL1"];?>"/>		
		<input type="hidden" name="tgl2" value="<?php echo $_SESSION["SELECT_TGL2"];?>"/>		
			<table width="100%" class="gridtable_form" border="1px">
				<tr>
					<td>No.Reservation</td>
					<td>: <input type="text" value="-Automatic-" disabled="disabled"></td>
				</tr>
				<tr>
					<td>Order Name</td>
					<td>: <input type="text" name="nm_pemesan" id="nm_pemesan" value="" required="required"></td>
				</tr>
				<input type="hidden" name="no_ktp" value="-">
				<tr>
					<td>Initial</td>
					<td>: <?php echo query_inisial("ins","001"); ?></td>
				</tr>
				<tr>
					<td>Guest Name</td>
					<td>: <input type="text" name="nm_pelanggan" id="nm_lengkap" value="-" required="required">
						<a href="#" id="copy"><img src="images/icon-pass.png"/></a>
					</td>
				</tr>
				
				<input type="hidden" name="nm_panggilan" value="-">
				<tr>
					<td>Address</td>
					<td>: <input type="text" name="alamat" value="-" required="required"></td>
				</tr>
				<tr>
					<td>City</td>
					<td>: <input type="text" name="kota" value="-" required="required"></td>
				</tr>
				<input type="hidden" name="kd_pos" value="00000" >
				<!--tr>
					<td>Kode Pos</td>
					<td>: <input type="text" name="kd_pos" value="" ></td>
				</tr-->
				<tr>
					<td>Country</td>
					<td>: <?php echo query_negara("negara","064"); ?></td>
				</tr>
				<tr>
					<td>Handphone</td>
					<td>: <input type="text" name="no_hp" value="-" required="required"></td>
				</tr>
				<tr>
					<td>Email</td>
					<td>: <input type="text" name="email" value="" required="required"></td>
				</tr>
				<tr>
					<td>Company</td>
					<td>: <input type="text" name="instansi" value="-" required="required"></td>
				</tr>
				<tr>
					<td>Price /Night</td>
					<td>: <input type="text" name="harga1" align="right" value="<?php echo number_format($d->harga,2,',','.'); ?>" readonly="readonly"></td>
					
				</tr>
				<tr>
					<td>Stay Overnight</td>
					<td>: <input type="text" name="lama_inap" value="<?php echo $lama_inap;?>" readonly="readonly" ></td>
				</tr>
				<tr>
					<td>Total</td>
					<td>: <input type="text" name="total_tagihan" value="<?php echo number_format($d->harga * $lama_inap,2,',','.');?>" readonly="readonly" ></td>
				</tr>
				<?php
				$pax = "<select name='pax'>\n";
				for ($i = 1; $i <= 10; $i++){
					$pax .= "<option value = $i>$i</option>";
				}
				$pax .= "</select>\n";
				?>
				<tr>
					<td>Pax</td>
					<td>: <?php echo $pax;?> </td>
				</tr>
				<input type="hidden" name="down_paymen" value="0" >
				<tr>
					<td>&nbsp;</td>
					<td>: <input type="submit" value="Submit" class="blue ui mini button"></td>
				</tr>
			</table>
		</form>
		<?php	
		}		
		?>
	</div>	
</div>	

<script language='JavaScript'>
	$(function(){
		$('#copy').click(function(){
	    	var nm = $("#nm_pemesan").val();
	        $("#nm_lengkap").val(nm);
	         
    	});
    });
function cek_kamar() {
	var tgl1 = $("#tgl1").val();
	var tgl2 = $("#tgl2").val();
    sWin = window.open('includes/cek_kamar.php?tgl1='+tgl1+'&tgl2='+tgl2, 'xWin',
 'top=0,left=0,width=750,height=550,menubar=no,scrollbars=yes');
    sWin.focus();
}
</script>
<?php

//include 'footer.php';
?>