diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 4b9e7d7e9faf..405148a08ccb 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -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', ); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index f9b1f3004f05..56ec4128fdf6 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1195,7 +1195,7 @@ model.invoice().invoice_footer(model.invoice().default_footer()); refreshPDF(); }); - + return false; } @@ -1215,10 +1215,22 @@ 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 } +8 } + sweetConfirm(function() { var accountLanguageId = parseInt({{ $account->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