This patch adds a new js include file form-submit.js which will read data elements from a link and use those to submit a form This patch fixes forms on acqui/invoice.pl as an example To test: 1 - Add some invoices for a vendor 2 - Got to Acquisitions->Invoices 3 - Actions -> Close - confirm it works 4 - Got to 'Closed invoices' - reopen 5 - Go to Details on the invoice 6 - Add an adjustment 7 - Delete the adjustment 8 - Confirm it works Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
34 lines
1 KiB
JavaScript
34 lines
1 KiB
JavaScript
$(document).ready(function(){
|
|
|
|
$('.submit-form-link').click(function(e){
|
|
e.preventDefault();
|
|
let form_data = $(this).data();
|
|
|
|
form_confirm = form_data.confirmation;
|
|
let confirmation = 1;
|
|
if( form_confirm ){
|
|
delete form_data.confirmation;
|
|
confirmation = confirm( eval(form_confirm) );
|
|
}
|
|
if( !confirmation ){ return false }
|
|
|
|
let the_form = $('<form/>');
|
|
if( form_data.method === 'post' ){
|
|
form_data.csrf_token = $('meta[name="csrf-token"]').attr('content');
|
|
}
|
|
the_form.attr('method', form_data.method);
|
|
the_form.attr('action', form_data.action);
|
|
delete form_data.method;
|
|
delete form_data.action;
|
|
$.each( form_data, function( key, value){
|
|
the_form.append( $('<input/>',{
|
|
type: "hidden",
|
|
name: key,
|
|
value: value,
|
|
})
|
|
);
|
|
});
|
|
$('body').append( the_form );
|
|
the_form.submit();
|
|
});
|
|
});
|