From 4093327b7fd74cf7ab68c74418ffc2fde827b737 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 13 Feb 2024 16:52:12 -0500 Subject: [PATCH 1/2] adding in Last Checkin Date to Hardware view and index --- app/Http/Controllers/Api/AssetsController.php | 2 +- .../Controllers/Assets/AssetCheckinController.php | 2 +- app/Http/Transformers/AssetsTransformer.php | 1 + app/Presenters/AssetPresenter.php | 7 +++++++ resources/views/hardware/view.blade.php | 12 ++++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index f5168a5914..3c1059374c 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -879,7 +879,7 @@ class AssetsController extends Controller } $asset->expected_checkin = null; - $asset->last_checkout = null; + //$asset->last_checkout = null; $asset->last_checkin = now(); $asset->assigned_to = null; $asset->assignedTo()->disassociate($asset); diff --git a/app/Http/Controllers/Assets/AssetCheckinController.php b/app/Http/Controllers/Assets/AssetCheckinController.php index 4fe10e895f..a8ed32deb1 100644 --- a/app/Http/Controllers/Assets/AssetCheckinController.php +++ b/app/Http/Controllers/Assets/AssetCheckinController.php @@ -67,7 +67,7 @@ class AssetCheckinController extends Controller } $asset->expected_checkin = null; - $asset->last_checkout = null; + //$asset->last_checkout = null; $asset->last_checkin = now(); $asset->assigned_to = null; $asset->assignedTo()->disassociate($asset); diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index f5d5ae12b5..eeb0b60451 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -87,6 +87,7 @@ class AssetsTransformer 'purchase_date' => Helper::getFormattedDateObject($asset->purchase_date, 'date'), 'age' => $asset->purchase_date ? $asset->purchase_date->diffForHumans() : '', 'last_checkout' => Helper::getFormattedDateObject($asset->last_checkout, 'datetime'), + 'last_checkin' => Helper::getFormattedDateObject($asset->last_checkin, 'datetime'), 'expected_checkin' => Helper::getFormattedDateObject($asset->expected_checkin, 'date'), 'purchase_cost' => Helper::formatCurrencyOutput($asset->purchase_cost), 'checkin_counter' => (int) $asset->checkin_counter, diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index de7c2c7709..c3b78ddb0f 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -244,6 +244,13 @@ class AssetPresenter extends Presenter 'visible' => false, 'title' => trans('admin/hardware/table.checkout_date'), 'formatter' => 'dateDisplayFormatter', + ], [ + 'field' => 'last_checkin', + 'searchable' => false, + 'sortable' => true, + 'visible' => false, + 'title' => trans('admin/hardware/table.last_checkin_date'), + 'formatter' => 'dateDisplayFormatter', ], [ 'field' => 'expected_checkin', 'searchable' => false, diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index d856427bd3..01e3abdf04 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -775,6 +775,18 @@ @endif + @if ($asset->last_checkin!='') +
+
+ + {{ trans('admin/hardware/table.last_checkin_date') }} + +
+
+ {{ Helper::getFormattedDateObject($asset->last_checkin, 'datetime', false) }} +
+
+ @endif From c5e8d1c276b653f638a8f3f106a80961293b6219 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 13 Feb 2024 17:09:51 -0500 Subject: [PATCH 2/2] custom report tinker --- app/Http/Controllers/ReportsController.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 162469bcd2..b881396582 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -694,12 +694,13 @@ class ReportsController extends Controller } if (($request->filled('checkin_date_start'))) { - $assets->whereBetween('last_checkin', [ - Carbon::parse($request->input('checkin_date_start'))->startOfDay(), + $checkin_start = \Carbon::parse($request->input('checkin_date_start'))->startOfDay(); // use today's date is `checkin_date_end` is not provided - Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(), - ]); + $checkin_end = \Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(); + + $assets->whereBetween('assets.last_checkin', [$checkin_start, $checkin_end ]); } + //last checkin is exporting, but currently is a date and not a datetime in the custom report ONLY. if (($request->filled('expected_checkin_start')) && ($request->filled('expected_checkin_end'))) { $assets->whereBetween('assets.expected_checkin', [$request->input('expected_checkin_start'), $request->input('expected_checkin_end')]);