//alert auto close
setTimeout(function(){
    $('.alert').fadeOut('slow');
}, 3000);

if ($.fn.DataTable.isDataTable('#zero_config')) {
    $('#zero_config').DataTable().destroy();
}

$('#zero_config').DataTable({
    order: [],
    //scrollX: true,
    fixedColumns: {
        end: 1
    },
    columnDefs: [
        {
            targets: -1,
            orderable: false
        }
    ]
});

//show messages
function showMessage(type, message){
    let alertClass = 'alert-success';

    if(type === 'error'){
        alertClass = 'alert-danger';
    } else if(type === 'warning'){
        alertClass = 'alert-warning';
    } else if(type === 'info'){
        alertClass = 'alert-info';
    }

    $('#msg').html(
        '<div class="alert ' + alertClass + ' shadow">' +message +'</div>'
    );

    setTimeout(function(){
        $('#msg .alert').fadeOut(500, function(){
            $(this).remove();
        });
    }, 3000);
}