<?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");


mysql_query("update tbl_transaksi set status_trans = 0 where no_booking = '".$_POST[idx]."' and jns_trans = 'ROOM' ");

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', '".$_POST[tgl_trans]."', '$tgl', 
        	'$wkt', '".$_POST[idx]."', '".$_POST[id_kamar]."', 1, ".$_POST[harga].",
        	0, ".$_POST[harga].", '".$_SESSION[nama_usr]."')");

mysql_query("update tbl_room set stat_isi = 0, status_kmr = 'kosong' where id = '".$_POST[id_kamar_lama]."' ");
mysql_query("update tbl_room set stat_isi = 1, status_kmr = 'isi' where id = '".$_POST[id_kamar]."' ");

mysql_query("update tbl_booking set jns_room = '".$_POST[jns_room]."' where id_booking = '".$_POST[idx]."' ");
	
unset($_SESSION["SELECT_KAMAR_CEKIN"]);
unset($_SESSION["SELECT_NOMOR_CEKIN"]);

echo "<script language='JavaScript'>document.location='../index2.php?p=change_room'</script>";
?>