<?php
$PID = "banquet";
session_start();
require_once("../lib/dbconn.php");

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

$cek1 = getFromTable("select count(no_banquet) from tbl_banquet");
$cek3 = $cek1 + 1;
$cek2 = str_pad(((int) $cek1 + 1), 3, "0", STR_PAD_LEFT);
$tgl = date("m");
$bln = date("y");

$kd = "BQ-".$bln.$tgl.$cek2;
$harga = getFromTable("select hrg_layanan from tbl_layanan where id = ".$_SESSION["SELECT_PACK"]);

mysql_query("insert into tbl_banquet (id, no_banquet, tgl_pakai, 
			wkt_pakai, jns_room, nm_pemesan, alamat, kota, 
			no_tlpn, email, instansi, tgl_booking, 
			user_entry, keterangan) values 
            ('$cek3', '".$kd."', '".$_POST[tgl_pakai]."', 
        	'".$_POST[wkt_pakai]."', '".$_POST[jns]."', '".$_POST[nm_pemesan]."', '".$_POST[alamat]."', '".$_POST[kota]."',
        	'".$_POST[no_tlpn]."', '".$_POST[email]."', '".$_POST[instansi]."', CURRENT_DATE,
        	'".$_SESSION[nama_usr]."', '".$_POST[keterangan]."')");

/**
* @Insert ke tabel transaksi
*/
$ceka1 = getFromTable("select count(id) from tbl_transaksi");
$kda = $ceka1 + 1;
$tgl = $_POST[tgl_pakai];
$wkt = $_POST[wkt_pakai];

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 
            ('$kda', 'PAKET', '$tgl', CURRENT_DATE, 
        	'$wkt', '".$kd."', '".$_SESSION["SELECT_PACK"]."', 1, $harga,
        	$harga, 0, '".$_SESSION[nama_usr]."')");


unset($_SESSION["SELECT_ROOM"]);
unset($_SESSION["SELECT_PACK"]);

echo "<script language='JavaScript'>document.location='../index2.php?p=input_dp&idx=$kd'</script>";
?>