angular.module("RdmApp").controller("sikapspiritualCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,i,n,e,l,t,o,s,p){i.knilai={},a.sikapAll="",a.setsikapAll=function(a){console.log(a),i.knilai.tambahsikap={},angular.forEach(i.datasikapspi,(function(n){null!==a&&""!==a&&(i.knilai.tambahsikap[n.siswa_id]=a)}))},a.editKompnilai=function(n){i.knilai.edit=!0,i.knilai.jenisnilai_id=n.jenisnilai_id,i.knilai.komponennilai_id=n.komponennilai_id,i.knilai.tambahsikap={},a.FilSikap=i.jenisnilaispi.filter((function(a){return a.jenisnilai_id==n.jenisnilai_id})),i.knilai.tambahsikap=a.FilSikap[0].datanilai,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.tambahharian=function(){i.knilai={},i.knilai.edit=!1,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.UploadTemplate=function(){i.knilai={},i.knilai.edit=!1,$(".upload-modal").modal("show")},a.deleteKompnilai=function(a){Swal.fire({type:"warning",title:"Perhatian",confirmButtonText:"Ya, Hapus!",showCancelButton:!0,html:"Apakah Anda yakin akan menghapus nilai ini? Nilai yang sudah di hapus tidak bisa dikembalikan lagi."}).then((n=>{n.value&&($.blockUI({}),s.post("guru/sikap/deletesikapwalas",a,(function(a){$.unblockUI({}),i.getSikapsspi(),a.success?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.savedatasikap=function(){$(".edit-modal").modal("hide"),$.blockUI({}),s.post("guru/sikap/savesikapwalas/"+i.walas,i.knilai,(function(a){$.unblockUI({}),a.success?(i.getSikapsspi(),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.dtOptions=e.newOptions().withOption("searching",!0).withOption("stateSave",!0).withOption("paging",!1).withOption("responsive",!0).withOption("ordering",!1).withOption("processing",!1),a.dtOptions2=e.newOptions().withOption("stateSave",!0).withOption("searching",!0).withOption("paging",!1).withOption("ordering",!1).withOption("processing",!1);var r=a.uploader=new p({url:base_url+"guru/sikap/importnilaiwalas"});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,i){return this.queue.length<100}}),r.filters.push({name:"imageFilter",fn:function(a,i){var n="|"+a.name.substr(a.name.lastIndexOf(".")+1)+"|";return console.info("type",n),-1!=="|xls|xlsx|".indexOf(n)}}),r.onSuccessItem=function(i,n,e,l){a.berhasilka=a.berhasilka+n.sukses,a.gandaaa=a.gandaaa+n.double1,a.gagalaa=a.gagalaa+n.gagal,a.$apply(),console.info("onSuccessItem",i,n,e,l,a.gandaaa)},r.onCompleteAll=function(){i.getSikapsspi()},r.onBeforeUploadItem=function(a){a.url=base_url+"guru/sikap/importnilaiwalas/spi/"+i.walas},r.onAfterAddingAll=function(a){r.uploadAll()}}]);