angular.module("RdmApp").controller("sikapsosCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,i,n,l,e,t,o,s,r){i.knilai={},i.knilai.sikapAll="",a.setsikapAll=function(a){console.log(a),i.knilai.tambahsikap={},angular.forEach(i.datasikapsos,(function(n){null!==a&&""!==a&&(i.knilai.tambahsikap[n.siswa_id]=a)}))},a.editKompnilai=function(n){i.knilai.sikapAll="",i.knilai.edit=!0,i.knilai.jenisnilai_id=n.jenisnilai_id,i.knilai.komponennilai_id=n.komponennilai_id,i.knilai.tambahsikap={},a.FilSikap=i.jenisnilaisos.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.sikapAll="",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.getSikapsos(),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.getSikapsos(),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=l.newOptions().withOption("searching",!0).withOption("stateSave",!0).withOption("paging",!1).withOption("responsive",!0).withOption("ordering",!1).withOption("processing",!1),a.dtOptions2=l.newOptions().withOption("stateSave",!0).withOption("searching",!0).withOption("paging",!1).withOption("ordering",!1).withOption("processing",!1);var p=a.uploader=new r({url:base_url+"guru/sikap/importnilai"});a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0,a.hapussemua=function(){p.clearQueue(),a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0},p.filters.push({name:"customFilter",fn:function(a,i){return this.queue.length<100}}),p.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)}}),p.onSuccessItem=function(i,n,l,e){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,l,e,a.gandaaa)},p.onCompleteAll=function(){i.getSikapsos()},p.onBeforeUploadItem=function(a){a.url=base_url+"guru/sikap/importnilaiwalas/sos/"+i.walas},p.onAfterAddingAll=function(a){p.uploadAll()}}]);