1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/ninja/mailers/UserMailer.php

58 lines
1.6 KiB
PHP
Raw Normal View History

2013-12-25 22:34:42 +01:00
<?php namespace ninja\mailers;
use Invoice;
2014-01-29 11:41:38 +01:00
use Payment;
2013-12-25 22:34:42 +01:00
use Contact;
use User;
2014-01-29 11:41:38 +01:00
use Utils;
2013-12-25 22:34:42 +01:00
class UserMailer extends Mailer {
2014-03-10 22:55:56 +01:00
2014-07-23 17:02:56 +02:00
public function sendConfirmation(User $user, User $invitor = null)
2014-03-10 22:55:56 +01:00
{
if (!$user->email)
{
return;
}
$view = 'confirm';
2014-04-02 14:28:23 +02:00
$subject = trans('texts.confirmation_subject');
2014-03-10 22:55:56 +01:00
$data = [
2014-07-23 17:02:56 +02:00
'user' => $user,
'invitationMessage' => $invitor ? trans('texts.invitation_message', ['invitor' => $invitor->getDisplayName()]) : ''
2014-03-10 22:55:56 +01:00
];
2014-04-12 20:55:40 +02:00
2014-03-27 13:25:31 +01:00
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
2014-03-10 22:55:56 +01:00
}
2013-12-25 22:34:42 +01:00
2014-05-20 23:40:09 +02:00
public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null)
2013-12-25 22:34:42 +01:00
{
if (!$user->email)
{
return;
}
2014-05-20 23:40:09 +02:00
$view = 'invoice_' . $notificationType;
$entityType = $invoice->getEntityType();
2014-01-29 11:41:38 +01:00
$data = [
2014-05-20 23:40:09 +02:00
'entityType' => $entityType,
2014-01-29 11:41:38 +01:00
'clientName' => $invoice->client->getDisplayName(),
'accountName' => $invoice->account->getDisplayName(),
'userName' => $user->getDisplayName(),
'invoiceAmount' => Utils::formatMoney($invoice->amount, $invoice->client->currency_id),
'invoiceNumber' => $invoice->invoice_number,
2014-05-20 23:40:09 +02:00
'invoiceLink' => SITE_URL . "/{$entityType}s/{$invoice->public_id}"
2014-01-29 11:41:38 +01:00
];
if ($payment)
{
$data['paymentAmount'] = Utils::formatMoney($payment->amount, $invoice->client->currency_id);
}
2014-05-20 23:40:09 +02:00
$subject = trans("texts.notification_{$entityType}_{$notificationType}_subject", ['invoice'=>$invoice->invoice_number, 'client'=>$invoice->client->getDisplayName()]);
2013-12-25 22:34:42 +01:00
2014-03-27 13:25:31 +01:00
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
2013-12-25 22:34:42 +01:00
}
}