angular.module("RdmApp").controller("mapelCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer",function(t,e,a,o,l,i,n,s){e.dataEdit={},t.syncronMapel=function(){$.blockUI({}),s.get("proktor/mapel/syncron",(function(t){$.unblockUI({}),t.success?(e.getdataMapel(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1500})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message})}))},t.savedataEdit=function(){$(".edit-modal").modal("hide"),$.blockUI({}),s.post("proktor/mapel/save",e.dataEdit,(function(t){$.unblockUI({}),t.success?(e.getdataMapel(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message}).then((t=>{t.value&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},t.dodatamoveUp=function(t){console.log(t),$.blockUI({}),s.post("proktor/mapel/moveup",{mapel_id:t},(function(t){$.unblockUI({}),t.success?(e.getdataMapel(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Nomor Urut Mapel berhasil di naikkan",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message})}))},t.dodatamoveDown=function(t){console.log(t),$.blockUI({}),s.post("proktor/mapel/movedown",{mapel_id:t},(function(t){$.unblockUI({}),t.success?(e.getdataMapel(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Nomor Urut Mapel berhasil di turunkan",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message})}))},t.dodataDelete=function(t){Swal.fire({type:"warning",title:"Perhatian",confirmButtonText:"Yes, delete it!",showCancelButton:!0,html:"Apakah Anda yakin akan menghapus data ini?"}).then((a=>{a.value&&($.blockUI({}),s.post("proktor/mapel/delete",{mapel_id:t},(function(t){$.unblockUI({}),t.success?(e.getdataMapel(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Dihapus",timer:1e3})):Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:t.message})})))}))},t.tambahMapel=function(){e.dataEdit={},$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},t.dodataEdit=function(t){e.dataEdit=t,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},t.dtOptions=o.newOptions().withOption("searching",!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(t){e.customepdf(t,"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("stateSave",!0).withOption("paging",!0).withPaginationType("full_numbers")}]);