Added consumables to user matrix for #782

This commit is contained in:
snipe
2015-06-09 20:05:24 -07:00
parent e4517a8782
commit d0189fb076
4 changed files with 27 additions and 16 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<?php
return array (
'app_version' => 'v1.2.7-master',
'hash_version' => 'v1.2.7-master-43-g704d66b',
'hash_version' => 'v1.2.7-master-44-g1960448',
);
+8 -3
View File
@@ -687,7 +687,7 @@ class UsersController extends AdminController
public function getDatatable($status = null)
{
$users = User::with('assets','accessories','licenses','manager','sentryThrottle','groups','userloc');
$users = User::with('assets','accessories','consumables','licenses','manager','sentryThrottle','groups','userloc');
switch ($status) {
case 'deleted':
@@ -765,12 +765,17 @@ class UsersController extends AdminController
{
return $users->accessories->count();
})
->addColumn('consumables',function($users)
{
return $users->consumables->count();
})
->addColumn('groups',function($users)
{
$group_names = '';
foreach ($users->groups as $group) {
$group_names .= '<a href="'.Config::get('app.url').'/admin/groups/'.$group->id.'/edit">'.$group->name.'</a> ';
$group_names .= '<a href="'.Config::get('app.url').'/admin/groups/'.$group->id.'/edit" class="label label-default">'.$group->name.'</a> ';
}
return $group_names;
})
@@ -778,7 +783,7 @@ class UsersController extends AdminController
->addColumn($actions)
->searchColumns('name','email','manager','activated','groups','location')
->orderColumns('name','email','manager','activated', 'licenses','assets','accessories','groups','location')
->orderColumns('name','email','manager','activated', 'licenses','assets','accessories','consumables','groups','location')
->make();
}
+17 -12
View File
@@ -23,7 +23,7 @@ class User extends SentryUserModel
{
return "{$this->first_name} {$this->last_name}";
}
/**
* Returns the user Gravatar image url.
@@ -43,12 +43,17 @@ class User extends SentryUserModel
{
return $this->hasMany('Asset', 'assigned_to')->withTrashed();
}
public function accessories()
{
return $this->belongsToMany('Accessory', 'accessories_users', 'assigned_to','accessory_id')->withPivot('id')->withTrashed();
}
public function consumables()
{
return $this->belongsToMany('Consumable', 'consumables_users', 'assigned_to','consumable_id')->withPivot('id')->withTrashed();
}
public function licenses()
{
return $this->belongsToMany('License', 'license_seats', 'assigned_to', 'license_id')->withPivot('id');
@@ -77,32 +82,32 @@ class User extends SentryUserModel
{
return $this->belongsTo('User','manager_id')->withTrashed();
}
public function accountStatus()
{
if ($this->sentryThrottle) {
if ($this->sentryThrottle->suspended==1) {
return 'suspended';
return 'suspended';
} elseif ($this->sentryThrottle->banned==1) {
return 'banned';
} else {
return 'banned';
} else {
return false;
}
} else {
return false;
}
}
public function sentryThrottle() {
return $this->hasOne('Throttle');
public function sentryThrottle() {
return $this->hasOne('Throttle');
}
public function scopeGetDeleted($query)
{
return $query->withTrashed()->whereNotNull('deleted_at');
}
public function scopeGetNotDeleted($query)
{
return $query->whereNull('deleted_at');
+1
View File
@@ -41,6 +41,7 @@
'<i class="fa fa-barcode fa-lg"></i>',
'<i class="fa fa-certificate fa-lg"></i>',
'<i class="fa fa-keyboard-o fa-lg"></i>',
'<i class="fa fa-tint fa-lg"></i>',
Lang::get('general.groups'),
Lang::get('table.actions')
)