angular.module("RdmApp").controller("kkmtingkatCtrl",["$scope","$rootScope","common","DTOptionsBuilder","DTColumnBuilder","$http","$q","ApiServer",function(a,t,e,i,n,r,k,o){a.dtInstance={},a.kkmChange=function(a,t){var e=Math.round((100-parseInt(t))/3,0),i=100-e,n=parseInt(t)+e;parseInt(t)<98?angular.forEach(a,(function(a,e){"A"==a.kkmgrade_kode?(a.kkmgrade_max=100,a.kkmgrade_min=i+1):"B"==a.kkmgrade_kode?(a.kkmgrade_max=i,a.kkmgrade_min=n):"C"==a.kkmgrade_kode?(a.kkmgrade_max=n-1,a.kkmgrade_min=t):(a.kkmgrade_max=parseInt(t)-1,a.kkmgrade_min=0)})):Swal.fire({type:"warning",title:"Perhatian",showConfirmButton:!0,html:"Nilai KKM tidak boleh melebihi angka 97"})},a.saveKkmTingkat=function(a){$(".edit-modal").modal("hide"),$.blockUI({}),o.post("proktor/kkmtingkat/save",a,(function(a){$.unblockUI({}),a.success?(t.getdatakkm(),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.editekstra=function(t,e,i,n,r,k){a.dataekstraedit.ekstra_id=t,a.dataekstraedit.ekstra_nama=e,a.dataekstraedit.tingkat_id=i,a.dataekstraedit.jurusan_id=n,a.dataekstraedit.guru_id=r,a.dataekstraedit.edit=k;try{a.$apply()}catch(a){}$(".edit-modal").modal("show"),$(".modal-dialog").draggable({handle:".modal-header"})},a.currPg=0,a.dtOptions=i.newOptions().withOption("searching",!0).withOption("drawCallback",(function(t){if(t.aoData.length>0){var e=this.api().page.info();a.currPg=e.start}})).withOption("stateSave",!0).withOption("paging",!0).withOption("processing",!0).withPaginationType("full_numbers"),t.datakkmtingkat=[],t.getdatakkm=function(){$(".table-responsive").block({}),o.get("proktor/kkmtingkat/data",(function(a){$(".table-responsive").unblock({}),t.datakkmtingkat=a.data}))},0==t.datakkmtingkat.length&&t.getdatakkm()}]);