Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,25 @@ public function showCheckout() : View
{
$this->authorize('checkout', Asset::class);

$alreadyAssigned = collect();

if (old('selected_assets') && is_array(old('selected_assets'))) {
$assets = Asset::findMany(old('selected_assets'));

[$assignable, $alreadyAssigned] = $assets->partition(function (Asset $asset) {
return !$asset->assigned_to;
});

session()->flashInput(['selected_assets' => $assignable->pluck('id')->values()->toArray()]);
}

$do_not_change = ['' => trans('general.do_not_change')];
$status_label_list = $do_not_change + Helper::deployableStatusLabelList();
return view('hardware/bulk-checkout')->with('statusLabel_list', $status_label_list);

return view('hardware/bulk-checkout', [
'statusLabel_list' => $status_label_list,
'removed_assets' => $alreadyAssigned,
]);
}

/**
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-US/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
'error_user_company_multiple' => 'One or more of the checkout target company and asset company do not match',
'error_user_company_accept_view' => 'An Asset assigned to you belongs to a different company so you can\'t accept nor deny it, please check with your manager',
'error_assets_already_checked_out' => 'One or more of the assets are already checked out',
'assigned_assets_removed' => 'The following were removed from the selected assets because they are already checked out',
'importer' => [
'checked_out_to_fullname' => 'Checked Out to: Full Name',
'checked_out_to_first_name' => 'Checked Out to: First Name',
Expand Down
20 changes: 20 additions & 0 deletions resources/views/hardware/bulk-checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@
<form class="form-horizontal" method="post" action="" autocomplete="off">
{{ csrf_field() }}

@if ($removed_assets->isNotEmpty())
<div class="box box-solid box-warning">
<div class="box-header with-border">
<span class="box-title col-xs-12">Warning</span>
</div>
<div class="box-body">
<p>{{ trans('general.assigned_assets_removed') }}</p>
<ul>
@foreach($removed_assets as $removed_asset)
<li>
<a href="{{ route('hardware.show', $removed_asset->id) }}">
{{ $removed_asset->present()->fullName }}
</a>
</li>
@endforeach
</ul>
</div>
</div>
@endif

@include ('partials.forms.edit.asset-select', [
'translated_name' => trans('general.assets'),
'fieldname' => 'selected_assets[]',
Expand Down
Loading