added other target options to accessories and assets
This commit is contained in:
parent
715fc2de59
commit
9824f43780
7 changed files with 35 additions and 18 deletions
|
@ -1480,7 +1480,7 @@ class Helper
|
|||
|
||||
$redirect_option = Session::get('redirect_option');
|
||||
$checkout_to_type = Session::get('checkout_to_type');
|
||||
$checkedInBy = Session::get('checkedInBy');
|
||||
$checkedInFrom = Session::get('checkedInFrom');
|
||||
|
||||
// return to index
|
||||
if ($redirect_option == 'index') {
|
||||
|
@ -1522,11 +1522,11 @@ class Helper
|
|||
if ($redirect_option == 'target') {
|
||||
switch ($checkout_to_type) {
|
||||
case 'user':
|
||||
return route('users.show', $request->assigned_user ?? $checkedInBy);
|
||||
return route('users.show', $request->assigned_user ?? $checkedInFrom);
|
||||
case 'location':
|
||||
return route('locations.show', $request->assigned_location);
|
||||
return route('locations.show', $request->assigned_location ?? $checkedInFrom);
|
||||
case 'asset':
|
||||
return route('hardware.show', $request->assigned_asset);
|
||||
return route('hardware.show', $request->assigned_asset ?? $checkedInFrom);
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));
|
||||
|
|
|
@ -29,9 +29,17 @@ class AccessoryCheckinController extends Controller
|
|||
}
|
||||
|
||||
$accessory = Accessory::find($accessory_user->accessory_id);
|
||||
|
||||
//based on what the accessory is checked out to the target redirect option will be displayed accordingly.
|
||||
$target_option = match ($accessory_user->assigned_type) {
|
||||
'App\Models\Asset' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset')]),
|
||||
'App\Models\Location' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.location')]),
|
||||
default => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
|
||||
};
|
||||
$this->authorize('checkin', $accessory);
|
||||
|
||||
return view('accessories/checkin', compact('accessory'))->with('backto', $backto);
|
||||
return view('accessories/checkin', compact('accessory', 'target_option'))->with('backto', $backto);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,10 +58,12 @@ class AccessoryCheckinController extends Controller
|
|||
|
||||
$accessory = Accessory::find($accessory_checkout->accessory_id);
|
||||
|
||||
if($accessory_checkout->assigned_type === 'App\Models\User') {
|
||||
session()->put('checkout_to_type', 'user');
|
||||
session()->put('checkedInBy', $accessory_checkout->assigned_to);
|
||||
}
|
||||
session()->put('checkedInFrom', $accessory_checkout->assigned_to);
|
||||
session()->put('checkout_to_type', match ($accessory_checkout->assigned_type) {
|
||||
'App\Models\User' => 'user',
|
||||
'App\Models\Location' => 'location',
|
||||
'App\Models\Asset' => 'asset',
|
||||
});
|
||||
|
||||
$this->authorize('checkin', $accessory);
|
||||
$checkin_hours = date('H:i:s');
|
||||
|
|
|
@ -40,8 +40,12 @@ class AssetCheckinController extends Controller
|
|||
if (!$asset->model) {
|
||||
return redirect()->route('hardware.show', $asset->id)->with('error', trans('admin/hardware/general.model_invalid_fix'));
|
||||
}
|
||||
|
||||
return view('hardware/checkin', compact('asset'))
|
||||
$target_option = match ($asset->assigned_type) {
|
||||
'App\Models\Asset' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.asset_previous')]),
|
||||
'App\Models\Location' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.location')]),
|
||||
default => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
|
||||
};
|
||||
return view('hardware/checkin', compact('asset', 'target_option'))
|
||||
->with('item', $asset)
|
||||
->with('statusLabel_list', Helper::statusLabelList())
|
||||
->with('backto', $backto)
|
||||
|
@ -75,10 +79,12 @@ class AssetCheckinController extends Controller
|
|||
|
||||
$this->authorize('checkin', $asset);
|
||||
|
||||
if ($asset->assignedType() == Asset::USER) {
|
||||
$user = $asset->assignedTo;
|
||||
session()->put('checkedInBy', $user->id);
|
||||
}
|
||||
session()->put('checkedInFrom', $asset->assignedTo->id);
|
||||
session()->put('checkout_to_type', match ($asset->assigned_type) {
|
||||
'App\Models\User' => 'user',
|
||||
'App\Models\Location' => 'location',
|
||||
'App\Models\Asset' => 'asset',
|
||||
});
|
||||
|
||||
$asset->expected_checkin = null;
|
||||
$asset->last_checkin = now();
|
||||
|
|
|
@ -87,7 +87,7 @@ class LicenseCheckinController extends Controller
|
|||
|
||||
if($licenseSeat->assigned_to != null){
|
||||
$return_to = User::find($licenseSeat->assigned_to);
|
||||
session()->put('checkedInBy', $return_to->id);
|
||||
session()->put('checkedInFrom', $return_to->id);
|
||||
} else {
|
||||
$return_to = Asset::find($licenseSeat->asset_id);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ return [
|
|||
'asset_models' => 'Asset Models',
|
||||
'asset_model' => 'Model',
|
||||
'asset' => 'Asset',
|
||||
'asset_previous' => 'Asset (Previously Assigned)',
|
||||
'asset_report' => 'Asset Report',
|
||||
'asset_tag' => 'Asset Tag',
|
||||
'asset_tags' => 'Asset Tags',
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
:options="[
|
||||
'index' => trans('admin/hardware/form.redirect_to_all', ['type' => trans('general.accessories')]),
|
||||
'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.accessory')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
|
||||
'target' => $target_option
|
||||
]"
|
||||
/>
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
: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')]),
|
||||
'target' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),
|
||||
'target' => $target_option,
|
||||
]"
|
||||
/>
|
||||
</form>
|
||||
|
|
Loading…
Add table
Reference in a new issue