var detailetraining=(function(){
	var jumlahreq=0;
	var idpelatihan=0;
	return {
		reqcb:function(jumlah){
			var requestcb = new reqcb({
			    jumlahReq: jumlah
			});
			return requestcb;
		},
		init:function(a){
			idpelatihan=a['id'];
			
			$("#grid_jadwal_pelatihan").html("");
			$("#loader_jadwal_pelatihan").html("");
			
			$("#grid_narsum_pelatihan").html("");
			$("#loader_narsum_pelatihan").html("");
			
			var obj=new Object;
			var cbf=detailetraining.reqcb(3);
			
	        cbf.addCallbackToQueue(true, function() {
	            detailetraining.getjadwalpelatihan();
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            detailetraining.getnarsum();
	        });
	        
	        cbf.addCallbackToQueue(true, function() {
	            detailetraining.getdokkonten();
	        });
		},
		getjadwalpelatihan:function(){
			var loaderjadwalpelatihan=mload.loading({"el":"loader_jadwal_pelatihan"});
			
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "detailetraining",
				ikdata: {0:"getjadwalpelatihan",
					idpelatihan:idpelatihan}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					loaderjadwalpelatihan.tutup();
					//alert(JSON.stringify(e));
					if(e!=false && e.length>0){
						var datatb={
							box:"grid_jadwal_pelatihan",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tbclass:"table_grid-konten",
							isi:[
									{"col":"tanggal","judul":"Tanggal","tipe":"data","lebar":"110px","align":"center","format":"tanggal"},
									{"col":"nama","judul":"Detail Jadwal","tipe":"tpl","tpl":"btdetailjadwal"},
									{"col":"jam_mulai","judul":"Mulai","tipe":"data","lebar":"70px","align":"center"},
									{"col":"jam_selesai","judul":"Selesai","tipe":"data","lebar":"70px","align":"center"},
									
								],
							mod:"mod",
							module:"detailetraining"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_jadwal_pelatihan").html("Belum ada data Jadwal Pelatihan");
					}
					
				}
			});
		},
		getnarsum:function(){
			var loadernarsum=mload.loading({"el":"loader_narsum_pelatihan"});
			
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "detailetraining",
				ikdata: {0:"getnarsum",
					idpelatihan:idpelatihan}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					loadernarsum.tutup();
					//alert(JSON.stringify(e));
					if(e!=false && e.length>0){
						var datatb={
							box:"grid_narsum_pelatihan",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tbclass:"table_grid-konten",
							header:"tidak",
							isi:[
									{"col":"nama","judul":"Nama","tipe":"tpl","tpl":"btdetailnarsum"},
									
								],
							mod:"mod",
							module:"detailetraining"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_narsum_pelatihan").html("Nara sumber belum diatur");
					}
					
				}
			});
		},
		getdokkonten:function(){
			var loaderdokkonten=mload.loading({"el":"loader_dok_pelatihan"});
			
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "detailetraining",
				ikdata: {0:"getdokkonten",
					idpelatihan:idpelatihan}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					
					loaderdokkonten.tutup();
					//alert(JSON.stringify(e));
					if(e!=false && e.length>0){
						var datatb={
							box:"grid_dok_pelatihan",
							data:e,
							lebarmin:"500px",
							trklik:{"data":"id","fungsi":"barisklik"},
							title:"kategori Menu",
							tbclass:"table_grid-konten",
							header:"tidak",
							isi:[
									{"col":"judul","judul":"Detail Dokumen","tipe":"tpl","tpl":"btdetaildokkonten"},
									{"align":"center","judul":"Prev","tipe":"tpl","tpl":"btlihatdokkonten","lebar":"40px"},
									
								],
							mod:"mod",
							module:"detailetraining"
						};
						tabel.multisub(datatb);
					}else{
						$("#grid_dok_pelatihan").html("Tidak ada dokumen pelatihan");
					}
				}
			});
		},
		lihatdokkonten:function(b,c){
			var iddata=tabel.gettabel(b).getdata(c,"id");
			if(iddata<=0) return;
			var myWindow = window.open(lokal+"service.php?pos=detailetraining&mode=mod&fl=download&id="+iddata, "", "left=100,top=50,width=800, height=500");
		}
	};
})();
