1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00
invoiceninja/app/Ninja/Intents/EmailInvoiceIntent.php

33 lines
853 B
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
2016-08-09 22:06:24 +02:00
2017-01-30 20:40:43 +01:00
namespace App\Ninja\Intents;
use App\Libraries\Skype\SkypeResponse;
2016-08-09 22:06:24 +02:00
use Auth;
use Exception;
class EmailInvoiceIntent extends InvoiceIntent
{
public function process()
{
2016-08-13 21:19:37 +02:00
$invoice = $this->stateInvoice();
2016-08-09 22:06:24 +02:00
2017-01-30 17:05:31 +01:00
if (! Auth::user()->can('edit', $invoice)) {
2016-08-09 22:06:24 +02:00
throw new Exception(trans('texts.not_allowed'));
}
$contactMailer = app('App\Ninja\Mailers\ContactMailer');
$contactMailer->sendInvoice($invoice);
$message = trans('texts.bot_emailed_' . $invoice->getEntityType());
2016-08-13 21:19:37 +02:00
if (Auth::user()->notify_viewed) {
$message .= '<br/>' . trans('texts.bot_emailed_notify_viewed');
} elseif (Auth::user()->notify_paid) {
$message .= '<br/>' . trans('texts.bot_emailed_notify_paid');
}
2016-08-10 14:57:34 +02:00
return SkypeResponse::message($message);
2016-08-09 22:06:24 +02:00
}
}