angular.module("RdmApp").controller("harianCtrl",["$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.dataharian,(function(n){null!==n.nilai&&void 0!==n.nilai[a.komponennilai_id]?i.knilai.tambahharian[n.siswa_id]=parseInt(n.nilai[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,i.knilai.komponennilai_materi="",i.knilai.komponennilai_nama="",i.knilai.tambahharian={},$(".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(i){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/pengetahuan/deleteharian",i,(function(i){$.unblockUI({}),a.getharian(),i.success?Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Dihapus",timer:1e3}):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:i.message})})))}))},a.savedataharian=function(){$(".edit-modal").modal("hide"),$.blockUI({}),r.post("guru/pengetahuan/saveharian",i.knilai,(function(a){$.unblockUI({}),a.success?(i.getharian(),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("searching",!0).withOption("paging",!1).withOption("ordering",!1).withOption("processing",!1);var h=a.uploader=new s({url:base_url+"guru/pengetahuan/importnilai"});a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0,a.hapussemua=function(){h.clearQueue(),a.berhasilaa=0,a.gandaaa=0,a.gagalaa=0},h.filters.push({name:"customFilter",fn:function(a,i){return this.queue.length<100}}),h.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)}}),h.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)},h.onCompleteAll=function(){i.getharian()},h.onBeforeUploadItem=function(a){a.url=base_url+"guru/pengetahuan/importnilai/harian/"+i.selectKelas},h.onAfterAddingAll=function(a){h.uploadAll()}}]);