From 89f3671205d0a0fc67443154a4e4f06eda18ba21 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 12 Feb 2018 11:34:48 +0200 Subject: [PATCH] Proposals --- app/Http/Controllers/ProposalController.php | 5 +++-- app/Jobs/SendInvoiceEmail.php | 10 ++++++++-- app/Ninja/Mailers/ContactMailer.php | 10 +++++----- resources/views/proposals/edit.blade.php | 6 ++++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/ProposalController.php b/app/Http/Controllers/ProposalController.php index b775432d4981..71ddb3cd22bf 100644 --- a/app/Http/Controllers/ProposalController.php +++ b/app/Http/Controllers/ProposalController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Http\Requests\CreateProposalRequest; use App\Http\Requests\ProposalRequest; use App\Http\Requests\UpdateProposalRequest; +use App\Jobs\SendInvoiceEmail; use App\Models\Invoice; use App\Models\Proposal; use App\Models\ProposalTemplate; @@ -107,7 +108,7 @@ class ProposalController extends BaseController $action = Input::get('action'); if ($action == 'email') { - $this->contactMailer->sendInvoice($proposal->invoice, false, false, $proposal); + $this->dispatch(new SendInvoiceEmail($proposal->invoice, auth()->user()->id, false, false, $proposal)); Session::flash('message', trans('texts.emailed_proposal')); } else { Session::flash('message', trans('texts.created_proposal')); @@ -126,7 +127,7 @@ class ProposalController extends BaseController } if ($action == 'email') { - $this->contactMailer->sendInvoice($proposal->invoice, false, false, $proposal); + $this->dispatch(new SendInvoiceEmail($proposal->invoice, auth()->user()->id, false, false, $proposal)); Session::flash('message', trans('texts.emailed_proposal')); } else { Session::flash('message', trans('texts.updated_proposal')); diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php index 1046372686ca..effa021b9be7 100644 --- a/app/Jobs/SendInvoiceEmail.php +++ b/app/Jobs/SendInvoiceEmail.php @@ -43,6 +43,11 @@ class SendInvoiceEmail extends Job implements ShouldQueue */ protected $server; + /** + * @var Proposal + */ + protected $proposal; + /** * Create a new job instance. * @@ -51,12 +56,13 @@ class SendInvoiceEmail extends Job implements ShouldQueue * @param bool $reminder * @param mixed $pdfString */ - public function __construct(Invoice $invoice, $userId = false, $reminder = false, $template = false) + public function __construct(Invoice $invoice, $userId = false, $reminder = false, $template = false, $proposal = false) { $this->invoice = $invoice; $this->userId = $userId; $this->reminder = $reminder; $this->template = $template; + $this->proposal = $proposal; $this->server = config('database.default'); } @@ -72,7 +78,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue Auth::onceUsingId($this->userId); } - $mailer->sendInvoice($this->invoice, $this->reminder, $this->template); + $mailer->sendInvoice($this->invoice, $this->reminder, $this->template, $this->proposal); if (App::runningInConsole() && $this->userId) { Auth::logout(); diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 7c426b893068..79ac13650dd5 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -146,12 +146,12 @@ class ContactMailer extends Mailer $subject, $reminder, $isFirst, - $data + $extra ) { $client = $invoice->client; $account = $invoice->account; $user = $invitation->user; - $proposal = $data['proposal']; + $proposal = $extra['proposal']; if ($user->trashed()) { $user = $account->users()->orderBy('id')->first(); @@ -197,7 +197,7 @@ class ContactMailer extends Mailer 'account' => $account, 'client' => $client, 'invoice' => $invoice, - 'documents' => $data['documentStrings'], + 'documents' => $extra['documentStrings'], 'notes' => $reminder, 'bccEmail' => $isFirst ? $account->getBccEmail() : false, 'fromEmail' => $account->getFromEmail(), @@ -205,11 +205,11 @@ class ContactMailer extends Mailer if (! $proposal) { if ($account->attachPDF()) { - $data['pdfString'] = $data['pdfString']; + $data['pdfString'] = $extra['pdfString']; $data['pdfFileName'] = $invoice->getFileName(); } if ($account->attachUBL()) { - $data['ublString'] = $data['ublString']; + $data['ublString'] = $extra['ublString']; $data['ublFileName'] = $invoice->getFileName('xml'); } } diff --git a/resources/views/proposals/edit.blade.php b/resources/views/proposals/edit.blade.php index 086e3b91a41a..69e3b32c1e22 100644 --- a/resources/views/proposals/edit.blade.php +++ b/resources/views/proposals/edit.blade.php @@ -106,8 +106,10 @@ } function onEmailClick() { - $('#action').val('email'); - $('#saveButton').click(); + sweetConfirm(function() { + $('#action').val('email'); + $('#saveButton').click(); + }) } @if ($proposal)