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

/*echo "<pre>";
echo print_r($_POST);
echo "</pre>";
die();
*/
$tgl = getFromTable("select CURRENT_DATE");
$wkt = getFromTable("select CURRENT_TIME");

$item_id = $_POST[layananid];
$harga = $_POST[harga];
$qty = $_POST[qty];
$diskon = $_POST[diskon];
$jumlah = $_POST[jumlah];
$s = $_POST[max_layanan];

for ($i = 0; $i <= $s-1; $i++) {
    $cek1 = getFromTable("select count(id) from tbl_transaksi");
	$kd = $cek1 + 1;
     	
   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', '".$_POST[jns_trans]."', '$tgl', '$tgl', 
        	'$wkt', '".$_POST[idx]."', '".$item_id[$i]."', ".$qty[$i].", ".$harga[$i].",
        	".$diskon[$i].", ".$jumlah[$i].", '".$_SESSION[nama_usr]."')");
}


if ($_POST[act] == "pos_out"){
	echo "<script language='JavaScript'>document.location='../index2.php?p=".$_POST["p"]."&jns=".$_POST[jns]."&kd=".$_POST[kd]."&act=".$_POST[act]."&e=tambah&t=".$_POST[idx]."'</script>";
} else {
	echo "<script language='JavaScript'>document.location='../index2.php?p=".$_POST["p"]."&idx=".$_POST[idx]."'</script>";
}

?>