Add checkin/checkout log to user profile view

This commit is contained in:
snipe
2013-11-19 03:58:26 -05:00
parent f7f79681f3
commit b8908bf246
6 changed files with 69 additions and 22 deletions
+8 -7
View File
@@ -302,24 +302,25 @@ class AssetsController extends AdminController {
return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.not_found'));
}
// Update the asset data
$asset->assigned_to = '';
if (!is_null($asset->assigned_to)) {
$user = User::find($asset->assigned_to);
}
$logaction = new Actionlog();
$logaction->checkedout_to = $asset->assigned_to;
// Update the asset data to null, since it's being checked in
$asset->assigned_to = '';
// Was the asset updated?
if($asset->save())
{
$logaction = new Actionlog();
$logaction->asset_id = $asset->id;
//$logaction->user_id = $loggedin->user_id ;
$logaction->location_id = NULL;
$logaction->user_id = Sentry::getUser()->id;
$log = $logaction->logaction('checkin');
$log = $logaction->logaction('checkin from');
// Redirect to the new asset page
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.checkin.success'));
+1 -1
View File
@@ -11,6 +11,7 @@ use Input;
use User;
use Asset;
use Lang;
use Actionlog;
use Location;
use Redirect;
use Sentry;
@@ -414,7 +415,6 @@ class UsersController extends AdminController {
public function getView($userId = null)
{
$user = User::find($userId);
// Show the page
return View::make('backend/users/view', compact('user'));
}
+9 -11
View File
@@ -5,22 +5,20 @@ class ActionLog extends Eloquent {
protected $table = 'asset_logs';
public $timestamps = false;
/**
* Get the parent category name
*/
public function assetlog()
{
public function assetlog() {
return $this->belongsTo('Asset','asset_id');
}
/**
* Get the parent category name
*/
public function userlog()
{
public function adminlog() {
return $this->belongsTo('User','user_id');
}
public function userlog() {
return $this->belongsTo('User','assigned_to');
}
/**
* Get the parent category name
*/
+8
View File
@@ -55,4 +55,12 @@ class Asset extends Elegant {
}
/**
* Get action logs for this asset
*/
public function asssetlog()
{
return $this->hasMany('Actionlog','asset_id');
}
}
+7 -1
View File
@@ -39,9 +39,15 @@ class User extends SentryUserModel {
public function assets()
{
return $this->hasMany('Asset', 'assigned_to');
}
/**
* Get action logs for this user
*/
public function userlog()
{
return $this->hasMany('Actionlog','checkedout_to');
}
}
+36 -2
View File
@@ -65,13 +65,47 @@ View User {{ $user->fullName() }} ::
<div class="col-md-6">
<div class="alert alert-warning alert-block">
<i class="icon-warning-sign"></i>
@lang('admin/users/table.noresults')
</div>
</div>
@endif
<h6>History for {{ $user->first_name }}</h6>
<br>
<!-- checked out assets table -->
@if (count($user->userlog) > 0)
<table class="table table-hover">
<thead>
<tr>
<th class="span3">Date</th>
<th class="span3"><span class="line"></span>Action</th>
<th class="span3"><span class="line"></span>Asset</th>
<th class="span3"><span class="line"></span>By</th>
</tr>
</thead>
<tbody>
@foreach ($user->userlog as $log)
<tr>
<td>{{ $log->added_on }}</td>
<td>{{ $log->action_type }}</td>
<td>{{ $log->assetlog->name }}</td>
<td>{{ $log->adminlog->fullName() }}</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="col-md-6">
<div class="alert alert-warning alert-block">
<i class="icon-warning-sign"></i>
@lang('admin/users/table.noresults')
</div>
</div>
@endif
</div>
</div>