Skip to content

A free open source IT asset/license management system

Remove company select option if the user is not an admin and FCS is enabled

snipea516e4278ec5
diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php
index 0c4a5f0859..5dbb279673 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 14f5a0a232..94243f2262 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 03e539d2cc..538490d52e 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())
+
<!-- Company -->
<div id="{{ $fieldname }}" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
@@ -17,3 +19,14 @@
{!! $errors->first($fieldname, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg"><i class="fa fa-times"></i> :message</span></div>') !!}
</div>
+
+@else
+ <div class="form-group">
+ {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
+ <div class="col-md-7">
+ <p class="form-control-static">{{ Auth::user()->company->name }}</p>
+ <input type="hidden" name="company_id" value="{{ Auth::user()->company->id }}">
+ </div>
+
+ </div>
+@endif