<script type="text/javascript">
    $(document).ready(function() {
        list_data();
    });

    function list_data() {
        $("#list_data").load("<?= route('master.karyawan.pendidikan.pengajuan.list-data') . '/' . $id ?>");
    }

    function approve() {
        var l = Ladda.create(document.querySelector('#approve'));
        l.start();
        $.get('<?= route("master.karyawan.pendidikan.pengajuan.approve"); ?>', {
                id: $('#id').val()
            },
            function(result) {
                l.stop();
                if (result.success) {
                    $('.card-footer').hide();
                    $('.title').html(result.message.replace("009900", "FFFFFF"));
                    list_data();
                } else {
                    $('#message_modal').html(result.message);
                }
            },
            'json');
    }

    function hapus() {
        var l = Ladda.create(document.querySelector('#hapus'));
        l.start();
        $.get('<?= route("master.karyawan.pendidikan.pengajuan.hapus"); ?>', {
                id: $('#id').val()
            },
            function(result) {
                l.stop();
                if (result.success) {
                    $('.card-footer').hide();
                    $('.title').html(result.message.replace("009900", "FFFFFF"));
                    list_data();
                } else {
                    $('#message_modal').html(result.message);
                }
            },
            'json');
    }

    function revisi() {
        var l = Ladda.create(document.querySelector('#revisi'));
        l.start();
        $.get('<?= route("master.karyawan.pendidikan.pengajuan.revisi"); ?>', {
                id: $('#id').val(),
                keterangan: $('#keterangan').val()
            },
            function(result) {
                l.stop();
                if (result.success) {
                    $('#revisi, #keterangan, #batal').prop('disabled', true);
                    list_data();
                }
                $('#message_modal').html(result.message);
            },
            'json');
    }

    function form_approve(id) {
        $('#tampil_form').load("<?= route('master.karyawan.pendidikan.pengajuan.form') ?>/approve/" + id, function() {
            $('#modal_form').modal('show');
            $("#form_input :input").prop("disabled", true);
            $(".title").text("<?= strtoupper($this->lang->line('title_form_approve_pengajuan')) ?>");
        });
    }

    function form_hapus(id) {
        $('#tampil_form').load("<?= route('master.karyawan.pendidikan.pengajuan.form') ?>/hapus/" + id, function() {
            $('#modal_form').modal('show');
            $("#form_input :input").prop("disabled", true);
            $(".title").text("<?= strtoupper($this->lang->line('title_form_hapus_data')) ?>");
        });
    }

    function form_revisi(id) {
        $('#tampil_form').load("<?= route('master.karyawan.pendidikan.pengajuan.form') ?>/revisi/" + id, function() {
            $('#modal_form').modal('show');
            $("#form_input :input").prop("disabled", true);
            $(".title").text("<?= strtoupper($this->lang->line('title_form_revisi_pengajuan')) ?>");
        });
    }
</script>
<?= $tab ?><br>
<div class="row">
    <div id="list_data" class="col-md-12"></div>
</div>
