1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/ninja/mailers/ContactMailer.php

68 lines
1.7 KiB
PHP
Raw Normal View History

2013-12-25 22:34:42 +01:00
<?php namespace ninja\mailers;
2013-12-10 18:18:35 +01:00
use Invoice;
2014-01-29 11:41:38 +01:00
use Payment;
2013-12-10 18:18:35 +01:00
use Contact;
use Invitation;
use URL;
use Auth;
2013-12-30 21:17:45 +01:00
use Activity;
2014-01-29 11:41:38 +01:00
use Utils;
2013-12-10 18:18:35 +01:00
class ContactMailer extends Mailer {
public function sendInvoice(Invoice $invoice)
2013-12-10 18:18:35 +01:00
{
$view = 'invoice';
2014-01-29 11:41:38 +01:00
$subject = 'New invoice ' . $invoice->invoice_number;
2013-12-10 18:18:35 +01:00
2014-01-29 11:41:38 +01:00
$invoice->load('invitations', 'client', 'account');
2014-01-09 11:05:35 +01:00
foreach ($invoice->invitations as $invitation)
{
2014-01-08 00:59:06 +01:00
if (!$invitation->user->email)
{
return false;
}
2014-01-06 19:03:00 +01:00
$invitation->sent_date = \Carbon::now()->toDateTimeString();
$invitation->save();
2014-01-06 07:48:11 +01:00
2014-01-29 11:41:38 +01:00
$data = [
'link' => URL::to('view') . '/' . $invitation->invitation_key,
'clientName' => $invoice->client->getDisplayName(),
'accountName' => $invoice->account->getDisplayName(),
'contactName' => $invitation->contact->getDisplayName(),
'invoiceAmount' => Utils::formatMoney($invoice->amount, $invoice->client->currency_id),
'emailFooter' => $invoice->account->email_footer
];
2014-01-07 16:50:41 +01:00
$this->sendTo($invitation->contact->email, $invitation->user->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
}
2014-01-29 11:41:38 +01:00
public function sendPaymentConfirmation(Payment $payment)
{
$view = 'payment_confirmation';
$subject = 'Payment confirmation';
$data = [
'accountName' => $payment->account->getDisplayName(),
'clientName' => $payment->client->getDisplayName(),
'emailFooter' => $payment->account->email_footer,
'paymentAmount' => Utils::formatMoney($payment->amount, $payment->client->currency_id)
];
$this->sendTo($payment->contact->email, $payment->invitation->user->email, $subject, $view, $data);
}
2013-12-10 18:18:35 +01:00
}