mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge e106e8ad2d
into c9f55bfd94
This commit is contained in:
commit
437cd95440
|
@ -539,12 +539,39 @@ class BulkAssetsController extends Controller
|
||||||
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));
|
return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$assignedAssets = Asset::whereIn('id', $assetIds)->whereNotNull('assigned_to')->get();
|
$parentAssets = Asset::whereIn('id', $assetIds)
|
||||||
if($assignedAssets->isNotEmpty()) {
|
->whereHas('assignedAssets')
|
||||||
|
->get();
|
||||||
|
|
||||||
//if assets are checked out, return a list of asset tags that would need to be checked in first.
|
$assignedAssets = Asset::whereIn('id', $assetIds)
|
||||||
$assetTags = $assignedAssets->pluck('asset_tag')->implode(', ');
|
->whereNotNull('assigned_to')
|
||||||
return redirect($bulk_back_url)->with('error', trans_choice('admin/hardware/message.delete.assigned_to_error', $assignedAssets->count(), ['asset_tag' => $assetTags] ));
|
->get();
|
||||||
|
|
||||||
|
$errorMessages = [];
|
||||||
|
|
||||||
|
if ($assignedAssets->isNotEmpty()) {
|
||||||
|
$assignedTags = $assignedAssets->pluck('asset_tag')->implode(', ');
|
||||||
|
$errorMessages[] = trans_choice(
|
||||||
|
'admin/hardware/message.delete.assigned_to_error',
|
||||||
|
$assignedAssets->count(),
|
||||||
|
['asset_tag' => e($assignedTags)]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($parentAssets->isNotEmpty()) {
|
||||||
|
$parentTags = $parentAssets->pluck('asset_tag')->implode(', ');
|
||||||
|
$errorMessages[] = trans_choice(
|
||||||
|
'admin/hardware/message.delete.parent_assigned_error',
|
||||||
|
$parentAssets->count(),
|
||||||
|
['asset_tag' => e($parentTags)]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($errorMessages)) {
|
||||||
|
// Combine both messages
|
||||||
|
$combinedErrorMessage = implode('<br>', $errorMessages);
|
||||||
|
|
||||||
|
return redirect($bulk_back_url)->with('error-unescaped', $combinedErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Asset::wherein('id', $assetIds)->get() as $asset) {
|
foreach (Asset::wherein('id', $assetIds)->get() as $asset) {
|
||||||
|
|
|
@ -73,7 +73,8 @@ return [
|
||||||
'delete' => [
|
'delete' => [
|
||||||
'confirm' => 'Are you sure you wish to delete this asset?',
|
'confirm' => 'Are you sure you wish to delete this asset?',
|
||||||
'error' => 'There was an issue deleting the asset. Please try again.',
|
'error' => 'There was an issue deleting the asset. Please try again.',
|
||||||
'assigned_to_error' => '{1}Asset Tag: :asset_tag is currently checked out. Check in this device before deletion.|[2,*]Asset Tags: :asset_tag are currently checked out. Check in these devices before deletion.',
|
'assigned_to_error' => 'Asset Tag: :asset_tag is currently checked out. Check in this device before deletion of this asset.|[2,*]Asset Tags: :asset_tag are currently checked out. Check in these devices before deletion of these assets.',
|
||||||
|
'parent_assigned_error' => 'Asset Tag: :asset_tag currently has items checked out. Check in all items attached before deletion of this asset.|[2,*]Asset Tags: :asset_tag currently have items checked out. Check in these devices before deletion of these assets.',
|
||||||
'nothing_updated' => 'No assets were selected, so nothing was deleted.',
|
'nothing_updated' => 'No assets were selected, so nothing was deleted.',
|
||||||
'success' => 'The asset was deleted successfully.',
|
'success' => 'The asset was deleted successfully.',
|
||||||
],
|
],
|
||||||
|
|
|
@ -113,6 +113,16 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
@if ($message = session()->get('error-unescaped'))
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="alert alert-error fade in">
|
||||||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
|
<i class="fas fa-exclamation-triangle faa-pulse animated"></i>
|
||||||
|
<strong>{{ trans('general.notification_error') }}: </strong>
|
||||||
|
{!! $message !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
@if ($messages = session()->get('error_messages'))
|
@if ($messages = session()->get('error_messages'))
|
||||||
|
|
Loading…
Reference in a new issue