mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Actionlog Class: Improvements and polymorphism (#2561)
* Save progress * Create a new action_log table to replace asset_log. Use Polymorphism to generalize class and targets. Port everything I can find to use it. Add a migration to port the asset_logs table to action_logs. * Allow accepted_id to be nullable. * Comment out the thread_id migration, because it b0rks on a new database with the move. I'm unsure if the thread_id does anything...It doesn't seem to be used * Clean up all old methods from Actionlog model. Port everything to use new cleaner interface. * Port the actionlog factory to fix travis. * Adjust code to work on php5. Also fix lurking adminlog call. * Remove weird code * Port the pave command. Also fix dangling adminlog
This commit is contained in:
parent
35f3f1432f
commit
e86adccf19
|
@ -77,6 +77,8 @@ class PaveIt extends Command
|
|||
DB::statement('delete from asset_logs');
|
||||
DB::statement('delete from asset_maintenances');
|
||||
DB::statement('delete from asset_uploads');
|
||||
DB::statement('delete from action_logs');
|
||||
DB::statement('delete from checkout_requests');
|
||||
DB::statement('delete from consumables_users');
|
||||
DB::statement('delete from custom_field_custom_fieldset');
|
||||
DB::statement('delete from custom_fields');
|
||||
|
@ -92,10 +94,12 @@ class PaveIt extends Command
|
|||
\DB::statement('drop table IF EXISTS accessories_users');
|
||||
\DB::statement('drop table IF EXISTS accessories');
|
||||
\DB::statement('drop table IF EXISTS asset_logs');
|
||||
\DB::statement('drop table IF EXISTS action_logs');
|
||||
\DB::statement('drop table IF EXISTS asset_maintenances');
|
||||
\DB::statement('drop table IF EXISTS asset_uploads');
|
||||
\DB::statement('drop table IF EXISTS assets');
|
||||
\DB::statement('drop table IF EXISTS categories');
|
||||
\DB::statement('drop table IF EXISTS checkout_requests');
|
||||
\DB::statement('drop table IF EXISTS companies');
|
||||
\DB::statement('drop table IF EXISTS consumables_users');
|
||||
\DB::statement('drop table IF EXISTS consumables');
|
||||
|
|
|
@ -309,14 +309,7 @@ class AccessoriesController extends Controller
|
|||
'user_id' => Auth::user()->id,
|
||||
'assigned_to' => e(Input::get('assigned_to'))));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $accessory->id;
|
||||
$logaction->asset_id = 0;
|
||||
$logaction->checkedout_to = $accessory->assigned_to;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->location_id = $user->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $accessory->logCheckout(e(Input::get('note')));
|
||||
|
||||
|
||||
|
||||
|
@ -340,11 +333,11 @@ class AccessoriesController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/accessories/'.$accessory->id.'/view'.'|'.$accessory->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => 'Accessory <'.config('app.url').'/admin/accessories/'.$accessory->id.'/view'.'|'.$accessory->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
]
|
||||
])->send('Accessory Checked Out');
|
||||
|
@ -355,9 +348,6 @@ class AccessoriesController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
$accessory_user = DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
|
@ -435,8 +425,7 @@ class AccessoriesController extends Controller
|
|||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->checkedout_to = e($accessory_user->assigned_to);
|
||||
$logaction = $accessory->logCheckin(e(Input::get('note')));
|
||||
$return_to = e($accessory_user->assigned_to);
|
||||
$admin_user = Auth::user();
|
||||
|
||||
|
@ -444,12 +433,6 @@ class AccessoriesController extends Controller
|
|||
// Was the accessory updated?
|
||||
if (DB::table('accessories_users')->where('id', '=', $accessory_user->id)->delete()) {
|
||||
|
||||
$logaction->accessory_id = e($accessory->id);
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->user_id = e($admin_user->id);
|
||||
$logaction->note = e(Input::get('note'));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
if ($settings->slack_endpoint) {
|
||||
|
@ -469,7 +452,7 @@ class AccessoriesController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked In:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/accessories/'.e($accessory->id).'/view'.'|'.e($accessory->name).'> checked in by <'.config('app.url').'/admin/users/'.e($admin_user->id).'/view'.'|'.e($admin_user->fullName()).'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' <'.config('app.url').'/admin/accessories/'.e($accessory->id).'/view'.'|'.e($accessory->name).'> checked in by <'.config('app.url').'/admin/users/'.e($admin_user->id).'/view'.'|'.e($admin_user->fullName()).'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
|
@ -485,9 +468,6 @@ class AccessoriesController extends Controller
|
|||
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkin from');
|
||||
|
||||
if (!is_null($accessory_user->assigned_to)) {
|
||||
$user = User::find($accessory_user->assigned_to);
|
||||
}
|
||||
|
|
|
@ -659,7 +659,7 @@ class AssetsController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked In:',
|
||||
'value' => strtoupper($logaction->asset_type).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.e($asset->showAssetName()).'> checked in by <'.config('app.url').'/admin/users/'.Auth::user()->id.'/view'.'|'.e(Auth::user()->fullName()).'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.e($asset->showAssetName()).'> checked in by <'.config('app.url').'/admin/users/'.Auth::user()->id.'/view'.'|'.e(Auth::user()->fullName()).'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
|
@ -1150,11 +1150,12 @@ class AssetsController extends Controller
|
|||
$item[$asset_tag][$batch_counter]['user_id'] = $user->id;
|
||||
|
||||
Actionlog::firstOrCreate(array(
|
||||
'asset_id' => $asset->id,
|
||||
'asset_type' => 'hardware',
|
||||
'item_id' => $asset->id,
|
||||
'item_type' => Asset::class,
|
||||
'user_id' => Auth::user()->id,
|
||||
'note' => 'Checkout imported by '.Auth::user()->fullName().' from history importer',
|
||||
'checkedout_to' => $item[$asset_tag][$batch_counter]['user_id'],
|
||||
'target_id' => $item[$asset_tag][$batch_counter]['user_id'],
|
||||
'target_type' => User::class,
|
||||
'created_at' => $item[$asset_tag][$batch_counter]['checkout_date'],
|
||||
'action_type' => 'checkout'
|
||||
)
|
||||
|
@ -1190,11 +1191,11 @@ class AssetsController extends Controller
|
|||
$asset_batch[$x]['real_checkin'] = $checkin_date;
|
||||
|
||||
Actionlog::firstOrCreate(array(
|
||||
'asset_id' => $asset_batch[$x]['asset_id'],
|
||||
'asset_type' => 'hardware',
|
||||
'item_id' => $asset_batch[$x]['asset_id'],
|
||||
'item_type' => Asset::class,
|
||||
'user_id' => Auth::user()->id,
|
||||
'note' => 'Checkin imported by ' . Auth::user()->fullName() . ' from history importer',
|
||||
'checkedout_to' => null,
|
||||
'target_id' => null,
|
||||
'created_at' => $checkin_date,
|
||||
'action_type' => 'checkin'
|
||||
)
|
||||
|
@ -1272,15 +1273,8 @@ class AssetsController extends Controller
|
|||
$upload_success = $file->move($destinationPath, $filename);
|
||||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('notes'));
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
$logaction->filename = $filename;
|
||||
$log = $logaction->logaction('uploaded');
|
||||
$asset->logUpload($filename, e(Input::get('notes')));
|
||||
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('admin/hardware/message.upload.nofiles'));
|
||||
|
@ -1537,8 +1531,8 @@ class AssetsController extends Controller
|
|||
->update($update_array)) {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $key;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $key;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
|
||||
if (Input::has('rtd_location_id')) {
|
||||
|
@ -1595,8 +1589,8 @@ class AssetsController extends Controller
|
|||
->update($update_array)) {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $asset->id;
|
||||
$logaction->created_at = date("Y-m-d H:i:s");
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$log = $logaction->logaction('deleted');
|
||||
|
|
|
@ -349,13 +349,7 @@ class ComponentsController extends Controller
|
|||
'assigned_qty' => e(Input::get('assigned_qty')),
|
||||
'asset_id' => $asset_id));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->component_id = $component->id;
|
||||
$logaction->asset_id = $asset_id;
|
||||
$logaction->asset_type = 'component';
|
||||
$logaction->location_id = $asset->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $component->logCheckout(e(Input::get('note')), $asset_id);
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
|
@ -375,7 +369,7 @@ class ComponentsController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' <'.config('app.url').'/admin/components/'.$component->id.'/view'.'|'.$component->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
|
@ -389,9 +383,6 @@ class ComponentsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
// Redirect to the new component page
|
||||
return redirect()->to("admin/components")->with('success', trans('admin/components/message.checkout.success'));
|
||||
|
||||
|
|
|
@ -316,14 +316,7 @@ class ConsumablesController extends Controller
|
|||
'user_id' => $admin_user->id,
|
||||
'assigned_to' => e(Input::get('assigned_to'))));
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->consumable_id = $consumable->id;
|
||||
$logaction->checkedout_to = $consumable->assigned_to;
|
||||
$logaction->asset_type = 'consumable';
|
||||
$logaction->asset_id = 0;
|
||||
$logaction->location_id = $user->location_id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction = $consumable->logCheckout(e(Input::get('note')));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
|
@ -343,7 +336,7 @@ class ConsumablesController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked Out:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
'value' => strtoupper($logaction->item_type).' <'.config('app.url').'/admin/consumables/'.$consumable->id.'/view'.'|'.$consumable->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$user->fullName().'> by <'.config('app.url').'/admin/users/'.$admin_user->id.'/view'.'|'.$admin_user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
|
@ -357,9 +350,6 @@ class ConsumablesController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
$consumable_user = DB::table('consumables_users')->where('assigned_to', '=', $consumable->assigned_to)->where('consumable_id', '=', $consumable->id)->first();
|
||||
|
||||
$data['log_id'] = $logaction->id;
|
||||
|
|
|
@ -30,8 +30,8 @@ class DashboardController extends Controller
|
|||
// Show the page
|
||||
if (Auth::user()->hasAccess('admin')) {
|
||||
|
||||
$recent_activity = Actionlog::orderBy('created_at', 'DESC')
|
||||
->with('accessorylog', 'consumablelog', 'licenselog', 'assetlog', 'adminlog', 'userlog', 'componentlog')
|
||||
$recent_activity = Actionlog::latest()
|
||||
->with('item')
|
||||
->take(20)
|
||||
->get();
|
||||
|
||||
|
|
|
@ -334,11 +334,11 @@ class LicensesController extends Controller
|
|||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = abs($difference)." seats";
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->note = '-'.abs($difference)." seats";
|
||||
$logaction->target_id = null;
|
||||
$log = $logaction->logaction('delete seats');
|
||||
|
||||
} else {
|
||||
|
@ -359,10 +359,11 @@ class LicensesController extends Controller
|
|||
|
||||
//Log the addition of license to the log.
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = abs($difference)." seats";
|
||||
$logaction->note = '+'.abs($difference)." seats";
|
||||
$logaction->target_id = null;
|
||||
$log = $logaction->logaction('add seats');
|
||||
}
|
||||
$license->seats = e(Input::get('seats'));
|
||||
|
@ -543,14 +544,10 @@ class LicensesController extends Controller
|
|||
// Was the asset updated?
|
||||
if ($licenseseat->save()) {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
|
||||
//$logaction->location_id = $assigned_to->location_id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->asset_id = $licenseseat->license_id;
|
||||
$licenseseat->logCheckout(e(Input::get('note')));
|
||||
|
||||
$data['license_id'] =$licenseseat->license_id;
|
||||
$data['note'] = e(Input::get('note'));
|
||||
|
||||
$license = License::find($licenseseat->license_id);
|
||||
$settings = Setting::getSettings();
|
||||
|
@ -558,11 +555,9 @@ class LicensesController extends Controller
|
|||
|
||||
// Update the asset data
|
||||
if (e(Input::get('assigned_to')) == '') {
|
||||
$logaction->checkedout_to = null;
|
||||
$slack_msg = strtoupper($logaction->asset_type).' license <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
$slack_msg = 'License <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/hardware/'.$asset->id.'/view|'.$asset->showAssetName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
} else {
|
||||
$logaction->checkedout_to = e(Input::get('assigned_to'));
|
||||
$slack_msg = strtoupper($logaction->asset_type).' license <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$is_assigned_to->fullName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
$slack_msg = 'License <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked out to <'.config('app.url').'/admin/users/'.$user->id.'/view|'.$is_assigned_to->fullName().'> by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.';
|
||||
}
|
||||
|
||||
|
||||
|
@ -588,7 +583,7 @@ class LicensesController extends Controller
|
|||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
|
||||
|
||||
|
@ -602,9 +597,6 @@ class LicensesController extends Controller
|
|||
|
||||
}
|
||||
|
||||
$log = $logaction->logaction('checkout');
|
||||
|
||||
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to("admin/licenses")->with('success', trans('admin/licenses/message.checkout.success'));
|
||||
}
|
||||
|
@ -683,8 +675,6 @@ class LicensesController extends Controller
|
|||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
$return_to = $licenseseat->assigned_to;
|
||||
$logaction = new Actionlog();
|
||||
$logaction->checkedout_to = $licenseseat->assigned_to;
|
||||
|
||||
// Update the asset data
|
||||
$licenseseat->assigned_to = null;
|
||||
|
@ -694,11 +684,7 @@ class LicensesController extends Controller
|
|||
|
||||
// Was the asset updated?
|
||||
if ($licenseseat->save()) {
|
||||
$logaction->asset_id = $licenseseat->license_id;
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->user_id = $user->id;
|
||||
$licenseseat->logCheckin(e(Input::get('note')));
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
|
||||
|
@ -719,11 +705,11 @@ class LicensesController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'Checked In:',
|
||||
'value' => strtoupper($logaction->asset_type).' <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked in by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.'
|
||||
'value' => 'License: <'.config('app.url').'/admin/licenses/'.$license->id.'/view'.'|'.$license->name.'> checked in by <'.config('app.url').'/admin/users/'.$user->id.'/view'.'|'.$user->fullName().'>.'
|
||||
],
|
||||
[
|
||||
'title' => 'Note:',
|
||||
'value' => e($logaction->note)
|
||||
'value' => e(Input::get('note'))
|
||||
],
|
||||
|
||||
]
|
||||
|
@ -736,9 +722,6 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
|
||||
$log = $logaction->logaction('checkin from');
|
||||
|
||||
|
||||
|
||||
if ($backto=='user') {
|
||||
return redirect()->to("admin/users/".$return_to.'/view')->with('success', trans('admin/licenses/message.checkin.success'));
|
||||
|
@ -853,16 +836,8 @@ class LicensesController extends Controller
|
|||
$filename .= '-'.str_slug($file->getClientOriginalName()).'.'.$extension;
|
||||
$upload_success = $file->move($destinationPath, $filename);
|
||||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('notes'));
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->created_at = date("Y-m-d h:i:s");
|
||||
$logaction->filename = $filename;
|
||||
$log = $logaction->logaction('uploaded');
|
||||
//Log the upload to the log
|
||||
$license->logUpload($filename, e(Input::get('notes')));
|
||||
} else {
|
||||
return redirect()->back()->with('error', trans('admin/licenses/message.upload.invalidfiles'));
|
||||
}
|
||||
|
|
|
@ -330,12 +330,8 @@ class ReportsController extends Controller
|
|||
public function getActivityReport()
|
||||
{
|
||||
$log_actions = Actionlog::orderBy('created_at', 'DESC')
|
||||
->with('adminlog')
|
||||
->with('accessorylog')
|
||||
->with('assetlog')
|
||||
->with('licenselog')
|
||||
->with('userlog')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->with('user')
|
||||
->with('item')
|
||||
->get();
|
||||
|
||||
return View::make('reports/activity', compact('log_actions'));
|
||||
|
@ -755,11 +751,11 @@ class ReportsController extends Controller
|
|||
|
||||
foreach ($assetsForReport as $assetItem) {
|
||||
$row = [ ];
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->model->category->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->model->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->showAssetName()));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->asset_tag));
|
||||
$row[] = str_replace(',', '', e($assetItem->assetlog->assigneduser->fullName()));
|
||||
$row[] = str_replace(',', '', e($assetItem->item->model->category->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->item->model->name));
|
||||
$row[] = str_replace(',', '', e($assetItem->item->showAssetName()));
|
||||
$row[] = str_replace(',', '', e($assetItem->item->asset_tag));
|
||||
$row[] = str_replace(',', '', e($assetItem->item->assigneduser->fullName()));
|
||||
$rows[] = implode($row, ',');
|
||||
}
|
||||
|
||||
|
|
|
@ -495,9 +495,10 @@ class UsersController extends Controller
|
|||
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->checkedout_to = $asset->assigned_to;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_id = $asset->id;
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->target_id = $asset->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin asset and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
|
@ -514,9 +515,10 @@ class UsersController extends Controller
|
|||
$accessory_array[] = $accessory->accessory_id;
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->accessory_id = $accessory->id;
|
||||
$logaction->checkedout_to = $accessory->assigned_to;
|
||||
$logaction->asset_type = 'accessory';
|
||||
$logaction->item_id = $accessory->id;
|
||||
$logaction->item_type = Accessory::class;
|
||||
$logaction->target_id = $accessory->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin accessory and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
|
@ -528,9 +530,10 @@ class UsersController extends Controller
|
|||
$license_array[] = $license->id;
|
||||
// Update the asset log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $license->id;
|
||||
$logaction->checkedout_to = $license->assigned_to;
|
||||
$logaction->asset_type = 'software';
|
||||
$logaction->item_id = $license->id;
|
||||
$logaction->item_type = License::class;
|
||||
$logaction->target_id = $license->assigned_to;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = 'Bulk checkin license and delete user';
|
||||
$logaction->logaction('checkin from');
|
||||
|
@ -598,7 +601,7 @@ class UsersController extends Controller
|
|||
|
||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId);
|
||||
|
||||
$userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
|
||||
$userlog = $user->userlog->load('item');
|
||||
|
||||
if (isset($user->id)) {
|
||||
|
||||
|
@ -1017,11 +1020,11 @@ class UsersController extends Controller
|
|||
|
||||
//Log the deletion of seats to the log
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $user->id;
|
||||
$logaction->asset_type = 'user';
|
||||
$logaction->item_id = $user->id;
|
||||
$logaction->item_type = User::class;
|
||||
$logaction->user_id = Auth::user()->id;
|
||||
$logaction->note = e(Input::get('notes'));
|
||||
$logaction->checkedout_to = null;
|
||||
$logaction->target_id = null;
|
||||
$logaction->created_at = date("Y-m-d h:i:s");
|
||||
$logaction->filename = $filename;
|
||||
$logaction->action_type = 'uploaded';
|
||||
|
|
|
@ -39,7 +39,7 @@ class ViewAssetsController extends Controller
|
|||
|
||||
$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find(Auth::user()->id);
|
||||
|
||||
$userlog = $user->userlog->load('assetlog', 'consumablelog', 'assetlog.model', 'licenselog', 'accessorylog', 'userlog', 'adminlog');
|
||||
$userlog = $user->userlog->load('item', 'item.model', 'user', 'target');
|
||||
|
||||
|
||||
|
||||
|
@ -79,14 +79,15 @@ class ViewAssetsController extends Controller
|
|||
} else {
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $data['asset_id'] = $asset->id;
|
||||
$logaction->asset_type = $data['asset_type'] = 'hardware';
|
||||
$logaction->item_id = $data['asset_id'] = $asset->id;
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->created_at = $data['requested_date'] = date("Y-m-d h:i:s");
|
||||
|
||||
$data['asset_type'] = 'hardware';
|
||||
if ($user->location_id) {
|
||||
$logaction->location_id = $user->location_id;
|
||||
}
|
||||
$logaction->user_id = $data['user_id'] = Auth::user()->id;
|
||||
$logaction->target_id = $data['user_id'] = Auth::user()->id;
|
||||
$logaction->target_type = User::class;
|
||||
$log = $logaction->logaction('requested');
|
||||
|
||||
$data['requested_by'] = $user->fullName();
|
||||
|
@ -119,7 +120,7 @@ class ViewAssetsController extends Controller
|
|||
'fields' => [
|
||||
[
|
||||
'title' => 'REQUESTED:',
|
||||
'value' => strtoupper($logaction->asset_type).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.$asset->showAssetName().'> requested by <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.Auth::user()->fullName().'>.'
|
||||
'value' => class_basename(strtoupper($logaction->item_type)).' asset <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.$asset->showAssetName().'> requested by <'.config('app.url').'/hardware/'.$asset->id.'/view'.'|'.Auth::user()->fullName().'>.'
|
||||
]
|
||||
|
||||
]
|
||||
|
@ -143,7 +144,7 @@ class ViewAssetsController extends Controller
|
|||
public function getAcceptAsset($logID = null)
|
||||
{
|
||||
|
||||
if (!$findlog = DB::table('asset_logs')->where('id', '=', $logID)->first()) {
|
||||
if (!$findlog = Actionlog::where('id', $logID)->first()) {
|
||||
echo 'no record';
|
||||
//return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
@ -155,23 +156,7 @@ class ViewAssetsController extends Controller
|
|||
return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
|
||||
}
|
||||
|
||||
// Asset
|
||||
if (($findlog->asset_id!='') && ($findlog->asset_type=='hardware')) {
|
||||
$item = Asset::find($findlog->asset_id);
|
||||
|
||||
// software
|
||||
} elseif (($findlog->asset_id!='') && ($findlog->asset_type=='software')) {
|
||||
$item = License::find($findlog->asset_id);
|
||||
// accessories
|
||||
} elseif ($findlog->accessory_id!='') {
|
||||
$item = Accessory::find($findlog->accessory_id);
|
||||
// consumable
|
||||
} elseif ($findlog->consumable_id!='') {
|
||||
$item = Consumable::find($findlog->consumable_id);
|
||||
// components
|
||||
} elseif ($findlog->component_id!='') {
|
||||
$item = Component::find($findlog->component_id);
|
||||
}
|
||||
$item = $findlog->item;
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($item)) {
|
||||
|
@ -189,7 +174,7 @@ class ViewAssetsController extends Controller
|
|||
{
|
||||
|
||||
// Check if the asset exists
|
||||
if (is_null($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) {
|
||||
if (is_null($findlog = Actionlog::where('id', $logID)->first())) {
|
||||
// Redirect to the asset management page
|
||||
return redirect()->to('account/view-assets')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
@ -221,56 +206,24 @@ class ViewAssetsController extends Controller
|
|||
$accepted="rejected";
|
||||
$return_msg = trans('admin/users/message.declined');
|
||||
}
|
||||
|
||||
$logaction->item_id = $findlog->item_id;
|
||||
$logaction->item_type = $findlog->item_type;
|
||||
// Asset
|
||||
if (($findlog->asset_id!='') && ($findlog->asset_type=='hardware')) {
|
||||
$logaction->asset_id = $findlog->asset_id;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
|
||||
if (($findlog->item_id!='') && ($findlog->item_type==Asset::class)) {
|
||||
if (Input::get('asset_acceptance')!='accepted') {
|
||||
DB::table('assets')
|
||||
->where('id', $findlog->asset_id)
|
||||
->where('id', $findlog->item_id)
|
||||
->update(array('assigned_to' => null));
|
||||
}
|
||||
|
||||
|
||||
// software
|
||||
} elseif (($findlog->asset_id!='') && ($findlog->asset_type=='software')) {
|
||||
$logaction->asset_id = $findlog->asset_id;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->component_id = null;
|
||||
$logaction->asset_type = 'software';
|
||||
|
||||
// accessories
|
||||
} elseif ($findlog->accessory_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->component_id = null;
|
||||
$logaction->accessory_id = $findlog->accessory_id;
|
||||
$logaction->asset_type = 'accessory';
|
||||
// accessories
|
||||
} elseif ($findlog->consumable_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->component_id = null;
|
||||
$logaction->consumable_id = $findlog->consumable_id;
|
||||
$logaction->asset_type = 'consumable';
|
||||
} elseif ($findlog->component_id!='') {
|
||||
$logaction->asset_id = null;
|
||||
$logaction->accessory_id = null;
|
||||
$logaction->consumable_id = null;
|
||||
$logaction->component_id = $findlog->component_id;
|
||||
$logaction->asset_type = 'component';
|
||||
}
|
||||
|
||||
$logaction->checkedout_to = $findlog->checkedout_to;
|
||||
$logaction->target_id = $findlog->target_id;
|
||||
|
||||
$logaction->note = e(Input::get('note'));
|
||||
$logaction->user_id = $user->id;
|
||||
$logaction->accepted_at = date("Y-m-d h:i:s");
|
||||
$log = $logaction->logaction($logaction_msg);
|
||||
|
||||
$update_checkout = DB::table('asset_logs')
|
||||
$update_checkout = DB::table('action_logs')
|
||||
->where('id', $findlog->id)
|
||||
->update(array('accepted_id' => $logaction->id));
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Loggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
@ -12,8 +13,9 @@ use Watson\Validating\ValidatingTrait;
|
|||
*/
|
||||
class Accessory extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'accessories';
|
||||
|
@ -68,7 +70,7 @@ class Accessory extends Model
|
|||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'accessory_id')->where('asset_type', '=', 'accessory')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Accessory::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,77 +19,51 @@ class Actionlog extends Model implements ICompanyableChild
|
|||
|
||||
protected $dates = [ 'deleted_at' ];
|
||||
|
||||
protected $table = 'asset_logs';
|
||||
protected $table = 'action_logs';
|
||||
public $timestamps = true;
|
||||
protected $fillable = [ 'created_at', 'asset_type','user_id','asset_id','action_type','note','checkedout_to' ];
|
||||
protected $fillable = [ 'created_at', 'item_type','user_id','item_id','action_type','note','target_id', 'target_type' ];
|
||||
|
||||
public function getCompanyableParents()
|
||||
{
|
||||
return [ 'accessorylog', 'assetlog', 'licenselog', 'consumablelog' ];
|
||||
}
|
||||
|
||||
public function assetlog()
|
||||
// Eloquent Relationships below
|
||||
public function item()
|
||||
{
|
||||
return $this->morphTo('item')->withTrashed();
|
||||
}
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
->withTrashed();
|
||||
public function itemType()
|
||||
{
|
||||
// dd($this);
|
||||
return camel_case(class_basename($this->item_type));
|
||||
}
|
||||
|
||||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Asset', 'asset_id')
|
||||
return $this->morphTo('item')
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function licenselog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\License', 'asset_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function componentlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Component', 'component_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function accessorylog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Accessory', 'accessory_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function consumablelog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\Consumable', 'consumable_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function adminlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'user_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function userlog()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'checkedout_to')
|
||||
// return $this->belongsTo(User::class, 'target_id')
|
||||
return $this->target();
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id')
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function userasassetlog()
|
||||
public function target()
|
||||
{
|
||||
|
||||
return $this->belongsTo('\App\Models\User', 'asset_id')
|
||||
->withTrashed();
|
||||
return $this->morphTo('target');
|
||||
}
|
||||
|
||||
public function childlogs()
|
||||
|
@ -141,44 +115,10 @@ class Actionlog extends Model implements ICompanyableChild
|
|||
public function getListingOfActionLogsChronologicalOrder()
|
||||
{
|
||||
|
||||
return DB::table('asset_logs')
|
||||
->select('*')
|
||||
return $this->all()
|
||||
->where('action_type', '!=', 'uploaded')
|
||||
->orderBy('asset_id', 'asc')
|
||||
->orderBy('item_id', 'asc')
|
||||
->orderBy('created_at', 'asc')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* getLatestCheckoutActionForAssets
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function getLatestCheckoutActionForAssets()
|
||||
{
|
||||
|
||||
return DB::table('asset_logs')
|
||||
->select(DB::raw('asset_id, MAX(created_at) as last_created'))
|
||||
->where('action_type', '=', 'checkout')
|
||||
->groupBy('asset_id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* scopeCheckoutWithoutAcceptance
|
||||
*
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
* @author Vincent Sposato <vincent.sposato@gmail.com>
|
||||
* @version v1.0
|
||||
*/
|
||||
public function scopeCheckoutWithoutAcceptance($query)
|
||||
{
|
||||
|
||||
return $query->where('action_type', '=', 'checkout')
|
||||
->where('accepted_id', '=', null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\Setting;
|
||||
use Auth;
|
||||
use Config;
|
||||
use DateTime;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Log;
|
||||
use Parsedown;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
use App\Http\Traits\UniqueUndeletedTrait;
|
||||
use DateTime;
|
||||
use App\Models\Setting;
|
||||
use App\Helpers\Helper;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Model for Assets.
|
||||
|
@ -23,6 +24,7 @@ use Auth;
|
|||
*/
|
||||
class Asset extends Depreciable
|
||||
{
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
|
@ -209,10 +211,12 @@ class Asset extends Depreciable
|
|||
{
|
||||
|
||||
$logaction = new Actionlog();
|
||||
$logaction->asset_id = $this->id;
|
||||
$logaction->checkedout_to = $this->assigned_to;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->item_type = Asset::class;
|
||||
$logaction->item_id = $this->id;
|
||||
$logaction->target_type = User::class;
|
||||
$logaction->target_id = $this->assigned_to;
|
||||
$logaction->note = $note;
|
||||
$logaction->user_id = $admin->id;
|
||||
if ($checkout_at!='') {
|
||||
$logaction->created_at = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', strtotime($checkout_at)));
|
||||
} else {
|
||||
|
@ -225,15 +229,10 @@ class Asset extends Depreciable
|
|||
}
|
||||
} else {
|
||||
// Update the asset data to null, since it's being checked in
|
||||
$logaction->checkedout_to = $asset->assigned_to;
|
||||
$logaction->checkedout_to = '';
|
||||
$logaction->asset_id = $asset->id;
|
||||
$logaction->target_id = '';
|
||||
$logaction->location_id = null;
|
||||
$logaction->asset_type = 'hardware';
|
||||
$logaction->note = $note;
|
||||
$logaction->user_id = $admin->id;
|
||||
}
|
||||
$logaction->adminlog()->associate($admin);
|
||||
$logaction->user()->associate($admin);
|
||||
$log = $logaction->logaction($action);
|
||||
|
||||
return $logaction;
|
||||
|
@ -270,8 +269,8 @@ class Asset extends Depreciable
|
|||
public function uploads()
|
||||
{
|
||||
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', Asset::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
|
@ -308,8 +307,8 @@ class Asset extends Depreciable
|
|||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'hardware')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', Asset::class)
|
||||
->orderBy('created_at', 'desc')
|
||||
->withTrashed();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\ActionLog;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
@ -18,8 +19,9 @@ use Watson\Validating\ValidatingTrait;
|
|||
*/
|
||||
class Component extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'components';
|
||||
|
@ -85,7 +87,7 @@ class Component extends Model
|
|||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'component_id')->where('asset_type', '=', 'component')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Component::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Category;
|
||||
use App\Models\ActionLog;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\ConsumableAssignment;
|
||||
use App\Models\Location;
|
||||
use App\Models\Loggable;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Consumable extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $table = 'consumables';
|
||||
|
@ -85,7 +87,7 @@ class Consumable extends Model
|
|||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'consumable_id')->where('asset_type', '=', 'consumable')->orderBy('created_at', 'desc')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', Consumable::class)->orderBy('created_at', 'desc')->withTrashed();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Models\Company;
|
||||
use App\Models\Loggable;
|
||||
use DB;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class License extends Depreciable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use CompanyableTrait;
|
||||
use Loggable;
|
||||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
|
@ -54,8 +55,8 @@ class License extends Depreciable
|
|||
*/
|
||||
public function assetlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', License::class)
|
||||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
|
@ -64,8 +65,8 @@ class License extends Depreciable
|
|||
*/
|
||||
public function uploads()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'software')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', '=', License::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Loggable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
@ -8,6 +9,7 @@ class LicenseSeat extends Model implements ICompanyableChild
|
|||
{
|
||||
use CompanyableChildTrait;
|
||||
use SoftDeletes;
|
||||
use Loggable;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
protected $guarded = 'id';
|
||||
|
|
84
app/Models/Loggable.php
Normal file
84
app/Models/Loggable.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\CheckoutRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait Loggable
|
||||
{
|
||||
|
||||
public function log()
|
||||
{
|
||||
return $this->morphMany(Actionlog::class, 'item');
|
||||
}
|
||||
|
||||
public function logCheckout($note, $target = null /*target is overridable for components*/)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
// We need to special case licenses because of license_seat vs license. So much for clean polymorphism :)
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
$log->user_id = Auth::user()->id;
|
||||
if (!is_null($this->asset_id) || isset($target)) {
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $this->asset_id;
|
||||
} else if (!is_null($this->assigned_to)) {
|
||||
$log->target_type = User::class;
|
||||
$log->target_id = $this->assigned_to;
|
||||
}
|
||||
$item =call_user_func(array($log->target_type, 'find'), $log->target_id);
|
||||
$log->location_id = $item->location_id;
|
||||
$log->note = $note;
|
||||
$log->logaction('checkout');
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
public function logCheckin($note)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
$log->location_id = null;
|
||||
$log->note = $note;
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->logaction('checkin from');
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
public function logUpload($filename, $note)
|
||||
{
|
||||
$log = new Actionlog;
|
||||
if (static::class == LicenseSeat::class) {
|
||||
$log->item_type = License::class;
|
||||
$log->item_id = $this->license_id;
|
||||
} else {
|
||||
$log->item_type = static::class;
|
||||
$log->item_id = $this->id;
|
||||
}
|
||||
$log->user_id = Auth::user()->id;
|
||||
$log->note = $note;
|
||||
$log->target_id = null;
|
||||
$log->created_at = date("Y-m-d h:i:s");
|
||||
$log->filename = $filename;
|
||||
$log->logaction('uploaded');
|
||||
|
||||
return $log;
|
||||
}
|
||||
|
||||
}
|
|
@ -202,7 +202,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
*/
|
||||
public function userlog()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'checkedout_to')->orderBy('created_at', 'DESC')->withTrashed();
|
||||
return $this->hasMany('\App\Models\Actionlog', 'target_id')->orderBy('created_at', 'DESC')->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,8 +255,8 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||
*/
|
||||
public function uploads()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Actionlog', 'asset_id')
|
||||
->where('asset_type', '=', 'user')
|
||||
return $this->hasMany('\App\Models\Actionlog', 'item_id')
|
||||
->where('item_type', User::class)
|
||||
->where('action_type', '=', 'uploaded')
|
||||
->whereNotNull('filename')
|
||||
->orderBy('created_at', 'desc');
|
||||
|
|
|
@ -268,10 +268,11 @@ $factory->defineAs(App\Models\Actionlog::class, 'asset-checkout', function (Fake
|
|||
return [
|
||||
'user_id' => 1,
|
||||
'action_type' => 'checkout',
|
||||
'asset_id' => $faker->numberBetween(1, 10),
|
||||
'checkedout_to' => 1,
|
||||
'item_id' => $faker->numberBetween(1, 10),
|
||||
'target_id' => 1,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'asset_type' => 'hardware',
|
||||
'item_type' => 'App\\Models\\Asset',
|
||||
'note' => $faker->sentence,
|
||||
'user_id' => '1',
|
||||
];
|
||||
|
|
|
@ -64,39 +64,39 @@
|
|||
public function up()
|
||||
{
|
||||
|
||||
if (!Schema::hasColumn('asset_logs', 'thread_id')) {
|
||||
// if (!Schema::hasColumn('asset_logs', 'thread_id')) {
|
||||
|
||||
Schema::table( 'asset_logs', function ( Blueprint $table ) {
|
||||
// Schema::table( 'asset_logs', function ( Blueprint $table ) {
|
||||
|
||||
$table->integer( 'thread_id' )
|
||||
->nullable()
|
||||
->default( null );
|
||||
$table->index( 'thread_id' );
|
||||
} );
|
||||
}
|
||||
// $table->integer( 'thread_id' )
|
||||
// ->nullable()
|
||||
// ->default( null );
|
||||
// $table->index( 'thread_id' );
|
||||
// } );
|
||||
// }
|
||||
|
||||
$this->actionlog = new App\Models\Actionlog();
|
||||
$this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
|
||||
// $this->actionlog = new App\Models\Actionlog();
|
||||
// $this->assetLogs = $this->actionlog->getListingOfActionLogsChronologicalOrder();
|
||||
|
||||
foreach ($this->assetLogs as $assetLog) {
|
||||
// foreach ($this->assetLogs as $assetLog) {
|
||||
|
||||
if ($this->hasAssetChanged( $assetLog )) {
|
||||
$this->resetCurrentAssetInformation( $assetLog );
|
||||
}
|
||||
// if ($this->hasAssetChanged( $assetLog )) {
|
||||
// $this->resetCurrentAssetInformation( $assetLog );
|
||||
// }
|
||||
|
||||
if ($this->hasBegunNewChain( $assetLog )) {
|
||||
$this->startOfCurrentThread = false;
|
||||
continue;
|
||||
}
|
||||
// if ($this->hasBegunNewChain( $assetLog )) {
|
||||
// $this->startOfCurrentThread = false;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
$this->updateAssetLogWithThreadInformation( $assetLog );
|
||||
// $this->updateAssetLogWithThreadInformation( $assetLog );
|
||||
|
||||
if ($this->hasReachedEndOfChain( $assetLog )
|
||||
) {
|
||||
$this->clearCurrentAssetInformation();
|
||||
}
|
||||
// if ($this->hasReachedEndOfChain( $assetLog )
|
||||
// ) {
|
||||
// $this->clearCurrentAssetInformation();
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateActionlogTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('action_logs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id')->nullable();
|
||||
$table->string('action_type');
|
||||
$table->integer('target_id')->nullable(); // Was checkedout_to
|
||||
$table->integer('target_type')->nullable(); // For polymorphic thingies
|
||||
$table->integer('location_id')->nullable();
|
||||
$table->text('note')->nullable();
|
||||
$table->text('filename')->nullable();
|
||||
$table->string('item_type');
|
||||
$table->integer('item_id'); // Replaces asset_id, accessory_id, etc.
|
||||
$table->date('expected_checkin')->nullable()->default(null);
|
||||
$table->integer('accepted_id')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->integer('thread_id')
|
||||
->nullable()
|
||||
->default(null);
|
||||
$table->index('thread_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('action_logs');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class MigrateAssetLogToActionLog extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
//
|
||||
$logs = DB::table('asset_logs')->get();
|
||||
|
||||
foreach ($logs as $log) {
|
||||
// protected $fillable = [ 'created_at', 'asset_type','user_id','asset_id','action_type','note','checkedout_to' ];
|
||||
$a = new Actionlog(compact($log));
|
||||
// var_dump($log);
|
||||
$a->user_id = $log->user_id;
|
||||
|
||||
if (!is_null($log->asset_id)) {
|
||||
$a->item_id = $log->asset_id;
|
||||
if ($log->asset_type == "hardware") {
|
||||
$a->item_type = 'App\\Models\\Asset';
|
||||
} else {
|
||||
$a->item_type = 'App\\Models\\License';
|
||||
}
|
||||
}
|
||||
if (!is_null($log->accessory_id)) {
|
||||
$a->item_id = $log->accessory_id;
|
||||
$a->item_type = 'App\\Models\\Accessory';
|
||||
} else if (!is_null($log->consumable_id)) {
|
||||
$a->item_id = $log->consumable_id;
|
||||
$a->item_type = 'App\\Models\\Consumable';
|
||||
} else if (!is_null($log->component_id)) {
|
||||
$a->item_id = $log->component_id;
|
||||
$a->item_type = 'App\\Models\\Component';
|
||||
}
|
||||
$a->action_type = $log->action_type;
|
||||
// $a->checkout_to = $log->checkout_to;
|
||||
if(!is_null($log->checkedout_to)) {
|
||||
$a->target_id = $log->checkedout_to;
|
||||
$a->target_type = User::class;
|
||||
}
|
||||
if(!is_null($log->accepted_id)) {
|
||||
$a->target_id = $log->accepted_id;
|
||||
$a->target_type = User::class;
|
||||
}
|
||||
$a->location_id = $log->location_id;
|
||||
$a->created_at = $log->created_at;
|
||||
$a->updated_at = $log->updated_at;
|
||||
$a->deleted_at = $log->deleted_at;
|
||||
$a->note = $log->note;
|
||||
$a->expected_checkin = $log->expected_checkin;
|
||||
$a->thread_id = $log->thread_id;
|
||||
$a->accepted_id = $log->accepted_id;
|
||||
|
||||
$a->save();
|
||||
|
||||
}
|
||||
// dd($logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -247,65 +247,45 @@ View Assets for {{ $user->fullName() }}
|
|||
@foreach ($user->userlog as $log)
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
@if (($log->assetlog) && ($log->asset_type=="hardware"))
|
||||
@if ($log->itemType()=="asset")
|
||||
<i class="fa fa-barcode"></i>
|
||||
@elseif (($log->accessorylog) && ($log->asset_type=="accessory"))
|
||||
@elseif ($log->itemType()=="accessory")
|
||||
<i class="fa fa-keyboard-o"></i>
|
||||
@elseif (($log->consumablelog) && ($log->asset_type=="consumable"))
|
||||
@elseif ($log->itemType()=="consumable")
|
||||
<i class="fa fa-tint"></i>
|
||||
@elseif (($log->licenselog) && ($log->asset_type=="software"))
|
||||
@elseif ($log->itemType()=="license")
|
||||
<i class="fa fa-floppy-o"></i>
|
||||
@else
|
||||
<i class="fa fa-times"></i>
|
||||
<i class="fa fa-times"></i>
|
||||
@endif
|
||||
|
||||
</td>
|
||||
<td>{{ $log->action_type }}</td>
|
||||
<td>
|
||||
|
||||
@if (($log->assetlog) && ($log->asset_type=="hardware"))
|
||||
@if ($log->itemType()=="asset")
|
||||
@if ($log->item->deleted_at=='')
|
||||
|
||||
@if ($log->assetlog->deleted_at=='')
|
||||
|
||||
{{ $log->assetlog->showAssetName() }}
|
||||
{{ $log->item->showAssetName() }}
|
||||
|
||||
@else
|
||||
<del>{{ $log->assetlog->showAssetName() }}</del> (deleted)
|
||||
<del>{{ $log->item->showAssetName() }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->licenselog) && ($log->asset_type=="software"))
|
||||
|
||||
@if ($log->licenselog->deleted_at=='')
|
||||
|
||||
{{ $log->licenselog->name }}
|
||||
|
||||
@else
|
||||
<del>{{ $log->licenselog->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->consumablelog) && ($log->asset_type=="consumable"))
|
||||
|
||||
@if ($log->consumablelog->deleted_at=='')
|
||||
{{ $log->consumablelog->name }}
|
||||
@elseif (!is_null($log->itemType()))
|
||||
@if ($log->item->deleted_at=='')
|
||||
{{ $log->item->name }}
|
||||
@else
|
||||
<del>{{ $log->consumablelog->name }}</del> (deleted)
|
||||
<del>{{ $log->item->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->accessorylog) && ($log->asset_type=="accessory"))
|
||||
@if ($log->accessorylog->deleted_at=='')
|
||||
{{ $log->accessorylog->name }}
|
||||
@else
|
||||
<del>{{ $log->accessorylog->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@else
|
||||
{{ trans('general.bad_data') }}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@if ($log->adminlog)
|
||||
{{ $log->adminlog->fullName() }}
|
||||
@if ($log->user)
|
||||
{{ $log->user->fullName() }}
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $log->created_at }}</td>
|
||||
|
|
|
@ -111,15 +111,15 @@
|
|||
@foreach ($recent_activity as $activity)
|
||||
<tr>
|
||||
<td>
|
||||
@if ($activity->asset_type=="hardware")
|
||||
@if ($activity->itemType()=="asset")
|
||||
<i class="fa fa-barcode"></i>
|
||||
@elseif ($activity->asset_type=="accessory")
|
||||
@elseif ($activity->itemType()=="accessory")
|
||||
<i class="fa fa-keyboard-o"></i>
|
||||
@elseif ($activity->asset_type=="consumable")
|
||||
@elseif ($activity->itemType()=="consumable")
|
||||
<i class="fa fa-tint"></i>
|
||||
@elseif ($activity->asset_type=="license")
|
||||
@elseif ($activity->itemType()=="license")
|
||||
<i class="fa fa-floppy-o"></i>
|
||||
@elseif ($activity->asset_type=="component")
|
||||
@elseif ($activity->itemType()=="component")
|
||||
<i class="fa fa-hdd-o"></i>
|
||||
@else
|
||||
<i class="fa fa-paperclip"></i>
|
||||
|
@ -128,8 +128,8 @@
|
|||
<td>{{ date("M d, Y g:iA", strtotime($activity->created_at)) }}</td>
|
||||
<td>
|
||||
@if ($activity->action_type!='requested')
|
||||
@if ($activity->adminlog)
|
||||
<a href="{{ route('view/user', $activity->user_id) }}">{{ $activity->adminlog->fullName() }}</a>
|
||||
@if ($activity->user)
|
||||
<a href="{{ route('view/user', $activity->user_id) }}">{{ $activity->user->fullName() }}</a>
|
||||
@else
|
||||
Deleted Admin
|
||||
@endif
|
||||
|
@ -140,34 +140,23 @@
|
|||
{{ strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))) }}
|
||||
</td>
|
||||
<td>
|
||||
@if (($activity->assetlog) && ($activity->asset_type=="hardware"))
|
||||
<a href="{{ route('view/hardware', $activity->asset_id) }}">{{ $activity->assetlog->asset_tag }} - {{ $activity->assetlog->showAssetName() }}</a>
|
||||
@elseif (($activity->licenselog) && ($activity->asset_type=="software"))
|
||||
<a href="{{ route('view/license', $activity->asset_id) }}">{{ $activity->licenselog->name }}</a>
|
||||
@elseif (($activity->consumablelog) && ($activity->asset_type=="consumable"))
|
||||
<a href="{{ route('view/consumable', $activity->consumable_id) }}">{{ $activity->consumablelog->name }}</a>
|
||||
@elseif (($activity->accessorylog) && ($activity->asset_type=="accessory"))
|
||||
<a href="{{ route('view/accessory', $activity->accessory_id) }}">{{ $activity->accessorylog->name }}</a>
|
||||
@elseif (($activity->componentlog) && ($activity->asset_type=="component"))
|
||||
<a href="{{ route('view/component', $activity->component_id) }}">{{ $activity->componentlog->name }}</a>
|
||||
@elseif (($activity->assetlog) && ($activity->action_type=="uploaded") && ($activity->asset_type=="hardware"))
|
||||
<a href="{{ route('view/hardware', $activity->asset_id) }}">{{ $activity->assetlog->showAssetName() }}</a>
|
||||
|
||||
@if (($activity->item) && ($activity->itemType()=="asset"))
|
||||
<a href="{{ route('view/hardware', $activity->item_id) }}">{{ $activity->item->asset_tag }} - {{ $activity->item->showAssetName() }}</a>
|
||||
@elseif ($activity->item)
|
||||
<a href="{{ route('view/'. $activity->itemType(), $activity->item_id) }}">{{ $activity->item->name }}</a>
|
||||
@endif
|
||||
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if (($activity->userasassetlog) && ($activity->action_type=="uploaded") && ($activity->asset_type=="user"))
|
||||
<a href="{{ route('view/user', $activity->asset_id) }}">{{ $activity->userasassetlog->fullName() }}</a>
|
||||
@elseif (($activity->componentlog) && ($activity->asset_type=="component"))
|
||||
<a href="{{ route('view/hardware', $activity->asset_id) }}">{{ $activity->assetlog->showAssetName() }}</a>
|
||||
@elseif($activity->action_type=='requested')
|
||||
@if ($activity->adminlog)
|
||||
<a href="{{ route('view/user', $activity->user_id) }}">{{ $activity->adminlog->fullName() }}</a>
|
||||
@endif
|
||||
@elseif ($activity->userlog)
|
||||
<a href="{{ route('view/user', $activity->checkedout_to) }}">{{ $activity->userlog->fullName() }}</a>
|
||||
@if (($activity->userasassetlog) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user"))
|
||||
<a href="{{ route('view/user', $activity->target_id) }}">{{ $activity->userasassetlog->fullName() }}</a>
|
||||
@elseif (($activity->item) && ($activity->target instanceof \App\Models\Asset))
|
||||
<a href="{{ route('view/hardware', $activity->target_id) }}">{{ $activity->target->showAssetName() }}</a>
|
||||
@elseif (($activity->item) && ($activity->target instanceof \App\Models\User))
|
||||
<a href="{{route('view/user', $activity->target_id) }}"> {{ $activity->target->fullName() }}</a>
|
||||
@elseif ($activity->action_type=='requested') <!--The user is who requested the item, not the target-->
|
||||
<a href="{{ route('view/user', $activity->user_id) }}">{{ $activity->user->fullName() }}</a>
|
||||
|
||||
@endif
|
||||
|
||||
|
|
|
@ -273,19 +273,19 @@
|
|||
<td>{{ $log->created_at }}</td>
|
||||
<td>
|
||||
@if (isset($log->user_id))
|
||||
{{ $log->adminlog->fullName() }}
|
||||
{{ $log->user->fullName() }}
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $log->action_type }}</td>
|
||||
<td>
|
||||
@if ((isset($log->checkedout_to)) && ($log->checkedout_to!=0) && ($log->checkedout_to!=''))
|
||||
@if ((isset($log->target_id)) && ($log->target_id!=0) && ($log->target_id!=''))
|
||||
|
||||
@if ($log->userlog->deleted_at=='')
|
||||
<a href="{{ route('view/user', $log->checkedout_to) }}">
|
||||
{{ $log->userlog->fullName() }}
|
||||
@if ($log->target->deleted_at=='')
|
||||
<a href="{{ route('view/user', $log->target_id) }}">
|
||||
{{ $log->user->fullName() }}
|
||||
</a>
|
||||
@else
|
||||
<del>{{ $log->userlog->fullName() }}</del>
|
||||
<del>{{ $log->user->fullName() }}</del>
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
|
|
@ -513,26 +513,42 @@
|
|||
<tr>
|
||||
<td>{{ $log->created_at }}</td>
|
||||
<td>
|
||||
@if (isset($log->adminlog))
|
||||
{{ $log->adminlog->fullName() }}
|
||||
@else
|
||||
Deleted Admin
|
||||
@if ($log->action_type != 'requested')
|
||||
@if (isset($log->user))
|
||||
{{ $log->user->fullName() }}
|
||||
@else
|
||||
Deleted Admin
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $log->action_type }}</td>
|
||||
<td>
|
||||
@if ((isset($log->checkedout_to)) && ($log->checkedout_to!=0) && ($log->checkedout_to!=''))
|
||||
|
||||
@if ($log->userlog)
|
||||
@if ($log->action_type=='uploaded')
|
||||
|
||||
@if ($log->userlog->deleted_at=='')
|
||||
<a href="{{ route('view/user', $log->checkedout_to) }}">
|
||||
{{ $log->userlog->fullName() }}
|
||||
{{ $log->filename }}
|
||||
@elseif ((isset($log->target_id)) && ($log->target_id!=0) && ($log->target_id!=''))
|
||||
|
||||
|
||||
@if ($log->target instanceof \App\Models\User)
|
||||
|
||||
@if ($log->target->deleted_at=='')
|
||||
<a href="{{ route('view/user', $log->target_id) }}">
|
||||
{{ $log->target->fullName() }}
|
||||
</a>
|
||||
|
||||
@else
|
||||
<del>{{ $log->userlog->fullName() }}</del>
|
||||
<del>{{ $log->target->fullName() }}</del>
|
||||
@endif
|
||||
@elseif($log->target instanceof \App\Models\Asset)
|
||||
@if ($log->target->deleted_at=='')
|
||||
<a href="{{ route('view/hardware', $log->target_id) }}">
|
||||
{{ $log->target->showAssetName() }}
|
||||
</a>
|
||||
|
||||
@else
|
||||
<del>{{ $log->target->showAssetName() }}</del>
|
||||
@endif
|
||||
@else
|
||||
Deleted User
|
||||
@endif
|
||||
|
|
|
@ -370,14 +370,14 @@
|
|||
<td>{{ $log->created_at }}</td>
|
||||
<td>
|
||||
@if (isset($log->user_id))
|
||||
{{ $log->adminlog->fullName() }}
|
||||
<a href="{{ route('view/user', $log->user_id)}}">{{ $log->user->fullName() }}</a>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $log->action_type }}</td>
|
||||
|
||||
<td>
|
||||
@if (($log->userlog) && ($log->userlog->id!='0'))
|
||||
<a href="{{ route('view/user', $log->checkedout_to) }}">
|
||||
@if (($log->target) && ($log->target->id!='0'))
|
||||
<a href="{{ route('view/user', $log->target_id) }}">
|
||||
{{ $log->userlog->fullName() }}
|
||||
</a>
|
||||
|
||||
|
|
|
@ -40,36 +40,36 @@
|
|||
|
||||
@foreach ($log_actions as $log_action)
|
||||
<tr>
|
||||
<td><a href="../admin/users/{{ $log_action->adminlog->id }}/view">{{ $log_action->adminlog->fullName() }}</a></td>
|
||||
<td>
|
||||
@if($log_action->user)
|
||||
<a href="../admin/users/{{ $log_action->user->id }}/view">{{ $log_action->user->fullName() }}</a>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $log_action->action_type }}</td>
|
||||
<td>
|
||||
@if ($log_action->asset_type=="hardware")
|
||||
Asset
|
||||
@elseif ($log_action->asset_type=="software")
|
||||
License
|
||||
@elseif ($log_action->asset_type=="accessory")
|
||||
Accessory
|
||||
@elseif ($log_action->asset_type=="consumable")
|
||||
Consumable
|
||||
@endif
|
||||
{{ title_case($log_action->itemType()) }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
@if (($log_action->assetlog) && ($log_action->asset_type=="hardware"))
|
||||
{{ $log_action->assetlog->showAssetName() }}
|
||||
@elseif (($log_action->licenselog) && ($log_action->asset_type=="software"))
|
||||
{{ $log_action->licenselog->name }}
|
||||
@elseif (($log_action->consumablelog) && ($log_action->asset_type=="consumable"))
|
||||
{{ $log_action->consumablelog->name }}
|
||||
@elseif (($log_action->accessorylog) && ($log_action->asset_type=="accessory"))
|
||||
{{ $log_action->accessorylog->name }}
|
||||
@else
|
||||
{{ trans('general.bad_data') }}
|
||||
@endif
|
||||
|
||||
@if ($item = $log_action->item)
|
||||
@if ($log_action->itemType()=="asset")
|
||||
{{ $item->showAssetName() }}
|
||||
@else
|
||||
{{ $item->name }}
|
||||
@endif
|
||||
@else
|
||||
{{ trans('general.bad_data') }}
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if ($log_action->userlog)
|
||||
<a href="../admin/users/{{ $log_action->userlog->id }}/view">{{ $log_action->userlog->fullName() }}</a>
|
||||
@if ($log_action->target)
|
||||
@if ($log_action->target instanceof \App\Models\User)
|
||||
<a href="../admin/users/{{ $log_action->target->id }}/view">{{ $log_action->target->fullName() }}</a>
|
||||
@elseif ($log_action->target instanceof \App\Models\Asset)
|
||||
<a href="../hardware/{{ $log_action->target->id }}/view">{{ $log_action->target->showAssetName() }}</a>
|
||||
@endif
|
||||
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
|
|
@ -385,13 +385,13 @@
|
|||
@foreach ($userlog as $log)
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
@if (($log->assetlog) && ($log->asset_type=="hardware"))
|
||||
@if ($log->itemType()=="asset")
|
||||
<i class="fa fa-barcode"></i>
|
||||
@elseif (($log->accessorylog) && ($log->asset_type=="accessory"))
|
||||
@elseif ($log->itemType()=="accessory")
|
||||
<i class="fa fa-keyboard-o"></i>
|
||||
@elseif (($log->consumablelog) && ($log->asset_type=="consumable"))
|
||||
@elseif ($log->itemType()=="consumable")
|
||||
<i class="fa fa-tint"></i>
|
||||
@elseif (($log->licenselog) && ($log->asset_type=="software"))
|
||||
@elseif ($log->itemType()=="license")
|
||||
<i class="fa fa-floppy-o"></i>
|
||||
@else
|
||||
<i class="fa fa-times"></i>
|
||||
|
@ -402,58 +402,23 @@
|
|||
<td>{{ $log->action_type }}</td>
|
||||
<td>
|
||||
|
||||
@if (($log->assetlog) && ($log->asset_type=="hardware"))
|
||||
|
||||
@if ($log->assetlog->deleted_at=='')
|
||||
<a href="{{ route('view/hardware', $log->asset_id) }}">
|
||||
{{ $log->assetlog->showAssetName() }}
|
||||
</a>
|
||||
@else
|
||||
<del>{{ $log->assetlog->showAssetName() }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->licenselog) && ($log->asset_type=="software"))
|
||||
|
||||
@if ($log->licenselog->deleted_at=='')
|
||||
<a href="{{ route('view/license', $log->license_id) }}">
|
||||
{{ $log->licenselog->name }}
|
||||
</a>
|
||||
@else
|
||||
<del>{{ $log->licenselog->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->consumablelog) && ($log->asset_type=="consumable"))
|
||||
|
||||
@if ($log->consumablelog->deleted_at=='')
|
||||
<a href="{{ route('view/consumable', $log->consumable_id) }}">{{ $log->consumablelog->name }}</a>
|
||||
@else
|
||||
<del>{{ $log->consumablelog->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@elseif (($log->accessorylog) && ($log->asset_type=="accessory"))
|
||||
@if ($log->accessorylog->deleted_at=='')
|
||||
<a href="{{ route('view/accessory', $log->accessory_id) }}">{{ $log->accessorylog->name }}</a>
|
||||
@else
|
||||
<del>{{ $log->accessorylog->name }}</del> (deleted)
|
||||
@endif
|
||||
|
||||
@else
|
||||
{{ trans('general.bad_data') }}
|
||||
@endif
|
||||
@if (($log->item) && ($log->itemType()=="asset"))
|
||||
<a href="{{ route('view/hardware', $log->item_id) }}">{{ $log->item->asset_tag }} - {{ $log->item->showAssetName() }}</a>
|
||||
@elseif ($log->item)
|
||||
<a href="{{ route('view/'. $log->itemType(), $log->item_id) }}">{{ $log->item->name }}</a
|
||||
@else
|
||||
{{ trans('general.bad_data') }}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
<td>@if ($log->adminlog)
|
||||
|
||||
@if ($log->adminlog->deleted_at=='')
|
||||
<a href="{{ route('view/user', $log->checkedout_to) }}">
|
||||
{{ $log->adminlog->fullName() }}
|
||||
</a>
|
||||
<td>
|
||||
@if ($log->action_type != 'requested')
|
||||
@if (isset($log->user))
|
||||
<a href="{{route('view/user', $log->user_id)}}">{{ $log->user->fullName() }}</a>
|
||||
@else
|
||||
<del>{{ $log->adminlog->fullName() }}</del>
|
||||
Deleted Admin
|
||||
@endif
|
||||
@else
|
||||
Deleted User
|
||||
@endif</td>
|
||||
@endif
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in a new issue