Merge pull request #13704 from Godmartinz/feature/sc-23571_v2

Added a check-in button on components tab of Asset view
This commit is contained in:
snipe 2023-10-05 14:28:37 +01:00 committed by GitHub
commit cd3b4754e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -56,10 +56,11 @@ class ComponentCheckinController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Auth\Access\AuthorizationException * @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function store(Request $request, $component_asset_id) public function store(Request $request, $component_asset_id, $backto = null)
{ {
if ($component_assets = DB::table('components_assets')->find($component_asset_id)) { if ($component_assets = DB::table('components_assets')->find($component_asset_id)) {
if (is_null($component = Component::find($component_assets->component_id))) { if (is_null($component = Component::find($component_assets->component_id))) {
return redirect()->route('components.index')->with('error', return redirect()->route('components.index')->with('error',
trans('admin/components/message.not_found')); trans('admin/components/message.not_found'));
} }
@ -95,6 +96,10 @@ class ComponentCheckinController extends Controller
$asset = Asset::find($component_assets->asset_id); $asset = Asset::find($component_assets->asset_id);
event(new CheckoutableCheckedIn($component, $asset, Auth::user(), $request->input('note'), Carbon::now())); event(new CheckoutableCheckedIn($component, $asset, Auth::user(), $request->input('note'), Carbon::now()));
if($backto == 'asset'){
return redirect()->route('hardware.view', $asset->id)->with('success',
trans('admin/components/message.checkin.success'));
}
return redirect()->route('components.index')->with('success', return redirect()->route('components.index')->with('success',
trans('admin/components/message.checkin.success')); trans('admin/components/message.checkin.success'));

View file

@ -17,7 +17,7 @@
<div class="row"> <div class="row">
<!-- left column --> <!-- left column -->
<div class="col-md-7"> <div class="col-md-7">
<form class="form-horizontal" method="post" action="{{ route('components.checkin.store', $component_assets->id) }}" autocomplete="off"> <form class="form-horizontal" method="post" action="{{ route('components.checkin.store', [$component_assets->id, 'backto' => 'asset']) }}" autocomplete="off">
{{csrf_field()}} {{csrf_field()}}
<div class="box box-default"> <div class="box box-default">

View file

@ -1030,6 +1030,8 @@
<th>{{ trans('general.qty') }}</th> <th>{{ trans('general.qty') }}</th>
<th>{{ trans('general.purchase_cost') }}</th> <th>{{ trans('general.purchase_cost') }}</th>
<th>{{trans('admin/hardware/form.serial')}}</th> <th>{{trans('admin/hardware/form.serial')}}</th>
<th>{{trans('general.checkin')}}</th>
<th></th>
</thead> </thead>
<tbody> <tbody>
<?php $totalCost = 0; ?> <?php $totalCost = 0; ?>
@ -1044,6 +1046,9 @@
<td>{{ $component->pivot->assigned_qty }}</td> <td>{{ $component->pivot->assigned_qty }}</td>
<td>{{ Helper::formatCurrencyOutput($component->purchase_cost) }} each</td> <td>{{ Helper::formatCurrencyOutput($component->purchase_cost) }} each</td>
<td>{{ $component->serial }}</td> <td>{{ $component->serial }}</td>
<td>
<a href="{{ route('components.checkin.show', $component->pivot->id) }}" class="btn btn-sm bg-purple" data-tooltip="true">{{ trans('general.checkin') }}</a>
</td>
<?php $totalCost = $totalCost + ($component->purchase_cost *$component->pivot->assigned_qty) ?> <?php $totalCost = $totalCost + ($component->purchase_cost *$component->pivot->assigned_qty) ?>
</tr> </tr>