mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 22:37:28 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
9fc4565bc1
|
@ -36,6 +36,7 @@ class UsersController extends Controller
|
|||
|
||||
$users = User::select([
|
||||
'users.activated',
|
||||
'users.created_by',
|
||||
'users.address',
|
||||
'users.avatar',
|
||||
'users.city',
|
||||
|
@ -66,7 +67,7 @@ class UsersController extends Controller
|
|||
'users.remote',
|
||||
'users.ldap_import',
|
||||
|
||||
])->with('manager', 'groups', 'userloc', 'company', 'department', 'assets', 'licenses', 'accessories', 'consumables')
|
||||
])->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');
|
||||
$users = Company::scopeCompanyables($users);
|
||||
|
||||
|
@ -89,6 +90,10 @@ class UsersController extends Controller
|
|||
$users = $users->where('users.location_id', '=', $request->input('location_id'));
|
||||
}
|
||||
|
||||
if ($request->filled('created_by')) {
|
||||
$users = $users->where('users.created_by', '=', $request->input('created_by'));
|
||||
}
|
||||
|
||||
if ($request->filled('email')) {
|
||||
$users = $users->where('users.email', '=', $request->input('email'));
|
||||
}
|
||||
|
@ -182,6 +187,9 @@ class UsersController extends Controller
|
|||
case 'department':
|
||||
$users = $users->OrderDepartment($order);
|
||||
break;
|
||||
case 'created_by':
|
||||
$users = $users->CreatedBy($order);
|
||||
break;
|
||||
case 'company':
|
||||
$users = $users->OrderCompany($order);
|
||||
break;
|
||||
|
|
|
@ -117,6 +117,7 @@ class UsersController extends Controller
|
|||
$user->zip = $request->input('zip', null);
|
||||
$user->remote = $request->input('remote', 0);
|
||||
$user->website = $request->input('website', null);
|
||||
$user->created_by = Auth::user()->id;
|
||||
|
||||
// Strip out the superuser permission if the user isn't a superadmin
|
||||
$permissions_array = $request->input('permission');
|
||||
|
|
|
@ -63,6 +63,10 @@ class UsersTransformer
|
|||
'accessories_count' => (int) $user->accessories_count,
|
||||
'consumables_count' => (int) $user->consumables_count,
|
||||
'company' => ($user->company) ? ['id' => (int) $user->company->id, 'name'=> e($user->company->name)] : null,
|
||||
'created_by' => ($user->createdBy) ? [
|
||||
'id' => (int) $user->createdBy->id,
|
||||
'name'=> e($user->createdBy->present()->fullName),
|
||||
] : null,
|
||||
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
|
||||
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
|
||||
'last_login' => Helper::getFormattedDateObject($user->last_login, 'datetime'),
|
||||
|
|
|
@ -561,6 +561,18 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the admin user who created this user
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v6.0.5]
|
||||
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||
*/
|
||||
public function createdBy()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether two-factor authorization is required and the user has activated it
|
||||
* and enrolled a device
|
||||
|
@ -685,6 +697,23 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
|
|||
return $query->leftJoin('departments as departments_users', 'users.department_id', '=', 'departments_users.id')->orderBy('departments_users.name', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query builder scope to order on admin user
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query Query builder instance
|
||||
* @param string $order Order
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder Modified query builder
|
||||
*/
|
||||
public function scopeCreatedBy($query, $order)
|
||||
{
|
||||
// Left join here, or it will only return results with parents
|
||||
return $query->leftJoin('users as admin_user', 'users.created_by', '=', 'admin_user.id')
|
||||
->orderBy('admin_user.first_name', $order)
|
||||
->orderBy('admin_user.last_name', $order);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query builder scope to order on company
|
||||
*
|
||||
|
|
|
@ -285,6 +285,14 @@ class UserPresenter extends Presenter
|
|||
'visible' => true,
|
||||
'formatter' => 'trueFalseFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'created_by',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'title' => trans('general.admin'),
|
||||
'visible' => false,
|
||||
'formatter' => 'usersLinkObjFormatter',
|
||||
],
|
||||
[
|
||||
'field' => 'created_at',
|
||||
'searchable' => true,
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddUserIdToUsers extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('created_by')->after('activated')->nullable()->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('users', 'created_by')) {
|
||||
$table->dropColumn('created_by');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -137,7 +137,9 @@ a {
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,9 @@ a {
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
@ -149,7 +151,9 @@ a:link {
|
|||
.btn-primary.hover {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
.small-box h3, .small-box p {
|
||||
color: var(--nav-link) !important;
|
||||
a:hover {
|
||||
|
|
|
@ -119,6 +119,9 @@
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
|
|
|
@ -132,7 +132,9 @@ a {
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,9 @@ a {
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
|
|
|
@ -103,10 +103,10 @@ a {
|
|||
--back-main: #333;
|
||||
--back-sub: #3d4144;
|
||||
--back-sub-alt: rgba(0, 0, 0, 0.36);
|
||||
--button-default: #FFFF00;
|
||||
--button-primary: darken(#FFFF00, 25%);
|
||||
--button-hover: darken(#FFFF00, 30%);
|
||||
--header: #FFFF00; /* Use same as Header picker */
|
||||
--button-default: #FFCC32;
|
||||
--button-primary: darken(#FFCC32, 25%);
|
||||
--button-hover: darken(#FFCC32, 30%);
|
||||
--header: #FFCC32; /* Use same as Header picker */
|
||||
--text-main: #BBB;
|
||||
--text-sub: #9b9b9b;
|
||||
--link: #F0E68C; /* Use same as Header picker, lighten by 70% */
|
||||
|
@ -131,7 +131,9 @@ a.btn.btn-default{
|
|||
.bootstrap-table .fixed-table-container .table thead th .sortable {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
||||
.bootstrap-table .fixed-table-toolbar .columns label {
|
||||
color:#000;
|
||||
}
|
||||
.thead, .navbar-nav>li>a:link {
|
||||
color: var(--nav-link);
|
||||
}
|
||||
|
|
|
@ -463,6 +463,17 @@
|
|||
</div>
|
||||
<div class="col-md-9">
|
||||
{{ \App\Helpers\Helper::getFormattedDateObject($user->created_at, 'datetime')['formatted']}}
|
||||
|
||||
@if ($user->createdBy)
|
||||
by
|
||||
@if ($user->createdBy->deleted_at=='')
|
||||
<a href="{{ route('users.show', ['user' => $user->created_by]) }}">{{ $user->createdBy->present()->fullName }}</a>
|
||||
@else
|
||||
<del>{{ $user->createdBy->present()->fullName }}</del>
|
||||
@endif
|
||||
|
||||
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
|
Loading…
Reference in a new issue