2015-11-12 21:36:28 +01:00
|
|
|
<?php namespace App\Ninja\Presenters;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* Class TaskPresenter
|
|
|
|
*/
|
|
|
|
class TaskPresenter extends EntityPresenter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2015-11-12 21:36:28 +01:00
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
return $this->entity->client ? $this->entity->client->getDisplayName() : '';
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2015-11-12 21:36:28 +01:00
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->entity->user->getDisplayName();
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param $account
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2015-12-13 21:12:54 +01:00
|
|
|
public function times($account)
|
|
|
|
{
|
|
|
|
$parts = json_decode($this->entity->time_log) ?: [];
|
|
|
|
$times = [];
|
|
|
|
|
|
|
|
foreach ($parts as $part) {
|
|
|
|
$start = $part[0];
|
|
|
|
if (count($part) == 1 || !$part[1]) {
|
|
|
|
$end = time();
|
|
|
|
} else {
|
|
|
|
$end = $part[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
$start = $account->formatDateTime("@{$start}");
|
|
|
|
$end = $account->formatTime("@{$end}");
|
|
|
|
|
2015-12-31 09:04:12 +01:00
|
|
|
$times[] = "### {$start} - {$end}";
|
2015-12-13 21:12:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return implode("\n", $times);
|
|
|
|
}
|
2016-02-04 19:36:39 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-02-04 19:36:39 +01:00
|
|
|
public function status()
|
|
|
|
{
|
|
|
|
$class = $text = '';
|
|
|
|
|
|
|
|
if ($this->entity->is_deleted) {
|
|
|
|
$class = 'danger';
|
|
|
|
$text = trans('texts.deleted');
|
|
|
|
} elseif ($this->entity->trashed()) {
|
|
|
|
$class = 'warning';
|
|
|
|
$text = trans('texts.archived');
|
|
|
|
} else {
|
|
|
|
$class = 'success';
|
|
|
|
$text = trans('texts.active');
|
|
|
|
}
|
|
|
|
|
|
|
|
return "<span class=\"label label-{$class}\">{$text}</span>";
|
|
|
|
}
|
2016-05-23 11:26:08 +02:00
|
|
|
}
|