angular.module("RdmApp").controller("raporCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,t,e,i,l,s,n,o,d){a.dtInstance={},a.dataEdit={},a.setnaikKelas=function(a,e){console.log(a),console.log(e),$.blockUI({}),o.post("guru/walas/naikkelas/"+t.walas,{siswa_id:a,absen_siswanaik:e},(function(a){$.unblockUI({}),a.success?(t.getwalassiswa(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:a.message}).then((a=>{a.value&&t.getwalassiswa()}))}))},a.savedataEdit=function(){$(".edit-modal").modal("hide"),$.blockUI({}),o.post("guru/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({}),o.post("guru/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.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).withOption("stateSave",!0).withOption("paging",!0).withOption("responsive",!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+"guru/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+"guru/siswa/import?kelas_id="+a.selectData.kelas_id+"&tingkat_id="+a.selectData.tingkat_id},r.onAfterAddingAll=function(a){r.uploadAll()}}]);