Skip to content

A free open source IT asset/license management system

Add location to mail

Marcus Mooree248a3ec0196
diff --git a/app/Mail/CheckoutAccessoryMail.php b/app/Mail/CheckoutAccessoryMail.php
index c323017386..89340f277f 100644
--- a/app/Mail/CheckoutAccessoryMail.php
+++ b/app/Mail/CheckoutAccessoryMail.php
@@ -79,6 +79,7 @@ class CheckoutAccessoryMail extends BaseMailable
'req_accept' => $req_accept,
'accept_url' => $accept_url,
'checkout_qty' => $this->checkout_qty,
+ 'location' => $this->getLocation(),
'introduction_line' => $this->introductionLine(),
],
);
@@ -129,4 +130,21 @@ class CheckoutAccessoryMail extends BaseMailable
return trans('mail.unaccepted_asset_reminder');
}
+
+ private function getLocation(): ?string
+ {
+ if ($this->target instanceof User) {
+ return $this->target->location?->name;
+ }
+
+ if ($this->target instanceof Asset) {
+ return $this->target->location?->name;
+ }
+
+ if ($this->target instanceof Location) {
+ return $this->target->name;
+ }
+
+ return null;
+ }
}
diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php
index dcd26eaeec..772536df27 100644
--- a/app/Mail/CheckoutAssetMail.php
+++ b/app/Mail/CheckoutAssetMail.php
@@ -123,6 +123,7 @@ class CheckoutAssetMail extends BaseMailable
'accept_url' => $accept_url,
'last_checkout' => $this->last_checkout,
'expected_checkin' => $this->expected_checkin,
+ 'location' => $this->getLocation(),
'introduction_line' => $this->introductionLine(),
],
);
@@ -176,4 +177,21 @@ class CheckoutAssetMail extends BaseMailable
{
return method_exists($this->item, 'requireAcceptance') ? $this->item->requireAcceptance() : 0;
}
+
+ private function getLocation(): ?string
+ {
+ if ($this->target instanceof User) {
+ return $this->target->location?->name;
+ }
+
+ if ($this->target instanceof Asset) {
+ return $this->target->location?->name;
+ }
+
+ if ($this->target instanceof Location) {
+ return $this->target->name;
+ }
+
+ return null;
+ }
}
diff --git a/resources/views/mail/markdown/checkin-accessory.blade.php b/resources/views/mail/markdown/checkin-accessory.blade.php
index 1f5b672916..0c3f9f7b07 100644
--- a/resources/views/mail/markdown/checkin-accessory.blade.php
+++ b/resources/views/mail/markdown/checkin-accessory.blade.php
@@ -17,6 +17,9 @@
@if (isset($item->model_no))
| **{{ trans('general.model_no') }}** | {{ $item->model_no }} |
@endif
+@if ($item->location)
+| **{{ trans('general.location') }}** | {{ $item->location->name }} |
+@endif
@if ($admin)
| **{{ trans('general.administrator') }}** | {{ $admin->display_name }} |
@endif
diff --git a/resources/views/mail/markdown/checkin-asset.blade.php b/resources/views/mail/markdown/checkin-asset.blade.php
index e993f0a7b4..1623b3531e 100644
--- a/resources/views/mail/markdown/checkin-asset.blade.php
+++ b/resources/views/mail/markdown/checkin-asset.blade.php
@@ -33,6 +33,9 @@
@if (isset($item->serial))
| **{{ trans('mail.serial') }}** | {{ $item->serial }} |
@endif
+@if ($item->location)
+| **{{ trans('general.location') }}** | {{ $item->location->name }} |
+@endif
@if (isset($last_checkout))
| **{{ trans('mail.checkout_date') }}** | {{ $last_checkout }} |
@endif
diff --git a/resources/views/mail/markdown/checkin-component.blade.php b/resources/views/mail/markdown/checkin-component.blade.php
index 58f7c54577..3307880e9b 100644
--- a/resources/views/mail/markdown/checkin-component.blade.php
+++ b/resources/views/mail/markdown/checkin-component.blade.php
@@ -10,6 +10,9 @@
@if (isset($item->manufacturer))
| **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} |
@endif
+@if ($item->location)
+| **{{ trans('general.location') }}** | {{ $item->location->name }} |
+@endif
@if ($admin)
| **{{ trans('general.administrator') }}** | {{ $admin->display_name }} |
@endif
diff --git a/resources/views/mail/markdown/checkout-accessory.blade.php b/resources/views/mail/markdown/checkout-accessory.blade.php
index ecca7036df..dff4fa640f 100644
--- a/resources/views/mail/markdown/checkout-accessory.blade.php
+++ b/resources/views/mail/markdown/checkout-accessory.blade.php
@@ -29,6 +29,9 @@
@if (isset($checkout_qty))
| **{{ trans('general.qty') }}** | {{ $checkout_qty }} |
@endif
+@if ($location)
+| **{{ trans('general.location') }}** | {{ $location }} |
+@endisset
@if ($note)
| **{{ trans('mail.additional_notes') }}** | {{ $note }} |
@endif
diff --git a/resources/views/mail/markdown/checkout-asset.blade.php b/resources/views/mail/markdown/checkout-asset.blade.php
index eb28387765..918b66e0c9 100644
--- a/resources/views/mail/markdown/checkout-asset.blade.php
+++ b/resources/views/mail/markdown/checkout-asset.blade.php
@@ -33,6 +33,9 @@
@if (isset($item->serial))
| **{{ trans('mail.serial') }}** | {{ $item->serial }} |
@endif
+@if ($location)
+| **{{ trans('general.location') }}** | {{ $location }} |
+@endif
@if (isset($last_checkout))
| **{{ trans('mail.checkout_date') }}** | {{ $last_checkout }} |
@endif
diff --git a/resources/views/mail/markdown/checkout-component.blade.php b/resources/views/mail/markdown/checkout-component.blade.php
index de9a685c21..ee33c20577 100644
--- a/resources/views/mail/markdown/checkout-component.blade.php
+++ b/resources/views/mail/markdown/checkout-component.blade.php
@@ -16,6 +16,9 @@
@if (isset($item->manufacturer))
| **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} |
@endif
+@if ($target->location)
+| **{{ trans('general.location') }}** | {{ $target->location->name }} |
+@endif
@if ($note)
| **{{ trans('mail.additional_notes') }}** | {{ $note }} |
@endif
diff --git a/resources/views/mail/markdown/checkout-consumable.blade.php b/resources/views/mail/markdown/checkout-consumable.blade.php
index 6b3c33c79d..c17c6273e7 100644
--- a/resources/views/mail/markdown/checkout-consumable.blade.php
+++ b/resources/views/mail/markdown/checkout-consumable.blade.php
@@ -23,6 +23,9 @@
@if (isset($item->model_no))
| **{{ trans('general.model_no') }}** | {{ $item->model_no }} |
@endif
+@if ($target->location)
+| **{{ trans('general.location') }}** | {{ $target->location->name }} |
+@endif
@if ($note)
| **{{ trans('mail.additional_notes') }}** | {{ $note }} |
@endif