angular.module("RdmApp").controller("naikkelasCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer",function(a,t,e,i,n,l,s,o){a.dtInstance={},a.dtInstance2={},a.dataEdit={},a.datakelasedit={},a.prosesNaik=function(){a.filteredArray=a.datasiswaasal.filter((function(a){return 1==a.select}));var t={};t.kelas_id=a.tujuanData.kelas_id,t.tahunajaran_id=a.tujuanData.tahunajaran_id,t.tingkat_id=a.tujuanData.tingkat_id,t.data=a.filteredArray,$.blockUI({}),o.post("proktor/naikkelas/save",t,(function(t){$.unblockUI({}),t.success?(a.reloadTable(),a.reloadTableTujuan(),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((a=>{a.dismiss===Swal.DismissReason.timer&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},a.batalNaik=function(){a.filteredArray=a.datasiswatujuan.filter((function(a){return 1==a.select}));var t={};t.kelas_id=a.selectData.kelas_id,t.tahunajaran_id=a.selectData.tahunajaran_id,t.tingkat_id=a.selectData.tingkat_id,t.data=a.filteredArray,$.blockUI({}),o.post("proktor/naikkelas/batalnaik",t,(function(t){$.unblockUI({}),t.success?(a.reloadTable(),a.reloadTableTujuan(),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((a=>{a.value&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},t.datasiswaasal=[],a.reloadTable=function(){t.datasiswaasal=[],""!==a.selectData.kelas_id&&($.blockUI({}),o.post("proktor/naikkelas/data",a.selectData,(function(a){$.unblockUI({}),t.datasiswaasal=a.data})))},t.datasiswatujuan=[],a.reloadTableTujuan=function(){t.datasiswatujuan=[],""!==a.tujuanData.kelas_id&&($.blockUI({}),o.post("proktor/naikkelas/data",a.tujuanData,(function(a){$.unblockUI({}),t.datasiswatujuan=a.data})))},a.saveeditkelas=function(){$(".edit-modal").modal("hide"),$.blockUI({}),console.log(a.datakelasedit),o.post("proktor/naikkelas/savekelas",a.datakelasedit,(function(t){$.unblockUI({}),t.success?(a.getdatatingkat(),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((a=>{a.value&&($(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"}))}))}))},a.datakelasedit={},a.dodataEdit=function(){a.datakelasedit={},a.datakelasedit.tingkat_id=a.tujuanData.tingkat_id,a.datakelasedit.tahunajaran_id=t.tujuanajaran.tahunajaran_id,$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.changeTingkat=function(){a.tujuanData.tingkat_id=parseInt(a.selectData.tingkat_id)+1+"",a.selectData.kelas_id="",a.tujuanData.kelas_id="",t.datasiswaasal=[],t.datasiswatujuan=[]},a.currPg=0,a.recordsDisplay=0,a.currPg2=0,a.recordsDisplay2=0,a.tujuanData={},a.tujuanData.kelas_id="",a.tujuanData.tingkat_id="",a.tujuanData.tahunajaran_id="",a.selectData={},a.selectData.kelas_id="",a.selectData.tingkat_id="",a.selectData.tahunajaran_id="",a.dtOptions=i.newOptions().withOption("searching",!0).withOption("paging",!0).withOption("processing",!0).withOption("stateSave",!0).withOption("columnDefs",[{orderable:!1,targets:0}]).withOption("drawCallback",(function(t){if(t.aoData.length>0){var e=this.api().page.info();a.currPg=e.start,a.recordsDisplay=e.recordsDisplay}})).withOption("lengthMenu",[[10,25,50,100,200,-1],[10,25,50,100,200,"All"]]),a.dtOptions2=i.newOptions().withOption("searching",!0).withOption("paging",!0).withOption("processing",!0).withOption("columnDefs",[{orderable:!1,targets:0}]).withOption("drawCallback",(function(t){if(t.aoData.length>0){var e=this.api().page.info();a.currPg2=e.start,a.recordsDisplay2=e.recordsDisplay}})).withOption("lengthMenu",[[10,25,50,100,200,-1],[10,25,50,100,200,"All"]]),a.getdatatingkat=function(){o.get("proktor/naikkelas/datatingkat",(function(e){t.asalajaran=e.asalajaran,t.tujuanajaran=e.tujuanajaran,t.tujuantingkat=e.tujuantingkat,t.tujuankelas=e.tujuankelas,a.tujuanData.tahunajaran_id=t.tujuanajaran.tahunajaran_id,a.selectData.tahunajaran_id=t.asalajaran.tahunajaran_id,a.lastkelas=0,angular.forEach(t.tujuantingkat,(function(t){a.lastkelas=t.tingkat_id}))}))},a.getdatatingkat()}]);