diff --git a/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php b/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php
index c3dd58f424..a433ee9a28 100644
--- a/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php
+++ b/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php
@@ -16,8 +16,14 @@ class UserCannotSwitchCompaniesIfItemsAssigned implements ValidationRule
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$user = User::find(request()->route('user')->id);
- if (($value) && ($user->allAssignedCount() > 0) && (Setting::getSettings()->full_multiple_companies_support)) {
- $fail(trans('admin/users/message.error.multi_company_items_assigned'));
+
+ if (($value) && ($user->allAssignedCount() > 0) && (Setting::getSettings()->full_multiple_companies_support=='1')) {
+
+ // Check for assets with a different company_id than the selected company_id
+ $user_assets = $user->assets()->where('assets.company_id', '!=', $value)->count();
+ if ($user_assets > 0) {
+ $fail(trans('admin/users/message.error.multi_company_items_assigned'));
+ }
}
}
}
diff --git a/resources/lang/en-US/admin/users/message.php b/resources/lang/en-US/admin/users/message.php
index 3f44226335..b6ddad3aac 100644
--- a/resources/lang/en-US/admin/users/message.php
+++ b/resources/lang/en-US/admin/users/message.php
@@ -53,7 +53,7 @@ return array(
'ldap_could_not_search' => 'Could not search the LDAP server. Please check your LDAP server configuration in the LDAP config file.
Error from LDAP Server:',
'ldap_could_not_get_entries' => 'Could not get entries from the LDAP server. Please check your LDAP server configuration in the LDAP config file.
Error from LDAP Server:',
'password_ldap' => 'The password for this account is managed by LDAP/Active Directory. Please contact your IT department to change your password. ',
- 'multi_company_items_assigned' => 'This user has items assigned, please check them in before moving companies.'
+ 'multi_company_items_assigned' => 'This user has items assigned that belong to a different company. Please check them in or edit their company.'
),
'deletefile' => array(
diff --git a/resources/views/consumables/view.blade.php b/resources/views/consumables/view.blade.php
index 7cfbef2445..88ea19195f 100644
--- a/resources/views/consumables/view.blade.php
+++ b/resources/views/consumables/view.blade.php
@@ -83,9 +83,9 @@