From a516e4278ec508f195cc01a2e8d966aac2df22bb Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 5 Oct 2018 07:30:42 -0700 Subject: [PATCH] Remove company select option if the user is not an admin and FCS is enabled --- .../Controllers/Assets/AssetsController.php | 17 +++++++++-------- resources/views/components/edit.blade.php | 2 +- .../forms/edit/company-select.blade.php | 13 +++++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 0c4a5f085..5dbb27967 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -317,12 +317,14 @@ class AssetsController extends Controller // Update the asset data + $asset_tag = $request->input('asset_tags'); + $serial = $request->input('serials'); $asset->name = $request->input('name'); - $asset->serial = $request->input('serial'); + $asset->serial = $serial[1]; $asset->company_id = Company::getIdForCurrentUser($request->input('company_id')); $asset->model_id = $request->input('model_id'); $asset->order_number = $request->input('order_number'); - $asset->asset_tag = $request->input('asset_tag'); + $asset->asset_tag = $asset_tag[1]; $asset->notes = $request->input('notes'); $asset->physical = '1'; @@ -347,13 +349,12 @@ class AssetsController extends Controller if ($asset->save()) { - // Redirect to the new asset page - \Session::flash('success', trans('admin/hardware/message.update.success')); - return response()->json(['redirect_url' => route("hardware.show", $assetId)]); + return redirect()->route("hardware.show", $assetId) + ->with('success', trans('admin/hardware/message.update.success')); } - \Input::flash(); - \Session::flash('errors', $asset->getErrors()); - return response()->json(['errors' => $asset->getErrors()], 500); + + return redirect()->back()->withInput()->withErrors()->with('error', trans('admin/hardware/message.does_not_exist')); + } /** diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.php index 14f5a0a23..94243f226 100644 --- a/resources/views/components/edit.blade.php +++ b/resources/views/components/edit.blade.php @@ -14,7 +14,7 @@ @include ('partials.forms.edit.category-select', ['translated_name' => trans('general.category'), 'fieldname' => 'category_id','category_type' => 'component']) @include ('partials.forms.edit.quantity') @include ('partials.forms.edit.minimum_quantity') -@include ('partials.forms.edit.serial') +@include ('partials.forms.edit.serial', ['fieldname' => 'serial']) @include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id']) @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id']) @include ('partials.forms.edit.order_number') diff --git a/resources/views/partials/forms/edit/company-select.blade.php b/resources/views/partials/forms/edit/company-select.blade.php index 03e539d2c..538490d52 100644 --- a/resources/views/partials/forms/edit/company-select.blade.php +++ b/resources/views/partials/forms/edit/company-select.blade.php @@ -1,3 +1,5 @@ +@if (($snipeSettings->full_multiple_companies_support=='1') && (Auth::user())->isSuperUser()) +
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} @@ -17,3 +19,14 @@ {!! $errors->first($fieldname, '
:message
') !!}
+ +@else +
+ {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} +
+

{{ Auth::user()->company->name }}

+ +
+ +
+@endif