<?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 Jabatan Struktural Baru");
	$nama="";
	$iddata=1;
	$idparrent=0;
	$qr="select max(id) as maxid from tb_master_jabatan where id>0";
	$rsj=$db->loadAssoc($qr);
	if(isset($rsj['maxid'])) $iddata=$rsj['maxid']+1;
	
	if($id>0){
		$page->setJudul("Edit Data Master Jabatan Struktural");
		$query="SELECT * FROM tb_master_jabatan 
			WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$nama=$rs['nama'];
			$iddata=$rs['id'];
			$idparrent=$rs['idparrent'];
		}
	}
	$datahasil=array(
		"id"=>$id,
		"idparrent"=>$idparrent
	);
	$page->addLoad("masterjabatan.edit(".json_encode($datahasil,true).")");
	
	?>
	<div class="box_main_konten">
		<h3>DATA JABATAN</h3>
		<div class="group_form">
			<title>ID</title>
			<div class="col10">
				<input id="iddata" value="<?php echo $iddata;?>" />
			</div>
		</div>
		<div class="group_form">
			<title>Nama Jabatan</title>
			<div class="col10">
				<input id="nama" value="<?php echo $nama;?>" />
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_masterjabatan" class="error"></div>
		<span class="btmerah btncancel" onclick="masterjabatan.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="masterjabatan.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<?php
}else{
	$page->addLoad("masterjabatan.load()");
	$page->setJudul("Data Master Jabatan Struktural");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="masterjabatan.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="masterjabatan.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Nama Jabatan" onkeypress="masterjabatan.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="masterjabatan.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="masterjabatan.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_masterjabatan"></div>
	<div id="loader_datamasterjabatan" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="masterjabatan.buat(0)" class="bthijau btninput">Buat Data Jabatan Struktural Baru</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="masterjabatan.hapus(#{id})"></span>
		<span class="icon_edit" onclick="masterjabatan.buat(#{id})"></span>
	</div>
	<span id="btstatus" class="#(#{status}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterjabatan.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btjumlahsub" class="bthijau medium" style="display:none;" onclick="masterjabatan.bukasub(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_sub}</span>
	<div id="bteditsub" style="display:none;">
		<span class="icon_del" onclick="masterjabatan.hapussub(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
		<span class="icon_edit" onclick="masterjabatan.editsub(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	</div>
	<div id="box_subjabatan" style="display:none;padding:10px">
		<div style="padding: 10px;">
			<div class="group_form">
				<title>ID Sub Jabatan</title>
				<div class="col10">
					<input id="idsub" />
				</div>
			</div>
			<div class="group_form">
				<title>Nama Sub Jabatan</title>
				<div class="col10">
					<input id="namasub" />
				</div>
			</div>
			
			<div class="group_form">
				<title>&nbsp;</title>
				<div class="col10">
					<div class="box_button_bawah">
						<div class="err" id="loader_sub"></div>
						<span class="btmerah" onclick="masterjabatan.batalsub()">BATAL</span>&nbsp;&nbsp;
						<span class="bthijau" onclick="masterjabatan.inputsub()">SIMPAN</span>
					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<?php
}
?>
