A free open source IT asset/license management system
fix checkout to location email
Godfrey M75995b210989
diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.phpindex 72a96ee271..81b4ec35b5 100644--- a/app/Mail/CheckoutAssetMail.php+++ b/app/Mail/CheckoutAssetMail.php@@ -4,6 +4,7 @@ namespace App\Mail;use App\Helpers\Helper;use App\Models\Asset;+use App\Models\Location;use App\Models\Setting;use App\Models\User;use Illuminate\Bus\Queueable;@@ -36,14 +37,6 @@ class CheckoutAssetMail extends Mailable$this->settings = Setting::getSettings();$this->target = $checkedOutTo;- // Location is a target option, but there are no emails currently associated with locations.- if($this->target instanceof User){- $this->target = $this->target->display_name;- }- else if($this->target instanceof Asset){- $this->target = $this->target->assignedto?->display_name;- }-$this->last_checkout = '';$this->expected_checkin = '';@@ -85,6 +78,17 @@ class CheckoutAssetMail extends Mailable$eula = method_exists($this->item, 'getEula') ? $this->item->getEula() : '';$req_accept = $this->requiresAcceptance();$fields = [];+ $location = [false, ''];+ if($this->target instanceof User){+ $this->target = $this->target->display_name;+ }+ else if($this->target instanceof Asset){+ $this->target = $this->target->assignedto?->display_name;+ }+ else if($this->target instanceof Location){+ $location = [true, $this->target->name];+ $this->target = $this->target->manager->name;+ }// Check if the item has custom fields associated with itif (($this->item->model) && ($this->item->model->fieldset)) {@@ -107,7 +111,7 @@ class CheckoutAssetMail extends Mailable'accept_url' => $accept_url,'last_checkout' => $this->last_checkout,'expected_checkin' => $this->expected_checkin,- 'introduction_line' => $this->introductionLine(),+ 'introduction_line' => $this->introductionLine($location),],);}@@ -131,8 +135,11 @@ class CheckoutAssetMail extends Mailablereturn trans('mail.unaccepted_asset_reminder');}- private function introductionLine(): string+ private function introductionLine($location= null): string{+ if ($this->firstTimeSending && $location[0]) {+ return trans('mail.new_item_checked_location', ['location' => $location[1] ]);+ }if ($this->firstTimeSending && $this->requiresAcceptance()) {return trans('mail.new_item_checked_with_acceptance');}diff --git a/resources/lang/en-US/mail.php b/resources/lang/en-US/mail.phpindex 40a3918cb7..0ab74a47eb 100644--- a/resources/lang/en-US/mail.php+++ b/resources/lang/en-US/mail.php@@ -77,6 +77,7 @@ return ['name' => 'Name','new_item_checked' => 'A new item has been checked out under your name, details are below.','new_item_checked_with_acceptance' => 'A new item has been checked out under your name that requires acceptance, details are below.',+ 'new_item_checked_location' => 'A new item has been checked out to :location details are below.','recent_item_checked' => 'An item was recently checked out under your name that requires acceptance, details are below.','notes' => 'Notes','password' => 'Password',