var pesertastatus=(function(){
	var hal=0;
	var jumlah=30;
	var idpesertastatus=0;
	var level=0;
	var boxstatus=null;
	return{
		caricanggih:function(){
			mload.sh();
			var ik_data = {ajax: 1,mode: "mod",cl: "pesertastatus",
				ikdata: {0:"datacari01",1:1}
			};
			
			$.ajax({url: lokal+"man.ajax.php",type: "POST",dataType: "json",async:true,data: ik_data,
				success: function(e){
					mload.hd();
					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){
				pesertastatus.loade();
			}
		},
		loade:function(){
			$("#hal_ke").val(0);
			pesertastatus.load();
		},
		load:function(){
			var nohal=$("#hal_ke").val()
			jumlah=$("#jumlah_hal").val();
			hal=(nohal-1)*jumlah;
			var cr=$("#cari").val();
			
			$("#grid_pesertastatus").html("");
			var loaderdata=mload.loading({"el":"loader_datapesertastatus"});
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "pesertastatus",
				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_pesertastatus",
							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":"urutan","judul":"No Urut","tipe":"data","align":"center","lebar":"60px"},
									{"col":"nama","judul":"Detail peserta","tipe":"tpl","tpl":"btdetailpeserta"},
									{"align":"right","col":"omset","judul":"Omset","tipe":"data","lebar":"120px","format":"desimal"},
									{"align":"right","col":"point","judul":"Point Bulan Sekarang","tipe":"data","lebar":"120px","format":"desimal2"},
									{"align":"center","judul":"Status","tipe":"tpl","tpl":"btstatus","lebar":"130px"},
									//{"align":"center","judul":"","tipe":"tpl","tpl":"btedit","lebar":"60px"},
									
								],
							mod:"mod",
							module:"pesertastatus"
						};
						tabel.multisub(datatb);
					}else{
						loaderdata.pesan("BELUM ADA DATA PESERTA");
					}
				}
			});
		},
		buat:function(a){
			document.location=lokal+"member/mod/pesertastatus?id="+a+"&scrmenu="+modmenu.getmenuscr();
		},
		kembali:function(){
			document.location=lokal+"member/mod/pesertastatus?scrmenu="+modmenu.getmenuscr();
		},
		bayar:function(a){
			document.location=lokal+"member/mod/pembayaranpeserta?id=0&idpeserta="+a+"&scrmenu="+modmenu.getmenuscr()
		},
		edit:function(a){
			idpesertastatus=a['id'];
			level=a['level'];
			$("#sl_propinsi").val(a['idpropinsi']);
			$("#sl_jk").val(a['idjeniskelamin']);
			$("#sl_marketing").val(a['idmarketing']);
			
			$("#boxkode").hide();
			$("#boxstatus").hide();
			if(idpesertastatus>0){
				$("#boxstatus").show();
				$("#boxkode").show();
			}
			
			$("#boxmarketing").hide();
			if(level>15) $("#boxmarketing").show();
			$("#boxpass").hide();
			$("#username").prop( "disabled", true );
			if(idpesertastatus<=0) {
				$("#username").prop( "disabled", false );
				$("#boxpass").show();
			}
			
			idkota=a['idkota'];
			pesertastatus.propch(idkota);
		},
		propch:function(a){
			var idkota=a || 0;
			var idpropinsi=$("#sl_propinsi").val();
			var loaderkota=mload.loading({"el":"sl_kota"});
			
			var htm="<option value='0'>Pilih Kota/Kabupaten</option>";
			var ik_data = {
				ajax: 1,
				mode: "mod",
				cl: "pesertastatus",
				ikdata: {0:"getdatakota",idpropinsi:idpropinsi}
			};
			
			$.ajax({
				url: lokal+"man.ajax.php",
				type: "POST",
				dataType: "json",
				async:true,
				data: ik_data,
				success: function(e){
					loaderkota.tutup();
					if(e!=false && e.length>0){
						for(var i=0;i<e.length;i++){
							htm+="<option value='"+e[i]['id']+"'>"+e[i]['kota']+"</option>";
						}
					}
					
					$("#sl_kota").html(htm);
					$("#sl_kota").val(idkota);
				}
			});
		},
		
		
		
	};
})();