mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Text email templates
This commit is contained in:
parent
bed77a2710
commit
c02bc2c389
@ -62,21 +62,46 @@ class RecurringInvoiceController extends Controller
|
||||
|
||||
public function requestCancellation(RequestCancellationRequest $request, RecurringInvoice $recurring_invoice)
|
||||
{
|
||||
if (is_null($recurring_invoice->subscription_id) || optional($recurring_invoice->subscription)->allow_cancellation) {
|
||||
nlog("outside cancellation");
|
||||
|
||||
if (optional($recurring_invoice->subscription)->allow_cancellation) {
|
||||
|
||||
nlog("inside the cancellation");
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->user()))->build()));
|
||||
$nmo->company = $recurring_invoice->company;
|
||||
$nmo->settings = $recurring_invoice->company->settings;
|
||||
|
||||
$notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
||||
// $notifiable_users = $this->filterUsersByPermissions($recurring_invoice->company->company_users, $recurring_invoice, ['recurring_cancellation']);
|
||||
|
||||
$recurring_invoice->company->company_users->each(function ($company_user) use ($nmo){
|
||||
|
||||
|
||||
$methods = $this->findCompanyUserNotificationType($company_user, ['recurring_cancellation', 'all_notifications']);
|
||||
|
||||
|
||||
//if mail is a method type -fire mail!!
|
||||
if (($key = array_search('mail', $methods)) !== false) {
|
||||
unset($methods[$key]);
|
||||
|
||||
|
||||
$nmo->to_user = $company_user->user;
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
}
|
||||
|
||||
$notifiable_users->each(function ($company_user) use($nmo){
|
||||
|
||||
$nmo->to_user = $company_user->user;
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
});
|
||||
|
||||
// $notifiable_users->each(function ($company_user) use($nmo){
|
||||
|
||||
// $nmo->to_user = $company_user->user;
|
||||
// NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
// });
|
||||
|
||||
//$recurring_invoice->user->notify(new ClientContactRequestCancellation($recurring_invoice, auth()->user()));
|
||||
|
||||
return $this->render('recurring_invoices.cancellation.index', [
|
||||
|
@ -77,9 +77,6 @@ class UserEmailChanged implements ShouldQueue
|
||||
|
||||
NinjaMailerJob::dispatch($nmo, true);
|
||||
|
||||
// $nmo->to_user = $this->new_user;
|
||||
// NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
$this->new_user->service()->invite($this->company);
|
||||
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ class ContactPasswordlessLogin extends Mailable
|
||||
|
||||
return $this
|
||||
->subject(ctrans('texts.account_passwordless_login'))
|
||||
->text('email.billing.passwordless-login_text')
|
||||
->view('email.billing.passwordless-login', [
|
||||
'logo' => $this->company->present()->logo(),
|
||||
'settings' => $this->company->settings,
|
||||
|
@ -58,6 +58,7 @@ class ClientContactRequestCancellationObject
|
||||
$mail_obj->data = $data;
|
||||
$mail_obj->markdown = 'email.admin.generic';
|
||||
$mail_obj->tag = $this->company->company_key;
|
||||
$mail_obj->text_view = 'email.admin.generic_text';
|
||||
|
||||
return $mail_obj;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ class UserAdded extends Mailable
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.created_user'))
|
||||
->text('email.admin.user_added_text')
|
||||
->view('email.admin.user_added')
|
||||
->with([
|
||||
'settings' => $this->company->settings,
|
||||
|
@ -50,6 +50,10 @@ class UserLoggedIn extends Mailable
|
||||
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject(ctrans('texts.new_login_detected'))
|
||||
->text('email.admin.generic_text',[
|
||||
'title' => ctrans('texts.new_login_detected'),
|
||||
'body' => strip_tags(ctrans('texts.new_login_description', ['email' => $this->user->email, 'ip' => $this->ip, 'time' => now()]))
|
||||
])
|
||||
->view('email.admin.notification')
|
||||
->with([
|
||||
'settings' => $this->company->settings,
|
||||
|
@ -37,6 +37,10 @@ class UserNotificationMailer extends Mailable
|
||||
{
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject($this->mail_obj->subject)
|
||||
->text('email.admin.generic_text',[
|
||||
'title' => $this->mail_obj->data['title'],
|
||||
'body' => $this->mail_obj->data['message'],
|
||||
])
|
||||
->view($this->mail_obj->markdown, $this->mail_obj->data)
|
||||
->withSwiftMessage(function ($message) {
|
||||
$message->getHeaders()->addTextHeader('Tag', $this->mail_obj->tag);
|
||||
|
@ -16,9 +16,13 @@ use App\Factory\CreditFactory;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\InvoiceToRecurringInvoiceFactory;
|
||||
use App\Factory\RecurringInvoiceFactory;
|
||||
use App\Jobs\Mail\NinjaMailer;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Jobs\Util\SubscriptionWebhookHandler;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\RecurringInvoice\ClientContactRequestCancellationObject;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Credit;
|
||||
@ -36,6 +40,7 @@ use App\Services\Subscription\ZeroCostProduct;
|
||||
use App\Utils\Ninja;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Utils\Traits\Notifications\UserNotifies;
|
||||
use App\Utils\Traits\SubscriptionHooker;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
@ -46,6 +51,7 @@ class SubscriptionService
|
||||
use MakesHash;
|
||||
use CleanLineItems;
|
||||
use SubscriptionHooker;
|
||||
use UserNotifies;
|
||||
|
||||
/** @var subscription */
|
||||
private $subscription;
|
||||
@ -934,6 +940,29 @@ class SubscriptionService
|
||||
|
||||
$this->triggerWebhook($context);
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = (new NinjaMailer((new ClientContactRequestCancellationObject($recurring_invoice, auth()->guard('contact')->user()))->build()));
|
||||
$nmo->company = $recurring_invoice->company;
|
||||
$nmo->settings = $recurring_invoice->company->settings;
|
||||
|
||||
$recurring_invoice->company->company_users->each(function ($company_user) use ($nmo){
|
||||
|
||||
$methods = $this->findCompanyUserNotificationType($company_user, ['recurring_cancellation', 'all_notifications']);
|
||||
|
||||
//if mail is a method type -fire mail!!
|
||||
if (($key = array_search('mail', $methods)) !== false) {
|
||||
unset($methods[$key]);
|
||||
|
||||
$nmo->to_user = $company_user->user;
|
||||
NinjaMailerJob::dispatch($nmo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return $this->handleRedirect('client/subscriptions');
|
||||
|
||||
}
|
||||
|
9
resources/views/email/admin/generic_text.blade.php
Normal file
9
resources/views/email/admin/generic_text.blade.php
Normal file
@ -0,0 +1,9 @@
|
||||
{!! $title !!}
|
||||
|
||||
@isset($body)
|
||||
{!! $body !!}
|
||||
@endisset
|
||||
|
||||
@isset($content)
|
||||
{!! $content !!}
|
||||
@endisset
|
3
resources/views/email/admin/user_added_text.blade.php
Normal file
3
resources/views/email/admin/user_added_text.blade.php
Normal file
@ -0,0 +1,3 @@
|
||||
{!! $title !!}
|
||||
|
||||
{!! $body !!}
|
@ -0,0 +1,6 @@
|
||||
{!! ctrans('texts.login_link_requested_label') !!}
|
||||
|
||||
{!! ctrans('texts.login_link_requested') !!}
|
||||
|
||||
{!! $url !!}
|
||||
|
Loading…
x
Reference in New Issue
Block a user