diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php index d655b5ace..c81408442 100644 --- a/app/Console/Commands/CheckoutLicenseToAllUsers.php +++ b/app/Console/Commands/CheckoutLicenseToAllUsers.php @@ -56,7 +56,7 @@ class CheckoutLicenseToAllUsers extends Command return false; } - $users = User::whereNull('deleted_at')->with('licenses')->get(); + $users = User::whereNull('deleted_at')->where('autoassign_licenses', '==', 1)->with('licenses')->get(); if ($users->count() > $license->getAvailSeatsCountAttribute()) { $this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. '); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 2a3499255..0c6ab8834 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -121,6 +121,7 @@ class UsersController extends Controller $user->created_by = Auth::user()->id; $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); + $user->autoassign_licenses= $request->input('autoassign_licenses', 1); // Strip out the superuser permission if the user isn't a superadmin $permissions_array = $request->input('permission'); @@ -274,6 +275,7 @@ class UsersController extends Controller $user->website = $request->input('website', null); $user->start_date = $request->input('start_date', null); $user->end_date = $request->input('end_date', null); + $user->autoassign_licenses = $request->input('autoassign_licenses', 1); // Update the location of any assets checked out to this user Asset::where('assigned_type', User::class) diff --git a/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php new file mode 100644 index 000000000..b728e1f22 --- /dev/null +++ b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php @@ -0,0 +1,32 @@ +boolean('autoassign_licenses')->nullable(false)->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('autoassign_licenses'); + }); + } +} diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php index d58a0bc67..bdd9401da 100644 --- a/resources/lang/en/admin/users/general.php +++ b/resources/lang/en/admin/users/general.php @@ -19,6 +19,8 @@ return [ 'print_assigned' => 'Print All Assigned', 'email_assigned' => 'Email List of All Assigned', 'user_notified' => 'User has been emailed a list of their currently assigned items.', + 'auto_assign_label' => 'Include this user when auto-assigning eligible licenses', + 'auto_assign_help' => 'Skip this user in auto assignment of licenses', 'software_user' => 'Software Checked out to :name', 'send_email_help' => 'You must provide an email address for this user to send them credentials. Emailing credentials can only be done on user creation. Passwords are stored in a one-way hash and cannot be retrieved once saved.', 'view_user' => 'View User :name', diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index adfa261ca..3a85874b9 100755 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -384,6 +384,19 @@ + +
{{ trans('admin/users/general.auto_assign_help') }} +
+