Adds company-scoped dropdown for parent location
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user