Warn user before auto-creating credit

This commit is contained in:
Hillel Coren 2018-01-16 16:44:01 +02:00
parent 6ab5ae0df3
commit f164d9d92e
2 changed files with 13 additions and 2 deletions

View File

@ -2650,6 +2650,7 @@ $LANG = array(
'expired_white_label' => 'The white label license has expired',
'return_to_login' => 'Return to Login',
'convert_products_tip' => 'Note: add a custom field named ":name" to see the exchange rate.',
'amount_greater_than_balance' => 'The amount is greater than the invoice balance, a credit will be created with the remaining amount.',
);

View File

@ -16,7 +16,7 @@
{!! Former::open($url)
->addClass('col-lg-10 col-lg-offset-1 warn-on-exit main-form')
->onsubmit('onFormSubmit(event)')
->onsubmit('return onFormSubmit(event)')
->method($method)
->rules(array(
'client' => 'required',
@ -215,7 +215,17 @@
});
function onFormSubmit(event) {
$('#saveButton').attr('disabled', true);
// warn if amount is more than balance/credit will be created
var invoiceId = $('input[name=invoice]').val();
var invoice = invoiceMap[invoiceId];
var amount = $('#amount').val();
if (amount <= invoice.balance || confirm("{{ trans('texts.amount_greater_than_balance') }}")) {
$('#saveButton').attr('disabled', true);
return true;
} else {
return false;
}
}
function submitAction(action) {