<?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 Data Catatan Baru");
	$nama="";
	$idkategori=0;
	$catatan="";
	if($id>0){
		$page->setJudul("Edit Data Catatan");
		$query="SELECT * FROM tb_master_catatan 
			WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$nama=$rs['nama'];
			$idkategori=$rs['idkategori'];
			$catatan=$rs['catatan'];
		}
	}
	$hasil=array(
		"id"=>$id,
		"idkategori"=>$idkategori
	);
	$page->addLoad("mastercatatan.edit(".json_encode($hasil,true).")");
	?>
	<div class="box_main_konten">
		<h3>DETAIL DATA CATATAN</h3>
		<div class="group_form">
			<title>Kategori</title>
			<div class="col10">
				<select id="sl_kategori">
					<?php
					$query="select * from tb_master_catatan_kategori where status=1 ";
					$rskat=$db->loadAll($query);
					foreach ($rskat as $obk) {
						?>
						<option value="<?php echo $obk['id'];?>"><?php echo $obk['nama'];?></option>
						<?php
					}
					?>
				</select>
			</div>
		</div>
		<div class="group_form">
			<title>Judul Catatan</title>
			<div class="col10">
				<input id="nama" value="<?php echo $nama;?>" />
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_main_konten">
		<h3>CATATAN</h3>
		<div>
			<textarea id="catatan"><?php echo $catatan;?></textarea>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_simpan_err" class="error"></div>
		<span class="btmerah btncancel" onclick="mastercatatan.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="mastercatatan.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<?php
}else{
	$page->addLoad("mastercatatan.load()");
	$page->setJudul("Master Data Catatan");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="mastercatatan.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="mastercatatan.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Nama Catatan" onkeypress="mastercatatan.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="mastercatatan.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="mastercatatan.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_mastercatatan"></div>
	<div id="loader_data_golongan" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="mastercatatan.buat(0)" class="bthijau btninput">Tambah Data Catatan Baru</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="mastercatatan.hapus(#{id})"></span>
		<span class="icon_edit" onclick="mastercatatan.buat(#{id})"></span>
	</div>
	<span id="btstatus" style="display: none" class="#(#{status}==1)?'mini_ok':'mini_dis'#" onclick="mastercatatan.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	
	<?php
}
?>
