Skip to content

A free open source IT asset/license management system

Flesh out mail contents

Marcus Moore628d2a0a0a82
diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php
index 6c44d9b846..67d27310a0 100644
--- a/app/Http/Controllers/Account/AcceptanceController.php
+++ b/app/Http/Controllers/Account/AcceptanceController.php
@@ -346,6 +346,7 @@ class AcceptanceController extends Controller
if ($recipient) {
Mail::to($recipient)->send(new CheckoutAcceptanceResponseMail(
+ $acceptance,
$recipient,
$request->input('asset_acceptance') === 'accepted'
));
diff --git a/app/Mail/CheckoutAcceptanceResponseMail.php b/app/Mail/CheckoutAcceptanceResponseMail.php
index 4e75d3e7e5..b568d87765 100644
--- a/app/Mail/CheckoutAcceptanceResponseMail.php
+++ b/app/Mail/CheckoutAcceptanceResponseMail.php
@@ -2,6 +2,7 @@
namespace App\Mail;
+use App\Models\CheckoutAcceptance;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -14,14 +15,16 @@ class CheckoutAcceptanceResponseMail extends Mailable
{
use Queueable, SerializesModels;
- public bool $wasAccepted;
+ public CheckoutAcceptance $acceptance;
public User $recipient;
+ public bool $wasAccepted;
/**
* Create a new message instance.
*/
- public function __construct(User $recipient, bool $wasAccepted)
+ public function __construct(CheckoutAcceptance $acceptance, User $recipient, bool $wasAccepted)
{
+ $this->acceptance = $acceptance;
$this->recipient = $recipient;
$this->wasAccepted = $wasAccepted;
}
@@ -31,8 +34,13 @@ class CheckoutAcceptanceResponseMail extends Mailable
*/
public function envelope(): Envelope
{
+ // @todo: translate
+ $subject = $this->wasAccepted
+ ? 'A checkout you initiated was accepted'
+ : 'A checkout you initiated was declined';
+
return new Envelope(
- subject: 'A checkout you initiated was ' . ($this->wasAccepted ? 'accepted' : 'declined'),
+ subject: $subject,
);
}
@@ -44,12 +52,23 @@ class CheckoutAcceptanceResponseMail extends Mailable
return new Content(
markdown: 'mail.markdown.checkout-acceptance-response',
with: [
+ 'assignedTo' => $this->acceptance->assignedTo,
+ 'introduction' => $this->introduction(),
+ 'item' => $this->acceptance->checkoutable,
+ 'note' => $this->acceptance->note,
'recipient' => $this->recipient,
- 'wasAccepted' => $this->wasAccepted,
]
);
}
+ private function introduction(): string
+ {
+ // @todo: translate
+ return $this->wasAccepted
+ ? 'The following was accepted'
+ : 'The following was declined';
+ }
+
/**
* Get the attachments for the message.
*
diff --git a/resources/views/mail/markdown/checkout-acceptance-response.blade.php b/resources/views/mail/markdown/checkout-acceptance-response.blade.php
index c616f98415..aa80dc49fe 100644
--- a/resources/views/mail/markdown/checkout-acceptance-response.blade.php
+++ b/resources/views/mail/markdown/checkout-acceptance-response.blade.php
@@ -1,19 +1,20 @@
@component('mail::message')
# {{ trans('mail.hello') }} {{ $recipient->present()->fullName() }},
-{fullName} {accepted|declined} the following checkout:
+{{ $introduction }}:
@component('mail::table')
| | |
| ------------- | ------------- |
+| **{{ trans('mail.user') }}** | {{ $assignedTo->present()->fullName() }} |
@if ((isset($item->name)) && ($item->name!=''))
- | **{{ trans('mail.name') }}** | {{ $item->name }} |
+| **{{ trans('mail.name') }}** | {{ $item->name }} |
@endif
@if (isset($item->asset_tag))
- | **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} |
+| **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} |
@endif
-@if (isset($note) && $note != '')
- | **{{ trans('mail.notes') }}** | {{ $note }} |
+@if ($note != '')
+| **{{ trans('mail.notes') }}** | {{ $note }} |
@endif
@endcomponent