mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #12124 from Godmartinz/feature/sc-16946/add-checkbox-to-allow-skipping-a-user-during
Adds Boolean to Users Table for Auto Assigning Licenses
This commit is contained in:
commit
4bf1566d2a
|
@ -56,7 +56,7 @@ class CheckoutLicenseToAllUsers extends Command
|
||||||
return false;
|
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()) {
|
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. ');
|
$this->info('You do not have enough free seats to complete this task, so we will check out as many as we can. ');
|
||||||
|
|
|
@ -121,6 +121,7 @@ class UsersController extends Controller
|
||||||
$user->created_by = Auth::user()->id;
|
$user->created_by = Auth::user()->id;
|
||||||
$user->start_date = $request->input('start_date', null);
|
$user->start_date = $request->input('start_date', null);
|
||||||
$user->end_date = $request->input('end_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
|
// Strip out the superuser permission if the user isn't a superadmin
|
||||||
$permissions_array = $request->input('permission');
|
$permissions_array = $request->input('permission');
|
||||||
|
@ -274,6 +275,7 @@ class UsersController extends Controller
|
||||||
$user->website = $request->input('website', null);
|
$user->website = $request->input('website', null);
|
||||||
$user->start_date = $request->input('start_date', null);
|
$user->start_date = $request->input('start_date', null);
|
||||||
$user->end_date = $request->input('end_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
|
// Update the location of any assets checked out to this user
|
||||||
Asset::where('assigned_type', User::class)
|
Asset::where('assigned_type', User::class)
|
||||||
|
|
|
@ -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('autoassign_licenses')->nullable(false)->default(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('autoassign_licenses');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ return [
|
||||||
'print_assigned' => 'Print All Assigned',
|
'print_assigned' => 'Print All Assigned',
|
||||||
'email_assigned' => 'Email List of All Assigned',
|
'email_assigned' => 'Email List of All Assigned',
|
||||||
'user_notified' => 'User has been emailed a list of their currently assigned items.',
|
'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',
|
'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.',
|
'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',
|
'view_user' => 'View User :name',
|
||||||
|
|
|
@ -384,6 +384,19 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Auto Assign checkbox -->
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-7 col-md-offset-3">
|
||||||
|
<label for="autoassign_licenses">
|
||||||
|
<input type="checkbox" value="1" name="autoassign_licenses" class="minimal" {{ (old('autoassign_licenses', $user->autoassign_licenses)) == '1' ? ' checked="checked"' : '' }} aria-label="autoassign_licenses">
|
||||||
|
{{ trans('admin/users/general.auto_assign_label') }}
|
||||||
|
|
||||||
|
</label>
|
||||||
|
<p class="help-block">{{ trans('admin/users/general.auto_assign_help') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Location -->
|
<!-- Location -->
|
||||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue