angular.module("RdmApp").controller("guruCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,t,e,o,i,n,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,2,3,4,5,7,8,9]},titleAttr:"Print",customize:function(a){t.customepdf(a,"Data Guru","Rapor Digital Madrasah")}},{extend:"excelHtml5",text:'<i class="fa fa-file-text-o"></i> Excel',exportOptions:{columns:[0,2,3,4,5,7,8,9]},titleAttr:"Excel"}]).withOption("stateSave",!0).withOption("paging",!0).withOption("processing",!0).withOption("drawCallback",(function(){$(".lazy").Lazy();try{a.$apply()}catch(a){}})).withPaginationType("full_numbers");var u=a.uploader=new s({url:base_url+"proktor/guru/import"});a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0,a.hapussemua=function(){u.clearQueue(),a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0},u.filters.push({name:"customFilter",fn:function(a,t){return this.queue.length<100}}),u.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)}}),u.onSuccessItem=function(t,e,o,i){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,i,a.gandaaa)},u.onCompleteAll=function(){t.getdataguru()},u.onBeforeUploadItem=function(a){a.url=base_url+"proktor/guru/import"},u.onAfterAddingAll=function(a){u.uploadAll()}}]);