A free open source IT asset/license management system
Merge branch 'develop' into feature/locations_with_companies
snipe43c15ef1347f
diff --cc app/Http/Controllers/Api/LocationsController.phpindex be96dc4c98,6a312e5bcf..638765928b--- a/app/Http/Controllers/Api/LocationsController.php+++ b/app/Http/Controllers/Api/LocationsController.php@@@ -76,9 -74,8 +77,10 @@@ class LocationsController extends Contr'locations.image','locations.ldap_ou','locations.currency',+ 'locations.company_id',+ 'locations.notes',])+ ->withCount('assignedAssets as assigned_assets_count')->withCount('assignedAssets as assigned_assets_count')->withCount('assets as assets_count')->withCount('assignedAccessories as assigned_accessories_count')diff --cc app/Http/Controllers/LocationsController.phpindex c7a8476c46,a018b8a68a..9e0bd6bfb1--- a/app/Http/Controllers/LocationsController.php+++ b/app/Http/Controllers/LocationsController.php@@@ -81,18 -78,7 +81,19 @@@ class LocationsController extends Contr$location->created_by = auth()->id();$location->phone = request('phone');$location->fax = request('fax');+ $location->notes = $request->input('notes');+ $location->company_id = Company::getIdForCurrentUser($request->input('company_id'));++ // Only scope the location if the setting is enabled+ if (Setting::getSettings()->scope_locations_fmcs) {+ $location->company_id = Company::getIdForCurrentUser($request->input('company_id'));+ // check if parent is set and has a different company+ if ($location->parent_id && Location::find($location->parent_id)->company_id != $location->company_id) {+ return redirect()->back()->withInput()->withInput()->with('error', 'different company than parent');+ }+ } else {+ $location->company_id = $request->input('company_id');+ }$location = $request->handleImages($location);@@@ -153,18 -129,8 +144,19 @@@$location->fax = request('fax');$location->ldap_ou = $request->input('ldap_ou');$location->manager_id = $request->input('manager_id');+ $location->notes = $request->input('notes');+ // Only scope the location if the setting is enabled+ if (Setting::getSettings()->scope_locations_fmcs) {+ $location->company_id = Company::getIdForCurrentUser($request->input('company_id'));+ // check if there are related objects with different company+ if (Helper::test_locations_fmcs(false, $locationId, $location->company_id)) {+ return redirect()->back()->withInput()->withInput()->with('error', 'error scoped locations');+ }+ } else {+ $location->company_id = $request->input('company_id');+ }+$location = $request->handleImages($location);if ($location->save()) {diff --cc app/Http/Controllers/SettingsController.phpindex 6f69de8bda,2300f2f682..bca72a911emode 100755,100644..100644--- a/app/Http/Controllers/SettingsController.php+++ b/app/Http/Controllers/SettingsController.phpdiff --cc app/Models/Location.phpindex 0418792e3a,63cb2de39d..69c79cfaeb--- a/app/Models/Location.php+++ b/app/Models/Location.php@@@ -76,7 -72,7 +76,8 @@@ class Location extends SnipeMode'currency','manager_id','image',+ 'company_id',+ 'notes',];protected $hidden = ['user_id'];