fixed asset checkout markdown, and notifiable variable

This commit is contained in:
Godfrey M 2024-10-16 16:46:52 -07:00
parent 02bda3cd95
commit a7754c1a7f
2 changed files with 67 additions and 96 deletions

View file

@ -16,10 +16,9 @@ use App\Models\CheckoutAcceptance;
use App\Models\Component; use App\Models\Component;
use App\Models\Consumable; use App\Models\Consumable;
use App\Models\LicenseSeat; use App\Models\LicenseSeat;
use App\Models\Recipients\AdminRecipient;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User;
use App\Notifications\CheckinAccessoryNotification; use App\Notifications\CheckinAccessoryNotification;
use App\Notifications\CheckinAssetNotification;
use App\Notifications\CheckinLicenseSeatNotification; use App\Notifications\CheckinLicenseSeatNotification;
use App\Notifications\CheckoutAccessoryNotification; use App\Notifications\CheckoutAccessoryNotification;
use App\Notifications\CheckoutAssetNotification; use App\Notifications\CheckoutAssetNotification;
@ -51,7 +50,7 @@ class CheckoutableListener
* Make a checkout acceptance and attach it in the notification * Make a checkout acceptance and attach it in the notification
*/ */
$acceptance = $this->getCheckoutAcceptance($event); $acceptance = $this->getCheckoutAcceptance($event);
$notifiable = $this->getNotifiable($event); $notifiable = $event->checkedOutTo;
$mailable = $this->getCheckoutMailType($event, $acceptance); $mailable = $this->getCheckoutMailType($event, $acceptance);
// Send email notifications // Send email notifications
try { try {
@ -99,7 +98,7 @@ class CheckoutableListener
} }
} }
$notifiable = $this->getNotifiable($event); $notifiable = $event->checkedInBy;
$mailable = $this->getCheckinMailType($event); $mailable = $this->getCheckinMailType($event);
// Send email notifications // Send email notifications
@ -144,34 +143,6 @@ class CheckoutableListener
return $acceptance; return $acceptance;
} }
/**
* Gets the entities to be notified of the passed event
*
* @param Event $event
* @return Collection
*/
private function getNotifiable($event)
{
$notifiable = collect();
/**
* Notify who checked out the item as long as the model can route notifications
*/
if (method_exists($event->checkedOutTo, 'routeNotificationFor')) {
$notifiable->push($event->checkedOutTo);
}
/**
* Notify Admin users if the settings is activated
*/
if ((Setting::getSettings()) && (Setting::getSettings()->admin_cc_email != '')) {
$adminRecipient= new AdminRecipient;
$notifiable->push($adminRecipient->getEmail());
}
return new $notifiable;
}
/** /**
* Get the appropriate notification for the event * Get the appropriate notification for the event
* *

View file

@ -1,76 +1,76 @@
@component('mail::message') @component('mail::message')
# {{ trans('mail.hello') }} {{ $target->present()->fullName() }}, # {{ trans('mail.hello') }} {{ $target->present()->fullName() }},
{{ trans('mail.new_item_checked') }} {{ trans('mail.new_item_checked') }}
@if (($snipeSettings->show_images_in_email =='1') && $item->getImageUrl()) @if (($snipeSettings->show_images_in_email =='1') && $item->getImageUrl())
<center><img src="{{ $item->getImageUrl() }}" alt="Asset" style="max-width: 570px;"></center> <center><img src="{{ $item->getImageUrl() }}" alt="Asset" style="max-width: 570px;"></center>
@endif @endif
@component('mail::table') @component('mail::table')
| | | | | |
| ------------- | ------------- | | ------------- | ------------- |
@if ((isset($item->name)) && ($item->name!='')) @if ((isset($item->name)) && ($item->name!=''))
| **{{ trans('mail.asset_name') }}** | {{ $item->name }} | | **{{ trans('mail.asset_name') }}** | {{ $item->name }} |
@endif @endif
@if (($item->name!=$item->asset_tag)) @if (($item->name!=$item->asset_tag))
| **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} | | **{{ trans('mail.asset_tag') }}** | {{ $item->asset_tag }} |
@endif @endif
@if (isset($item->manufacturer)) @if (isset($item->manufacturer))
| **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} | | **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} |
@endif @endif
@if (isset($item->model)) @if (isset($item->model))
| **{{ trans('general.asset_model') }}** | {{ $item->model->name }} | | **{{ trans('general.asset_model') }}** | {{ $item->model->name }} |
@endif @endif
@if ((isset($item->model->model_number)) && ($item->model->name!=$item->model->model_number)) @if ((isset($item->model->model_number)) && ($item->model->name!=$item->model->model_number))
| **{{ trans('general.model_no') }}** | {{ $item->model->model_number }} | | **{{ trans('general.model_no') }}** | {{ $item->model->model_number }} |
@endif @endif
@if (isset($item->serial)) @if (isset($item->serial))
| **{{ trans('mail.serial') }}** | {{ $item->serial }} | | **{{ trans('mail.serial') }}** | {{ $item->serial }} |
@endif @endif
@if (isset($last_checkout)) @if (isset($last_checkout))
| **{{ trans('mail.checkout_date') }}** | {{ $last_checkout }} | | **{{ trans('mail.checkout_date') }}** | {{ $last_checkout }} |
@endif @endif
@if (isset($status)) @if (isset($status))
| **{{ trans('general.status') }}** | {{ $status }} | | **{{ trans('general.status') }}** | {{ $status }} |
@endif @endif
@if ((isset($expected_checkin)) && ($expected_checkin!='')) @if ((isset($expected_checkin)) && ($expected_checkin!=''))
| **{{ trans('mail.expecting_checkin_date') }}** | {{ $expected_checkin }} | | **{{ trans('mail.expecting_checkin_date') }}** | {{ $expected_checkin }} |
@endif @endif
@foreach($fields as $field) @foreach($fields as $field)
@if (($item->{ $field->db_column_name() }!='') && ($field->show_in_email) && ($field->field_encrypted=='0')) @if (($item->{ $field->db_column_name() }!='') && ($field->show_in_email) && ($field->field_encrypted=='0'))
| **{{ $field->name }}** | {{ $item->{ $field->db_column_name() } }} | | **{{ $field->name }}** | {{ $item->{ $field->db_column_name() } }} |
@endif @endif
@endforeach @endforeach
@if ($admin) @if ($admin)
| **{{ trans('general.administrator') }}** | {{ $admin->present()->fullName() }} | | **{{ trans('general.administrator') }}** | {{ $admin->present()->fullName() }} |
@endif @endif
@if ($note) @if ($note)
| **{{ trans('mail.additional_notes') }}** | {{ $note }} | | **{{ trans('mail.additional_notes') }}** | {{ $note }} |
@endif @endif
@endcomponent @endcomponent
@if (($req_accept == 1) && ($eula!='')) @if (($req_accept == 1) && ($eula!=''))
{{ trans('mail.read_the_terms_and_click') }} {{ trans('mail.read_the_terms_and_click') }}
@elseif (($req_accept == 1) && ($eula=='')) @elseif (($req_accept == 1) && ($eula==''))
{{ trans('mail.click_on_the_link_asset') }} {{ trans('mail.click_on_the_link_asset') }}
@elseif (($req_accept == 0) && ($eula!='')) @elseif (($req_accept == 0) && ($eula!=''))
{{ trans('mail.read_the_terms') }} {{ trans('mail.read_the_terms') }}
@endif @endif
@if ($eula) @if ($eula)
@component('mail::panel') @component('mail::panel')
{!! $eula !!} {!! $eula !!}
@endcomponent @endcomponent
@endif @endif
@if ($req_accept == 1) @if ($req_accept == 1)
**[ {{ trans('mail.i_have_read') }}]({{ $accept_url }})** **[ {{ trans('mail.i_have_read') }}]({{ $accept_url }})**
@endif @endif
{{ trans('mail.best_regards') }} {{ trans('mail.best_regards') }}
{{ $snipeSettings->site_name }} {{ $snipeSettings->site_name }}
@endcomponent @endcomponent