angular.module("RdmApp").controller("unjukkerjaCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer","FileUploader",function(a,i,n,e,l,t,o,r,s){i.knilai={},a.setallNilai=function(a){null!==a&&""!==a&&angular.forEach(i.dataharian,(function(n){null==i.knilai.tambahharian&&(i.knilai.tambahharian={}),i.knilai.tambahharian[n.siswa_id]=a}))},a.editKompnilai=function(a){i.knilai.edit=!0,i.knilai.komponennilai_id=a.komponennilai_id,i.knilai.komponennilai_materi=a.komponennilai_materi,i.knilai.komponennilai_nama=a.komponennilai_nama,i.knilai.tambahharian={},angular.forEach(i.dataketerampilan,(function(n){null!==n.nilaiuk&&void 0!==n.nilaiuk[a.komponennilai_id]?i.knilai.tambahharian[n.siswa_id]=parseInt(n.nilaiuk[a.komponennilai_id]):i.knilai.tambahharian[n.siswa_id]=0})),$(".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.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({}),r.post("guru/keterampilan/deletenilai",a,(function(a){$.unblockUI({}),i.getketerampilan(),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.savedataharian=function(){$(".edit-modal").modal("hide"),$.blockUI({}),r.post("guru/keterampilan/saveunjukkerja",i.knilai,(function(a){$.unblockUI({}),a.success?(i.getketerampilan(),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("ordering",!1).withOption("processing",!1),a.dtOptions2=e.newOptions().withOption("searching",!0).withOption("paging",!1).withOption("ordering",!1).withOption("processing",!1),a.UploadTemplate=function(){i.knilai={},i.knilai.edit=!1,$(".upload-modal").modal("show")};var u=a.uploader=new s({url:base_url+"guru/keterampilan/importnilai"});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,i){return this.queue.length<100}}),u.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)}}),u.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)},u.onCompleteAll=function(){i.getketerampilan()},u.onBeforeUploadItem=function(a){a.url=base_url+"guru/keterampilan/importnilai/praktek/"+i.selectKelas},u.onAfterAddingAll=function(a){u.uploadAll()}}]);