<?php 
	class dataAgenda extends mysql{
		function get_agenda_by_id($kolom,$id){
			if($this->cek_result != "on"){
			$sql = "select * from tbagenda 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_agenda($kolom,$a,$type, $beranda, $status, $tglawal, $tglakhir){
			if($type == '') return trim ($this->sql_order_seek($sql,$kolom,$a));
			$sql = "select * from tbagenda where beranda = '".$beranda."' and status = '".$status."' and tgl >= '".$tglawal."' and tgl <= '".$tglakhir."'";
			$this->query = $this->execute($sql,'');
			if ($type == 'jumlah') return $this->sql_order_count($sql);
		}
		
		function add_surat($tgl, $asal, $nosurat, $prihal, $tujuan, $disposisi, $dokumen, $beranda, $status){
		    $sql = "insert into tbagenda (tgl, asal, nosurat, prihal, tujuan, disposisi, dokumen, beranda, status) VALUES ('".$tgl."', '".$asal."', '".$nosurat."', '".$prihal."', '".$tujuan."', '".$disposisi."', '".$dokumen."', '".$beranda."', '".$status."')";
		    $this->query = $this-> execute($sql,''); 
		}
		function edit_surat($id, $tgl, $asal, $nosurat, $prihal, $tujuan, $disposisi, $dokumen, $beranda){
		    $sql = "update tbagenda set tgl = '".$tgl."', asal = '".$asal."', nosurat = '".$nosurat."', prihal = '".$prihal."', tujuan = '".$tujuan."', disposisi = '".$disposisi."', dokumen = '".$dokumen."', beranda = '".$beranda."' where id = '".$id."'";
			echo $sql;
		    $this->query = $this-> execute($sql,''); 
		}
		function edit_surat_dx($id, $tgl, $asal, $nosurat, $prihal, $tujuan, $disposisi, $beranda){
		    $sql = "update tbagenda set tgl = '".$tgl."', asal = '".$asal."', nosurat = '".$nosurat."', prihal = '".$prihal."', tujuan = '".$tujuan."', disposisi = '".$disposisi."', beranda = '".$beranda."' where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
		function delete_surat($id){
		    $sql = "delete from tbagenda where id = '".$id."'";
		    $this->query = $this-> execute($sql,''); 
		}
				
	}
?>