A free open source IT asset/license management system
Scope assets, locations, etc to the target, not the admin
snipee7c80b89ebe3
diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.phpindex 3093d3de4d..840e30a128 100644--- a/app/Http/Controllers/Api/LocationsController.php+++ b/app/Http/Controllers/Api/LocationsController.php@@ -427,6 +427,10 @@ class LocationsController extends Controller$locations = Company::scopeCompanyables($locations);}+ if ((Setting::getSettings()->full_multiple_companies_support == '1') && $request->filled('companyId')) {+ $locations->where('locations.company_id', $request->input('companyId'));+ }+$page = 1;if ($request->filled('page')) {$page = $request->input('page');diff --git a/resources/views/blade/input/location-select.blade.php b/resources/views/blade/input/location-select.blade.phpindex 2547195cf5..40410f540c 100644--- a/resources/views/blade/input/location-select.blade.php+++ b/resources/views/blade/input/location-select.blade.php@@ -9,6 +9,7 @@'multiple' => false,'helpText' => null,'hideNewButton' => false,+ 'companyId' => null,])@php@@ -41,6 +42,9 @@@if ($multiple)multiple@endif+ @if ($companyId)+ data-company-id="{{ $companyId }}"+ @endif><option value=""></option>@if ($selected)diff --git a/resources/views/consumables/checkout.blade.php b/resources/views/consumables/checkout.blade.phpindex cfdc9cc99b..42e5cf60a3 100644--- a/resources/views/consumables/checkout.blade.php+++ b/resources/views/consumables/checkout.blade.php@@ -79,7 +79,7 @@<!-- User -->- @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true'])+ @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true', 'company_id' => $consumable->company_id])@if ($consumable->requireAcceptance() || (string) $snipeSettings->require_accept_signature === '1' || $consumable->getEula() || ($snipeSettings->webhook_endpoint!=''))diff --git a/resources/views/hardware/audit.blade.php b/resources/views/hardware/audit.blade.phpindex 14c516348c..e15501bb7a 100644--- a/resources/views/hardware/audit.blade.php+++ b/resources/views/hardware/audit.blade.php@@ -67,7 +67,7 @@@endif<!-- Locations -->- @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])+ @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id', 'company_id' => $asset->company_id])<!-- Update location --><div class="form-group">diff --git a/resources/views/hardware/checkin.blade.php b/resources/views/hardware/checkin.blade.phpindex 00fa444df2..036f09052b 100755--- a/resources/views/hardware/checkin.blade.php+++ b/resources/views/hardware/checkin.blade.php@@ -141,6 +141,7 @@name="location_id":help_text="($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null":selected="old('location_id')"+ :company_id="$asset->company_id"/><!-- Update actual location -->diff --git a/resources/views/hardware/checkout.blade.php b/resources/views/hardware/checkout.blade.phpindex e6668c0d70..64da41e17c 100755--- a/resources/views/hardware/checkout.blade.php+++ b/resources/views/hardware/checkout.blade.php@@ -119,10 +119,10 @@@endif@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', 'style' => (session('checkout_to_type') ?: 'user') == 'user' ? '' : 'display: none;'])+ @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_user', 'company_id' => $asset->company_id, 'style' => (session('checkout_to_type') ?: 'user') == 'user' ? '' : 'display: none;'])<!-- We have to pass unselect here so that we don't default to the asset that's being checked out. We want that asset to be pre-selected everywhere else. -->@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.select_asset'), 'fieldname' => 'assigned_asset', 'company_id' => $asset->company_id, 'unselect' => 'true', 'style' => session('checkout_to_type') == 'asset' ? '' : 'display: none;'])- @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'style' => session('checkout_to_type') == 'location' ? '' : 'display: none;'])+ @include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'assigned_location', 'company_id' => $asset->company_id, 'style' => session('checkout_to_type') == 'location' ? '' : 'display: none;'])diff --git a/resources/views/licenses/checkout.blade.php b/resources/views/licenses/checkout.blade.phpindex 6542e754d9..dbc8eacd7f 100755--- a/resources/views/licenses/checkout.blade.php+++ b/resources/views/licenses/checkout.blade.php@@ -72,8 +72,8 @@@endcan@include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'false'])- @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_to', 'style' => (session('checkout_to_type') ?: 'user') == 'user' ? '' : 'display: none;'])- @include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.select_asset'), 'fieldname' => 'asset_id', 'style' => session('checkout_to_type') == 'asset' ? '' : 'display: none;'])+ @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.user'), 'fieldname' => 'assigned_to', 'company_id' => $license->company_id, 'style' => (session('checkout_to_type') ?: 'user') == 'user' ? '' : 'display: none;'])+ @include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.select_asset'), 'fieldname' => 'asset_id', 'company_id' => $license->company_id, 'style' => session('checkout_to_type') == 'asset' ? '' : 'display: none;'])<!-- Note --><div class="form-group {{ $errors->has('notes') ? 'error' : '' }}">diff --git a/resources/views/partials/forms/edit/location-select.blade.php b/resources/views/partials/forms/edit/location-select.blade.phpindex 2242a1c2b7..e65f06559d 100644--- a/resources/views/partials/forms/edit/location-select.blade.php+++ b/resources/views/partials/forms/edit/location-select.blade.php@@ -3,7 +3,7 @@<label for="{{ $fieldname }}" class="col-md-3 control-label">{{ $translated_name }}</label><div class="col-md-7">- <select class="js-data-ajax" data-endpoint="locations" data-placeholder="{{ trans('general.select_location') }}" name="{{ $fieldname }}" style="width: 100%" id="{{ $fieldname }}_location_select" aria-label="{{ $fieldname }}"{{ (isset($multiple) && ($multiple=='true')) ? " multiple='multiple'" : '' }}{!! ((isset($item)) && (Helper::checkIfRequired($item, $fieldname))) ? ' required ' : '' !!}>+ <select class="js-data-ajax" data-endpoint="locations" data-placeholder="{{ trans('general.select_location') }}" name="{{ $fieldname }}" style="width: 100%" id="{{ $fieldname }}_location_select" aria-label="{{ $fieldname }}"{{ (isset($multiple) && ($multiple=='true')) ? " multiple='multiple'" : '' }}{!! ((isset($item)) && (Helper::checkIfRequired($item, $fieldname))) ? ' required ' : '' !!}{!! (!empty($company_id)) ? ' data-company-id="'.e($company_id).'"' : '' !!}>@isset($selected)@foreach($selected as $location_id)<option value="{{ $location_id }}" selected="selected" role="option" aria-selected="true" role="option">