From 4a57cfaf3e18066b67372c497d2ba89bde0aa028 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 13 Feb 2024 16:21:18 -0500 Subject: [PATCH 1/5] commenting out the nulling of last checkout date on checkin page and API --- app/Http/Controllers/Api/AssetsController.php | 2 +- app/Http/Controllers/Assets/AssetCheckinController.php | 2 +- 2 files changed, 2 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); From 232fad0145100aeeb69f4c6aa2455cecc98949cd Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 14 Feb 2024 20:00:23 -0500 Subject: [PATCH 2/5] query and progress notes --- app/Http/Controllers/ReportsController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 162469bcd2..01d488d95b 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -686,17 +686,27 @@ class ReportsController extends Controller $assets->whereBetween('assets.created_at', [$created_start, $created_end]); } + + //This should parse the action log, and not the hardware table. + //There can be multiple checkouts in a given time that we want to track. if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) { $checkout_start = \Carbon::parse($request->input('checkout_date_start'))->startOfDay(); $checkout_end = \Carbon::parse($request->input('checkout_date_end'))->endOfDay(); $assets->whereBetween('assets.last_checkout', [$checkout_start, $checkout_end]); + //$assets->whereBetween('action_logs.created_at', [$checkout_start, $checkout_end]); + //action_logs bit was returning an ERR_INVALID_RESPONSE so I probably missed something + //sql query? -> WHERE (`action_type` = 'checkout') AND (`item_type` LIKE '%Asset%') + // AND whereBetween('action_logs.created_at', [$checkout_start, $checkout_end]); + // if ($action_logs->action_type == "checkout") {} + + } if (($request->filled('checkin_date_start'))) { $assets->whereBetween('last_checkin', [ Carbon::parse($request->input('checkin_date_start'))->startOfDay(), - // use today's date is `checkin_date_end` is not provided + // use today's date if `checkin_date_end` is not provided Carbon::parse($request->input('checkin_date_end', now()))->endOfDay(), ]); } From e3ef737ac457a6d2f5c6730a4809eab43d2fb2af Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 15 Feb 2024 19:15:27 -0500 Subject: [PATCH 3/5] query first go --- app/Http/Controllers/ReportsController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 01d488d95b..548e2a4599 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -694,6 +694,14 @@ class ReportsController extends Controller $checkout_end = \Carbon::parse($request->input('checkout_date_end'))->endOfDay(); $assets->whereBetween('assets.last_checkout', [$checkout_start, $checkout_end]); + + $actionlogassets = Actionlog::where('action_type','=', 'checkout')-> + where('item_type' 'LIKE' '%Asset%',) + whereBetween('created_at',[$checkout_start, $checkout_end]) + ->pluck('item_id'); + + $assets->whereIn('id',$actionlogassets); + //$assets->whereBetween('action_logs.created_at', [$checkout_start, $checkout_end]); //action_logs bit was returning an ERR_INVALID_RESPONSE so I probably missed something //sql query? -> WHERE (`action_type` = 'checkout') AND (`item_type` LIKE '%Asset%') From d01e1e8eeb361f6bd91458699b7086960cb06e9a Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 15 Feb 2024 19:56:08 -0500 Subject: [PATCH 4/5] query works, but still only shows the asset once even if it's been checked out multiple times --- app/Http/Controllers/ReportsController.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 548e2a4599..aa73908cc2 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -691,13 +691,11 @@ class ReportsController extends Controller //There can be multiple checkouts in a given time that we want to track. if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) { $checkout_start = \Carbon::parse($request->input('checkout_date_start'))->startOfDay(); - $checkout_end = \Carbon::parse($request->input('checkout_date_end'))->endOfDay(); + $checkout_end = \Carbon::parse($request->input('checkout_date_end',now()))->endOfDay(); - $assets->whereBetween('assets.last_checkout', [$checkout_start, $checkout_end]); - - $actionlogassets = Actionlog::where('action_type','=', 'checkout')-> - where('item_type' 'LIKE' '%Asset%',) - whereBetween('created_at',[$checkout_start, $checkout_end]) + $actionlogassets = Actionlog::where('action_type','=', 'checkout') + ->where('item_type', 'LIKE', '%Asset%',) + ->whereBetween('action_date',[$checkout_start, $checkout_end]) ->pluck('item_id'); $assets->whereIn('id',$actionlogassets); From 4dd479dad7c11569dd4f37160960c984d6a007c5 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 15 Feb 2024 19:59:26 -0500 Subject: [PATCH 5/5] formatting --- app/Http/Controllers/ReportsController.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index aa73908cc2..ccf9e232e3 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -687,8 +687,6 @@ class ReportsController extends Controller $assets->whereBetween('assets.created_at', [$created_start, $created_end]); } - //This should parse the action log, and not the hardware table. - //There can be multiple checkouts in a given time that we want to track. if (($request->filled('checkout_date_start')) && ($request->filled('checkout_date_end'))) { $checkout_start = \Carbon::parse($request->input('checkout_date_start'))->startOfDay(); $checkout_end = \Carbon::parse($request->input('checkout_date_end',now()))->endOfDay(); @@ -699,14 +697,6 @@ class ReportsController extends Controller ->pluck('item_id'); $assets->whereIn('id',$actionlogassets); - - //$assets->whereBetween('action_logs.created_at', [$checkout_start, $checkout_end]); - //action_logs bit was returning an ERR_INVALID_RESPONSE so I probably missed something - //sql query? -> WHERE (`action_type` = 'checkout') AND (`item_type` LIKE '%Asset%') - // AND whereBetween('action_logs.created_at', [$checkout_start, $checkout_end]); - // if ($action_logs->action_type == "checkout") {} - - } if (($request->filled('checkin_date_start'))) {