Better logic for disallowing company selection when user is not a superadmin and FCS is enabled

This commit is contained in:
snipe 2018-10-15 17:57:28 -07:00
parent 9797412d23
commit 0dbce93d1b

View file

@ -1,26 +1,6 @@
@if (($snipeSettings->full_multiple_companies_support=='1') && (Auth::user())->isSuperUser())
<!-- Company --> <!-- Company -->
<div id="{{ $fieldname }}" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}"> @if (($snipeSettings->full_multiple_companies_support=='1') && (!Auth::user())->isSuperUser())
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} <!-- full company support is enabled and this user isn't a superadmin -->
<div class="col-md-7">
<select class="js-data-ajax" data-endpoint="companies" data-placeholder="{{ trans('general.select_company') }}" name="{{ $fieldname }}" style="width: 100%" id="company_select">
@if ($company_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
<option value="{{ $company_id }}" selected="selected">
{{ (\App\Models\Company::find($company_id)) ? \App\Models\Company::find($company_id)->name : '' }}
</option>
@else
<option value="">{{ trans('general.select_company') }}</option>
@endif
</select>
</div>
{!! $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"> <div class="form-group">
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }} {{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
<div class="col-md-7"> <div class="col-md-7">
@ -29,4 +9,24 @@
</div> </div>
</div> </div>
@else
<!-- full company support is enabled or this user is a superadmin -->
<div id="{{ $fieldname }}" class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
<div class="col-md-7">
<select class="js-data-ajax" data-endpoint="companies" data-placeholder="{{ trans('general.select_company') }}" name="{{ $fieldname }}" style="width: 100%" id="company_select">
@if ($company_id = Input::old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
<option value="{{ $company_id }}" selected="selected">
{{ (\App\Models\Company::find($company_id)) ? \App\Models\Company::find($company_id)->name : '' }}
</option>
@else
<option value="">{{ trans('general.select_company') }}</option>
@endif
</select>
</div>
{!! $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>
@endif @endif