<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";
	include "php_class/class_grup.php";
	include "php_class/class_template.php";
	include "php_class/class_semesterpendek.php";
	
	$datasp = new DataSemesterPendek;
	$datasp5 = new DataSemesterPendek;
	$datasp3 = new DataSemesterPendek;
	$datasp4 = new DataSemesterPendek;
	$dataTemplate = new DataTemplate;
	$datagrup = new DataGrup;
	$DataTransaksi = new DataTransaksi;
	
	$biayasks = $datasp3->get_biaya('biaya');
	$idMhs = $_POST['idMhs'];
	$NPM = $_POST['nn'];
	$tahuntrx = $_POST['tahun'];
	$semester = $_POST['semester'];
	$Alamat = $_POST['Alamat'];
	$tahun = date('y'); 
	$bulan = date('m');
	$operasionalreguler =  $datasp4->get_biaya('biayaoperasionalreguler');
	$operasionalnonreguler =  $datasp4->get_biaya('biayaoperasionalnonreguler');

	$program = substr($NPM, 4, 3);
	
	if($program == 121){
		$biayaoperasional = $operasionalreguler;	
	}else{
		$biayaoperasional = $operasionalnonreguler;	
	}

	$jumlahG = $datasp->get_all_trx('', $a, 'jumlah', $ids);
	$NoArsip = $jumlahG + 1;
	
	$jumlah = $datasp->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 = $datasp->get_temp('',$a,'jumlah', $ids);
	for ($a=1;$a<=$JumlahData;$a++){
		$idtemp = $datasp->get_temp('idTemp', $a, '', $ids);
		$idmatakuliah = $datasp->get_temp('idmatakuliah',$a,'', $ids);
		$matakuliah = $datasp->get_temp('matakuliah',$a,'', $ids);
		$sks = $datasp->get_temp('sks',$a,'', $ids);
		$biaya = $datasp->get_temp('biaya',$a,'', $ids);
		$namadosen = $datasp->get_temp('namadosen',$a, '', $ids);
		$iddosen = $datasp->get_temp('iddosen',$a, '', $ids);
		$operasional = $biayaoperasional*$sks;
		$total = $total + $biaya + $operasional;	
		
		$datasp->add_detil($kodeMaster, $idmatakuliah, $sks, $biaya, $iddosen, $namadosen, $operasional);
		$datasp5->add_tempo($kodeMaster, $NPM, $total, $tahuntrx, $_SESSION['idOperator'], $Alamat, $NoArsip, $semester, $idmatakuliah, $sks, $biaya, $iddosen, $namadosen, $operasional);
	}
	$datasp->add_trx($kodeMaster, $NPM, $total, $tahuntrx, $_SESSION['idOperator'], $Alamat, $NoArsip, $semester);
	

	include "php_class/class_log_sistem.php";
	$DataLogSistem = new DataLogSistem;
	$idOperator = $_SESSION['idOperator'];
	$namaOp = $_SESSION["NamaOperator"];
	$keterangan = "Menambah Transaksi Semester Pendek dg Kode: ".$kodeMaster." dengan NPM ".$NPM." oleh ".$namaOp."";
	$DataLogSistem->add_data_log_sistem($keterangan,$idOperator);

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