var epengajuanpkl=(function(){
	var hal=0;
	var jumlah=30;
	var idepengajuanpkl=0;
	var datapeserta=[];
	var datadokumen=[];
	var boxpeserta=null;
	var boxuploaddokumen=null;
	var editstatus=1;
	var idsurat=0;
	var jumlahReq=0;
	return{
		reqcb:function(jumlah){
			var requestcb = new reqcb({
			    jumlahReq: jumlah
			});
			return requestcb;
		},
		caricanggih:function(){
			var loadercari=mload.loader({"keterangan":"Proses ...."});
			var ik_data = {ajax: 1,mode: "mod",cl: "epengajuanpkl",
				ikdata: {0:"datacari01",1:1}
			};
			
			$.ajax({url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					loadercari.tutup();
					if(e!=false){
						var boxcari;
						var obj=new Object;
						obj.proses=function(a){
							$("#cari").val(a);
							boxcari.tutup();
							document.getElementById("btcari").click();
						};
						var datacari={"data":e,"proses":obj}
						boxcari=caricanggih.buka(datacari);
					}
				}
			});
		},
		enter:function(e){
			if(e.which == 13 || e.keyCode == 13){
				epengajuanpkl.loade();
			}
		},
		loade:function(){
			$("#hal_ke").val(0);
			epengajuanpkl.load();
		},
		load:function(){
			var nohal=$("#hal_ke").val()
			jumlah=$("#jumlah_hal").val();
			hal=(nohal-1)*jumlah;
			var cr=$("#cari").val();
			
			$("#grid_epengajuanpkl").html("");
			var loaderdata=mload.loading({"el":"loader_dataepengajuanpkl"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getTabel",1:hal,2:jumlah,3:cr}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					loaderdata.tutup();
					//alert(JSON.stringify(e));
					if(e!=false && e.length>0){
						
						if(e.length>0 && e[0]['halaman']>0){
							var htm;
							for(var i=0;i<e[0]['halaman'];i++){
								htm+="<option value='"+(i+1)+"'>"+(i+1)+"</option>";
							}
							$("#hal_ke").html(htm);
							
						}
						$("#hal_ke").val(nohal);
						
						var datatb={
							box:"grid_epengajuanpkl",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":hal,"jumlah":jumlah},
									{"col":"tanggal_surat","judul":"Tanggal Surat","tipe":"data","format":"tanggal","lebar":"80px","align":"center"},
									{"judul":"Detail Sekolah","tipe":"tpl","tpl":"btdetailsekolah"},
									{"col":"nomor_surat_pengajuan","judul":"Nomor Surat","tipe":"data","lebar":"160px"},
									{"align":"center","judul":"Peserta","tipe":"tpl","tpl":"btpeserta","lebar":"80px"},
									{"align":"center","judul":"Catatan","tipe":"tpl","tpl":"btcatatan","lebar":"60px"},
									{"align":"center","judul":"Cetak","tipe":"tpl","tpl":"btcetak","lebar":"40px"},
									{"align":"center","judul":"Status","tipe":"tpl","tpl":"btstatus","lebar":"210px"},
									{"align":"center","judul":"","tipe":"tpl","tpl":"btedit","lebar":"60px"},
									
								],
							mod:"mod",
							module:"epengajuanpkl"
						};
						tabel.multisub(datatb);
					}else{
						loaderdata.pesan("BELUM ADA DATA");
					}
				}
			});
		},
		buat:function(a){
			document.location=lokal+"member/mod/epengajuanpkl?id="+a+"&scrmenu="+modmenu.getmenuscr();
		},
		kembali:function(){
			document.location=lokal+"member/mod/epengajuanpkl?scrmenu="+modmenu.getmenuscr();
		},
		edit:function(a){
			idepengajuanpkl=a['id'];
			idsurat=a['idsurat'];
			editstatus=a['editstatus'];
			statusdisposisi=a['statusdisposisi'];
			
            $("#tanggalsurat").datepicker({
                inline: true,
                dateFormat: 'dd/mm/yy'
            });
            
            
			$("#btcetaksurat").hide();
			if(a['statusdisposisi']==1 && (a['status']==68 || a['status']==69)){
				$("#btcetaksurat").show();
				document.getElementById("btcetaksurat").onclick=function(){
					var jenissurat=a['jenissurat'];
					var namalib=a['lib'];
					
					var judulsurat="Cetak "+jenissurat;
					var obj={
						"judul":judulsurat,
						"lib":namalib,
						"data":{"idsurat":idsurat}
					};
					cetak.cetaksample(obj);
				};
			}
			
			$("#sl_propinsi").val(a['idpropinsi']);
			epengajuanpkl.propch(a['idkota']);
			
			epengajuanpkl.getcatatansurat(idsurat);
			var obj=new Object;
			var cbf=epengajuanpkl.reqcb(3);
			
			cbf.addCallbackToQueue(true, function() {
	            epengajuanpkl.getcatatansurat(idsurat);
	        });
			
			cbf.addCallbackToQueue(true, function() {
	            epengajuanpkl.getdatapeserta(idepengajuanpkl);
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            epengajuanpkl.getdokumensurat(idepengajuanpkl);
	        });
		},
		propch:function(a){
			var idkota=a || 0;
			var idprop=$("#sl_propinsi").val();
			var loaderkota=mload.loading({"el":"sl_kota"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getdatakota",
					idpropinsi:idprop}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						var htm="<option value='0'>Pilih Kota</option>";
						for(var i=0;i<e.length;i++){
							htm+="<option value='"+e[i]['id']+"'>"+e[i]['kota']+"</option>";
						}
						loaderkota.pesan(htm);
						$("#sl_kota").val(idkota);
					}else{
						loaderkota.pesan("<option value='0'>Pilih Kota</option>");
					}
				}
			});
		},
		getcatatansurat:function(a){
			$("#grid_catatan").html("");
			var loaderdatacatatan=mload.loading({"el":"grid_catatan"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getcatatansurat",idsurat:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						var tabeldata={
							box:"grid_catatan",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tbclass:"table_grid",
							isi:[
									{"align":"center","judul":"Tanggal","tipe":"data","col":"tanggal","lebar":"140px","format":"tanggal"},
									{"judul":"Nama Pegawai","tipe":"data","col":"namapegawai","lebar":"250px"},
									{"col":"catatan","judul":"Catatan","tipe":"data"},
									
								],
							mod:"mod",
							module:"epengajuanpkl"
						};
						tabel.multisub(tabeldata);
						
					}else{
						loaderdatacatatan.pesan("Tidak ada catatan");
					}
				}
			});
		},
		getdatapeserta:function(a){
			datapeserta=[];
			var loaderdatacatatan=mload.loading({"el":"grid_peserta"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getdatapeserta",
					idsuratpkl:idepengajuanpkl}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						for(var i=0;i<e.length;i++){
							datapeserta.push({
								"nama":e[i]['nama'],
								"nopelajar":e[i]['nopelajar'],
								"alamat":e[i]['alamat'],
								"editstatus":editstatus
							});
						}
						epengajuanpkl.tabelpeserta();
					}else{
						loaderdatacatatan.pesan("TIDAK ADA PESERTA");
					}
				}
			});
		},
		getdokumensurat:function(a){
			datadokumen=[];
			$("#grid_dokumen").html("");
			var loaderdatadok=mload.loading({"el":"grid_dokumen"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getdokumensurat",
					idsuratpkl:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						loaderdatadok.tutup();
						for(var i=0;i<e.length;i++){
							datadokumen.push({
								"nama":e[i]['nama'],
								"iddokumen":e[i]['iddokumen'],
								"edit":editstatus,
								"statusdisposisi":statusdisposisi
							});
						}
						epengajuanpkl.tabeldokumen();
					}else{
						loaderdatadok.pesan("Tidak ada data dokumen");
					}
				}
			});
		},
		inputpeserta:function(){
			var ps={"box":"box_peserta",
				"judul":"Input Data Peserta",tinggi:"auto","lebar":"800"};
	
			boxpeserta=boxwin.load(ps);
			boxpeserta.buka();
			
			$("#loader_peserta").html("");
			$("#namapeserta").val("");
			$("#nopelajar").val("");
			$("#alamat").val("");
		},
		simpanpeserta:function(){
			$("#loader_peserta").html("");
			var nama=$("#namapeserta").val();
			var nopelajar=$("#nopelajar").val();
			var alamat=$("#alamat").val();
			
			var err="";
			if(nama=="") err+="Nama peserta belum diisi!<br/>";
			if(nopelajar=="") err+="NIM/NIS peserta belum diisi!<br/>";
			if(alamat=="") err+="Alamat peserta belum diisi!<br/>";
			if(err!=""){
				$("#loader_peserta").html(err);
				return;
			}
			
			datapeserta.push({
				"nama":nama,
				"nopelajar":nopelajar,
				"alamat":alamat,
				"editstatus":editstatus,
			});
			
			epengajuanpkl.tabelpeserta();
			epengajuanpkl.batalsimpanpeserta();
		},
		hapuspeserta:function(b,c,d){
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data peserta surat PKL ini ?? ",
				proses:function(){
					boxyesno.tutup();
					datapeserta.splice(c,1);
					epengajuanpkl.tabelpeserta();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		batalsimpanpeserta:function(){
			if(boxpeserta!=null) boxpeserta.tutup();
			boxpeserta=null;
		},
		inputdokumen:function(){
			var ps={"box":"box_upload_dok",
				"judul":"Upload Dokumen Surat",tinggi:"auto","lebar":"800"};
	
			boxuploaddokumen=boxwin.load(ps);
			boxuploaddokumen.id=0;
			boxuploaddokumen.iddokumen=0;
			boxuploaddokumen.tabel=0;
			boxuploaddokumen.baris=0;
			boxuploaddokumen.el=null;
			boxuploaddokumen.buka();
			
			$("#loader_upload").html("");
			$("#namadokumen").val("");
			$("#upload_dokumen").html("");
			
			upload.tambahupload("upload_dokumen",epengajuanpkl.objupload("UPLOAD DOKUMEN SURAT","tidak"));
		},
		simpandokumen:function(){
			$("#loader_upload").html("");
			var namadok=$("#namadokumen").val();
			var iddokumen=boxuploaddokumen.iddokumen;
			var err="";
			if(namadok=="") err+="Nama dokumen belum diisi!<br/>";
			if(iddokumen<=0) err+="Dokumen belum diupload!<br/>";
			if(err!=""){
				$("#loader_upload").html(err);
				return;
			}
			
			datadokumen.push({
				"nama":namadok,
				"iddokumen":boxuploaddokumen.iddokumen,
				"edit":editstatus,
				"statusdisposisi":statusdisposisi
			});
			
			epengajuanpkl.tabeldokumen();
			epengajuanpkl.bataluploaddokumen();
		},
		hapusdokumen:function(b,c,d){
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data dokumen pengajuan PKL ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					datadokumen.splice(c,1);
					epengajuanpkl.tabeldokumen();
					loaderhapus.tutup();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		bataluploaddokumen:function(){
			if(boxuploaddokumen!=null) boxuploaddokumen.tutup();
			boxuploaddokumen=null;
		},
		tabelpeserta:function(){
			$("#grid_peserta").html("TIDAK ADA PESERTA");
			if(datapeserta.length>0){
				var tabeldata={
					box:"grid_peserta",
					data:datapeserta,
					lebarmin:"500px",
					trklik:{"data":"id","fungsi":"barisklik"},
					title:"kategori Menu",
					tbclass:"table_grid",
					isi:[
							{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
							{"judul":"Nama Peserta","tipe":"data","col":"nama","lebar":"200px"},
							{"judul":"NIM/NIS","tipe":"data","col":"nopelajar","lebar":"120px"},
							{"judul":"Alamat Peserta","tipe":"data","col":"alamat"},
							{"align":"center","judul":"","tipe":"tpl","tpl":"bteditpeserta","lebar":"70px"},
						],
					mod:"mod",
					module:"epengajuanpkl"
				};
				tabel.multisub(tabeldata);
			}
			
		},
		tabeldokumen:function(){
			$("#grid_dokumen").html("Tidak ada data!");
			
			if(datadokumen.length>0){
				var tabeldata={
					box:"grid_dokumen",
					data:datadokumen,
					lebarmin:"500px",
					trklik:{"data":"id","fungsi":"barisklik"},
					title:"kategori Menu",
					tbclass:"table_grid",
					isi:[
							{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
							{"judul":"Nama Dokumen","tipe":"data","col":"nama"},
							{"align":"center","judul":"Dok","tipe":"tpl","tpl":"btdokumen","lebar":"70px"},
							{"align":"center","judul":"","tipe":"tpl","tpl":"bteditdokumen","lebar":"70px"},
						],
					mod:"mod",
					module:"epengajuanpkl"
				};
				tabel.multisub(tabeldata);
			}
		},
		simpan:function(a){
			var submitdata=a || 0;
			
			$("#loader_epengajuanpkl").html("");
			var keterangan=$("#keterangan").val();
			var namasekolah=$("#namasekolah").val();
			var alamatsekolah=$("#alamatsekolah").val();
			var tanggalsurat=$("#tanggalsurat").val();
			var idpropinsi=$("#sl_propinsi").val();
			var idkota=$("#sl_kota").val();
			var propinsi=kudus.selecttext("sl_propinsi");
			var kota=kudus.selecttext("sl_kota");
			var nomorsuratpengajuan=$("#nomorsuratpengajuan").val();
			
			var err="";
			if(namasekolah=="") err+="Nama sekolah belum diisi.</br>";
			if(alamatsekolah=="") err+="Alamat sekolah belum diisi.</br>";
			if(datapeserta.length<=0) err+="Daftar Peserta belum diisi.</br>";
			if(idpropinsi=="" || idpropinsi<=0) err+="Propinsi sekolah peserta belum diisi.</br>";
			if(idkota=="" || idkota<=0) err+="Kota/Kabupaten sekolah peserta belum diisi.</br>";
			if(err!=""){
				$("#loader_epengajuanpkl").html(err);
				return;
			}
			var fg="inputepengajuanpkl";
			if(idepengajuanpkl>0){
				fg="editepengajuanpkl";
			}
			
			var loadersimpan=mload.loader({"keterangan":"Proses simpan data"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:fg,
					nomorsuratpengajuan:nomorsuratpengajuan,
					namasekolah:namasekolah,
					idpropinsi:idpropinsi,
					idkota:idkota,
					propinsi:propinsi,
					kota:kota,
					alamatsekolah:alamatsekolah,
					keterangan:keterangan,
					datapeserta:datapeserta,
					datadokumen:datadokumen,
					submitdata:submitdata,
					id:idepengajuanpkl}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e.hasOwnProperty("status")){
						if(e['status']==1){
							epengajuanpkl.kembali();
						}else{
							loadersimpan.error(e['pesan']);
						}
					}else{
						loadersimpan.error([{"pesan":"Gagal proses simpan data"}]);
					}
				}
			});
		},
		hapus:function(a){
			if(a<=0) return;
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data pengajuan PKL ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					var ik_data = {
						ajax: 1,
						mode: "mod",
						cl: "epengajuanpkl",
						ikdata: {0:"hapusData",id:a}
					};
					
					$.ajax({
						url: lokal+"man.ajax.php",
						type: "POST",
						dataType: "json",
						async:true,
						data: ik_data,
						success: function(e){
							if(e!=false && e.hasOwnProperty("status")){
								if(e['status']==1){
									loaderhapus.error([{"pesan":"Berhasil"}]);
									epengajuanpkl.load();
								}else{
									loaderhapus.error(e['pesan']);
								}
								
							}else{
								loaderhapus.error([{"pesan":"Gagal hapus data"}]);
							}
						}
					});
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		lihatcatatan:function(a,b,c,d){
			var idtb=b+"_"+c;
            
            var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
            htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>CATATAN </b></div>";
            htm+="<select id=\"jumlah_hal_"+idtb+"\" class=\"slkecil\" onchange=\"epengajuanpkl.loaddatacttpe("+b+","+c+")\">";
            htm+="<option value=\"30\">30</option>";
            htm+="<option value=\"50\">50</option>";
            htm+="<option value=\"100\">100</option>";
            htm+="</select>";
            htm+="&nbsp;&nbsp;Hal <select id=\"hal_ke_"+idtb+"\" class=\"slkecil\" onchange=\"epengajuanpkl.loaddatactt("+b+","+c+")\"><option value=\"1\">1</option></select>";
            htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
            htm+="<div id='loader_sub_"+idtb+"'></div>";
            htm+="<div id='grid_sub_"+idtb+"'></div>";
            
            htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
            htm+="<div align='left'>";
            htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span>&nbsp;&nbsp;";
            
            htm+="</div>";
            htm+="</div>";
            
            htm+="</div>";
            var obj=new Object;
            obj.html=htm;
            
            if(tabel.gettabel(b)!=null){
                tabel.gettabel(b).maxim(obj,c);
                var trparr=d.offsetParent.parentNode;
                var tdarr=trparr.childNodes;
                for(var n=0;n<tdarr.length;n++){
                    tdarr[n].removeAttribute("class");
                    tdarr[n].setAttribute("class","garis_kiri_td");
                }
                d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
            };
            
            document.getElementById("bt_hide_"+idtb).onclick=function(){
                tabel.gettabel(b).minim(c);
                var trparr=d.offsetParent.parentNode;
                var tdarr=trparr.childNodes;
                for(var n=0;n<tdarr.length;n++){
                    tdarr[n].removeAttribute("class");
                    tdarr[n].setAttribute("class","garis_kiri_td");
                }
            };
            
            epengajuanpkl.loaddatactt(b,c);
		},
		loaddatactte:function(b,c){
			var idtb=b+"_"+c;
			$("#hal_ke_"+idtb).val(0);
			epengajuanpkl.loaddatactt(b,c);
		},
		loaddatactt:function(b,c){
			var idtb=b+"_"+c;
			var idsurat=tabel.gettabel(b).getdata(c,"idsurat");
			var loaderdatasub=mload.loading({"el":"loader_sub_"+idtb});
			var hal=$("#hal_ke_"+idtb).val();
			var jumlah=$("#jumlah_hal_"+idtb).val();
			var posisiawal=(hal-1)*jumlah;
			
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getdataCatatan",
					halaman:hal,jumlah:jumlah,
					idsurat:idsurat}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.hasOwnProperty("data")){
						loaderdatasub.tutup();
						var data=e['data'];
						var jumlahhalaman=e['totalhalaman'];
						if(data.length>0){
							var htm="";
							for(var i=0;i<jumlahhalaman;i++){
								htm+="<option value=\""+(i+1)+"\">"+(i+1)+"</option>";
							}
							$("#hal_ke_"+idtb).html(htm);
							$("#hal_ke_"+idtb).val(hal);
							
							var tabeldata={
								box:"grid_sub_"+idtb,
								data:data,
								lebarmin:"500px",
								trklik:{"data":"id","fungsi":"barisklik"},
								title:"kategori Menu",
								tbclass:"table_grid-1",
								tabelpar:b,
                            	barispar:c,
								isi:[
										{"align":"center","judul":"Tanggal","tipe":"data","col":"tanggal","lebar":"140px","format":"tanggal"},
										{"judul":"Nama Pegawai","tipe":"data","col":"namapegawai","lebar":"120px"},
										{"col":"catatan","judul":"Catatan","tipe":"data"},
									],
								mod:"mod",
								module:"epengajuanpkl"
							};
							tabel.multisub(tabeldata);
						}else{
							loaderdatasub.pesan("TIDAK ADA DATA");
						}
					}
				}
			});
		},
		bukapeserta:function(a,b,c,d){
			var idtb=b+"_"+c;
            
            var htm="<div align='left' style='padding-top:10px;padding-bottom:10px;width:100%;'>";
            htm+="<div style='margin-top:10px;margin-bottom:10px;'><b>DATA PESERTA </b></div>";
            htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
            htm+="<div id='loader_sub_"+idtb+"'></div>";
            htm+="<div id='grid_sub_"+idtb+"'></div>";
            
            htm+="<div style='margin-top:10px;margin-bottom:10px;'>";
            htm+="<div align='left'>";
            htm+="<span class='btmerah medium' id='bt_hide_"+idtb+"'>TUTUP</span>&nbsp;&nbsp;";
            
            htm+="</div>";
            htm+="</div>";
            
            htm+="</div>";
            var obj=new Object;
            obj.html=htm;
            
            if(tabel.gettabel(b)!=null){
                tabel.gettabel(b).maxim(obj,c);
                var trparr=d.offsetParent.parentNode;
                var tdarr=trparr.childNodes;
                for(var n=0;n<tdarr.length;n++){
                    tdarr[n].removeAttribute("class");
                    tdarr[n].setAttribute("class","garis_kiri_td");
                }
                d.offsetParent.setAttribute("class","garis_kiri_td bghijau");
            };
            
            document.getElementById("bt_hide_"+idtb).onclick=function(){
                tabel.gettabel(b).minim(c);
                var trparr=d.offsetParent.parentNode;
                var tdarr=trparr.childNodes;
                for(var n=0;n<tdarr.length;n++){
                    tdarr[n].removeAttribute("class");
                    tdarr[n].setAttribute("class","garis_kiri_td");
                }
            };
            
            var loaderpeserta=mload.loading({"el":"loader_sub_"+idtb});
            var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "epengajuanpkl",
				ikdata: {0:"getdatapeserta",
					idsuratpkl:a}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						loaderpeserta.tutup();
						var tabeldata={
							box:"grid_sub_"+idtb,
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tbclass:"table_grid-1",
							tabelpar:b,
                        	barispar:c,
							isi:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":0},
									{"judul":"Nama Peserta","tipe":"data","col":"nama","lebar":"200px"},
									{"judul":"NIM/NIS","tipe":"data","col":"nopelajar","lebar":"120px"},
									{"judul":"Alamat Peserta","tipe":"data","col":"alamat"},
								],
							mod:"mod",
							module:"epengajuanpkl"
						};
						tabel.multisub(tabeldata);
					}else{
						loaderpeserta.pesan("BELUM ADA PESERTA");
					}
				}
			});
		},
		initcetak:function(a,b,c,d){
			var status=tabel.gettabel(b).getdata(c,"status");
			var statusdisposisi=tabel.gettabel(b).getdata(c,"statusdisposisi");
			if((status!=68 && status!=69) || statusdisposisi!=1) return;
			var jenissurat=tabel.gettabel(b).getdata(c,"jenissurat");
			var lib=tabel.gettabel(b).getdata(c,"lib");
			var idsurat=tabel.gettabel(b).getdata(c,"idsurat");
			
			var datajs={
				"jenissurat":jenissurat,
				"lib":lib,
				"idsurat":idsurat
			};
			
			epengajuanpkl.cetaksurat(datajs);
		},
		cetaksurat:function(a){
			var jenissurat=a['jenissurat'];
			var namalib=a['lib'];
			
			var judulsurat="Cetak "+jenissurat;
			var obj={
				"judul":judulsurat,
				"lib":namalib,
				"data":{"idsurat":a['idsurat']}
			};
			cetak.cetaksample(obj);
		},
		lihatdokumen:function(a){
			var iddok=a;
			if(iddok<=0) return;
			var myWindow = window.open(lokal+"service.php?pos=epengajuanpkl&mode=mod&fl=download&id="+iddok, "", "left=100,top=50,width=800, height=600");
		},
		objupload:function(a,b){
			var nama=a || "PILIH FILE UNTUK UPLOAD DOKUMEN";
			var prev=b || "tidak";
			
			var disabled="tidak";
			if(editstatus==0) disabled="ya";
			
			var obp=new Object;
			obp.proses=function(dataupload){
				boxuploaddokumen.iddokumen=dataupload.id;
				var filelama=dataupload.nama
				$("#upload_dokumen").html("");
				upload.tambahupload("upload_dokumen",epengajuanpkl.objupload(filelama,"ya"));
			};
			
			obp.hapus=function(a){
				
			};
			obp.lihat=function(a){
				epengajuanpkl.lihatdokumen(boxuploaddokumen.iddokumen);
			};
			
			obp.pilihfile=function(a){
				boxuploaddokumen.iddokumen=0;
			};
			
			var dtpost={"jenis":13};
			var obj={"tautan":lokal+"service.php?pos=epengajuanpkl&mode=mod&fl=upload",
				"status":lokal+"service.php?pos=epengajuanpkl&mode=mod&fl=progres",
				"tutup":"tidak","finish":obp,disupload:disabled,
				"data":dtpost,"namafile":nama,"preview":prev};
			return obj;
		},
	};
})();