mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Add totals to the tasks report
This commit is contained in:
parent
d12ddb9beb
commit
3e39100eda
@ -33,7 +33,7 @@ class ProjectDatatable extends EntityDatatable
|
|||||||
return Utils::getClientDisplayName($model);
|
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 {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,39 @@ class TaskReport extends AbstractReport
|
|||||||
'project',
|
'project',
|
||||||
'description',
|
'description',
|
||||||
'duration',
|
'duration',
|
||||||
|
'amount',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$startDate = date_create($this->startDate);
|
||||||
|
$endDate = date_create($this->endDate);
|
||||||
|
|
||||||
$tasks = Task::scope()
|
$tasks = Task::scope()
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->with('client.contacts')
|
->with('client.contacts', 'project', 'account')
|
||||||
->withArchived()
|
->withArchived()
|
||||||
->dateRange($this->startDate, $this->endDate);
|
->dateRange($startDate, $endDate);
|
||||||
|
|
||||||
foreach ($tasks->get() as $task) {
|
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[] = [
|
$this->data[] = [
|
||||||
$task->client ? ($this->isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'),
|
$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()),
|
$this->isExport ? $task->getStartTime() : link_to($task->present()->url, $task->getStartTime()),
|
||||||
$task->present()->project,
|
$task->present()->project,
|
||||||
$task->description,
|
$task->description,
|
||||||
Utils::formatTime($task->getDuration()),
|
Utils::formatTime($task->getDuration()),
|
||||||
|
Utils::formatMoney($amount, $currencyId),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$this->addToTotals($currencyId, 'duration', $task->getDuration());
|
||||||
|
$this->addToTotals($currencyId, 'amount', $amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class ClientRepository extends BaseRepository
|
|||||||
->select(
|
->select(
|
||||||
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
|
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
|
||||||
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_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.public_id',
|
||||||
'clients.name',
|
'clients.name',
|
||||||
'clients.private_notes',
|
'clients.private_notes',
|
||||||
|
@ -262,8 +262,14 @@
|
|||||||
- {{ $dimension }}
|
- {{ $dimension }}
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@foreach ($val as $id => $field)
|
@foreach ($val as $field => $value)
|
||||||
<td>{!! Utils::formatMoney($field, $currencyId) !!}</td>
|
<td>
|
||||||
|
@if ($field == 'duration')
|
||||||
|
{{ Utils::formatTime($value) }}
|
||||||
|
@else
|
||||||
|
{{ Utils::formatMoney($value, $currencyId) }}
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
Loading…
Reference in New Issue
Block a user