A free open source IT asset/license management system
Adds company-scoped dropdown for parent location
snipecc526d9b4261
diff --git a/app/Http/Controllers/Api/LocationsController.php b/app/Http/Controllers/Api/LocationsController.phpindex 8353e00aec..d2b8885675 100644--- a/app/Http/Controllers/Api/LocationsController.php+++ b/app/Http/Controllers/Api/LocationsController.php@@ -484,6 +484,10 @@ class LocationsController extends Controller$locations->where('locations.id', '!=', (int) $request->input('excludeId'));}+ if ((Setting::getSettings()->full_multiple_companies_support == '1') && $request->filled('companyId')) {+ $locations->where('locations.company_id', '=', (int) $request->input('companyId'));+ }+$locations = $locations->orderBy('name', 'ASC')->get();$locations_with_children = [];diff --git a/resources/views/locations/edit.blade.php b/resources/views/locations/edit.blade.phpindex 6fb1609fd8..049189b3a2 100755--- a/resources/views/locations/edit.blade.php+++ b/resources/views/locations/edit.blade.php@@ -1,3 +1,16 @@+@push('js')+<script nonce="{{ csrf_token() }}">+ $(function () {+ $('[name="company_id"]').on('select2:select select2:clear', function (e) {+ var companyId = $(this).val() || null;+ var $parentSelect = $('#parent_id_location_select');+ $parentSelect.data('company-id', companyId);+ $parentSelect.val(null).trigger('change');+ });+ });+</script>+@endpush+@extends('layouts/edit-form', ['createText' => trans('admin/locations/table.create') ,'updateText' => trans('admin/locations/table.update'),@@ -10,7 +23,7 @@@include ('partials.forms.edit.name', ['translated_name' => trans('admin/locations/table.name')])<!-- parent -->-@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/locations/table.parent'), 'fieldname' => 'parent_id', 'exclude_id' => isset($item) ? $item->id : null])+@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/locations/table.parent'), 'fieldname' => 'parent_id', 'exclude_id' => isset($item) ? $item->id : null, 'company_id' => isset($item) ? $item->company_id : null])<!-- Manager-->@include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/users/table.manager'), 'fieldname' => 'manager_id'])