diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 7f8b17bb5bef..8359ec8ef4e0 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2517,6 +2517,7 @@ $LANG = array( 'set_phone_for_two_factor' => 'Set your phone number to enable.', 'enabled_two_factor' => 'Successfully enabled Two-Factor Authentication', 'add_product' => 'Add Product', + 'email_will_be_sent_on' => 'Note: the email will be sent on :date.', ); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 546466eff043..a0f5f95b721b 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1303,21 +1303,29 @@ return false; } if (!isSaveValid()) { - model.showClientForm(); - return false; - } - // warn invoice will be emailed when saving new recurring invoice - var text = '\n' + getSendToEmails(); + model.showClientForm(); + return false; + } + + var title = "{!! trans("texts.confirm_recurring_email_invoice") !!}"; + var text = '\n' + getSendToEmails(); + var startDate = moment($('#start_date').datepicker('getDate')); + + // warn invoice will be emailed when saving new recurring invoice if (model.invoice().start_date() == "{{ Utils::fromSqlDate(date('Y-m-d')) }}") { text += '\n\n' + "{!! trans("texts.confirm_recurring_timing") !!}"; + // check if the start date is in the future + } else if (startDate.isAfter(moment(), 'day')) { + var message = "{!! trans("texts.email_will_be_sent_on") !!}"; + text += '\n\n' + message.replace(':date', model.invoice().start_date()); } - var title = "{!! trans("texts.confirm_recurring_email_$entityType") !!}"; - sweetConfirm(function() { + + sweetConfirm(function() { model.invoice().is_public(true); - submitAction(''); - }, text, title); - return; - } else { + submitAction(''); + }, text, title); + return; + } else { model.invoice().is_public(true); onSaveClick(); }