mirror of
https://github.com/snipe/snipe-it.git
synced 2026-02-04 12:35:35 +00:00
add Component Checkout Mail
This commit is contained in:
@ -8,6 +8,7 @@ use App\Mail\CheckinLicenseMail;
|
||||
use App\Mail\CheckoutAccessoryMail;
|
||||
use App\Mail\CheckoutAssetMail;
|
||||
use App\Mail\CheckinAssetMail;
|
||||
use App\Mail\CheckoutComponentMail;
|
||||
use App\Mail\CheckoutConsumableMail;
|
||||
use App\Mail\CheckoutLicenseMail;
|
||||
use App\Models\Accessory;
|
||||
@ -152,7 +153,8 @@ class CheckoutableListener
|
||||
return;
|
||||
}
|
||||
|
||||
if ($shouldSendEmailToUser || $shouldSendEmailToAlertAddress) {
|
||||
if (($shouldSendEmailToUser || $shouldSendEmailToAlertAddress) &&
|
||||
!($event->checkoutable instanceof Component)) {
|
||||
/**
|
||||
* Send the appropriate notification
|
||||
*/
|
||||
@ -318,6 +320,7 @@ class CheckoutableListener
|
||||
Asset::class => CheckoutAssetMail::class,
|
||||
LicenseSeat::class => CheckoutLicenseMail::class,
|
||||
Consumable::class => CheckoutConsumableMail::class,
|
||||
Component::class => CheckoutComponentMail::class,
|
||||
];
|
||||
$mailable= $lookup[get_class($event->checkoutable)];
|
||||
|
||||
|
||||
88
app/Mail/CheckoutComponentMail.php
Normal file
88
app/Mail/CheckoutComponentMail.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Component;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CheckoutComponentMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct(Component $component, $checkedOutTo, User $checkedOutBy, $acceptance, $note)
|
||||
{
|
||||
$this->item = $component;
|
||||
$this->admin = $checkedOutBy;
|
||||
$this->note = $note;
|
||||
$this->target = $checkedOutTo;
|
||||
$this->acceptance = $acceptance;
|
||||
$this->qty = optional($component->assets->first())->pivot->assigned_qty;
|
||||
|
||||
|
||||
$this->settings = Setting::getSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = new Address(config('mail.from.address'), config('mail.from.name'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from,
|
||||
subject: trans('mail.Confirm_component_delivery'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
|
||||
$eula = $this->item->getEula();
|
||||
$req_accept = $this->item->requireAcceptance();
|
||||
|
||||
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
||||
|
||||
return new Content(
|
||||
markdown: 'mail.markdown.checkout-component',
|
||||
with: [
|
||||
'item' => $this->item,
|
||||
'admin' => $this->admin,
|
||||
'note' => $this->note,
|
||||
'target' => $this->target,
|
||||
'eula' => $eula,
|
||||
'req_accept' => $req_accept,
|
||||
'accept_url' => $accept_url,
|
||||
'qty' => $this->qty,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
public function build()
|
||||
{
|
||||
return $this
|
||||
->markdown('mail.markdown.checkout-component', $this->viewData);
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ return [
|
||||
'Confirm_accessory_delivery' => 'Accessory delivery confirmation',
|
||||
'Confirm_asset_delivery' => 'Asset delivery confirmation',
|
||||
'Confirm_consumable_delivery' => 'Consumable delivery confirmation',
|
||||
'Confirm_component_delivery' => 'Component delivery confirmation',
|
||||
'Confirm_license_delivery' => 'License delivery confirmation',
|
||||
'Consumable_checkout_notification' => 'Consumable checked out',
|
||||
'Component_checkout_notification' => 'Component checked out',
|
||||
|
||||
51
resources/views/mail/markdown/checkout-component.blade.php
Normal file
51
resources/views/mail/markdown/checkout-component.blade.php
Normal file
@ -0,0 +1,51 @@
|
||||
@component('mail::message')
|
||||
# {{ trans('mail.hello') }} {{ $target->assignedto->present()->fullName() }},
|
||||
|
||||
{{ trans('mail.new_item_checked') }}
|
||||
|
||||
|
||||
@component('mail::table')
|
||||
| | |
|
||||
| ------------- | ------------- |
|
||||
@if (isset($checkout_date))
|
||||
| **{{ trans('mail.checkout_date') }}** | {{ $checkout_date }} |
|
||||
@endif
|
||||
| **{{ trans('general.component') }}** | {{ $item->name }} |
|
||||
@if (isset($qty))
|
||||
| **{{ trans('general.qty') }}** | {{ $qty }} |
|
||||
@endif
|
||||
@if (isset($item->manufacturer))
|
||||
| **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} |
|
||||
@endif
|
||||
@if ($note)
|
||||
| **{{ trans('mail.additional_notes') }}** | {{ $note }} |
|
||||
@endif
|
||||
@if ($admin)
|
||||
| **{{ trans('general.administrator') }}** | {{ $admin->present()->fullName() }} |
|
||||
@endif
|
||||
@endcomponent
|
||||
|
||||
@if (($req_accept == 1) && ($eula!=''))
|
||||
{{ trans('mail.read_the_terms_and_click') }}
|
||||
@elseif (($req_accept == 1) && ($eula==''))
|
||||
{{ trans('mail.click_on_the_link_asset') }}
|
||||
@elseif (($req_accept == 0) && ($eula!=''))
|
||||
{{ trans('mail.read_the_terms') }}
|
||||
@endif
|
||||
|
||||
@if ($eula)
|
||||
@component('mail::panel')
|
||||
{!! $eula !!}
|
||||
@endcomponent
|
||||
@endif
|
||||
|
||||
@if ($req_accept == 1)
|
||||
**[✔ {{ trans('mail.i_have_read') }}]({{ $accept_url }})**
|
||||
@endif
|
||||
|
||||
|
||||
{{ trans('mail.best_regards') }}
|
||||
|
||||
{{ $snipeSettings->site_name }}
|
||||
|
||||
@endcomponent
|
||||
@ -52,7 +52,12 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
[LabelsController::class, 'show']
|
||||
)->where('labelName', '.*')->name('labels.show');
|
||||
|
||||
Route::get('/test-email', function () {
|
||||
$mailable = new \App\Mail\CheckoutComponentMail(
|
||||
|
||||
);
|
||||
return $mailable->render(); // dumps HTML
|
||||
});
|
||||
/*
|
||||
* Manufacturers
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user