diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index da46d1498a94..6512e6950a53 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -521,6 +521,8 @@ class InvoiceController extends BaseController if ($count > 0) { if ($action == 'markSent') { $key = 'marked_sent_invoice'; + } elseif ($action == 'emailInvoice') { + $key = 'emailed_' . $entityType; } elseif ($action == 'markPaid') { $key = 'created_payment'; } else { diff --git a/app/Ninja/Datatables/InvoiceDatatable.php b/app/Ninja/Datatables/InvoiceDatatable.php index b08676e144d6..3f3ec89a982f 100644 --- a/app/Ninja/Datatables/InvoiceDatatable.php +++ b/app/Ninja/Datatables/InvoiceDatatable.php @@ -180,6 +180,10 @@ class InvoiceDatatable extends EntityDatatable if ($this->entityType == ENTITY_INVOICE || $this->entityType == ENTITY_QUOTE) { $actions[] = \DropdownButton::DIVIDER; + $actions[] = [ + 'label' => mtrans($this->entityType, 'email_' . $this->entityType), + 'url' => 'javascript:submitForm_'.$this->entityType.'("emailInvoice")', + ]; $actions[] = [ 'label' => mtrans($this->entityType, 'mark_sent'), 'url' => 'javascript:submitForm_'.$this->entityType.'("markSent")', diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 1286c6ca13b1..d741578ab8a3 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -12,6 +12,7 @@ use App\Models\Task; use App\Models\Document; use App\Models\Expense; use App\Services\PaymentService; +use App\Jobs\SendInvoiceEmail; class InvoiceRepository extends BaseRepository { @@ -746,6 +747,15 @@ class InvoiceRepository extends BaseRepository return $clone; } + /** + * @param Invoice $invoice + */ + public function emailInvoice(Invoice $invoice) + { + dispatch(new SendInvoiceEmail($invoice)); + } + + /** * @param Invoice $invoice */ diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 620f22301f19..57b176ae9872 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2310,7 +2310,8 @@ $LANG = array( 'bcc_email_help' => 'All emails sent to your clients will also be sent to this address.', 'tax_quote' => 'Tax Quote', 'tax_invoice' => 'Tax Invoice', - + 'emailed_invoices' => 'Successfully emailed invoices', + 'emailed_quotes' => 'Successfully emailed quotes', ); return $LANG;