Merge pull request #14283 from akemidx/bug/sc-24788

FIXED: Checked in Assets Did Not Show in Custom Report when Selecting a Valid Checked Out Date
This commit is contained in:
snipe 2024-02-28 11:47:46 +00:00 committed by GitHub
commit a52181c995
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -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);

View file

@ -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);

View file

@ -686,17 +686,23 @@ class ReportsController extends Controller
$assets->whereBetween('assets.created_at', [$created_start, $created_end]);
}
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('action_date',[$checkout_start, $checkout_end])
->pluck('item_id');
$assets->whereIn('id',$actionlogassets);
}
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(),
]);
}