Add pdf detailed report and placeholder for aggregate endpoint

This commit is contained in:
Constantin Graf
2024-10-23 13:21:20 +02:00
committed by Constantin Graf
parent 5593d141ea
commit b0bcc4f330
16 changed files with 685 additions and 69 deletions

View File

@@ -13,17 +13,17 @@ use Illuminate\Database\Eloquent\Model;
class TimeEntriesDetailedCsvExport extends CsvExport
{
public const array HEADER = [
'id',
'user_id',
'project_id',
'task_id',
'start_time',
'end_time',
'duration',
'description',
'created_at',
'updated_at',
'deleted_at',
'Description',
'Task',
'Project',
'Client',
'User',
'Start',
'End',
'Duration',
'Duration (decimal)',
'Billable',
'Tags',
];
/**
@@ -31,16 +31,20 @@ class TimeEntriesDetailedCsvExport extends CsvExport
*/
public function mapRow(Model $model): array
{
$duration = $model->getDuration();
return [
'id' => $model->id,
'user_id' => $model->user_id,
'project_id' => $model->project_id,
'task_id' => $model->task_id,
'start_time' => $model->start,
'end_time' => $model->end,
'description' => $model->description,
'created_at' => $model->created_at,
'updated_at' => $model->updated_at,
'Description' => $model->description,
'Task' => $model->task?->name,
'Project' => $model->project?->name,
'Client' => $model->client?->name,
'User' => $model->user->name,
'Start' => $model->start->format('Y-m-d H:i:s'),
'End' => $model->end?->format('Y-m-d H:i:s'),
'Duration' => $duration !== null ? (int) floor($duration->totalHours).':'.$duration->format('%I:%S') : null,
'Duration (decimal)' => $duration?->totalHours,
'Billable' => $model->billable ? 'Yes' : 'No',
'Tags' => $model->tagsRelation->pluck('name')->implode(', '),
];
}
}