2016-12-29 22:23:36 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Presenters;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CompanyPresenter
|
|
|
|
*/
|
|
|
|
class ActionlogPresenter extends Presenter
|
|
|
|
{
|
|
|
|
public function admin()
|
|
|
|
{
|
2016-12-30 11:44:47 -08:00
|
|
|
if ($user = $this->model->user) {
|
2021-06-10 13:15:52 -07:00
|
|
|
if (empty($user->deleted_at)) {
|
2016-12-30 11:44:47 -08:00
|
|
|
return $user->present()->nameUrl();
|
|
|
|
}
|
|
|
|
// The user was deleted
|
2021-06-10 13:15:52 -07:00
|
|
|
return '<del>'.$user->getFullNameAttribute().'</del> (deleted)';
|
2016-12-30 11:44:47 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-30 11:44:47 -08:00
|
|
|
return '';
|
2016-12-29 22:23:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function item()
|
2017-04-06 20:08:38 -07:00
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
if ($this->action_type == 'uploaded') {
|
2016-12-29 22:23:36 -08:00
|
|
|
return (string) link_to_route('show/userfile', $this->model->filename, [$this->model->item->id, $this->model->id]);
|
|
|
|
}
|
2016-12-30 11:44:47 -08:00
|
|
|
if ($item = $this->model->item) {
|
|
|
|
if (empty($item->deleted_at)) {
|
|
|
|
return $this->model->item->present()->nameUrl();
|
|
|
|
}
|
|
|
|
// The item was deleted
|
2017-05-23 14:31:44 -07:00
|
|
|
return '<del>'.$item->name.'</del> (deleted)';
|
2016-12-29 22:23:36 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-29 22:23:36 -08:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2017-05-23 14:31:44 -07:00
|
|
|
public function icon()
|
|
|
|
{
|
2024-03-20 16:44:47 -07:00
|
|
|
|
2023-11-22 13:07:07 -08:00
|
|
|
// User related icons
|
|
|
|
if ($this->itemType() == 'user') {
|
|
|
|
|
2024-03-20 16:44:47 -07:00
|
|
|
if ($this->actionType()=='2fa reset') {
|
|
|
|
return 'fa-solid fa-mobile-screen';
|
|
|
|
}
|
|
|
|
|
2023-11-22 13:07:07 -08:00
|
|
|
if ($this->actionType()=='create new') {
|
|
|
|
return 'fa-solid fa-user-plus';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='merged') {
|
|
|
|
return 'fa-solid fa-people-arrows';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='delete') {
|
|
|
|
return 'fa-solid fa-user-minus';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='delete') {
|
|
|
|
return 'fa-solid fa-user-minus';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='update') {
|
|
|
|
return 'fa-solid fa-user-pen';
|
|
|
|
}
|
2024-03-20 16:44:47 -07:00
|
|
|
|
2023-11-22 13:07:07 -08:00
|
|
|
return 'fa-solid fa-user';
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2017-05-23 14:31:44 -07:00
|
|
|
|
2023-11-22 13:07:07 -08:00
|
|
|
// Everything else
|
|
|
|
if ($this->actionType()=='create new') {
|
|
|
|
return 'fa-solid fa-plus';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='delete') {
|
2024-07-11 09:00:12 -07:00
|
|
|
return 'fa-solid fa-trash';
|
2023-11-22 13:07:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='update') {
|
|
|
|
return 'fa-solid fa-pen';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='restore') {
|
|
|
|
return 'fa-solid fa-trash-arrow-up';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='upload') {
|
|
|
|
return 'fas fa-paperclip';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='checkout') {
|
|
|
|
return 'fa-solid fa-rotate-left';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->actionType()=='checkin from') {
|
|
|
|
return 'fa-solid fa-rotate-right';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'fa-solid fa-rotate-right';
|
|
|
|
|
2017-05-23 14:31:44 -07:00
|
|
|
}
|
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
public function actionType()
|
|
|
|
{
|
2018-01-20 00:27:45 -08:00
|
|
|
return mb_strtolower(trans('general.'.str_replace(' ', '_', $this->action_type)));
|
2017-05-23 14:31:44 -07:00
|
|
|
}
|
|
|
|
|
2016-12-29 22:23:36 -08:00
|
|
|
public function target()
|
|
|
|
{
|
2016-12-30 11:44:47 -08:00
|
|
|
$target = null;
|
2016-12-29 22:23:36 -08:00
|
|
|
// Target is messy.
|
|
|
|
// On an upload, the target is the item we are uploading to, stored as the "item" in the log.
|
2021-06-10 13:15:52 -07:00
|
|
|
if ($this->action_type == 'uploaded') {
|
2016-12-30 11:44:47 -08:00
|
|
|
$target = $this->model->item;
|
2021-06-10 13:15:52 -07:00
|
|
|
} elseif (($this->action_type == 'accepted') || ($this->action_type == 'declined')) {
|
|
|
|
// If we are logging an accept/reject, the target is not stored directly,
|
|
|
|
// so we access it through who the item is assigned to.
|
|
|
|
// FIXME: On a reject it's not assigned to anyone.
|
2016-12-30 11:44:47 -08:00
|
|
|
$target = $this->model->item->assignedTo;
|
2021-06-10 13:15:52 -07:00
|
|
|
} elseif ($this->action_type == 'requested') {
|
2016-12-29 22:23:36 -08:00
|
|
|
if ($this->model->user) {
|
2016-12-30 11:44:47 -08:00
|
|
|
$target = $this->model->user;
|
2016-12-29 22:23:36 -08:00
|
|
|
}
|
2016-12-30 11:44:47 -08:00
|
|
|
} elseif ($this->model->target) {
|
2021-06-10 13:15:52 -07:00
|
|
|
// Otherwise, we'll just take the target of the log.
|
2016-12-30 11:44:47 -08:00
|
|
|
$target = $this->model->target;
|
2016-12-29 22:23:36 -08:00
|
|
|
}
|
2016-12-30 11:44:47 -08:00
|
|
|
|
2021-06-10 13:15:52 -07:00
|
|
|
if ($target) {
|
2016-12-30 11:44:47 -08:00
|
|
|
if (empty($target->deleted_at)) {
|
|
|
|
return $target->present()->nameUrl();
|
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-30 11:44:47 -08:00
|
|
|
return '<del>'.$target->present()->name().'</del>';
|
2016-12-29 22:23:36 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2016-12-29 22:23:36 -08:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|