Proposals

This commit is contained in:
Hillel Coren 2018-02-12 11:34:48 +02:00
parent 754dd15af7
commit 89f3671205
4 changed files with 20 additions and 11 deletions

View File

@ -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'));

View File

@ -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();

View File

@ -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');
}
}

View File

@ -106,8 +106,10 @@
}
function onEmailClick() {
sweetConfirm(function() {
$('#action').val('email');
$('#saveButton').click();
})
}
@if ($proposal)