mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Merge pull request #11926 from snipe/features/add_start_and_term_dates_to_users
Added start and end dates to users
This commit is contained in:
commit
e9c61903f1
|
@ -66,6 +66,8 @@ class UsersController extends Controller
|
||||||
'users.zip',
|
'users.zip',
|
||||||
'users.remote',
|
'users.remote',
|
||||||
'users.ldap_import',
|
'users.ldap_import',
|
||||||
|
'users.start_date',
|
||||||
|
'users.end_date',
|
||||||
|
|
||||||
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'createdBy',)
|
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables', 'createdBy',)
|
||||||
->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count');
|
->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count');
|
||||||
|
@ -146,6 +148,15 @@ class UsersController extends Controller
|
||||||
$users = $users->where('remote', '=', $request->input('remote'));
|
$users = $users->where('remote', '=', $request->input('remote'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($request->filled('start_date')) {
|
||||||
|
$users = $users->where('users.start_date', '=', $request->input('start_date'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('end_date')) {
|
||||||
|
$users = $users->where('users.end_date', '=', $request->input('end_date'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->filled('assets_count')) {
|
if ($request->filled('assets_count')) {
|
||||||
$users->has('assets', '=', $request->input('assets_count'));
|
$users->has('assets', '=', $request->input('assets_count'));
|
||||||
}
|
}
|
||||||
|
@ -200,7 +211,7 @@ class UsersController extends Controller
|
||||||
'assets', 'accessories', 'consumables', 'licenses', 'groups', 'activated', 'created_at',
|
'assets', 'accessories', 'consumables', 'licenses', 'groups', 'activated', 'created_at',
|
||||||
'two_factor_enrolled', 'two_factor_optin', 'last_login', 'assets_count', 'licenses_count',
|
'two_factor_enrolled', 'two_factor_optin', 'last_login', 'assets_count', 'licenses_count',
|
||||||
'consumables_count', 'accessories_count', 'phone', 'address', 'city', 'state',
|
'consumables_count', 'accessories_count', 'phone', 'address', 'city', 'state',
|
||||||
'country', 'zip', 'id', 'ldap_import', 'remote',
|
'country', 'zip', 'id', 'ldap_import', 'remote', 'start_date', 'end_date',
|
||||||
];
|
];
|
||||||
|
|
||||||
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
|
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
|
||||||
|
|
|
@ -119,6 +119,8 @@ class UsersController extends Controller
|
||||||
$user->remote = $request->input('remote', 0);
|
$user->remote = $request->input('remote', 0);
|
||||||
$user->website = $request->input('website', null);
|
$user->website = $request->input('website', null);
|
||||||
$user->created_by = Auth::user()->id;
|
$user->created_by = Auth::user()->id;
|
||||||
|
$user->start_date = $request->input('start_date', null);
|
||||||
|
$user->end_date = $request->input('end_date', null);
|
||||||
|
|
||||||
// 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');
|
||||||
|
@ -270,6 +272,8 @@ class UsersController extends Controller
|
||||||
$user->zip = $request->input('zip', null);
|
$user->zip = $request->input('zip', null);
|
||||||
$user->remote = $request->input('remote', 0);
|
$user->remote = $request->input('remote', 0);
|
||||||
$user->website = $request->input('website', null);
|
$user->website = $request->input('website', null);
|
||||||
|
$user->start_date = $request->input('start_date', null);
|
||||||
|
$user->end_date = $request->input('end_date', null);
|
||||||
|
|
||||||
// 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)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class UsersTransformer
|
||||||
'username' => e($user->username),
|
'username' => e($user->username),
|
||||||
'remote' => ($user->remote == '1') ? true : false,
|
'remote' => ($user->remote == '1') ? true : false,
|
||||||
'locale' => ($user->locale) ? e($user->locale) : null,
|
'locale' => ($user->locale) ? e($user->locale) : null,
|
||||||
'employee_num' => e($user->employee_num),
|
'employee_num' => ($user->employee_num) ? e($user->employee_num) : null,
|
||||||
'manager' => ($user->manager) ? [
|
'manager' => ($user->manager) ? [
|
||||||
'id' => (int) $user->manager->id,
|
'id' => (int) $user->manager->id,
|
||||||
'name'=> e($user->manager->first_name).' '.e($user->manager->last_name),
|
'name'=> e($user->manager->first_name).' '.e($user->manager->last_name),
|
||||||
|
@ -43,7 +43,7 @@ class UsersTransformer
|
||||||
'state' => ($user->state) ? e($user->state) : null,
|
'state' => ($user->state) ? e($user->state) : null,
|
||||||
'country' => ($user->country) ? e($user->country) : null,
|
'country' => ($user->country) ? e($user->country) : null,
|
||||||
'zip' => ($user->zip) ? e($user->zip) : null,
|
'zip' => ($user->zip) ? e($user->zip) : null,
|
||||||
'email' => e($user->email),
|
'email' => ($user->email) ? e($user->email) : null,
|
||||||
'department' => ($user->department) ? [
|
'department' => ($user->department) ? [
|
||||||
'id' => (int) $user->department->id,
|
'id' => (int) $user->department->id,
|
||||||
'name'=> e($user->department->name),
|
'name'=> e($user->department->name),
|
||||||
|
@ -69,6 +69,8 @@ class UsersTransformer
|
||||||
] : null,
|
] : null,
|
||||||
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
|
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
|
||||||
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
|
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
|
||||||
|
'start_date' => Helper::getFormattedDateObject($user->start_date, 'date'),
|
||||||
|
'end_date' => Helper::getFormattedDateObject($user->end_date, 'date'),
|
||||||
'last_login' => Helper::getFormattedDateObject($user->last_login, 'datetime'),
|
'last_login' => Helper::getFormattedDateObject($user->last_login, 'datetime'),
|
||||||
'deleted_at' => ($user->deleted_at) ? Helper::getFormattedDateObject($user->deleted_at, 'datetime') : null,
|
'deleted_at' => ($user->deleted_at) ? Helper::getFormattedDateObject($user->deleted_at, 'datetime') : null,
|
||||||
];
|
];
|
||||||
|
|
|
@ -59,6 +59,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
'username',
|
'username',
|
||||||
'zip',
|
'zip',
|
||||||
'remote',
|
'remote',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
@ -68,6 +70,16 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
'company_id' => 'integer',
|
'company_id' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
protected $dates = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model validation rules
|
* Model validation rules
|
||||||
*
|
*
|
||||||
|
@ -83,6 +95,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
||||||
'website' => 'url|nullable|max:191',
|
'website' => 'url|nullable|max:191',
|
||||||
'manager_id' => 'nullable|exists:users,id|cant_manage_self',
|
'manager_id' => 'nullable|exists:users,id|cant_manage_self',
|
||||||
'location_id' => 'exists:locations,id|nullable',
|
'location_id' => 'exists:locations,id|nullable',
|
||||||
|
'start_date' => 'nullable|date',
|
||||||
|
'end_date' => 'nullable|date|after_or_equal:start_date',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -302,6 +302,24 @@ class UserPresenter extends Presenter
|
||||||
'visible' => false,
|
'visible' => false,
|
||||||
'formatter' => 'dateDisplayFormatter',
|
'formatter' => 'dateDisplayFormatter',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'field' => 'start_date',
|
||||||
|
'searchable' => true,
|
||||||
|
'sortable' => true,
|
||||||
|
'switchable' => true,
|
||||||
|
'title' => trans('general.start_date'),
|
||||||
|
'visible' => false,
|
||||||
|
'formatter' => 'dateDisplayFormatter',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'field' => 'end_date',
|
||||||
|
'searchable' => true,
|
||||||
|
'sortable' => true,
|
||||||
|
'switchable' => true,
|
||||||
|
'title' => trans('general.end_date'),
|
||||||
|
'visible' => false,
|
||||||
|
'formatter' => 'dateDisplayFormatter',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'field' => 'last_login',
|
'field' => 'last_login',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddStartTerminationDateToUsers extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->date('start_date')->nullable()->default(null);
|
||||||
|
$table->date('end_date')->nullable()->default(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('start_date');
|
||||||
|
$table->dropColumn('end_date');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -378,6 +378,8 @@ return [
|
||||||
'pie_chart_type' => 'Dashboard Pie Chart Type',
|
'pie_chart_type' => 'Dashboard Pie Chart Type',
|
||||||
'hello_name' => 'Hello, :name!',
|
'hello_name' => 'Hello, :name!',
|
||||||
'unaccepted_profile_warning' => 'You have :count items requiring acceptance. Click here to accept or decline them',
|
'unaccepted_profile_warning' => 'You have :count items requiring acceptance. Click here to accept or decline them',
|
||||||
|
'start_date' => 'Start Date',
|
||||||
|
'end_date' => 'End Date',
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
|
@ -1,9 +1,9 @@
|
||||||
<!-- Datepicker -->
|
<!-- Datepicker -->
|
||||||
<div class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
<div class="form-group{{ $errors->has($fieldname) ? ' has-error' : '' }}">
|
||||||
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
{{ Form::label($fieldname, $translated_name, array('class' => 'col-md-3 control-label')) }}
|
||||||
<div class="input-group col-md-3">
|
<div class="input-group col-md-4">
|
||||||
<div class="input-group date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-autoclose="true">
|
<div class="input-group date" data-provide="datepicker" data-date-clear-btn="true" data-date-format="yyyy-mm-dd" data-autoclose="true">
|
||||||
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="{{ $fieldname }}" id="{{ $fieldname }}" value="{{ old($fieldname, ($item->{$fieldname}) ? $item->{$fieldname}->format('Y-m-d') : '') }}">
|
<input type="text" class="form-control" placeholder="{{ trans('general.select_date') }}" name="{{ $fieldname }}" id="{{ $fieldname }}" value="{{ old($fieldname, ($item->{$fieldname}) ? $item->{$fieldname}->format('Y-m-d') : '') }}" readonly>
|
||||||
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
<span class="input-group-addon"><i class="fas fa-calendar" aria-hidden="true"></i></span>
|
||||||
</div>
|
</div>
|
||||||
{!! $errors->first($fieldname, '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
{!! $errors->first($fieldname, '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
|
||||||
|
|
|
@ -358,6 +358,10 @@
|
||||||
<!-- Department -->
|
<!-- Department -->
|
||||||
@include ('partials.forms.edit.department-select', ['translated_name' => trans('general.department'), 'fieldname' => 'department_id'])
|
@include ('partials.forms.edit.department-select', ['translated_name' => trans('general.department'), 'fieldname' => 'department_id'])
|
||||||
|
|
||||||
|
@include ('partials.forms.edit.datepicker', ['translated_name' => trans('general.start_date'), 'fieldname' => 'start_date'])
|
||||||
|
|
||||||
|
@include ('partials.forms.edit.datepicker', ['translated_name' => trans('general.end_date'), 'fieldname' => 'end_date'])
|
||||||
|
|
||||||
|
|
||||||
<!-- remote checkbox -->
|
<!-- remote checkbox -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -343,6 +343,30 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- start date -->
|
||||||
|
@if ($user->start_date)
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
{{ trans('general.start_date') }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
{{ \App\Helpers\Helper::getFormattedDateObject($user->start_date, 'date', false) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- end date -->
|
||||||
|
@if ($user->end_date)
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
{{ trans('general.end_date') }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
{{ \App\Helpers\Helper::getFormattedDateObject($user->end_date, 'date', false) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@if ($user->jobtitle)
|
@if ($user->jobtitle)
|
||||||
<!-- jobtitle -->
|
<!-- jobtitle -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in a new issue