A free open source IT asset/license management system
Fixed #9082 - allow deployable status type on checkout
snipe985193ffff1e
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 5a39cbdf11..a237775428 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -428,6 +428,26 @@ class Helperreturn $statuslabel_list;}+ /**+ * Get the list of deployable status labels in an array to make a dropdown menu+ *+ * @todo This should probably be a selectlist, same as the other endpoints+ * and we should probably add to the API controllers to make sure that+ * the status_id submitted is actually really deployable.+ *+ * @author [A. Gianotto] [<[email protected]>]+ * @since [v5.1.0]+ * @return Array+ */+ public static function deployableStatusLabelList()+ {+ $statuslabel_list = Statuslabel::where('deployable', '=', '1')->orderBy('default_label', 'desc')+ ->orderBy('name','asc')+ ->orderBy('deployable','desc')+ ->pluck('name', 'id')->toArray();+ return $statuslabel_list;+ }+/*** Get the list of status label types in an array to make a dropdown menu*diff --git a/app/Http/Controllers/Assets/AssetCheckoutController.php b/app/Http/Controllers/Assets/AssetCheckoutController.phpindex be3d9113b9..dcb5154cfc 100644--- a/app/Http/Controllers/Assets/AssetCheckoutController.php+++ b/app/Http/Controllers/Assets/AssetCheckoutController.php@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Assets;use App\Exceptions\CheckoutNotAllowed;+use App\Helpers\Helper;use App\Http\Controllers\CheckInOutRequest;use App\Http\Controllers\Controller;use App\Http\Requests\AssetCheckoutRequest;@@ -33,7 +34,8 @@ class AssetCheckoutController extends Controller$this->authorize('checkout', $asset);if ($asset->availableForCheckout()) {- return view('hardware/checkout', compact('asset'));+ return view('hardware/checkout', compact('asset'))+ ->with('statusLabel_list', Helper::deployableStatusLabelList());}return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkout.not_available'));@@ -75,6 +77,10 @@ class AssetCheckoutController extends Controller$expected_checkin = $request->get('expected_checkin');}+ if ($request->filled('status_id')) {+ $asset->status_id = $request->get('status_id');+ }+if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, e($request->get('note')), $request->get('name'))) {return redirect()->route("hardware.index")->with('success', trans('admin/hardware/message.checkout.success'));}diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.phpindex 8c04bbe9c3..30d0dab505 100755--- a/resources/views/hardware/checkout.blade.php+++ b/resources/views/hardware/checkout.blade.php@@ -51,6 +51,16 @@{!! $errors->first('name', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}</div></div>++ <!-- Status -->+ <div class="form-group {{ $errors->has('status_id') ? 'error' : '' }}">+ {{ Form::label('status_id', trans('admin/hardware/form.status'), array('class' => 'col-md-3 control-label')) }}+ <div class="col-md-7 required">+ {{ Form::select('status_id', $statusLabel_list, $asset->status_id, array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }}+ {!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}+ </div>+ </div>+@include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true'])@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_user', 'required'=>'true'])