adds dynamic redirects to Assets

This commit is contained in:
Godfrey M
2024-05-14 13:25:52 -07:00
parent c94a7613ca
commit 15cc4345ab
6 changed files with 26 additions and 21 deletions
@@ -45,7 +45,7 @@ class AssetCheckinController extends Controller
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.already_checked_in'));
}
return view('hardware/checkin', compact('asset'))->with('statusLabel_list', Helper::statusLabelList())->with('backto', $backto);
return view('hardware/checkin', compact('asset'))->with('statusLabel_list', Helper::statusLabelList())->with('backto', $backto)->with('table_name', 'Assets');
}
/**
@@ -125,12 +125,7 @@ class AssetCheckinController extends Controller
// Was the asset updated?
if ($asset->save()) {
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues));
if ((isset($user)) && ($backto == 'user')) {
return redirect()->route('users.show', $user->id)->with('success', trans('admin/hardware/message.checkin.success'));
}
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkin.success'));
return Helper::getRedirectOption($request, $assetId);
}
// Redirect to the asset management page with error
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors());
@@ -36,7 +36,8 @@ class AssetCheckoutController extends Controller
if ($asset->availableForCheckout()) {
return view('hardware/checkout', compact('asset'))
->with('statusLabel_list', Helper::deployableStatusLabelList());
->with('statusLabel_list', Helper::deployableStatusLabelList())
->with('table_name', 'Assets');
}
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));
@@ -100,7 +101,7 @@ class AssetCheckoutController extends Controller
}
$redirect_option = $request->get('redirect_option');
if($redirect_option != Session::get('redirect_option')) {
Session::put('redirect_option', $redirect_option);
Session::put(['redirect_option' => $redirect_option, 'checkout_to_type' => $request->get('checkout_to_type')]);
}
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {