var payment_id = 0 ;
var autosave_interval_id = null ;

/* MODAL */

// pre-submit callback
function showRequest_modal(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = jQuery.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];

    //console.log(queryString);
    invoice_id = parseInt(jQuery('#payment_id').val());

    if(jQuery('#task_modal').val() == "delete_entry"){
        jQuery('#deletebutton_modal').button('loading');
    }
    else jQuery('#savebutton_modal').button('loading');

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}

// post-submit callback
function showResponse_modal(response, statusText, xhr, $form)  {

    vm.current_payment.update(response.content);
    render_reload_item(vm.current_payment);

    jQuery('#savebutton_modal').button('reset');
    jQuery('#deletebutton_modal').button('reset');
    jQuery('#closebutton_modal').click();

    //notify if there are messages
    notify_messages(response.notifications);

}
