<?php 
	class DataSemesterPendek extends mysql{
		
		function get_jumlah_matkul($kolom,$a,$type, $program, $tahun, $semester, $idmatkul){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select *, tb2.Nama, tb2.NPM from tempbagi tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM where tahun = '".$tahun."' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."' and program = '".$program."'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_bagi_kelas($kolom,$a,$type, $program, $tahun, $semester, $idmatkul, $kelas){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select *, tb2.Nama, tb2.NPM from tempbagi tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM where tahun = '".$tahun."' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."' and program = '".$program."' and kelas='".$kelas."'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_bagi_id($kolom, $program, $tahun, $semester, $idmatkul, $kelas){
			if($this->cek_result != "on"){
			$sql = "select * from tempbagi where tahun = '".$tahun."' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."' and program = '".$program."' and kelas='".$kelas."' group by kelas desc";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function get_temp_bagi_kelas($kolom,$a,$type, $program, $tahun, $semester, $idmatkul){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama, tb2.NPM from tempbagi tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM where substr(tb1.NPM, 5, 3) ='".$program."' and tahun = '".$tahun."' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."' group by kelas";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_temp_bagi($kolom,$a,$type, $program, $tahun, $semester, $idmatkul){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama, tb2.NPM from tempbagi tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM where substr(tb1.NPM, 5, 3) ='".$program."' and tahun = '".$tahun."' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_matkul_sempek_mhs($kolom,$a,$type, $program, $tahun, $semester, $idmatkul){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb2.Nama, tb2.NPM from tempo tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM where substr(tb1.NPM, 5, 3) ='".$program."' and tahun = '".$tahun."' and status = '1' and semester = '".$semester."'  and idmatakuliah = '".$idmatkul."'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_matkul_sempek($kolom,$a,$type, $program, $tahun, $semester){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.matakuliah, tb2.kode, count(tb2.matakuliah) as peserta from tempo tb1 inner join tbmatakuliah tb2 on tb1.idmatakuliah = tb2.idmatakuliah where substr(NPM, 5, 3) ='".$program."' and tahun = '".$tahun."' and status = '1' and semester = '".$semester."'  group by idmatakuliah desc";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_trx_sempek_detil_all($kolom,$a,$type, $program, $tahun, $tgldari, $tglsampai){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.id, tb1.NoTrx, tb1.namadosen, tb1.tglinput, tb3.namaOperator, tb4.Nama, tb4.NPM, tb5.matakuliah, tb5.sks, tb1.biaya, tb5.kode, tb1.alamat, tb1.biayaoperasional 
					from tempo tb1 
					inner join tboperator tb3 on tb1.idoperator = tb3.kodeOperator
					inner join tbmahasiswa tb4 on tb1.NPM = tb4.NPM
					inner join tbmatakuliah tb5 on tb1.idmatakuliah = tb5.idmatakuliah
					where substr(tb1.NPM, 5, 3) ='".$program."' and tb1.tahun = '".$tahun."' and tb1.tglinput >= '".$tgldari."' and tb1.tglinput <= '".$tglsampai."' and tb1.status = '1'";
			//echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_matakuliah_id($kolom, $id){
			if($this->cek_result != "on"){
			$sql = "select * from tbmatakuliah where idmatakuliah = '".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function get_matakuliah_all($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbmatakuliah";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_trx_sempek_detil($kolom,$a,$type, $program, $tahun, $tgldari, $tglsampai){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.id, tb1.NoTrx, tb1.namadosen, tb2.tglinput, tb3.namaOperator, tb4.Nama, tb4.NPM, tb5.matakuliah, tb5.sks, tb1.biaya, tb5.kode, tb2.alamat, tb1.biayaoperasional 
					from tbdetilsempek tb1 
					inner join tbmastersempek tb2 on tb1.NoTrx = tb2.NoTrx
					inner join tboperator tb3 on tb2.idoperator = tb3.kodeOperator
					inner join tbmahasiswa tb4 on tb2.NPM = tb4.NPM
					inner join tbmatakuliah tb5 on tb1.idmatakuliah = tb5.idmatakuliah
					where tb1.NoTrx in (select NoTrx from tbmastersempek where substr(NPM, 5, 3) ='".$program."' and tahun = '".$tahun."' and tglinput >= '".$tgldari."' and tglinput <= '".$tglsampai."' and status = '1') order by tb1.id asc ";
			echo $sql;
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_trx_sempek($kolom,$a,$type, $program, $tahun, $tgldari, $tglsampai, $semester){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama, tb3.namaOperator from tbmastersempek tb1 inner join tbmahasiswa tb2 on tb1.NPM = tb2.NPM inner join tboperator tb3 on tb1.idoperator = tb3.kodeOperator where substr(tb1.NPM, 5, 3) ='".$program."' and tb1.tahun = '".$tahun."' and tb1.tglinput >= '".$tgldari."' and tb1.tglinput <= '".$tglsampai."' and status = '1' and semester = '".$semester."' order by NoTrx desc ";
			
$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_biaya($kolom){
			if($this->cek_result != "on"){
			$sql = "select * from tbbiayasks";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_detil_by_id($kolom,$notrx, $id){
			if($this->cek_result != "on"){
			$sql = "select tb1.*, tb2.* from tbdetilsempek tb1 inner join tbmatakuliah tb2 on tb1.idmatakuliah = tb2.idmatakuliah where tb1.NoTrx = '".$notrx."' and tb1.id = '".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		//baru
		function get_sks_by_id($kolom,$notrx){
			if($this->cek_result != "on"){
			$sql = "select sum(sks) as jml, sum(biayaoperasional) as operasional from tbdetilsempek where NoTrx = '".$notrx."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_master_by_id($kolom,$notrx){
			if($this->cek_result != "on"){
			$sql = "select * from tbmastersempek where NoTrx = '".$notrx."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function get_temp_by_id_jml($kolom,$ids){
			if($this->cek_result != "on"){
			$sql = "select *, sum(sks) as jml from tempmatakuliah where idSession = '".$ids."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_detil_trx($kolom,$a,$type, $notrx){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbdetilsempek where NoTrx = '".$notrx."' ";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_last_trans($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbmastersempek where month(tglinput) = month(curdate())";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_all_trx($kolom,$a,$type, $ids){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbmastersempek";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_mk_all($kolom,$a,$type, $jurusan){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
				if($jurusan == 'IESP'){
					$kdjurusan = '1';	
				}elseif($jurusan == 'MANAJEMEN'){
					$kdjurusan = '2';	
				}elseif($jurusan == 'AKUNTANSI'){
					$kdjurusan = '3';	
				}
				
			$sql = "select * from tbmatakuliah where idjurusan = '".$kdjurusan."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_temp($kolom,$a,$type, $ids){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tempmatakuliah where idSession = '".$ids."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_temp_by_id($kolom,$a,$type, $ids, $idmatakuliah){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tempmatakuliah where idSession = '".$ids."' and idmatakuliah = '".$idmatakuliah."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}

		function get_mk_temp($kolom,$jurusan){
			if($this->cek_result != "on"){
			$sql = "select * from tempmatakuliah where idSession = '' and idmatakuliah = ''";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function add_temp($idSession, $idmatakuliah, $matakuliah, $sks, $kode, $jurusan, $biaya, $iddosen, $namadosen){
			  $sql = "insert tempmatakuliah (idSession, idmatakuliah, matakuliah, sks, kode, jurusan, biaya, iddosen, namadosen) values ('".$idSession."', '".$idmatakuliah."', '".$matakuliah."', '".$sks."', '".$kode."', '".$jurusan."', '".$biaya."', '".$iddosen."', '".$namadosen."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_temp_id($idtemp){
			  $sql = "delete from tempmatakuliah where idTemp = '".$idtemp."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_trx($NoTrx, $NPM, $total, $tahun, $idoperator, $alamat, $noarsip, $semester){
			  $sql = "insert into tbmastersempek (NoTrx, tglinput, NPM, total, tahun, idoperator, alamat, noarsip, status, semester) values ('".$NoTrx."', curdate(), '".$NPM."', '".$total."', '".$tahun."', '".$idoperator."', '".$alamat."', '".$noarsip."', '1', '".$semester."') ";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_detil($NoTrx, $idmatakuliah, $sks, $biaya, $iddosen, $namadosen, $biayaoperasional){
			  $sql = "insert into tbdetilsempek (NoTrx, idmatakuliah, sks, biaya, iddosen, namadosen, biayaoperasional) values ('".$NoTrx."', '".$idmatakuliah."', '".$sks."', '".$biaya."', '".$iddosen."', '".$namadosen."', '".$biayaoperasional."')";
			  $this->query = $this-> execute($sql,''); 
		}
		
		function edit_data($biaya, $idbendaharareguler, $namabendaharareguler, $nipbendaharareguler, $idbendaharanonreguler, $namabendaharanonreguler, $nipbendaharanonreguler, $biayanonreguler, $biayaoperasionalreguler, $biayaoperasionalnonreguler){
			  $sql = "update tbbiayasks set biaya = '".$biaya."', idbendaharareguler = '".$idbendaharareguler."', namabendaharareguler = '".$namabendaharareguler."', nipbendaharareguler = '".$nipbendaharareguler."', idbendaharanonreguler = '".$idbendaharanonreguler."', namabendaharanonreguler = '".$namabendaharanonreguler."', nipbendaharanonreguler = '".$nipbendaharanonreguler."', biayanonreguler = '".$biayanonreguler."', biayaoperasionalreguler='".$biayaoperasionalreguler."', biayaoperasionalnonreguler='".$biayaoperasionalnonreguler."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_trx($notrx){
			  $sql = "update tbmastersempek set status = '0' where NoTrx = '".$notrx."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_trx_detil($notrx){
			  $sql = "delete from tbdetilsempek where NoTrx = '".$notrx."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_mata_kuliah($matakuliah, $sks, $idjurusan, $kode){
			  $sql = "insert into tbmatakuliah (matakuliah, sks, idjurusan, kode) values ('".$matakuliah."', '".$sks."', '".$idjurusan."', '".$kode."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function edit_mata_kuliah($idmatakuliah, $matakuliah, $sks, $idjurusan, $kode){
			  $sql = "update tbmatakuliah set matakuliah = '".$matakuliah."', sks = '".$sks."', idjurusan = '".$idjurusan."', kode = '".$kode."' where idmatakuliah = '".$idmatakuliah."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_mata_kuliah($idmatakuliah){
			  $sql = "delete from tbmatakuliah where idmatakuliah = '".$idmatakuliah."'";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_tempo($NoTrx, $NPM, $total, $tahun, $idoperator, $alamat, $noarsip, $semester, $idmatakuliah, $sks, $biaya, $iddosen, $namadosen, $biayaoperasional){
			  $sql = "insert into tempo (NoTrx, tglinput, NPM, total, tahun, idoperator, alamat, noarsip, status, semester, idmatakuliah, sks, biaya, iddosen, namadosen, biayaoperasional) values ('".$NoTrx."', curdate(), '".$NPM."', '".$total."', '".$tahun."', '".$idoperator."', '".$alamat."', '".$noarsip."', '1', '".$semester."', '".$idmatakuliah."', '".$sks."', '".$biaya."', '".$iddosen."', '".$namadosen."', '".$biayaoperasional."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function add_temp_bagi($NPM, $idmatakuliah, $tahun, $semester, $program, $kelas){
			  $sql = "insert into tempbagi (NPM, idmatakuliah, tahun, semester, program, kelas) values ('".$NPM."', '".$idmatakuliah."', '".$tahun."', '".$semester."', '".$program."', '".$kelas."')";
			  $this->query = $this-> execute($sql,''); 
		}
		function delete_tempbagi($idmatakuliah, $tahun, $semester, $program){
			  $sql = "delete from tempbagi where idmatakuliah = '".$idmatakuliah."' and tahun = '".$tahun."' and semester = '".$semester."' and program = '".$program."' ";
			  $this->query = $this-> execute($sql,''); 
		}
		function update_tempbagi($kelas, $dosen, $nip, $tahun, $semester, $program, $idmatkul){
			  $sql = "update tempbagi set nip = '".$nip."', dosen = '".$dosen."' where idmatakuliah = '".$idmatkul."' and tahun = '".$tahun."' and semester = '".$semester."' and program = '".$program."' and kelas = '".$kelas."' ";
			  $this->query = $this-> execute($sql,''); 
		}

	}
?>