mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Improve warning messages when sending emails
This commit is contained in:
parent
a26cb74170
commit
028743e440
@ -2046,7 +2046,8 @@ $LANG = array(
|
||||
'error_title' => 'Something went wrong',
|
||||
'error_contact_text' => 'If you\'d like help please email us at :mailaddress',
|
||||
'no_undo' => 'Warning: this can\'t be undone.',
|
||||
|
||||
'no_contact_selected' => 'Please select a contact',
|
||||
'no_client_selected' => 'Please select a client',
|
||||
|
||||
);
|
||||
|
||||
|
@ -1215,11 +1215,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var clientId = parseInt($('input[name=client]').val(), 10) || 0;
|
||||
if (clientId == 0 ) {
|
||||
swal("{!! trans('texts.no_client_selected') !!}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isContactSelected()) {
|
||||
swal("{!! trans('texts.no_contact_selected') !!}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isEmailValid()) {
|
||||
swal("{!! trans('texts.provide_email') !!}");
|
||||
return;
|
||||
8 }
|
||||
|
||||
|
||||
sweetConfirm(function() {
|
||||
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
|
||||
var clientLanguageId = parseInt(model.invoice().client().language_id()) || 0;
|
||||
@ -1349,8 +1361,7 @@
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function isEmailValid() {
|
||||
var isValid = true;
|
||||
function isContactSelected() {
|
||||
var sendTo = false;
|
||||
var client = model.invoice().client();
|
||||
for (var i=0; i<client.contacts().length; i++) {
|
||||
@ -1359,14 +1370,29 @@
|
||||
continue;
|
||||
}
|
||||
if (isValidEmailAddress(contact.email())) {
|
||||
isValid = true;
|
||||
sendTo = true;
|
||||
}
|
||||
}
|
||||
return sendTo;
|
||||
|
||||
}
|
||||
|
||||
function isEmailValid() {
|
||||
var isValid = true;
|
||||
var client = model.invoice().client();
|
||||
for (var i=0; i<client.contacts().length; i++) {
|
||||
var contact = client.contacts()[i];
|
||||
if ( ! contact.send_invoice()) {
|
||||
continue;
|
||||
}
|
||||
if (isValidEmailAddress(contact.email())) {
|
||||
isValid = true;
|
||||
} else {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (isValid && sendTo)
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function onMarkClick() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user