
function ifnull(value, default_value) {
    if (typeof value !== 'undefined') {
        return value;
    } else {
        return default_value;
    }
}

function submit_form(form) {

    if ($(form).attr('ajax-enabled')) {
        $.ajax({
            type: $(form).attr('method'),
            url: $(form).attr('action'),
            data: $(form).serialize(),
            success: function (data) {
                $(htmlid).html(data);
                eval(onAjaxRequestDone);
            }
        });

        $(".page-content").find('.alert').remove();
        $(".page-content").find('.invalid-feedback').html('');
        $(".page-content").find('.is-invalid').removeClass('is-invalid');
        var htmlid = $(form).attr('ajax-request') || ".page-content";
        var onAjaxRequestDone = $(form).attr('ajax-request-done');
    }else{
        form.submit();
    }


}

function submit_grid(element, sf, so, page) {
    var form = $(element).closest('FORM')[0];
    form.sf.value = sf || form.sf.value;
    form.so.value = so || form.so.value;
    form.page.value = page || form.page.value;
    submit_form(form);
}
