mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Show warning when changing recurring invoice start date
This commit is contained in:
parent
bb2fa9a18e
commit
ac09d86f68
@ -1305,6 +1305,11 @@ $LANG = array(
|
|||||||
'canada' => 'Canada',
|
'canada' => 'Canada',
|
||||||
'accept_debit_cards' => 'Accept Debit Cards',
|
'accept_debit_cards' => 'Accept Debit Cards',
|
||||||
'debit_cards' => '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;
|
return $LANG;
|
||||||
|
@ -530,7 +530,7 @@
|
|||||||
@if ( ! $invoice->is_recurring)
|
@if ( ! $invoice->is_recurring)
|
||||||
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!}
|
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($invoice->isClientTrashed())
|
@if ($invoice->isClientTrashed())
|
||||||
<!-- do nothing -->
|
<!-- do nothing -->
|
||||||
@elseif ($invoice->trashed())
|
@elseif ($invoice->trashed())
|
||||||
@ -809,6 +809,7 @@
|
|||||||
var invoice = {!! $invoice !!};
|
var invoice = {!! $invoice !!};
|
||||||
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
|
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
|
||||||
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
|
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
|
||||||
|
model.invoice().start_date_orig(model.invoice().start_date());
|
||||||
|
|
||||||
@if ($invoice->id)
|
@if ($invoice->id)
|
||||||
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
|
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
|
||||||
@ -1192,14 +1193,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSaveClick() {
|
function onSaveClick() {
|
||||||
if (model.invoice().is_recurring() && {{ $invoice ? 'false' : 'true' }}) {
|
if (model.invoice().is_recurring()) {
|
||||||
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
|
// warn invoice will be emailed when saving new recurring invoice
|
||||||
submitAction('');
|
if ({{ $invoice->exists() ? 'false' : 'true' }}) {
|
||||||
}
|
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
|
||||||
} else {
|
submitAction('');
|
||||||
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() {
|
function getSendToEmails() {
|
||||||
var client = model.invoice().client();
|
var client = model.invoice().client();
|
||||||
|
@ -55,7 +55,7 @@ function ViewModel(data) {
|
|||||||
if (self.invoice().tax_name1() || self.invoice().tax_name2()) {
|
if (self.invoice().tax_name1() || self.invoice().tax_name2()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.invoice_taxes() && {{ count($taxRateOptions) ? 'true' : 'false' }};
|
return self.invoice_taxes() && {{ count($taxRateOptions) ? 'true' : 'false' }};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,11 +100,11 @@ function ViewModel(data) {
|
|||||||
$('input.client-email').each(function(item, value) {
|
$('input.client-email').each(function(item, value) {
|
||||||
var $email = $(value);
|
var $email = $(value);
|
||||||
var email = $(value).val();
|
var email = $(value).val();
|
||||||
|
|
||||||
// Trim whitespace
|
// Trim whitespace
|
||||||
email = (email || '').trim();
|
email = (email || '').trim();
|
||||||
$email.val(email);
|
$email.val(email);
|
||||||
|
|
||||||
if (!firstName && (!email || !isValidEmailAddress(email))) {
|
if (!firstName && (!email || !isValidEmailAddress(email))) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
@ -180,6 +180,7 @@ function InvoiceModel(data) {
|
|||||||
self.due_date = ko.observable('');
|
self.due_date = ko.observable('');
|
||||||
self.recurring_due_date = ko.observable('');
|
self.recurring_due_date = ko.observable('');
|
||||||
self.start_date = ko.observable('');
|
self.start_date = ko.observable('');
|
||||||
|
self.start_date_orig = ko.observable('');
|
||||||
self.end_date = ko.observable('');
|
self.end_date = ko.observable('');
|
||||||
self.last_sent_date = ko.observable('');
|
self.last_sent_date = ko.observable('');
|
||||||
self.tax_name1 = ko.observable();
|
self.tax_name1 = ko.observable();
|
||||||
@ -240,13 +241,13 @@ function InvoiceModel(data) {
|
|||||||
applyComboboxListeners();
|
applyComboboxListeners();
|
||||||
return itemModel;
|
return itemModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.addDocument = function() {
|
self.addDocument = function() {
|
||||||
var documentModel = new DocumentModel();
|
var documentModel = new DocumentModel();
|
||||||
self.documents.push(documentModel);
|
self.documents.push(documentModel);
|
||||||
return documentModel;
|
return documentModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.removeDocument = function(doc) {
|
self.removeDocument = function(doc) {
|
||||||
var public_id = doc.public_id?doc.public_id():doc;
|
var public_id = doc.public_id?doc.public_id():doc;
|
||||||
self.documents.remove(function(document) {
|
self.documents.remove(function(document) {
|
||||||
@ -291,7 +292,7 @@ function InvoiceModel(data) {
|
|||||||
self.tax_rate2(rate);
|
self.tax_rate2(rate);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
self.wrapped_terms = ko.computed({
|
self.wrapped_terms = ko.computed({
|
||||||
read: function() {
|
read: function() {
|
||||||
return this.terms();
|
return this.terms();
|
||||||
@ -386,7 +387,7 @@ function InvoiceModel(data) {
|
|||||||
|
|
||||||
var taxRate2 = parseFloat(self.tax_rate2());
|
var taxRate2 = parseFloat(self.tax_rate2());
|
||||||
var tax2 = roundToTwo(total * (taxRate2/100));
|
var tax2 = roundToTwo(total * (taxRate2/100));
|
||||||
|
|
||||||
return self.formatMoney(tax1 + tax2);
|
return self.formatMoney(tax1 + tax2);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -403,7 +404,7 @@ function InvoiceModel(data) {
|
|||||||
lineTotal -= roundToTwo(lineTotal * (self.discount()/100));
|
lineTotal -= roundToTwo(lineTotal * (self.discount()/100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var taxAmount = roundToTwo(lineTotal * item.tax_rate1() / 100);
|
var taxAmount = roundToTwo(lineTotal * item.tax_rate1() / 100);
|
||||||
if (taxAmount) {
|
if (taxAmount) {
|
||||||
var key = item.tax_name1() + item.tax_rate1();
|
var key = item.tax_name1() + item.tax_rate1();
|
||||||
@ -664,12 +665,12 @@ function ContactModel(data) {
|
|||||||
|
|
||||||
return str;
|
return str;
|
||||||
});
|
});
|
||||||
|
|
||||||
self.info_color = ko.computed(function() {
|
self.info_color = ko.computed(function() {
|
||||||
if (self.invitation_viewed()) {
|
if (self.invitation_viewed()) {
|
||||||
return '#57D172';
|
return '#57D172';
|
||||||
} else if (self.invitation_openend()) {
|
} else if (self.invitation_openend()) {
|
||||||
return '#FFCC00';
|
return '#FFCC00';
|
||||||
} else {
|
} else {
|
||||||
return '#B1B5BA';
|
return '#B1B5BA';
|
||||||
}
|
}
|
||||||
@ -780,7 +781,7 @@ function ItemModel(data) {
|
|||||||
|
|
||||||
this.onSelect = function() {}
|
this.onSelect = function() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DocumentModel(data) {
|
function DocumentModel(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.public_id = ko.observable(0);
|
self.public_id = ko.observable(0);
|
||||||
@ -788,16 +789,16 @@ function DocumentModel(data) {
|
|||||||
self.name = ko.observable('');
|
self.name = ko.observable('');
|
||||||
self.type = ko.observable('');
|
self.type = ko.observable('');
|
||||||
self.url = ko.observable('');
|
self.url = ko.observable('');
|
||||||
|
|
||||||
self.update = function(data){
|
self.update = function(data){
|
||||||
ko.mapping.fromJS(data, {}, this);
|
ko.mapping.fromJS(data, {}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
self.update(data);
|
self.update(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ExpenseModel = function(data) {
|
var ExpenseModel = function(data) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -808,7 +809,7 @@ var ExpenseModel = function(data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.description = ko.observable('');
|
self.description = ko.observable('');
|
||||||
self.qty = ko.observable(0);
|
self.qty = ko.observable(0);
|
||||||
self.public_id = ko.observable(0);
|
self.public_id = ko.observable(0);
|
||||||
@ -825,7 +826,7 @@ ko.bindingHandlers.typeahead = {
|
|||||||
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||||||
var $element = $(element);
|
var $element = $(element);
|
||||||
var allBindings = allBindingsAccessor();
|
var allBindings = allBindingsAccessor();
|
||||||
|
|
||||||
$element.typeahead({
|
$element.typeahead({
|
||||||
highlight: true,
|
highlight: true,
|
||||||
minLength: 0,
|
minLength: 0,
|
||||||
@ -875,4 +876,4 @@ ko.bindingHandlers.typeahead = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user