Refactor api for handling audit/expected checkins

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-04-26 18:56:57 +01:00
parent 4b4e3badb7
commit 6dc9ccffcd

View file

@ -59,7 +59,7 @@ class AssetsController extends Controller
* @since [v4.0] * @since [v4.0]
* @return \Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function index(Request $request, $audit = null) public function index(Request $request, $action = null, $upcoming_status = null)
{ {
$filter_non_deprecable_assets = false; $filter_non_deprecable_assets = false;
@ -155,20 +155,46 @@ class AssetsController extends Controller
$assets->TextSearch($request->input('search')); $assets->TextSearch($request->input('search'));
} }
// This is used by the audit reporting routes
if (Gate::allows('audit', Asset::class)) { /**
switch ($audit) { * Handle due and overdue audits and checkin dates
*/
switch ($action) {
case 'audits':
\Log::debug('audits');
switch ($upcoming_status) {
case 'due': case 'due':
$assets->DueForAudit($settings); $assets->DueForAudit($settings);
break; break;
case 'overdue': case 'overdue':
$assets->OverdueForAudit($settings); $assets->OverdueForAudit($settings);
break; break;
case 'duooroverdue': case 'due-or-overdue':
$assets->DueOrOverdueForAudit($settings); $assets->DueOrOverdueForAudit($settings);
break; break;
} }
break;
case 'checkins':
switch ($upcoming_status) {
case 'due':
$assets->DueForCheckin($settings);
break;
case 'overdue':
$assets->OverdueForCheckin($settings);
break;
case 'due-or-overdue':
$assets->DueOrOverdueForCheckin($settings);
break;
} }
break;
}
/**
* End handling due and overdue audits and checkin dates
*/
// This is used by the sidenav, mostly // This is used by the sidenav, mostly