angular.module("RdmApp").controller("ekstraCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer",function(t,e,a,r,i,n,o,s){t.dtInstance={},t.newextra={},t.newextra.ekstrakurikuler_nama="",t.newextra.guru_id="",t.setpembina=function(e){t.newextra=e,t.saveeditekstra1()},t.saveeditekstra1=function(){$.blockUI({}),s.post("proktor/ekstrakurikuler/save",t.newextra,(function(a){$.unblockUI({}),a.success?(t.newextra={},t.newextra.ekstrakurikuler_nama="",t.newextra.guru_id="",e.getdataekstra(),Swal.fire({type:"success",title:"Berhasil",showConfirmButton:!1,html:"Data Berhasil Disimpan",timer:1e3})):(e.getdataekstra(),Swal.fire({type:"error",title:"Gagal",showConfirmButton:!0,html:a.message}))}))},t.saveeditekstra=function(){$(".edit-modal").modal("hide"),$.blockUI({}),s.post("proktor/ekstrakurikuler/save",t.newextra,(function(a){$.unblockUI({}),a.success?(t.newextra={},t.newextra.ekstrakurikuler_nama="",t.newextra.guru_id="",e.getdataekstra(),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((t=>{t.value&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},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/ekstrakurikuler/delete",{ekstrakurikuler_id:t},(function(t){$.unblockUI({}),t.success?(e.getdataekstra(),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})})))}))},t.dodataEdit=function(e){t.editekstra(e.ekstrakurikuler_id,e.ekstrakurikuler_nama,e.guru_id,!0)},t.editekstra=function(e,a,r,i){t.newextra.ekstrakurikuler_id=e,t.newextra.ekstrakurikuler_nama=a,t.newextra.guru_id=r,t.newextra.edit=i,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},t.currPg=0,e.getdataekstra=function(){s.get("proktor/ekstrakurikuler/data",(function(t){$.unblockUI({}),e.dataekstrakurikuler1=t.data,e.datapembina1=t.guru}))},e.getdataekstra(),t.dtOptions=r.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("drawCallback",(function(e){if(e.aoData.length>0){var a=this.api().page.info();t.currPg=a.start}})).withOption("paging",!0).withOption("processing",!1).withPaginationType("full_numbers")}]);