<?php 
	class dataDosen extends mysql{
		function get_pejabat_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select * from tbpejabat where id='".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
			
		function get_data_pejabat($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbpejabat";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		
		function get_data_dosen($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbdosen";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		
		function get_operator_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select * from tbdosen where Id='".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_dosen_ttd($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select tb2.Nama, tb2.NIP, tb2.Id from tbttd tb1 inner join tbdosen tb2 on tb1.".$id." = tb2.Id";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_dosen_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select * from tbdosen where Id='".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_dosen_single_by_nama($kolom,$nama){
			if($this->cek_result != "on"){
			$sql = "select * from tbdosen where Nama='".$nama."'";
			echo $sql;
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
				
		function edit_wadek($idWadek){
		    $sql = "update tbttd set wadek = '".$idWadek."'";
		    $this->query = $this-> execute($sql,''); 
		}
		function delete_dosen($id){
		    $sql = "delete from tbdosen where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
		
		function add_dosen($nama, $jk, $NIDN, $NIP, $jurusan, $pangkat, $jabatan, $gol){
		    $sql = "INSERT INTO tbdosen (Nama, JK, NIDN, NIP, JURUSAN, PANGKAT, JABATAN, GOL) VALUES ('".$nama."', '".$jk."', '".$NIDN."', '".$NIP."', '".$jurusan."', '".$pangkat."', '".$jabatan."', '".$gol."')";
		    $this->query = $this-> execute($sql,''); 
		}

		function edit_dosen($id, $nama, $jk, $NIDN, $NIP, $jurusan, $pangkat, $jabatan, $gol){
		    $sql = "UPDATE tbdosen set Nama = '".$nama."', JK = '".$jk."', NIDN = '".$NIDN."', NIP = '".$NIP."', JURUSAN = '".$jurusan."', PANGKAT = '".$pangkat."', JABATAN = '".$jabatan."', GOL = '".$gol."' where Id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}


		function edit_pejabat($id, $idDosen, $nama, $nip){
		    $sql = "update tbpejabat set nama = '".$nama."', NIP = '".$nip."', idDosen = '".$idDosen."' where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
				
	}
?>