Add remote option to user

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-03-04 05:35:26 -08:00
parent a9069e65e5
commit 43c1949092
8 changed files with 71 additions and 6 deletions

View file

@ -63,6 +63,7 @@ class UsersController extends Controller
'users.updated_at',
'users.username',
'users.zip',
'users.remote',
'users.ldap_import',
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables')
@ -136,6 +137,10 @@ class UsersController extends Controller
$users = $users->where('ldap_import', '=', $request->input('ldap_import'));
}
if ($request->filled('remote')) {
$users = $users->where('remote', '=', $request->input('remote'));
}
if ($request->filled('assets_count')) {
$users->has('assets', '=', $request->input('assets_count'));
}

View file

@ -115,6 +115,7 @@ class UsersController extends Controller
$user->state = $request->input('state', null);
$user->country = $request->input('country', null);
$user->zip = $request->input('zip', null);
$user->remote = $request->input('remote', 0);
// Strip out the superuser permission if the user isn't a superadmin
$permissions_array = $request->input('permission');
@ -179,7 +180,6 @@ class UsersController extends Controller
if ($user = User::find($id)) {
$this->authorize('update', $user);
$permissions = config('permissions');
$groups = Group::pluck('name', 'id');
$userGroups = $user->groups()->pluck('name', 'id');
@ -190,9 +190,7 @@ class UsersController extends Controller
return view('users/edit', compact('user', 'groups', 'userGroups', 'permissions', 'userPermissions'))->with('item', $user);
}
$error = trans('admin/users/message.user_not_found', compact('id'));
return redirect()->route('users.index')->with('error', $error);
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
}
/**
@ -267,6 +265,7 @@ class UsersController extends Controller
$user->country = $request->input('country', null);
$user->activated = $request->input('activated', 0);
$user->zip = $request->input('zip', null);
$user->remote = $request->input('remote', 0);
// Update the location of any assets checked out to this user
Asset::where('assigned_type', User::class)

View file

@ -28,6 +28,7 @@ class UsersTransformer
'first_name' => e($user->first_name),
'last_name' => e($user->last_name),
'username' => e($user->username),
'remote' => ($user->remote == '1') ? true : false,
'locale' => ($user->locale) ? e($user->locale) : null,
'employee_num' => e($user->employee_num),
'manager' => ($user->manager) ? [

View file

@ -58,6 +58,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
'state',
'username',
'zip',
'remote',
];
protected $casts = [

View file

@ -85,6 +85,15 @@ class UserPresenter extends Presenter
'visible' => true,
'formatter' => 'usersLinkFormatter',
],
[
'field' => 'remote',
'searchable' => false,
'sortable' => true,
'switchable' => true,
'title' => trans('admin/users/general.remote'),
'visible' => false,
'formatter' => 'trueFalseFormatter',
],
[
'field' => 'email',
'searchable' => true,

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddRemoteToUser extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('remote')->nullable()->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'remote')) {
$table->dropColumn('remote');
}
});
}
}

View file

@ -34,4 +34,7 @@ return [
'warning_deletion_information' => 'You are about to delete the :count user(s) listed below. Super admin names are highlighted in red.',
'update_user_asssets_status' => 'Update all assets for these users to this status',
'checkin_user_properties' => 'Check in all properties associated with these users',
'remote_label' => 'This is a remote user',
'remote' => 'Remote',
'remote_help' => 'This can be useful if you need to filter by remote users who never or rarely come into your physical locations.'
];

View file

@ -273,7 +273,7 @@
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.select_company'), 'fieldname' => 'company_id'])
@endif
<!-- Image -->
@if ($user->avatar)
<div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
@ -338,7 +338,20 @@
@include ('partials.forms.edit.department-select', ['translated_name' => trans('general.department'), 'fieldname' => 'department_id'])
<!-- Location -->
<!-- remote checkbox -->
<div class="form-group">
<div class="col-md-7 col-md-offset-3">
<label for="remote">
<input type="checkbox" value="1" name="remote" class="minimal" {{ (old('remote', $user->remote)) == '1' ? ' checked="checked"' : '' }} aria-label="remote">
{{ trans('admin/users/general.remote_label') }}
</label>
<p class="help-block">{{ trans('admin/users/general.remote_help') }}
</p>
</div>
</div>
<!-- Location -->
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
<!-- Phone -->