2013-12-25 22:34:42 +01:00
|
|
|
<?php namespace ninja\mailers;
|
2013-12-10 18:18:35 +01:00
|
|
|
|
|
|
|
use Invoice;
|
|
|
|
use Contact;
|
|
|
|
use Invitation;
|
|
|
|
use URL;
|
|
|
|
use Auth;
|
2013-12-30 21:17:45 +01:00
|
|
|
use Activity;
|
2013-12-10 18:18:35 +01:00
|
|
|
|
|
|
|
class ContactMailer extends Mailer {
|
|
|
|
|
2013-12-13 10:13:57 +01:00
|
|
|
public function sendInvoice(Invoice $invoice)
|
2013-12-10 18:18:35 +01:00
|
|
|
{
|
|
|
|
$view = 'invoice';
|
|
|
|
$subject = '';
|
|
|
|
|
2013-12-13 10:13:57 +01:00
|
|
|
foreach ($invoice->invitations as $invitation)
|
|
|
|
{
|
2014-01-06 19:03:00 +01:00
|
|
|
$invitation->sent_date = \Carbon::now()->toDateTimeString();
|
2013-12-13 10:13:57 +01:00
|
|
|
$invitation->save();
|
2014-01-06 07:48:11 +01:00
|
|
|
|
|
|
|
$data = array('link' => URL::to('view') . '/' . $invitation->invitation_key);
|
2013-12-10 18:18:35 +01:00
|
|
|
|
2013-12-13 10:13:57 +01:00
|
|
|
$this->sendTo($invitation->contact->email, $subject, $view, $data);
|
2013-12-10 18:18:35 +01:00
|
|
|
|
2013-12-30 21:17:45 +01:00
|
|
|
Activity::emailInvoice($invitation);
|
|
|
|
}
|
|
|
|
|
2013-12-11 12:11:59 +01:00
|
|
|
if (!$invoice->isSent())
|
|
|
|
{
|
|
|
|
$invoice->invoice_status_id = INVOICE_STATUS_SENT;
|
|
|
|
$invoice->save();
|
|
|
|
}
|
2013-12-25 22:34:42 +01:00
|
|
|
|
|
|
|
\Event::fire('invoice.sent', $invoice);
|
2013-12-10 18:18:35 +01:00
|
|
|
}
|
|
|
|
}
|