diff --git a/app/Ninja/Datatables/ProjectDatatable.php b/app/Ninja/Datatables/ProjectDatatable.php index 2051aea3f2..1d12f65743 100644 --- a/app/Ninja/Datatables/ProjectDatatable.php +++ b/app/Ninja/Datatables/ProjectDatatable.php @@ -33,7 +33,7 @@ class ProjectDatatable extends EntityDatatable return Utils::getClientDisplayName($model); } - return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml(); + return link_to("clients/{$model->client_public_id}", $model->client_name)->toHtml(); } else { return ''; } diff --git a/app/Ninja/Reports/TaskReport.php b/app/Ninja/Reports/TaskReport.php index fbc52b0591..b19e871c86 100644 --- a/app/Ninja/Reports/TaskReport.php +++ b/app/Ninja/Reports/TaskReport.php @@ -13,24 +13,39 @@ class TaskReport extends AbstractReport 'project', 'description', 'duration', + 'amount', ]; public function run() { + $startDate = date_create($this->startDate); + $endDate = date_create($this->endDate); + $tasks = Task::scope() ->orderBy('created_at', 'desc') - ->with('client.contacts') + ->with('client.contacts', 'project', 'account') ->withArchived() - ->dateRange($this->startDate, $this->endDate); + ->dateRange($startDate, $endDate); foreach ($tasks->get() as $task) { + $amount = $task->getRate() * ($task->getDuration() / 60 / 60); + if ($task->client && $task->client->currency_id) { + $currencyId = $task->client->currency_id; + } else { + $currencyId = auth()->user()->account->getCurrencyId(); + } + $this->data[] = [ $task->client ? ($this->isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'), $this->isExport ? $task->getStartTime() : link_to($task->present()->url, $task->getStartTime()), $task->present()->project, $task->description, Utils::formatTime($task->getDuration()), + Utils::formatMoney($amount, $currencyId), ]; + + $this->addToTotals($currencyId, 'duration', $task->getDuration()); + $this->addToTotals($currencyId, 'amount', $amount); } } } diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 316bc89845..9b41cc206a 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -38,7 +38,7 @@ class ClientRepository extends BaseRepository ->select( DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), - DB::raw("CONCAT(contacts.first_name, ' ', contacts.last_name) contact"), + DB::raw("CONCAT(COALESCE(contacts.first_name, ''), ' ', COALESCE(contacts.last_name, '')) contact"), 'clients.public_id', 'clients.name', 'clients.private_notes', diff --git a/resources/views/reports/report_builder.blade.php b/resources/views/reports/report_builder.blade.php index 9526fd0ca4..d0d838ae7f 100644 --- a/resources/views/reports/report_builder.blade.php +++ b/resources/views/reports/report_builder.blade.php @@ -262,8 +262,14 @@ - {{ $dimension }} @endif - @foreach ($val as $id => $field) - {!! Utils::formatMoney($field, $currencyId) !!} + @foreach ($val as $field => $value) + + @if ($field == 'duration') + {{ Utils::formatTime($value) }} + @else + {{ Utils::formatMoney($value, $currencyId) }} + @endif + @endforeach @endforeach