var surattugas=(function(){
	var hal=0;
	var jumlah=30;
	var idsurattugas=0;
	var idsurat=0;
	var datapegawai=[];
	var datamenimbang=[];
	var datadasar=[];
	var datacatatantugas=[];
	var editstatus=0;
	var statusdisposisi=0;
	var boxbukamenimbang=null;
	var boxbukadasar=null;
	var boxbukacatatantgs=null;
	var jumlahreq=0;
	var namalib="";
	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: "surattugas",
				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){
				surattugas.loade();
			}
		},
		loade:function(){
			$("#hal_ke").val(0);
			surattugas.load();
		},
		load:function(){
			var nohal=$("#hal_ke").val()
			jumlah=$("#jumlah_hal").val();
			hal=(nohal-1)*jumlah;
			var cr=$("#cari").val();
			
			$("#grid_surattugas").html("");
			var loaderdata=mload.loading({"el":"loader_datasurattugas"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				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_surattugas",
							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":"nama","judul":"Detail Tugas","tipe":"tpl","tpl":"btdetailtugas"},
									{"align":"center","judul":"Waktu","tipe":"tpl","tpl":"btwaktu","lebar":"110px"},
									{"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:"surattugas"
						};
						tabel.multisub(datatb);
					}else{
						loaderdata.pesan("BELUM ADA DATA");
					}
				}
			});
		},
		buat:function(a){
			document.location=lokal+"member/mod/surattugas?id="+a+"&scrmenu="+modmenu.getmenuscr();
		},
		kembali:function(){
			document.location=lokal+"member/mod/surattugas?scrmenu="+modmenu.getmenuscr();
		},
		edit:function(a){
			idsurattugas=a['id'];
			idsurat=a['idsurat'];
			editstatus=a['editstatus'];
			statusdisposisi=a['statusdisposisi'];
			
			$("#tanggalmulai").datepicker({
                inline: true,
                dateFormat: 'dd/mm/yy'
            });
            
            $("#tanggalselesai").datepicker({
                inline: true,
                dateFormat: 'dd/mm/yy'
            });
            
            var obj=new Object;
			var cbf=surattugas.reqcb(5);
			
			cbf.addCallbackToQueue(true, function() {
	            surattugas.getcatatansurat(idsurat);
	        });
	        
			cbf.addCallbackToQueue(true, function() {
	            surattugas.getdatapegawai(idsurat);
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            surattugas.getdatamenimbang(idsurat);
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            surattugas.getdatadasar(idsurat);
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            surattugas.getdatactttugas(idsurat);
	        });
		},
		getcatatansurat:function(a){
			$("#grid_catatan").html("");
			var loaderdatacatatan=mload.loading({"el":"grid_catatan"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				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:[
									{"col":"","judul":"No","tipe":"urut","align":"center","lebar":"50px","halaman":1},
									{"judul":"Nama Pegawai","tipe":"data","col":"namapegawai","lebar":"250px"},
									{"col":"catatan","judul":"Catatan","tipe":"data"},
									
								],
							mod:"mod",
							module:"surattugas"
						};
						tabel.multisub(tabeldata);
						
					}else{
						loaderdatacatatan.pesan("Tidak ada catatan");
					}
				}
			});
		},
		getdatapegawai:function(){
			datapegawai=[];
			var loaderdatapgw=mload.loading({"el":"grid_pegawai"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				ikdata: {0:"getdatapegawai",
					idsurattugas:idsurattugas}
			};
			
			$.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++){
							datapegawai.push({
								"id":e[i]['id'],
								"nama":e[i]['nama'],
								"nip":e[i]['nip'],
								"edit":editstatus,
								"statusdisposisi":statusdisposisi,
							});
						}
						loaderdatapgw.tutup();
						surattugas.tabelpegawai();
					}else{
						loaderdatapgw.pesan("TIDAK ADA DATA");
					}
				}
			});
		},
		getdatamenimbang:function(){
			datamenimbang=[];
			var loaderdatamnb=mload.loading({"el":"grid_menimbang"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				ikdata: {0:"getdatamenimbang",
					idsurattugas:idsurattugas}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						loaderdatamnb.tutup();
						for(var i=0;i<e.length;i++){
							datamenimbang.push({
								"catatan":e[i]['catatan'],
								"edit":editstatus,
								"statusdisposisi":statusdisposisi,
							});
						}
						surattugas.tabelmenimbang();
					}else{
						loaderdatamnb.pesan("TIDAK ADA DATA");
					}
				}
			});
		},
		getdatadasar:function(){
			datadasar=[];
			var loaderdatadsr=mload.loading({"el":"grid_dasar"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				ikdata: {0:"getdatadasar",
					idsurattugas:idsurattugas}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						loaderdatadsr.tutup();
						for(var i=0;i<e.length;i++){
							datadasar.push({
								"catatan":e[i]['catatan'],
								"edit":editstatus,
								"statusdisposisi":statusdisposisi,
							});
						}
						surattugas.tabeldasar();
					}else{
						loaderdatadsr.pesan("TIDAK ADA DATA");
					}
				}
			});
		},
		getdatactttugas:function(){
			datacatatantugas=[];
			var loaderdatactt=mload.loading({"el":"grid_catatantugas"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				ikdata: {0:"getdatacatatantugas",
					idsurattugas:idsurattugas}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					if(e!=false && e.length>0){
						loaderdatactt.tutup();
						for(var i=0;i<e.length;i++){
							datacatatantugas.push({
								"catatan":e[i]['catatan'],
								"edit":editstatus,
								"statusdisposisi":statusdisposisi,
							});
						}
						surattugas.tabelctttugas();
					}else{
						loaderdatactt.pesan("TIDAK ADA DATA");
					}
				}
			});
		},
		pilihpegawai:function(){
			var obj=new Object;
			obj['judul']="Pilih Data Pegawai";
			obj['modepilih']="multi";
			obj.pilih=function(a){
				var arrdatapegawai=a;
				var cari=false;
				for(var i=0;i<arrdatapegawai.length;i++){
					datapegawai.push({
							"id":arrdatapegawai[i]['id'],
							"nama":arrdatapegawai[i]['nama'],
							"nip":arrdatapegawai[i]['nip'],
							"edit":editstatus,
							"statusdisposisi":statusdisposisi
						}
					);
				}
				
				surattugas.tabelpegawai();
			};
			
			pilihpegawai.bukapegw(obj);
		},
		hapuspegawai:function(a,b,c,d){
			if(a<=0) return;
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data pegawai pada surat tugas ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					datapegawai.splice(c,1);
					loaderhapus.tutup();
					surattugas.tabelpegawai();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		tabelpegawai:function(){
			$("#grid_pegawai").html("BELUM ADA DATA");
			if(datapegawai.length>0){
				var tabeldata={
					box:"grid_pegawai",
					data:datapegawai,
					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},
							{"col":"nip","judul":"NIP","tipe":"data","lebar":"110px"},
							{"judul":"Nama Pegawai","tipe":"data","col":"nama"},
							{"judul":"","tipe":"tpl","tpl":"bteditpegawai","align":"center","lebar":"70px"},
							
						],
					mod:"mod",
					module:"surattugas"
				};
				tabel.multisub(tabeldata);
			}
		},
		pilihmenimbang:function(){
			var obj=new Object;
			obj['judul']="Pilih Data Catatan";
			obj['modepilih']="multi";
			obj.pilih=function(a){
				var arrdatamenimbang=a;
				var cari=false;
				for(var i=0;i<arrdatamenimbang.length;i++){
					datamenimbang.push({
							"catatan":arrdatamenimbang[i]['catatan'],
							"edit":editstatus,
							"statusdisposisi":statusdisposisi
						}
					);
				}
				
				surattugas.tabelmenimbang();
			};
			
			pilihcatatan.bukacttn(obj);
		},
		editmenimbang:function(b,c,d){
			var ps={"box":"box_editcatatantgs",
				"judul":"Edit Catatan menimbang",tinggi:"auto","lebar":"800"};
	
			boxbukamenimbang=boxwin.load(ps);
			boxbukamenimbang.tabel=b;
			boxbukamenimbang.baris=c;
			boxbukamenimbang.buka();
			
			$("#loader_boxcatatansurat").html("");
			$("#boxeditcatatan").html("<textarea id='textcatatan'>"+tabel.gettabel(b).getdata(c,"catatan")+"</textarea>");
			
			var ted=tinymce.init({
                selector: "textarea#textcatatan",
                theme: "modern",
                height: 200,
                relative_urls: false,
                remove_script_host: false,
                menubar:false,
                plugins: [
                     "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                     "searchreplace visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                     "save table contextmenu directionality emoticons template paste textcolor kfile"
                ],
            
                toolbar: "styleselect | bold italic fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"
            });
            
            document.getElementById("btbatalcatatan").onclick=function(){
				if(boxbukamenimbang!=null) boxbukamenimbang.tutup();
				boxbukamenimbang=null;
			};
			
			document.getElementById("btsimpancatatan").onclick=function(){
				$("#loader_boxcatatansurat").html("");
				var catatan=tinyMCE.get('textcatatan').getContent();
				if(catatan==""){
					$("#loader_boxcatatansurat").html("Catatan menimbang belum diisi!");
					return;
				}
				
				datamenimbang[c]['catatan']=catatan;
				surattugas.tabelmenimbang();
				
				if(boxbukamenimbang!=null) boxbukamenimbang.tutup();
				boxbukamenimbang=null;
			};
			
		},
		hapusmenimbang:function(b,c,d){
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data catatan menimbang pada surat tugas ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					datamenimbang.splice(c,1);
					loaderhapus.tutup();
					surattugas.tabelmenimbang();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		tabelmenimbang:function(){
			$("#grid_menimbang").html("BELUM ADA DATA");
			if(datamenimbang.length>0){
				var tabeldata={
					box:"grid_menimbang",
					data:datamenimbang,
					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":"Catatan","tipe":"data","col":"catatan"},
							{"judul":"","tipe":"tpl","tpl":"bteditmenimbang","align":"center","lebar":"70px"},
							
						],
					mod:"mod",
					module:"surattugas"
				};
				tabel.multisub(tabeldata);
			}
		},
		pilihdasar:function(){
			var obj=new Object;
			obj['judul']="Pilih Data Catatan";
			obj['modepilih']="multi";
			obj.pilih=function(a){
				var arrdatadasar=a;
				var cari=false;
				for(var i=0;i<arrdatadasar.length;i++){
					datadasar.push({
							"catatan":arrdatadasar[i]['catatan'],
							"edit":editstatus,
							"statusdisposisi":statusdisposisi
						}
					);
				}
				
				surattugas.tabeldasar();
			};
			
			pilihcatatan.bukacttn(obj);
		},
		editdasar:function(b,c,d){
			var ps={"box":"box_editcatatantgs",
				"judul":"Edit Catatan Dasar Surat",tinggi:"auto","lebar":"800"};
	
			boxbukadasar=boxwin.load(ps);
			boxbukadasar.tabel=b;
			boxbukadasar.baris=c;
			boxbukadasar.buka();
			
			$("#loader_boxcatatansurat").html("");
			$("#boxeditcatatan").html("<textarea id='textcatatan'>"+tabel.gettabel(b).getdata(c,"catatan")+"</textarea>");
			
			var ted=tinymce.init({
                selector: "textarea#textcatatan",
                theme: "modern",
                height: 200,
                relative_urls: false,
                remove_script_host: false,
                menubar:false,
                plugins: [
                     "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                     "searchreplace visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                     "save table contextmenu directionality emoticons template paste textcolor kfile"
                ],
            
                toolbar: "styleselect | bold italic fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"
            });
            
            document.getElementById("btbatalcatatan").onclick=function(){
				if(boxbukadasar!=null) boxbukadasar.tutup();
				boxbukadasar=null;
			};
			
			document.getElementById("btsimpancatatan").onclick=function(){
				$("#loader_boxcatatansurat").html("");
				var catatan=tinyMCE.get('textcatatan').getContent();
				if(catatan==""){
					$("#loader_boxcatatansurat").html("Catatan menimbang belum diisi!");
					return;
				}
				
				datadasar[c]['catatan']=catatan;
				surattugas.tabeldasar();
				
				if(boxbukadasar!=null) boxbukadasar.tutup();
				boxbukadasar=null;
			};
		},
		hapusdasar:function(b,c,d){
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data catatan dasar pada surat tugas ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					datadasar.splice(c,1);
					loaderhapus.tutup();
					surattugas.tabeldasar();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		tabeldasar:function(){
			$("#grid_dasar").html("BELUM ADA DATA");
			if(datadasar.length>0){
				var tabeldata={
					box:"grid_dasar",
					data:datadasar,
					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":"Catatan","tipe":"data","col":"catatan"},
							{"judul":"","tipe":"tpl","tpl":"bteditdasar","align":"center","lebar":"70px"},
							
						],
					mod:"mod",
					module:"surattugas"
				};
				tabel.multisub(tabeldata);
			}
		},
		pilihctttugas:function(){
			var obj=new Object;
			obj['judul']="Pilih Data Catatan";
			obj['modepilih']="multi";
			obj.pilih=function(a){
				var arrdatactttugas=a;
				var cari=false;
				for(var i=0;i<arrdatactttugas.length;i++){
					datacatatantugas.push({
							"catatan":arrdatactttugas[i]['catatan'],
							"edit":editstatus,
							"statusdisposisi":statusdisposisi
						}
					);
				}
				
				surattugas.tabelctttugas();
			};
			
			pilihcatatan.bukacttn(obj);
		},
		editctttugas:function(b,c,d){
			var ps={"box":"box_editcatatantgs",
				"judul":"Edit Catatan Surat Tugas",tinggi:"auto","lebar":"800"};
	
			boxbukacatatantgs=boxwin.load(ps);
			boxbukacatatantgs.tabel=b;
			boxbukacatatantgs.baris=c;
			boxbukacatatantgs.buka();
			
			$("#loader_boxcatatansurat").html("");
			$("#boxeditcatatan").html("<textarea id='textcatatan'>"+tabel.gettabel(b).getdata(c,"catatan")+"</textarea>");
			
			var ted=tinymce.init({
                selector: "textarea#textcatatan",
                theme: "modern",
                height: 200,
                relative_urls: false,
                remove_script_host: false,
                menubar:false,
                plugins: [
                     "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                     "searchreplace visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                     "save table contextmenu directionality emoticons template paste textcolor kfile"
                ],
            
                toolbar: "styleselect | bold italic fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent"
            });
            
            document.getElementById("btbatalcatatan").onclick=function(){
				if(boxbukacatatantgs!=null) boxbukacatatantgs.tutup();
				boxbukacatatantgs=null;
			};
			
			document.getElementById("btsimpancatatan").onclick=function(){
				$("#loader_boxcatatansurat").html("");
				var catatan=tinyMCE.get('textcatatan').getContent();
				if(catatan==""){
					$("#loader_boxcatatansurat").html("Catatan menimbang belum diisi!");
					return;
				}
				
				datacatatantugas[c]['catatan']=catatan;
				surattugas.tabelctttugas();
				
				if(boxbukacatatantgs!=null) boxbukacatatantgs.tutup();
				boxbukacatatantgs=null;
			};
		},
		hapusctttugas:function(b,c,d){
			var boxyesno=null;
			var databox={
				judul:"Yakin akan menghapus data catatan tugas pada surat tugas ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					datacatatantugas.splice(c,1);
					loaderhapus.tutup();
					surattugas.tabelctttugas();
				}
			};
			boxyesno=boxwin.yesno(databox);
			boxyesno.buka();
		},
		tabelctttugas:function(){
			$("#grid_catatantugas").html("BELUM ADA DATA");
			if(datacatatantugas.length>0){
				var tabeldata={
					box:"grid_catatantugas",
					data:datacatatantugas,
					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":"Catatan","tipe":"data","col":"catatan"},
							{"judul":"","tipe":"tpl","tpl":"bteditctttugas","align":"center","lebar":"70px"},
							
						],
					mod:"mod",
					module:"surattugas"
				};
				tabel.multisub(tabeldata);
			}
		},
		simpan:function(a){
			var submitdata=a || 0;
			
			$("#loader_surattugas").html("");
			var tugas=$("#tugas").val();
			var tanggalmulai=$("#tanggalmulai").val();
			var tanggalselesai=$("#tanggalselesai").val();
			var lokasi=$("#lokasi").val();
			var keterangan=$("#keterangan").val();
			
			var err="";
			if(tugas=="") err+="Nama tugas belum diisi.</br>";
			if(tanggalmulai=="") err+="Tanggal mulai cuti  cuti belum diisi.</br>";
			if(tanggalselesai=="") err+="Tanggal selesai cuti belum diisi.</br>";
			if(lokasi=="") err+="Lokasi tugas belum diisi.</br>";
			if(datapegawai.length<=0) err+="Data pegawai yang di beri tugas belum diisi.</br>";
			
			if(err!=""){
				$("#loader_surattugas").html(err);
				return;
			}
			var fg="inputsurattugas";
			if(idsurattugas>0){
				fg="editsurattugas";
			}
			
			var loadersimpan=mload.loader({"keterangan":"Proses simpan data"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "surattugas",
				ikdata: {0:fg,tugas:tugas,
					lokasi:lokasi,
					tanggalmulai:tanggalmulai,
					tanggalselesai:tanggalselesai,
					keterangan:keterangan,
					datapegawai:datapegawai,
					datamenimbang:datamenimbang,
					datadasar:datadasar,
					datacatatantugas:datacatatantugas,
					submitdata:submitdata,
					id:idsurattugas}
			};
			
			$.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){
							surattugas.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 surat tugas ini ?? ",
				proses:function(){
					var loaderhapus=mload.loader({"keterangan":"Proses hapus data.."});
					boxyesno.tutup();
					var ik_data = {
						ajax: 1,
						mode: "mod",
						cl: "surattugas",
						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"}]);
									surattugas.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=\"surattugas.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=\"surattugas.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");
                }
            };
            
            surattugas.loaddatactt(b,c);
		},
		loaddatactte:function(b,c){
			var idtb=b+"_"+c;
			$("#hal_ke_"+idtb).val(0);
			surattugas.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: "surattugas",
				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:"surattugas"
							};
							tabel.multisub(tabeldata);
						}else{
							loaderdatasub.pesan("TIDAK ADA DATA");
						}
					}
				}
			});
		},
		initcetak:function(a,b,c,d){
			var status=tabel.gettabel(b).getdata(c,"status");
			var statusdisposisi=tabel.gettabel(b).getdata(c,"statusdisposisi");
			if(status!=28 || 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
			};
			
			surattugas.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);
		}
	};
})();