<?php
session_start();
require_once("../lib/dbconn.php");

/*echo "<pre>";
echo print_r($_POST);
echo "</pre>";*/

$cek1 = getFromTable("select count(id) from tbl_transaksi");
$kd = $cek1 + 1;
$tgl = getFromTable("select CURRENT_DATE");
$wkt = getFromTable("select CURRENT_TIME");

if ($_POST[guest_type] == "001"){
	mysql_query("insert into tbl_transaksi (id, jns_trans, tgl_trans, tgl_entry,
				wkt_entry, no_booking, item_id, qty, harga, 
				diskon, jumlah, user_entry) values 
	            ('$kd', 'ROOM', '$tgl', '$tgl', 
	        	'$wkt', '".$_POST[idx]."', '".$_POST[id_kamar]."', 1, ".$_POST[harga].",
	        	0, ".$_POST[harga].", '".$_SESSION[nama_usr]."')");
} else {	
	mysql_query("insert into tbl_transaksi (id, jns_trans, tgl_trans, tgl_entry,
				wkt_entry, no_booking, item_id, qty, harga, 
				diskon, jumlah, user_entry) values 
	            ('$kd', 'ROOM', '$tgl', '$tgl', 
	        	'$wkt', '".$_POST[idx]."', '".$_POST[id_kamar]."', 1, ".$_POST[harga].",
	        	".$_POST[harga].", 0, '".$_SESSION[nama_usr]."')");
}
mysql_query("update tbl_booking set status_booking = 'cekin', tgl_cekin = CURRENT_DATE, no_tkp = '".$_POST[no_ktp]."', tgl_lahir = '".$_POST[tgl_lahir]."' where id_booking = '".$_POST[idx]."' ");

mysql_query("update tbl_room set stat_isi = 1, status_kmr = 'isi' where id = '".$_POST[id_kamar]."' ");
 	
unset($_SESSION["SELECT_KAMAR_CEKIN"]);
unset($_SESSION["SELECT_NOMOR_CEKIN"]);

echo "<script language='JavaScript'>document.location='../index2.php?p=cek_in'</script>";
/*echo "<script language='JavaScript'>document.location='../index2.php?p=input_dp&idx=".$_POST[idx]."'</script>";*/
?>