<div id="ld" style="position:fixed; top:50%; left:50%"><img src="img/ld.gif"></div>			
<?php
	if(!session_id()) session_start();
	$ids = session_id();
	
	include "php_class/class_mysql.php";
	include "php_class/class_transaksi.php";
	
	$DataTransaksi = new DataTransaksi;
	$idMhs = $_POST['idMhs'];
	$NPM = $_POST['nn'];
	$NamaMhs = $_POST['Nama'];

	$tahun = date('y'); 
	$bulan = date('m'); 
	
	$jumlah = $DataTransaksi->get_last_trans('', $a, 'jumlah');
	if ($jumlah==0){
	$kodeMaster = $tahun.$bulan."0001";	
	}else{
		$terakhir = $jumlah + 1;
		$panjangkarakter = strlen($terakhir);
		for ($i = 1; $i <= 4- $panjangkarakter; $i++){
			$nol = $nol."0";
		}
		$kodeMaster = $tahun.$bulan.$nol.$terakhir;
	}
	$total = 0;
	$JumlahData = $DataTransaksi->get_temp('',$a,'jumlah', $ids);
	for ($a=1;$a<=$JumlahData;$a++){
		$no = $DataTransaksi->get_temp('id', $a, '', $ids);
		$id = $DataTransaksi->get_temp('NoID',$a,'', $ids);
		$namaTrx = $DataTransaksi->get_temp('NamaTrx',$a,'', $ids);
		$Biaya = $DataTransaksi->get_temp('Biaya',$a,'', $ids);
		$tgl = $DataTransaksi->get_temp('tgl',$a,'', $ids);
		$total = $total + $Biaya;	
		
		$DataTransaksi->add_detil_transaksi($kodeMaster, $tgl, $id, $namaTrx, $Biaya, $NPM, $NamaMhs); 
	}
	
	$DataTransaksi->add_master_transaksi($kodeMaster, $NPM, $total, $idMhs);
	
	include "php_class/class_log_sistem.php";
	$DataLogSistem = new DataLogSistem;
	$idOperator = $_SESSION['idOperator'];
	$namaOp = $_SESSION["NamaOperator"];
	$keterangan = "Menambah Transaksi : ".$kodeMaster." oleh ".$namaOp."";
	$DataLogSistem->add_data_log_sistem($keterangan,$idOperator);

?>
<script>window.location='cetak-transaksi/<?php echo $kodeMaster?>'</script>
