function carianggota() {
    var val_nim = $("#nim").val();
    if (val_nim) {
        var request = $.ajax({
            url: urlPerson,
            beforeSend: function (xhr) {
                var token = $('meta[name="csrf_token"]').attr('content');

                if (token) {
                    return xhr.setRequestHeader('X-CSRF-TOKEN', token);
                }
            },
            data: "nim=" + val_nim,
            type: "post",
            dataType: "html"
        });

        $('#viewPersonil').html('<div class="progress mb-4"><div class="progress-bar bg-success" role="progressbar" style="width: 25%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div></div>');
        //$('#viewPersonil').html("<div class='progress'><div class='progress-bar progress-bar-success progress-bar-striped' role='progressbar' aria-valuenow='40' aria-valuemin='0' aria-valuemax='100' style='width: 40%'><span class='sr-only'>40% Complete (success)</span></div></div>");

        request.done(function (output) {
            $('#viewPersonil').html(output);
        });
    }
}

$('#nim').on('keydown', function (e) {
    if (e.which == 13) {
        carianggota();
        $("#nim").val("");
    }
});

function hanyaAngka(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))

        return false;
    return true;
}

$(".btnSimpanPersonil").click(function (e) {
    e.preventDefault();
    $(".btnSimpanPersonil").hide();
    $("#andou").html("<h3>Sedang proses ... </h3>");

    $("#addPersonil").submit();
});

$('a#btn_delete').on('click', function (e) {
    e.preventDefault();
    var data = $(this).attr('data-file');

    swal({
        title: "Apakah Anda Yakin?",
        text: "Anda akan menghapus data ini!",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "Yes",
        cancelButtonText: "No",
        closeOnConfirm: false,
        closeOnCancel: false
    },
        function (isConfirm) {
            if (isConfirm) {
                swal("Terhapus", "Data berhasil dihapus", "success");
                setTimeout(function () {
                    $("#" + data).submit();
                }, 1000); // 1 second delay
            }
            else {
                swal("Dibatalkan", "Data batal dihapus", "error");
            }
        }
    );
});
