3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-04 15:05:42 +00:00

Modified helper

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2025-05-06 16:12:06 +01:00
parent f013a4c5ea
commit 5c11a8c1e0
3 changed files with 28 additions and 8 deletions

View File

@ -1487,6 +1487,7 @@ class Helper
$redirect_option = Session::get('redirect_option');
$checkout_to_type = Session::get('checkout_to_type');
$checkedInFrom = Session::get('checkedInFrom');
$other_redirect = Session::get('other_redirect');
// return to index
if ($redirect_option == 'index') {
@ -1535,6 +1536,16 @@ class Helper
return route('hardware.show', $request->assigned_asset ?? $checkedInFrom);
}
}
// return to somewhere else
if ($redirect_option == 'other_redirect') {
switch ($other_redirect) {
case 'audit':
return route('assets.audit.due');
}
}
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));
}

View File

@ -899,6 +899,10 @@ class AssetsController extends Controller
$this->authorize('audit', Asset::class);
session()->put('redirect_option', $request->get('redirect_option'));
session()->put('other_redirect', 'audit');
$originalValues = $asset->getRawOriginal();
$asset->next_audit_date = $request->input('next_audit_date');
@ -974,7 +978,7 @@ class AssetsController extends Controller
}
$asset->logAudit($request->input('note'), $request->input('location_id'), $file_name, $originalValues);
return redirect()->route('assets.audit.due')->with('success', trans('admin/hardware/message.audit.success'));
return redirect()->to(Helper::getRedirectOption($request, $asset->id, 'Assets'))->with('success', trans('admin/hardware/message.audit.success'));
}
return redirect()->back()->withInput()->withErrors($asset->getErrors());

View File

@ -138,13 +138,18 @@
</div> <!--/.box-body-->
<div class="box-footer">
<a class="btn btn-link" href="{{ URL::previous() }}"> {{ trans('button.cancel') }}</a>
<button type="submit" class="btn btn-success pull-right{{ (!$asset->model ? ' disabled' : '') }}"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.model_invalid_fix').'" disabled' : '') !!}>
<x-icon type="checkmark" />
{{ trans('general.audit') }}
</button>
</div>
<x-redirect_submit_options
index_route="hardware.index"
:button_label="trans('general.audit')"
:disabled_select="!$asset->model"
:options="[
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.assets')]),
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
'other_redirect' => trans('general.audit_due')
]"
/>
</form>
</div>
</div> <!--/.col-md-7-->