angular.module("RdmApp").controller("guruCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,t,e,o,n,i,l,r,s){a.dtInstance={},a.datakelasedit={},a.savedataEdit=function(){$(".edit-modal").modal("hide"),$.blockUI({}),r.post("proktor/guru/save",a.dataEdit,(function(a){$.unblockUI({}),a.success?(t.getdataguru(),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&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},a.dodataDelete=function(a){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({}),r.post("proktor/guru/delete",{guru_id:a},(function(a){$.unblockUI({}),a.success?(t.getdataguru(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Dihapus",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:a.message})})))}))},a.dodataUpload=function(){$(".upload-modal").modal("show")},a.dodataTambah=function(){a.dataEdit={},a.dataEdit.edit=!1},a.dodataEdit=function(t){a.dataEdit=t,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.dtOptions=o.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,1,2,3]},titleAttr:"Print",customize:function(a){t.customepdf(a,"Absen Siswa","Rapor Digital Madrasah")}},{extend:"excelHtml5",text:'<i class="fa fa-file-text-o"></i> Excel',exportOptions:{columns:[0,2,3]},titleAttr:"Excel"}]).withOption("paging",!0).withOption("processing",!0).withOption("drawCallback",(function(){$(".lazy").Lazy();try{a.$apply()}catch(a){}})).withPaginationType("full_numbers");var d=a.uploader=new s({url:base_url+"proktor/guru/import"});a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0,a.hapussemua=function(){d.clearQueue(),a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0},d.filters.push({name:"customFilter",fn:function(a,t){return this.queue.length<100}}),d.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)}}),d.onSuccessItem=function(t,e,o,n){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,o,n,a.gandaaa)},d.onCompleteAll=function(){t.getdataguru()},d.onBeforeUploadItem=function(a){a.url=base_url+"proktor/guru/import"},d.onAfterAddingAll=function(a){d.uploadAll()}}]);