Added projects to history sidebar

This commit is contained in:
Hillel Coren 2018-01-25 11:26:53 +02:00
parent cfddcc940a
commit e936e9ccef
2 changed files with 9 additions and 2 deletions

View File

@ -37,7 +37,7 @@ class HistoryUtils
ACTIVITY_TYPE_VIEW_QUOTE, ACTIVITY_TYPE_VIEW_QUOTE,
]; ];
$activities = Activity::with(['client.contacts', 'invoice', 'task', 'expense']) $activities = Activity::with(['client.contacts', 'invoice', 'task.project', 'expense'])
->whereIn('user_id', $userIds) ->whereIn('user_id', $userIds)
->whereIn('activity_type_id', $activityTypes) ->whereIn('activity_type_id', $activityTypes)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
@ -53,6 +53,12 @@ class HistoryUtils
continue; continue;
} }
$entity->setRelation('client', $activity->client); $entity->setRelation('client', $activity->client);
if ($entity->project) {
$project = $entity->project;
$project->setRelation('client', $activity->client);
static::trackViewed($project);
}
} elseif ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_EXPENSE || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_EXPENSE) { } elseif ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_EXPENSE || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_EXPENSE) {
$entity = $activity->expense; $entity = $activity->expense;
if (! $entity) { if (! $entity) {
@ -80,6 +86,7 @@ class HistoryUtils
ENTITY_QUOTE, ENTITY_QUOTE,
ENTITY_TASK, ENTITY_TASK,
ENTITY_EXPENSE, ENTITY_EXPENSE,
ENTITY_PROJECT,
//ENTITY_RECURRING_EXPENSE, //ENTITY_RECURRING_EXPENSE,
]; ];

View File

@ -84,7 +84,7 @@ class EntityPresenter extends Presenter
$entity = $this->entity; $entity = $this->entity;
$entityType = $entity->getEntityType(); $entityType = $entity->getEntityType();
return sprintf('%s %s', trans('texts.' . $entityType), $entity->getDisplayName()); return sprintf('%s: %s', trans('texts.' . $entityType), $entity->getDisplayName());
} }
public function calendarEvent($subColors = false) public function calendarEvent($subColors = false)