<?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 Master data Status Baru");
	$nama="";
	$keterangan="";
	$idkategori=0;
	if(isset($_GET['idkat'])) $idkategori=$_GET['idkat'];
	
	$bg="#000000";
	$warna="#ffffff";
	$idmasterstatus="";
	if($id<=0 && $idkategori>0){
		$query="select max(id) as maxid from tb_master_status where idkategori=? ";
		$rsid=$db->loadAssoc($query,array($idkategori));
		if(isset($rsid['maxid'])) $idmasterstatus=$rsid['maxid']+1;
	}
	
	if($id>0){
		$idmasterstatus=$id;
		$page->setJudul("Edit Master data Status");
		$query="SELECT * FROM tb_master_status 
			WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$nama=$rs['nama'];
			$keterangan=$rs['keterangan'];
			$bg=$rs['bg'];
			$warna=$rs['warna'];
			$idkategori=$rs['idkategori'];
		}
	}
	$hasil=array("id"=>$id,"idkategori"=>$idkategori);
	$page->addLoad("masterstatus.edit(".json_encode($hasil,true).")");
	?>
	<div class="box_main_konten">
		<h3>DETAIL DATA STATUS</h3>
		<div class="group_form">
			<title>ID/Kode Status</title>
			<div class="col10"><input id="idmasterstatus" value="<?php echo $idmasterstatus;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Kategori Status</title>
			<div class="col10">
				<select id="sl_kategori">
					<option value="0">Pilih Kategori</option>
					<?php
					$query="select * from tb_kategori_status where status=1 order by id asc";
					$rskat=$db->getObj($query);
					foreach ($rskat as $obj) {
						?>
						<option value="<?php echo $obj->id;?>"><?php echo $obj->nama;?></option>
						<?php
					}
					?>
				</select>
			</div>
		</div>
		<div class="group_form">
			<title>Nama Status</title>
			<div class="col10"><input id="nama" value="<?php echo $nama;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Warna Status</title>
			<div class="col10"><input id="bg" value="<?php echo $bg;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Warna Text</title>
			<div class="col10"><input id="warna" value="<?php echo $warna;?>" />
				
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<span class="btmerah btncancel" onclick="masterstatus.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="masterstatus.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<?php
}else{
	$idkategori=0;
	if(isset($_GET['idkategori'])) $idkategori=$_GET['idkategori'];
	$dataload=array("idkategori"=>$idkategori);
	$page->addLoad("masterstatus.init(".json_encode($dataload,true).")");
	$page->setJudul("Master Status");
	?>
	<div class="box_button_atas">
		Kategori &nbsp;
		<select id="sl_kategori" onchange="masterstatus.loade()">
			<option value="0">Pilih Kategori</option>
			<?php
			$query="select * from tb_kategori_status where status=1 order by id asc";
			$rskat=$db->getObj($query);
			foreach ($rskat as $obj) {
				?>
				<option value="<?php echo $obj->id;?>"><?php echo $obj->nama;?></option>
				<?php
			}
			?>
		</select>&nbsp;&nbsp;
		Baris: <select id="jumlah_hal" class="slkecil" onchange="masterstatus.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="masterstatus.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Nama Status" onkeypress="masterstatus.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="masterstatus.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="masterstatus.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_masterstatus"></div>
	<div class="box_button_bawah">
		<div id="loader_data_status" class="error"></div>
		<span onclick="masterstatus.buat(0)" class="bthijau btninput">Tambah Status Baru</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="masterstatus.hapus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
		<span class="icon_edit" onclick="masterstatus.buat(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	</div>
	<span id="btjumlahmodule" class="bthijau medium" style="display:none;" onclick="masterstatus.bukamodule(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_module}</span>
	<span id="btstatus" class="#(#{status}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterstatus.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="bthapusmodule" style="display: none" class="icon_del" onclick="masterstatus.hapusmodule(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<div id="box_cari_module" class="boxwin boxwinhd">
		<div style="padding: 10px;">
			<div class="box_button_atas">
				Baris: <select id="jumlah_hal_module" class="slkecil" onchange="masterstatus.loademodule()">
					<option value="30">30</option>
					<option value="50">50</option>
					<option value="100">100</option>
				</select> &nbsp;
				Hal: <select id="hal_ke_module" class="slkecil" onchange="masterstatus.loadmodule()"><option value="1">1</option></select>
				&nbsp;<input placeholder="Default: Nama Module" onkeypress="masterstatus.entermodule(event)" id="cari_module" class="in_cari" />
				&nbsp;&nbsp;<span id="btcari_module" class="btnone btncari" onclick="masterstatus.loademodule()">Cari</span>
			</div>
			<div id="grid_data_module"></div>
			<div class="box_button_bawah">
				<div class="err" id="loader_module"></div>
				<span class="btmerah" onclick="masterstatus.batalpilihmodule()">BATAL</span>&nbsp;&nbsp;
				<span class="bthijau" onclick="masterstatus.prosespilihmodule()">PROSES</span>&nbsp;&nbsp;
			</div>
		</div>
	</div>
	<span id="btkode" class="bthijau medium" style="display:none;" onclick="masterstatus.editkode(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{id}</span>
	
	<span id="btpilihmodule" stpilih="0" style="display:none;" class="bt_tidak" onclick="masterstatus.pilihdatamodule(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btstatusedit" class="#(#{statusedit}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterstatus.setstatusedit(##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btstatushapus" class="#(#{statushapus}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterstatus.setstatushapus(##{jumlah_tabel},##{baris_tabel},this)"></span>
	
	<span id="btjumlahedit" class="bthijau medium" style="display:none;" onclick="masterstatus.bukaedit(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_edit}</span>
	<span id="btjumlahhapus" class="bthijau medium" style="display:none;" onclick="masterstatus.bukahapus(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_hapus}</span>
	<span id="btjumlahvalidasi" class="bthijau medium" style="display:none;" onclick="masterstatus.bukavalidasi(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_validasi}</span>
	
	<span id="btjumlahnotif" class="bthijau medium" style="display:none;" onclick="masterstatus.bukanotifikasi(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_notifikasi}</span>
	<span id="btstatuslevel" stpilih="0" style="display:none;" class="#(#{status}==1)?'mini_ok':'mini_dis'#" onclick="masterstatus.setaktiflevel(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btjumlahview" class="bthijau medium" style="display:none;" onclick="masterstatus.bukamoduleview(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{jumlah_view}</span>
	<span id="bthapusmoduleview" style="display: none" class="icon_del" onclick="masterstatus.hapusmoduleview(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btupdaterevisi" class="#(#{update_revis}==1)?'mini_ok':'mini_dis'#" style="display:none;" onclick="masterstatus.setstatusupdaterevisi(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<span id="btstatusvalidasi" stpilih="0" style="display:none;" class="#(#{statusvalidasi}==1)?'mini_ok':'mini_dis'#" onclick="masterstatus.setstatusvalidasi(##{jumlah_tabel},##{baris_tabel},this)"></span>
	<div id="box_kode" class="boxwin boxwinhd">
		<div style="padding: 10px;">
			<div class="group_form">
				<title>Kode Status</title>
				<div class="col10">
					<input id="kodestatus"/>
				</div>
			</div>
			<div class="group_form">
				<title>&nbsp;</title>
				<div class="col10">
					<div class="err" id="loader_kode"></div>
					<span class="btmerah" onclick="masterstatus.batalkode()">BATAL</span>&nbsp;&nbsp;
					<span class="bthijau" onclick="masterstatus.simpankode()">SIMPAN</span>&nbsp;&nbsp;
				</div>
			</div>
			
			<div style="clear: both;"></div>
		</div>
	</div>
	<?php
}
?>
