Skip to content

A free open source IT asset/license management system

adds should_autoassign boolean to users table

Godfrey M45636b81148c
diff --git a/app/Console/Commands/CheckoutLicenseToAllUsers.php b/app/Console/Commands/CheckoutLicenseToAllUsers.php
index fab2b318c6..e29b8991b6 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('should_autoassign', '==', 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 52d423036f..b863fb966b 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->should_autoassign= $request->input('should_autoassign', 0);
// 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->should_autoassign = $request->input('should_autoassign', 0);
// 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 0000000000..6f6f308e44
--- /dev/null
+++ b/database/migrations/2022_11_15_232525_adds_should_autoassign_bool_to_users_table.php
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddsShouldAutoassignBoolToUsersTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->boolean('should_autoassign')->nullable(false)->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('should_autoassign');
+ });
+ }
+}
diff --git a/resources/lang/en/admin/users/general.php b/resources/lang/en/admin/users/general.php
index daa568e8bf..2ae8709251 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' => 'User should skipped during auto assignment commands',
+ '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 7947d65a68..a689ab8983 100755
--- a/resources/views/users/edit.blade.php
+++ b/resources/views/users/edit.blade.php
@@ -376,6 +376,19 @@
</div>
</div>
+ <!-- Auto Assign checkbox -->
+ <div class="form-group">
+ <div class="col-md-7 col-md-offset-3">
+ <label for="should_autoassign">
+ <input type="checkbox" value="0" name="should_autoassign" class="minimal" {{ (old('remote', $user->should_autoassign)) }} aria-label="should_autoassign">
+ {{ trans('admin/users/general.auto_assign_label') }}
+
+ </label>
+ <p class="help-block">{{ trans('admin/users/general.auto_assign_help') }}
+ </p>
+ </div>
+ </div>
+
<!-- Location -->
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])