1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Show warning when changing recurring invoice start date

This commit is contained in:
Hillel Coren 2016-05-22 19:51:09 +03:00
parent bb2fa9a18e
commit ac09d86f68
3 changed files with 46 additions and 27 deletions

View File

@ -1305,6 +1305,11 @@ $LANG = array(
'canada' => 'Canada',
'accept_debit_cards' => 'Accept Debit Cards',
'debit_cards' => 'Debit Cards',
'warn_start_date_changed' => 'The next invoice will be sent on the new start date.',
'original_start_date' => 'Original start date',
'new_start_date' => 'New start date',
);
return $LANG;

View File

@ -809,6 +809,7 @@
var invoice = {!! $invoice !!};
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
model.invoice().start_date_orig(model.invoice().start_date());
@if ($invoice->id)
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
@ -1192,13 +1193,25 @@
}
function onSaveClick() {
if (model.invoice().is_recurring() && {{ $invoice ? 'false' : 'true' }}) {
if (model.invoice().is_recurring()) {
// warn invoice will be emailed when saving new recurring invoice
if ({{ $invoice->exists() ? 'false' : 'true' }}) {
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
submitAction('');
}
} else {
preparePdfData('');
return;
// warn invoice will be emailed again if start date is changed
} else if (model.invoice().start_date() != model.invoice().start_date_orig()) {
if (confirm("{!! trans("texts.warn_start_date_changed") !!}" + '\n\n'
+ "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date())) {
submitAction('');
}
return;
}
}
preparePdfData('');
}
function getSendToEmails() {

View File

@ -180,6 +180,7 @@ function InvoiceModel(data) {
self.due_date = ko.observable('');
self.recurring_due_date = ko.observable('');
self.start_date = ko.observable('');
self.start_date_orig = ko.observable('');
self.end_date = ko.observable('');
self.last_sent_date = ko.observable('');
self.tax_name1 = ko.observable();