From ec5b9ce903a728e5f3be1b28814e9ccd2eea4222 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 5 Aug 2025 12:44:07 -0700 Subject: [PATCH 1/8] adds category and model no to accessory checkout markdown --- resources/views/mail/markdown/checkout-accessory.blade.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/views/mail/markdown/checkout-accessory.blade.php b/resources/views/mail/markdown/checkout-accessory.blade.php index 7b7572e48d..5fcf093c01 100644 --- a/resources/views/mail/markdown/checkout-accessory.blade.php +++ b/resources/views/mail/markdown/checkout-accessory.blade.php @@ -14,6 +14,12 @@ | **{{ trans('mail.checkout_date') }}** | {{ $checkout_date }} | @endif | **{{ trans('general.accessory') }}** | {{ $item->name }} | +@if (isset($item->category)) + | **{{ trans('general.category') }}** | {{ $item->category->name }} | +@endif +@if (isset($item->model_number)) + | **{{ trans('general.model_no') }}** | {{ $item->model_number }} | +@endif @if (isset($item->manufacturer)) | **{{ trans('general.manufacturer') }}** | {{ $item->manufacturer->name }} | @endif From 5851cc9e416fa5dcd8f14f646920e79ca59548f4 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 7 Aug 2025 15:09:38 -0700 Subject: [PATCH 2/8] fixed target name for checkouts with licenses and assets --- app/Mail/CheckoutAssetMail.php | 10 +++++++++- app/Mail/CheckoutLicenseMail.php | 10 +++++++++- resources/views/mail/markdown/checkout-asset.blade.php | 2 +- .../views/mail/markdown/checkout-license.blade.php | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php index 7ac20861ed..6886a8741a 100644 --- a/app/Mail/CheckoutAssetMail.php +++ b/app/Mail/CheckoutAssetMail.php @@ -30,10 +30,18 @@ class CheckoutAssetMail extends Mailable $this->item = $asset; $this->admin = $checkedOutBy; $this->note = $note; - $this->target = $checkedOutTo; $this->acceptance = $acceptance; $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->present()->fullName(); + } + else if($this->target instanceof Asset){ + $this->target = $this->target->assignedto->present()->fullName(); + } $this->last_checkout = ''; $this->expected_checkin = ''; diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php index 9462c6c332..eb0bb341b5 100644 --- a/app/Mail/CheckoutLicenseMail.php +++ b/app/Mail/CheckoutLicenseMail.php @@ -2,6 +2,7 @@ namespace App\Mail; +use App\Models\Asset; use App\Models\LicenseSeat; use App\Models\Setting; use App\Models\User; @@ -25,9 +26,16 @@ class CheckoutLicenseMail extends Mailable $this->item = $licenseSeat; $this->admin = $checkedOutBy; $this->note = $note; - $this->target = $checkedOutTo; $this->acceptance = $acceptance; $this->settings = Setting::getSettings(); + $this->target = $checkedOutTo; + + if($this->target instanceof User){ + $this->target = $this->target->present()->fullName(); + } + elseif($this->target instanceof Asset){ + $this->target = $this->target->assignedto->present()->fullName(); + } } /** diff --git a/resources/views/mail/markdown/checkout-asset.blade.php b/resources/views/mail/markdown/checkout-asset.blade.php index b72e17e11a..5c53f188fc 100644 --- a/resources/views/mail/markdown/checkout-asset.blade.php +++ b/resources/views/mail/markdown/checkout-asset.blade.php @@ -1,5 +1,5 @@ @component('mail::message') -# {{ trans('mail.hello') }}{{ $target->assignedto?->present()->fullName() ? ' ' . $target->assignedto->present()->fullName() . ',' : ',' }} +# {{ trans('mail.hello').' '.$target.','}} {{ $introduction_line }} diff --git a/resources/views/mail/markdown/checkout-license.blade.php b/resources/views/mail/markdown/checkout-license.blade.php index 5d982d1b1b..373d11e8eb 100644 --- a/resources/views/mail/markdown/checkout-license.blade.php +++ b/resources/views/mail/markdown/checkout-license.blade.php @@ -1,5 +1,5 @@ @component('mail::message') -# {{ trans('mail.hello') }} {{ $target->present()->fullName() }}, +# {{ trans('mail.hello').' '.$target.','}} {{ trans('mail.new_item_checked') }} From c95aeb3730332e338fbda71d528582597869b747 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 7 Aug 2025 17:25:20 -0700 Subject: [PATCH 3/8] Filter out unallowed columns (custom fields) --- app/Http/Controllers/Api/AssetsController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 160f4a120a..22a2ba88fc 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -117,15 +117,19 @@ class AssetsController extends Controller 'jobtitle', ]; + $all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load + foreach ($all_custom_fields as $field) { + $allowed_columns[] = $field->db_column_name(); + } + $filter = []; if ($request->filled('filter')) { $filter = json_decode($request->input('filter'), true); - } - $all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load - foreach ($all_custom_fields as $field) { - $allowed_columns[] = $field->db_column_name(); + $filter = array_filter($filter, function ($key) use ($allowed_columns) { + return in_array($key, $allowed_columns); + }, ARRAY_FILTER_USE_KEY); } $assets = Asset::select('assets.*') From 4a7b7183d2d234d0ad25cc13a376eef6493634b1 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 11 Aug 2025 14:58:41 -0700 Subject: [PATCH 4/8] Add custom_fields. prefix so custom fields can be filtered against --- app/Http/Controllers/Api/AssetsController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 22a2ba88fc..1a7e80e313 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -119,7 +119,9 @@ class AssetsController extends Controller $all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load foreach ($all_custom_fields as $field) { - $allowed_columns[] = $field->db_column_name(); + // custom fields are prefixed with "custom_fields.". + // We'll add them to the allowed columns so they can be searched. + $allowed_columns[] = 'custom_fields.' . $field->db_column_name(); } $filter = []; From 817530429b7422e85df0a176c8cb56a9a6d420bc Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Tue, 12 Aug 2025 14:52:52 -0500 Subject: [PATCH 5/8] added condition to make sure the request has checkbox --- app/Http/Controllers/Assets/AssetsController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 10f03db215..67b6bfb4e0 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -424,6 +424,9 @@ class AssetsController extends Controller $model = AssetModel::find($request->get('model_id')); if (($model) && ($model->fieldset)) { foreach ($model->fieldset->fields as $field) { + if ($field->element == 'checkbox' && !$request->has($field->db_column)) { + $asset->{$field->db_column} = null; + } if ($request->has($field->db_column)) { if ($field->field_encrypted == '1') { if (Gate::allows('assets.view.encrypted_custom_fields')) { From 5cb8aae383b4c9c194cf067a26a991bb6b4b8775 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 12 Aug 2025 14:16:46 -0700 Subject: [PATCH 6/8] add ternaries --- app/Mail/CheckoutAssetMail.php | 4 ++-- app/Mail/CheckoutLicenseMail.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Mail/CheckoutAssetMail.php b/app/Mail/CheckoutAssetMail.php index 6886a8741a..a09a40ba8b 100644 --- a/app/Mail/CheckoutAssetMail.php +++ b/app/Mail/CheckoutAssetMail.php @@ -37,10 +37,10 @@ class CheckoutAssetMail extends Mailable // Location is a target option, but there are no emails currently associated with locations. if($this->target instanceof User){ - $this->target = $this->target->present()->fullName(); + $this->target = $this->target->present()?->fullName(); } else if($this->target instanceof Asset){ - $this->target = $this->target->assignedto->present()->fullName(); + $this->target = $this->target->assignedto?->present()?->fullName(); } $this->last_checkout = ''; diff --git a/app/Mail/CheckoutLicenseMail.php b/app/Mail/CheckoutLicenseMail.php index eb0bb341b5..bc5259c178 100644 --- a/app/Mail/CheckoutLicenseMail.php +++ b/app/Mail/CheckoutLicenseMail.php @@ -31,10 +31,10 @@ class CheckoutLicenseMail extends Mailable $this->target = $checkedOutTo; if($this->target instanceof User){ - $this->target = $this->target->present()->fullName(); + $this->target = $this->target?->present()?->fullName(); } elseif($this->target instanceof Asset){ - $this->target = $this->target->assignedto->present()->fullName(); + $this->target = $this->target->assignedto?->present()?->fullName(); } } From dfe2a75d72384138dd767425720fc1eec5f53984 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 12 Aug 2025 15:34:46 -0700 Subject: [PATCH 7/8] adds user that checked out item to acceptance emails --- app/Http/Controllers/Account/AcceptanceController.php | 1 + app/Notifications/AcceptanceAssetAcceptedNotification.php | 2 ++ .../views/notifications/markdown/asset-acceptance.blade.php | 1 + 3 files changed, 4 insertions(+) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index c273d36e3a..73e26422f6 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -232,6 +232,7 @@ class AcceptanceController extends Controller 'signature' => ($sig_filename) ? storage_path() . '/private_uploads/signatures/' . $sig_filename : null, 'logo' => $path_logo, 'date_settings' => $branding_settings->date_display_format, + 'admin' => auth()->user()->present()?->fullName, ]; if ($pdf_view_route!='') { diff --git a/app/Notifications/AcceptanceAssetAcceptedNotification.php b/app/Notifications/AcceptanceAssetAcceptedNotification.php index 7798dbc0d5..ddbaef2ef5 100644 --- a/app/Notifications/AcceptanceAssetAcceptedNotification.php +++ b/app/Notifications/AcceptanceAssetAcceptedNotification.php @@ -29,6 +29,7 @@ class AcceptanceAssetAcceptedNotification extends Notification $this->assigned_to = $params['assigned_to']; $this->note = $params['note']; $this->company_name = $params['company_name']; + $this->admin = $params['admin']; $this->settings = Setting::getSettings(); } @@ -72,6 +73,7 @@ class AcceptanceAssetAcceptedNotification extends Notification 'assigned_to' => $this->assigned_to, 'company_name' => $this->company_name, 'intro_text' => trans('mail.acceptance_asset_accepted'), + 'admin' => $this->admin, ]) ->subject(trans('mail.acceptance_asset_accepted')); diff --git a/resources/views/notifications/markdown/asset-acceptance.blade.php b/resources/views/notifications/markdown/asset-acceptance.blade.php index 1a9569609e..cbce684bd0 100644 --- a/resources/views/notifications/markdown/asset-acceptance.blade.php +++ b/resources/views/notifications/markdown/asset-acceptance.blade.php @@ -37,6 +37,7 @@ @if (isset($item_serial)) | **{{ trans('mail.serial') }}** | {{ $item_serial }} | @endif +| **{{ trans('general.checked_out').' '.trans('general.by')}}** | {{ $admin }} | @endcomponent {{ trans('mail.best_regards') }} From fe3d225cfa9f1efb47c851d84498e5b86c67bb99 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 14 Aug 2025 09:15:19 -0700 Subject: [PATCH 8/8] fix tests --- app/Notifications/AcceptanceAssetAcceptedNotification.php | 2 +- .../views/notifications/markdown/asset-acceptance.blade.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Notifications/AcceptanceAssetAcceptedNotification.php b/app/Notifications/AcceptanceAssetAcceptedNotification.php index ddbaef2ef5..6c4e2e99e0 100644 --- a/app/Notifications/AcceptanceAssetAcceptedNotification.php +++ b/app/Notifications/AcceptanceAssetAcceptedNotification.php @@ -29,7 +29,7 @@ class AcceptanceAssetAcceptedNotification extends Notification $this->assigned_to = $params['assigned_to']; $this->note = $params['note']; $this->company_name = $params['company_name']; - $this->admin = $params['admin']; + $this->admin = $params['admin'] ?? null; $this->settings = Setting::getSettings(); } diff --git a/resources/views/notifications/markdown/asset-acceptance.blade.php b/resources/views/notifications/markdown/asset-acceptance.blade.php index cbce684bd0..85bc110ffa 100644 --- a/resources/views/notifications/markdown/asset-acceptance.blade.php +++ b/resources/views/notifications/markdown/asset-acceptance.blade.php @@ -37,7 +37,9 @@ @if (isset($item_serial)) | **{{ trans('mail.serial') }}** | {{ $item_serial }} | @endif +@if (isset($admin)) | **{{ trans('general.checked_out').' '.trans('general.by')}}** | {{ $admin }} | +@endif @endcomponent {{ trans('mail.best_regards') }}