angular.module("RdmApp").controller("berandaCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer",function(a,t,e,i,l,n,s,o){void 0!==t.datakelas[t.selectKelas]?void 0!==t.datakelas[t.selectKelas].bahanajar?t.bahanajar=t.datakelas[t.selectKelas].bahanajar:t.datakelas[t.selectKelas].timeline=[]:(t.posts=[],t.datakelas[t.selectKelas]=[],t.datakelas[t.selectKelas].bahanajar=[]),a.dtInstance={},a.currPg=0,a.recordsDisplay=0,a.tambahsiswapilihan=function(){$(".tambah-modal").modal("show")},a.chselectAll=function(t){angular.forEach(a.datapilihan,(function(a){a.select=t}))},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=>{console.log(e),e.value&&($.blockUI({}),o.post("guru/kelas/deletepilihan/"+t.selectKelas,{siswa_id:a},(function(a){$.unblockUI({}),a.success?(t.getharian(),t.getketerampilan(),t.updateSikap(),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})})))}))},t.knilai={},a.savedatapilihan=function(){$(".tambah-modal").modal("hide"),t.knilai.kirimnilai=[],$i=0,t.knilai.selectKelas=t.selectKelas,angular.forEach(t.datapilihan,(function(a){if("0"!==a.select){var e={};e.siswa_id=a.siswa_id,t.knilai.kirimnilai[$i]=e,$i++}})),$.blockUI({}),o.post("guru/kelas/savepilihan",t.knilai,(function(a){$.unblockUI({}),null!==a&&a.success?(t.getharian(),t.getketerampilan(),t.updateSikap(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1e3})):null==a?Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:"Data Gagal Disimpan"}).then((a=>{a.value&&$(".tambah-modal").modal("show")})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:a.message}).then((a=>{a.value&&$(".tambah-modal").modal("show")}))}))},a.dtOptions=i.newOptions().withOption("searching",!0).withOption("stateSave",!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,1,2,3]},titleAttr:"Print",customize:function(a){t.customepdf(a,"Absen Siswa","Rapor Digital Madrasah")}},{extend:"excelHtml5",text:'<i class="fa fa-file-text-o"></i> Excel',exportOptions:{columns:[0,2,3]},titleAttr:"Excel"}]).withOption("paging",!0).withOption("processing",!0).withOption("AutoWidth",!0).withOption("responsive",!0).withOption("columnDefs",[{width:"2%",targets:0},{width:"10%",targets:-2},{width:"16%",targets:-1},{responsivePriority:1,targets:2},{responsivePriority:2,targets:-1}]).withOption("drawCallback",(function(t){if(t.aoData.length>0){var e=this.api().page.info();a.currPg=e.page,a.recordsDisplay=e.recordsDisplay}$(".lazy").Lazy();try{a.$apply()}catch(a){}})).withPaginationType("full_numbers")}]);