Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15320 - add deployable status to bulk checkout #15823

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public function destroy(Request $request) : RedirectResponse
public function showCheckout() : View
{
$this->authorize('checkout', Asset::class);
return view('hardware/bulk-checkout');
return view('hardware/bulk-checkout')->with('statusLabel_list', Helper::deployableStatusLabelList());
}

/**
Expand Down Expand Up @@ -577,6 +577,7 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse
}
}
}

$checkout_at = date('Y-m-d H:i:s');
if (($request->filled('checkout_at')) && ($request->get('checkout_at') != date('Y-m-d'))) {
$checkout_at = e($request->get('checkout_at'));
Expand All @@ -589,11 +590,15 @@ public function storeCheckout(AssetCheckoutRequest $request) : RedirectResponse
}

$errors = [];
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passsed by reference!
DB::transaction(function () use ($target, $admin, $checkout_at, $expected_checkin, &$errors, $asset_ids, $request) { //NOTE: $errors is passed by reference!
foreach ($asset_ids as $asset_id) {
$asset = Asset::findOrFail($asset_id);
$this->authorize('checkout', $asset);

if ($request->filled('status_id')) {
$asset->status_id = $request->input('status_id');
}

$checkout_success = $asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $asset->name, null);

//TODO - I think this logic is duplicated in the checkOut method?
Expand Down
11 changes: 11 additions & 0 deletions resources/views/hardware/bulk-checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.asset'), 'asset_selector_div_id' => 'assigned_asset', 'fieldname' => 'assigned_asset', 'unselect' => 'true', 'style' => 'display:none;'])
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => 'display:none;'])

<!-- Status -->
<div class="form-group {{ $errors->has('status_id') ? 'error' : '' }}">
<label for="status_id" class="col-md-3 control-label">
{{ trans('admin/hardware/form.status') }}
</label>
<div class="col-md-7">
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }}
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>

<!-- Checkout/Checkin Date -->
<div class="form-group {{ $errors->has('checkout_at') ? 'error' : '' }}">
<label for="checkout_at" class="col-sm-3 control-label">
Expand Down
Loading