<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
if(!$statuslogin) exit;
$mod = basename(__FILE__, '.php');
$page->tbJs($mod);
$page->addPlugin("pilihstatus");
if(isset($_GET['id'])){
	$id=strip_tags(stripslashes($_GET['id']));
	$page->setJudul("Input Data Master Disposisi Baru");
	$nama="";
	$idjenissurat=0;
	
	if($id>0){
		$page->setJudul("Edit Data Master Disposisi");
		$query="SELECT * FROM tb_master_disposisi 
			WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$nama=$rs['nama'];
			$idjenissurat=$rs['idjenissurat'];
		}
	}
	$datahasil=array(
		"id"=>$id,
		"idjenissurat"=>$idjenissurat
	);
	$page->addLoad("masterdisposisi.edit(".json_encode($datahasil,true).")");
	
	?>
	<div class="box_main_konten">
		<h3>DATA DISPOSISI</h3>
		
		<div class="group_form">
			<title>Nama Disposisi</title>
			<div class="col10">
				<input id="nama" value="<?php echo $nama;?>" />
			</div>
		</div>
		<div class="group_form">
			<title>Jenis Surat</title>
			<div class="col10">
				<select id="sj_jenissurat">
					<?php
					$query="select * from tb_master_jenissurat where status=1";
					$rsj=$db->loadAll($query);
					foreach ($rsj as $obj) {
						?>
						<option value="<?php echo $obj['id'];?>"><?php echo $obj['nama'];?></option>
						<?php
					}
					?>
				</select>
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_masterdisposisi" class="error"></div>
		<span class="btmerah btncancel" onclick="masterdisposisi.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="masterdisposisi.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<?php
}else{
	$page->addJs(BS_JS."reqcb.js");
	$page->addLoad("masterdisposisi.load()");
	$page->setJudul("Master Data Master Disposisi");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="masterdisposisi.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="masterdisposisi.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Nama Disposisi" onkeypress="masterdisposisi.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="masterdisposisi.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="masterdisposisi.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_masterdisposisi"></div>
	<div id="loader_datamasterdisposisi" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="masterdisposisi.buat(0)" class="bthijau btninput">Buat Data Master Disposisi Baru</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="masterdisposisi.hapus(#{id})"></span>
		<span class="icon_edit" onclick="masterdisposisi.buat(#{id})"></span>
	</div>
	<span id="btstatus" class="#(#{status}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterdisposisi.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="bturutan" class="bthijau medium" style="display:none;" onclick="masterdisposisi.bukaurutan(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{urutan}</span>
	<span id="btjumlahdis" class="bthijau medium" style="display:none;" onclick="masterdisposisi.bukadis(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_disposisi}</span>
	<span id="btjumlahjabatan" class="#(#{mode}!=2)?'bthijau medium':''#" style="display:none;" onclick="masterdisposisi.bukajabatandis(#{id},##{jumlah_tabel},##{baris_tabel},this)">#(#{mode}!=2)?'#{jumlah_jabatan}':''#</span>
	<span id="btstatussub" class="#(#{status}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterdisposisi.setstatussub(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btjumlahstatus" class="bthijau medium" style="display:none;" onclick="masterdisposisi.bukastatus(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_status}</span>
	<div id="bteditsub" style="display:none;">
		<span class="icon_del" onclick="masterdisposisi.hapussub(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
		<span class="icon_edit" onclick="masterdisposisi.editsub(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	</div>
	<div id="box_datadisposisi" style="display:none;padding:10px">
		<div style="padding: 10px;">
			<div class="group_form">
				<title>Urutan</title>
				<div class="col10">
					<input id="urutan" style="width: 110px;" />
					<div id="loader_urutan"></div>
				</div>
			</div>
			<div class="group_form">
				<title>Mode</title>
				<div class="col10">
					<select id="sl_mode"></select>
				</div>
			</div>
			<div class="group_form">
				<title>Nama</title>
				<div class="col10">
					<input id="nama"/>
				</div>
			</div>
			<div class="group_form">
				<title>Keterangan</title>
				<div class="col10">
					<input id="keterangan" />
				</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="masterdisposisi.bataldatadis()">BATAL</span>&nbsp;&nbsp;
						<span class="bthijau" onclick="masterdisposisi.inputdatadis()">SIMPAN</span>
					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div id="box_jabatandisposisi" style="display:none;padding:10px">
		<div style="padding: 10px;">
			<div class="group_form">
				<title>Mode Jabatan</title>
				<div class="col10">
					<select id="sl_modejabatan" onchange="masterdisposisi.getjabatan(0)">
						<option value="1">Struktural</option>
						<option value="2">Fungsional</option>
					</select>
				</div>
			</div>
			<div class="group_form">
				<title id="ttlnamajabatan">Jabatan</title>
				<div class="col10">
					<select id="sl_jabatan"></select>
				</div>
			</div>
			<div class="group_form">
				<title>&nbsp;</title>
				<div class="col10">
					<div class="box_button_bawah">
						<div class="err" id="loader_jabatan"></div>
						<span class="btmerah" onclick="masterdisposisi.bataldatadisjbt()">BATAL</span>&nbsp;&nbsp;
						<span class="bthijau" onclick="masterdisposisi.inputdatadisjbt()">SIMPAN</span>
					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div id="btmodedis" style="display: none;">#(#{mode}==0)?'Sesuai Jabatan':((#{mode}==1)?'Atasan pengirim':((#{mode}==2)?'Disposisi Manual':''))#</div>
	<span id="btmodejabatan" style="display: none">#(#{mode}==1)?'Struktural':'Fungsional'#</span>
	<div id="bteditjabatan" style="display:none;">
		<span class="icon_del" onclick="masterdisposisi.hapusjabatan(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
		<span class="icon_edit" onclick="masterdisposisi.editjabatan(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	</div>
	<span id="btjabatanview" class="#(#{view}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterdisposisi.setstatusview(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btjabatanedit" class="#(#{edit}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterdisposisi.setstatusedit(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btjabatanhapus" class="#(#{hapus}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterdisposisi.setstatushapus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<div id="bteditst" style="display:none;">
		<span class="icon_del" onclick="masterdisposisi.hapusjabatanst(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	</div>
	<?php
}
?>
