angular.module("RdmApp").controller("siswaCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,t,e,i,l,o,n,s,d){a.dtInstance={},a.dataEdit={},a.savedataEdit=function(){$(".edit-modal").modal("hide"),$.blockUI({}),s.post("proktor/siswa/save",a.dataEdit,(function(t){$.unblockUI({}),t.success?(a.reloadTable(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message}).then((a=>{a.value&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},a.dodataDelete=function(t){Swal.fire({type:"warning",title:"Perhatian",confirmButtonText:"Yes, delete it!",showCancelButton:!0,html:"Apakah Anda yakin akan menghapus data ini?"}).then((e=>{e.value&&($.blockUI({}),s.post("proktor/siswa/delete",{siswa_id:t},(function(t){$.unblockUI({}),t.success?(a.reloadTable(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Dihapus",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message})})))}))},a.reloadTable=function(){t.datasiswa={},""!==a.selectData.kelas_id&&t.getdatasiswa(a.selectData)},a.dodataTambah=function(){""==a.selectData.kelas_id?Swal.fire({type:"warning",title:"Perhatian",showConfirmButton:!1,html:"Pilih kelas terlebih dahulu",timer:1e3}):(a.dataEdit={},a.dataEdit.kelas_id=a.selectData.kelas_id,a.dataEdit.tingkat_id=a.selectData.tingkat_id,a.dataEdit.edit=!1,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))},a.dodataUpload=function(){""==a.selectData.kelas_id?Swal.fire({type:"warning",title:"Perhatian",showConfirmButton:!1,html:"Pilih kelas terlebih dahulu",timer:1e3}):(a.dataEdit={},a.dataEdit.kelas_id=a.selectData.kelas_id,a.dataEdit.tingkat_id=a.selectData.tingkat_id,a.dataEdit.edit=!1,$(".upload-modal").modal("show"))},a.clearKelas=function(e){a.selectData.kelas_id="",t.datasiswa={}},a.dodataEdit=function(t){a.dataEdit=t,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.selectData={},a.selectData.kelas_id="",a.selectData.tingkat_id="",a.dtOptions=i.newOptions().withOption("searching",!0).withButtons([{extend:"copy",text:'<i class="fa fa-files-o"></i> Copy',titleAttr:"Copy"},{extend:"pdfHtml5",text:'<i class="fa fa-print" aria-hidden="true"></i> Print',download:"open",exportOptions:{columns:[0,2,3,4,5,6]},titleAttr:"Print",customize:function(a){t.customepdf(a,"Data Siswa","RDM")}},{extend:"excelHtml5",text:'<i class="fa fa-file-text-o"></i> Excel',exportOptions:{columns:[0,2,3,4,5,6]},titleAttr:"Excel"}]).withOption("paging",!0).withOption("stateSave",!0).withOption("processing",!0).withOption("drawCallback",(function(){$(".lazy").Lazy();try{a.$apply()}catch(a){}})).withPaginationType("full_numbers");var r=a.uploader=new d({url:base_url+"proktor/siswa/import"});a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0,a.hapussemua=function(){r.clearQueue(),a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0},r.filters.push({name:"customFilter",fn:function(a,t){return this.queue.length<100}}),r.filters.push({name:"imageFilter",fn:function(a,t){var e="|"+a.name.substr(a.name.lastIndexOf(".")+1)+"|";return console.info("type",e),-1!=="|xls|xlsx|".indexOf(e)}}),r.onSuccessItem=function(t,e,i,l){a.berhasilka=a.berhasilka+e.sukses,a.gandaaa=a.gandaaa+e.double1,a.gagalaa=a.gagalaa+e.gagal,a.$apply(),console.info("onSuccessItem",t,e,i,l,a.gandaaa)},r.onCompleteAll=function(){a.reloadTable()},r.onBeforeUploadItem=function(t){t.url=base_url+"proktor/siswa/import?kelas_id="+a.selectData.kelas_id+"&tingkat_id="+a.selectData.tingkat_id},r.onAfterAddingAll=function(a){r.uploadAll()}}]);