<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
if(!$statuslogin) exit;
$mod = basename(__FILE__, '.php');
$page->tbJs($mod);
if(isset($_GET['id'])){
	$id=strip_tags(stripslashes($_GET['id']));
	$page->setJudul("Input Agenda Baru");
	$judul="";
	$sekarang=date('Y-m-d H:m:i');
	$arrtg=explode(" ", $sekarang);
	$tanggal=$db->sql_date($arrtg[0]);
	$jam=$arrtg[1];
	$keterangan="";
	
	if($id>0){
		$page->setJudul("Edit Agenda");
		$wh="";
		$datapush=array($id);
		
		$query="SELECT t1.`id`,
					t1.`tanggal`,
					t1.`judul`,
					t1.`keterangan`,
					t1.`status`
				FROM tb_agenda as t1
			WHERE t1.id=? ".$wh;
		$rs=$db->loadAssoc($query,$datapush);
		if(isset($rs['id'])){
			$judul=$rs['judul'];
			$arrtg=explode(" ", $rs['tanggal']);
			if(sizeof($arrtg)==2){
				$tanggal=$db->sql_date($arrtg[0]);
				$jam=$arrtg[1];
			}
			$keterangan=$rs['keterangan'];
		}
	}
	$datakonten=array("id"=>$id);
	$page->addLoad("managagenda.edit(".json_encode($datakonten,true).")");
	?>
	<div class="box_main_konten">
		<h3>DATA AGENDA</h3>
		<div class="group_form">
			<title>Tanggal</title>
			<div class="col10"><input style="width: 110px" id="tanggal" value="<?php echo $tanggal;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Jam</title>
			<div class="col10"><input style="width: 110px" id="jam" value="<?php echo $jam;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Judul</title>
			<div class="col10"><input id="judul" value="<?php echo $judul;?>" />
				
			</div>
		</div>
		
		<div style="clear: both;"></div>
	</div>
	<div class="box_main_konten">
		<h3>KETERANGAN AGENDA</h3>
		<div>
			<textarea id="keterangan"><?php echo $keterangan;?></textarea>
		</div>
		<div style="clear: both;"></div>
	</div>
	
	<div class="box_button_bawah" style="border-top: 1px solid #000000;padding-top: 15px;">
		<div id="loader_simpan_banner" class="error"></div>
		<span class="btmerah btncancel" onclick="managagenda.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="managagenda.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<div style="clear: both"></div>
	<?php
}else{
	$page->addLoad("managagenda.load()");
	$page->setJudul("Manajeman Agenda BPBJ");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="managagenda.loade()">
			<option value="30">30</option>
			<option value="50">50</option>
			<option value="100">100</option>
		</select> &nbsp;
		Hal: <select id="hal_ke" class="slkecil" onchange="managagenda.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Judul" onkeypress="managagenda.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="managagenda.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="managagenda.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_managagenda"></div>
	<div id="loader_data_agenda" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="managagenda.buat(0)" class="bthijau btninput">Input Agenda Baru</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="managagenda.hapus(#{id})"></span>
		<span class="icon_edit" onclick="managagenda.buat(#{id})"></span>
	</div>
	<span id="btstatus" class="#(#{status}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="managagenda.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	
	<?php
}
?>
