text: function formAjax(a,t=null){var e=!1;a.off().on("submit",function(a){a.preventDefault();var l=$(this),o=new FormData(this),n=l.data("url"),s=l.attr("method"),r=l.find("button[type=submit]").html();l.find("*").prop("disabled",!0),l.find("button[type=submit]").text("Silahkan tunggu ..."),e||(e=!0,$.ajax({url:n,type:s,dataType:"json",cache:!1,contentType:!1,processData:!1,data:o,success:function(a){e=!1,l.find("*").prop("disabled",!1),l.find("button[type=submit]").html(r),null!=a.message&&(toastr.remove(),toastr.success(a.message)),null!=a.view&&null!=t&&t.append(a.view),$(".summernote").length>0&&$(".summernote").summernote("reset")},error:function(a){e=!1,toastr.remove();try{var o=JSON.parse(a.responseText),n=o.errors[Object.keys(o.errors)[0]][0];toastr.error(n)}catch(t){null!=a.responseJSON.message&&toastr.error(a.responseJSON.message)}l.find("*").prop("disabled",!1),l.find("button[type=submit]").html(r),t.html(_bcontainer)}}))})}function formAjaxPost(a=null,t=null){$(".dtable").length>0&&$(".dtable").DataTable({scrollX:!0})}$(function(){var a,t={decimal:"",emptyTable:"Data tidak tersedia",info:"Menampilkan _START_ sampai _END_ dari _TOTAL_ data",infoEmpty:"Menampilkan 0 sampai 0 dari 0 data",infoFiltered:"(Difilter dari _MAX_ total data)",infoPostFix:"",thousands:",",lengthMenu:"Menampilkan _MENU_ data",loadingRecords:"Memuat...",processing:"Memproses...",search:"Cari:",zeroRecords:"Pencarian tidak ditemukan",paginate:{first:"Pertama",last:"Terakhir",next:"Selanjutnya",previous:"Sebelumnya"}},e='<div class="h4 text-center"><i class="fas fa-pulse fa-spinner"></i></div>',l='<div class="modal fade" data-backdrop="static" id="modal" aria-modal="true" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header py-2"> <h4 class="modal-title"></h4> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"></div> </div> </div> </div>',o=()=>{$("#modal .modal-dialog").attr("class","modal-dialog modal-sm"),$("#modal .modal-title").html("<h5>Memuat data ...</h5>"),$("#modal .modal-body").html(e),$("#modal").modal("show")},n=(a,t=null,e=null)=>{o(),$.get(a,{},function(a){null!=e?$("#modal .modal-dialog").attr("class","modal-dialog "+e):$("#modal .modal-dialog").attr("class","modal-dialog"),$("#modal .modal-title").html(a.title),$("#modal .modal-body").html(a.form);var l=!1;$(".modal-form").off().on("submit",function(a){a.preventDefault();var e=new FormData(this),o=$(this),n=o.find("button[type=submit]").html();o.find("*").prop("disabled",!0),o.find("button[type=submit]").text("Silahkan tunggu ..."),l||(l=!0,$.ajax({url:o.data("url"),type:"post",dataType:"json",cache:!1,contentType:!1,processData:!1,data:e,success:function(a){if(l=!1,toastr.remove(),toastr.success(a.message),$("#modal").modal("hide"),null!=a.redirect){var e=null!=a.timeout?a.timeout:25;setTimeout(()=>{location.href=a.redirect},e)}else null!=t&&t.ajax.reload(),o.find("*").prop("disabled",!1),o.find("button[type=submit]").html(n)},error:function(a){l=!1,toastr.remove();try{var t=JSON.parse(a.responseText),e=t.errors[Object.keys(t.errors)[0]][0];toastr.error(e)}catch(t){toastr.error(a.responseJSON.message)}o.find("*").prop("disabled",!1),o.find("button[type=submit]").html(n)}}))}),d(t)},"json").fail(function(a){$("#modal .modal-title").html("Kesalahan"),$("#modal .modal-body").html("Tidak dapat memuat data!")})},s=[],r=!1,d=(a=null)=>{$(".modal-dialog").draggable({cursor:"move",handle:".modal-header,.modal-body"}),s.length>0&&(s.forEach((a,t)=>{a.select2("destroy")}),s=[]),$(".open-modal").off().on("click",function(t){t.preventDefault();let e=null!=$(this).data("type")?$(this).data("type"):null;n($(this).data("url"),a,e)}),$(".select2").length>0&&$(".select2").each(function(){var a=$(this),t={allowClear:"false"!=a.attr("allow-clear"),placeholder:null!=$(this).data("placeholder")?$(this).data("placeholder"):"Pilih"};null!=a.data("max")&&(t.maximumSelectionLength=a.data("max"));var e=$(this).off().select2(t);s.push(e)}),$(".select2-ajax").length>0&&$(".select2-ajax").each(function(){var a=$(this),t={allowClear:"false"!=a.attr("allow-clear"),ajax:{url:a.data("url")},minimumInputLength:null!=a.data("length")?a.data("length"):1,placeholder:null!=a.data("placeholder")?a.data("placeholder"):"Pilih"};null!=a.data("max")&&(t.maximumSelectionLength=a.data("max"));var e=$(this).off().select2(t);s.push(e)}),$(".datepicker").length>0&&$(".datepicker").datepicker({dateFormat:"dd-mm-yy",changeYear:!0,changeMonth:!0,yearRange:"1900:"+(new Date).getFullYear()}),$(".daterange-btn").length>0&&(moment.locale("id"),$(".daterange-btn").daterangepicker({ranges:{"Hari Ini":[moment(),moment()],Kemarin:[moment().subtract(1,"days"),moment().subtract(1,"days")],"7 Hari Terakhir":[moment().subtract(6,"days"),moment()],"30 Hari Terakhir":[moment().subtract(29,"days"),moment()],"Bulan Ini":[moment().startOf("month"),moment().endOf("month")],"Bulan Lalu":[moment().subtract(1,"month").startOf("month"),moment().subtract(1,"month").endOf("month")]},startDate:moment().subtract(29,"days"),endDate:moment()},function(a,t){$("#reportrange").val(a.format("DD-MM-YYYY")+" s.d. "+t.format("DD-MM-YYYY"))})),$(".summernote").length>0&&$(".summernote").each(function(){var a=$(this);$(this).summernote({height:null!=a.data("height")?a.data("height"):300})}),$(".form-ajax").length>0&&$(".form-ajax").each(function(){var a=$(this);formAjax(a,$(a.data("container")))}),$("#jenis-surat").length>0&&(bsCustomFileInput.init(),$("#jenis-surat").on("change",function(){var a=$(this),t=$("option:selected",this).data("kode-depan"),e=$("option:selected",this).data("kode-belakang");""==a.val()?a.closest("form").find("input,textarea").prop("disabled",!0):(setTimeout(()=>{a.closest("form").find("#inomor").focus().select()},100),a.closest("form").find("input,textarea").prop("disabled",!1)),null!=t&&null!=t&&""!=t?($("#kode-depan").removeClass("d-none"),$("#kode-depan span").text(t),$.get("/search/nomor",{jenis:a.val()},function(t){a.closest("form").find("#inomor").val(t.nomor)},"json").fail(function(){a.closest("form").find("#inomor").val(1)})):(a.closest("form").find("#inomor").val(""),$("#kode-depan").addClass("d-none"),$("#kode-depan span").empty()),null!=e&&null!=e&&""!=e?($("#kode-belakang").removeClass("d-none"),$("#kode-belakang span").text(e)):(a.closest("form").find("#inomor").val(""),$("#kode-belakang").addClass("d-none"),$("#kode-belakang span").empty())})),$("#suratid").length>0&&null!=a&&($("#suratid").off().on("change",function(){var t=$(this).val();a.search(t).draw()}),r||(r=!0,setTimeout(()=>{$("#suratid").val($("#suratid").data("query")).trigger("change")},10)))};d(a),"guest"==$("#study-query").data("role")&&$("#study-query").submit(),$("body").append(l),$(".table-list").length>0&&$(".table-list").each(function(e,l){var o=$(this).data("url"),n=$(this).data("cols").split(","),s=[];n.forEach(a=>{var t=a.split("!"),e={};e.data=t[0],e.name=t[0],null!=t[1]&&t[1].split("|").forEach(a=>{"order"==a&&(e.orderable=!1),"search"==a&&(e.searchable=!1),"visible"==a&&(e.visible=!1)}),s.push(e)}),a=$(this).DataTable({language:t,processing:!0,serverSide:!0,scrollX:!0,autoWidth:!1,ajax:null!=o?o:location.href,columns:s,drawCallback:function(){d(a)}})})});