<?php 
	class DataPegawai extends mysql{
		
		function get_Nilai_Pegawai_tgl($kolom,$a,$type, $idPegawai, $tglAwal, $tglAkhir){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama from tbnilaipegawai tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id where tb1.idPegawai = '".$idPegawai."' and tb1.tanggal >= '".$tglAwal."' and tb1.tanggal <= '".$tglAkhir."' order by tanggal asc";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_Nilai_Pegawai($kolom,$a,$type, $idPegawai){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama from tbnilaipegawai tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id where tb1.idPegawai = '".$idPegawai."' order by tb1.tanggal desc";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_Tupoksi_Pegawai($kolom,$a,$type){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select tb1.*, tb2.Nama, tb2.NIP from tbtupoksi tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		function get_Tupoksi_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select tb1.*, tb2.Nama, tb2.NIP from tbtupoksi tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id where tb1.idPegawai = '".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}

		function get_Nilai_single_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select tb1.*, tb2.Nama, tb2.NIP, tb3.Nama as NamaPenilai, tb3.NIP as NIPPenilai from tbnilaipegawai tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id INNER JOIN tbdosen tb3 on tb1.idPenilai = tb3.Id where tb1.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_Nilai_single_by_idPegawai($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select tb1.*, tb2.Nama, tb2.NIP, tb3.Nama as NamaPenilai, tb3.NIP as NIPPenilai from tbnilaipegawai tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id INNER JOIN tbdosen tb3 on tb1.idPenilai = tb3.Id where tb1.idPegawai = '".$id."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function get_Nilai_all_by_id($kolom, $idPegawai, $tgl){
			if($this->cek_result != "on"){
			$sql = "select tb1.*, tb2.Nama, tb2.NIP from tbnilaipegawai tb1 INNER JOIN tbdosen tb2 on tb1.idPegawai = tb2.Id where tb1.idPegawai = '".$idPegawai."' and tb1.tanggal = '".$tgl."'";
			$this->result = $this->execute($sql,'order');
			$this->cek_result = "on";
			return trim($this->result[$kolom]);
			}
				else return trim($this->result[$kolom]);
		}
		function simpan_nilai($idPegawai, $tanggal, $nilai1, $nilai2, $nilai3, $nilai4, $nilai5, $tupoksi1, $tupoksi2, $tupoksi3, $tupoksi4, $tupoksi5, $idPejabat){
			  $sql = "insert into tbnilaipegawai (idPegawai, tanggal, nilai1, nilai2, nilai3, nilai4, nilai5, tupoksi1, tupoksi2, tupoksi3, tupoksi4, tupoksi5, idPenilai) values ('".$idPegawai."', '".$tanggal."', '".$nilai1."', '".$nilai2."', '".$nilai3."', '".$nilai4."', '".$nilai5."', '".$tupoksi1."', '".$tupoksi2."', '".$tupoksi3."', '".$tupoksi4."', '".$tupoksi5."', '".$idPejabat."')";
			  $this->query = $this-> execute($sql,''); 
		}

		function edit_nilai($id, $nilai1, $nilai2, $nilai3, $nilai4, $nilai5, $tanggal, $idPejabat){
			  $sql = "update tbnilaipegawai set nilai1 = '".$nilai1."', nilai2 = '".$nilai2."', nilai3 = '".$nilai3."', nilai4 = '".$nilai4."', nilai5 = '".$nilai5."', tanggal = '".$tanggal."', idPenilai = '".$idPejabat."' where id = '".$id."'";
			  $this->query = $this-> execute($sql,''); 
		}
		
		
	}
?>