mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-23 11:43:47 -08:00
Merge pull request #15589 from snipe/adds_checkin_action_on_asset_delete
Adds checkin action on asset delete via View UI
This commit is contained in:
commit
d274fb6963
|
@ -780,9 +780,16 @@ class AssetsController extends Controller
|
|||
if ($asset = Asset::find($id)) {
|
||||
$this->authorize('delete', $asset);
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
if ($asset->assignedTo) {
|
||||
|
||||
$target = $asset->assignedTo;
|
||||
$checkin_at = date('Y-m-d H:i:s');
|
||||
$originalValues = $asset->getRawOriginal();
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on delete', $checkin_at, $originalValues));
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
}
|
||||
|
||||
$asset->delete();
|
||||
|
||||
|
|
|
@ -428,7 +428,7 @@ class AssetsController extends Controller
|
|||
* @param int $assetId
|
||||
* @since [v1.0]
|
||||
*/
|
||||
public function destroy($assetId) : RedirectResponse
|
||||
public function destroy(Request $request, $assetId) : RedirectResponse
|
||||
{
|
||||
// Check if the asset exists
|
||||
if (is_null($asset = Asset::find($assetId))) {
|
||||
|
@ -438,9 +438,17 @@ class AssetsController extends Controller
|
|||
|
||||
$this->authorize('delete', $asset);
|
||||
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
if ($asset->assignedTo) {
|
||||
|
||||
$target = $asset->assignedTo;
|
||||
$checkin_at = date('Y-m-d H:i:s');
|
||||
$originalValues = $asset->getRawOriginal();
|
||||
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on delete', $checkin_at, $originalValues));
|
||||
DB::table('assets')
|
||||
->where('id', $asset->id)
|
||||
->update(['assigned_to' => null]);
|
||||
}
|
||||
|
||||
|
||||
if ($asset->image) {
|
||||
try {
|
||||
|
|
|
@ -64,6 +64,7 @@ return [
|
|||
'checkout' => 'Checkout',
|
||||
'checkouts_count' => 'Checkouts',
|
||||
'checkins_count' => 'Checkins',
|
||||
'checkin_and_delete' => 'Checkin and Delete',
|
||||
'user_requests_count' => 'Requests',
|
||||
'city' => 'City',
|
||||
'click_here' => 'Click here',
|
||||
|
|
|
@ -255,11 +255,16 @@
|
|||
|
||||
@can('delete', $asset)
|
||||
<div class="col-md-12 hidden-print" style="padding-top: 30px; padding-bottom: 30px;">
|
||||
|
||||
@if ($asset->deleted_at=='')
|
||||
<button class="btn btn-sm btn-block btn-danger btn-social delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $asset->asset_tag]) }}" data-target="#dataConfirmModal">
|
||||
|
||||
<x-icon type="delete" />
|
||||
{{ trans('general.delete') }}
|
||||
@if ($asset->assignedTo)
|
||||
{{ trans('general.checkin_and_delete') }}
|
||||
@else
|
||||
{{ trans('general.delete') }}
|
||||
@endif
|
||||
</button>
|
||||
<span class="sr-only">{{ trans('general.delete') }}</span>
|
||||
@else
|
||||
|
|
Loading…
Reference in a new issue