Replace the demo home page with a dashboard
Everyone sees their open tasks on an agenda, their open jobs, this week's hours and quick links. Admin and management also get a lazily loaded management panel: things to do, the month so far against the previous month, jobs and late work, and everyone's workload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* The management panel of the home page on a day:
|
||||
*
|
||||
* - to do: hours waiting for approval by person, done jobs waiting for
|
||||
* billing, the open billing draft, unclosed cash days and the value of
|
||||
* unbilled hours;
|
||||
* - this month so far against the same days of the previous month;
|
||||
* - the jobs by status, late jobs and late tasks (the oldest of them);
|
||||
* - everyone's workload this week and next (Mondays given).
|
||||
*/
|
||||
final readonly class ManagementOverview
|
||||
{
|
||||
/**
|
||||
* @param list<PendingApproval> $pendingApprovals
|
||||
* @param list<string> $unclosedCashDays
|
||||
* @param array<string, int> $jobCounts
|
||||
* @param list<WorkTask> $oldestOverdueTasks
|
||||
* @param list<PersonLoad> $workloads
|
||||
*/
|
||||
public function __construct(
|
||||
public array $pendingApprovals,
|
||||
public int $doneJobCount,
|
||||
public ?int $draftExportId,
|
||||
public array $unclosedCashDays,
|
||||
public int $unbilledValueCents,
|
||||
public string $monthFrom,
|
||||
public string $monthTo,
|
||||
public string $previousFrom,
|
||||
public string $previousTo,
|
||||
public PeriodFigures $month,
|
||||
public PeriodFigures $previousMonth,
|
||||
public array $jobCounts,
|
||||
public int $overdueJobCount,
|
||||
public int $overdueTaskCount,
|
||||
public array $oldestOverdueTasks,
|
||||
public string $thisMonday,
|
||||
public string $nextMonday,
|
||||
public array $workloads,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* A person's hours waiting for approval, in quarter hours, over some weeks.
|
||||
*/
|
||||
final readonly class PendingApproval
|
||||
{
|
||||
public function __construct(
|
||||
public int $userId,
|
||||
public string $name,
|
||||
public int $quarters,
|
||||
public int $weekCount,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* Key figures of a period: hours on customers' and internal jobs (quarter
|
||||
* hours), billed by the created billing materials of its months (work and
|
||||
* expenses, VAT 0), the margin (null without an internal hourly cost) and
|
||||
* quick sales (with VAT). Cents.
|
||||
*/
|
||||
final readonly class PeriodFigures
|
||||
{
|
||||
public function __construct(
|
||||
public int $customerQuarters,
|
||||
public int $internalQuarters,
|
||||
public int $billedCents,
|
||||
public ?int $marginCents,
|
||||
public int $salesCents,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
use App\Modules\Dashboard\Domain\ValueObjects\Workload;
|
||||
|
||||
/**
|
||||
* A person's workload this week and next week.
|
||||
*/
|
||||
final readonly class PersonLoad
|
||||
{
|
||||
public function __construct(
|
||||
public int $userId,
|
||||
public string $name,
|
||||
public Workload $thisWeek,
|
||||
public Workload $nextWeek,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* What the home page shows everyone: their open tasks on an agenda (late,
|
||||
* today or tomorrow, later this week, and how many later), their first
|
||||
* open jobs and how many there are, and their hours this week.
|
||||
*/
|
||||
final readonly class PersonalOverview
|
||||
{
|
||||
/**
|
||||
* @param list<WorkTask> $overdue
|
||||
* @param list<WorkTask> $soon
|
||||
* @param list<WorkTask> $thisWeek
|
||||
* @param list<WorkJob> $jobs
|
||||
*/
|
||||
public function __construct(
|
||||
public array $overdue,
|
||||
public array $soon,
|
||||
public array $thisWeek,
|
||||
public int $laterCount,
|
||||
public array $jobs,
|
||||
public int $jobCount,
|
||||
public WeekHours $week,
|
||||
) {}
|
||||
|
||||
public function hasTasks(): bool
|
||||
{
|
||||
return $this->overdue !== [] || $this->soon !== [] || $this->thisWeek !== [] || $this->laterCount > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* A user's hours in a week, in quarter hours: each day (Y-m-d, Monday to
|
||||
* Sunday), the total and those waiting for approval.
|
||||
*/
|
||||
final readonly class WeekHours
|
||||
{
|
||||
/**
|
||||
* @param array<string, int> $days
|
||||
*/
|
||||
public function __construct(
|
||||
public string $monday,
|
||||
public array $days,
|
||||
public int $totalQuarters,
|
||||
public int $unapprovedQuarters,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* An open customer job on the home page. Status and priority are the Jobs
|
||||
* module's keys; the due date is Y-m-d.
|
||||
*/
|
||||
final readonly class WorkJob
|
||||
{
|
||||
public function __construct(
|
||||
public int $id,
|
||||
public string $number,
|
||||
public string $name,
|
||||
public string $customerName,
|
||||
public string $status,
|
||||
public string $priority,
|
||||
public ?string $dueOn,
|
||||
public bool $isLate = false,
|
||||
) {}
|
||||
|
||||
public function late(): self
|
||||
{
|
||||
return new self($this->id, $this->number, $this->name, $this->customerName, $this->status, $this->priority, $this->dueOn, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Application\DTOs;
|
||||
|
||||
/**
|
||||
* An open task on the home page. The status is the Jobs module's task
|
||||
* status key; days are Y-m-d.
|
||||
*/
|
||||
final readonly class WorkTask
|
||||
{
|
||||
public function __construct(
|
||||
public int $taskId,
|
||||
public int $jobId,
|
||||
public string $jobNumber,
|
||||
public string $jobName,
|
||||
public string $title,
|
||||
public string $status,
|
||||
public ?string $dueOn,
|
||||
public ?string $plannedFrom,
|
||||
public ?string $plannedTo,
|
||||
public ?string $assigneeName,
|
||||
public bool $isLate = false,
|
||||
) {}
|
||||
|
||||
public function late(): self
|
||||
{
|
||||
return new self($this->taskId, $this->jobId, $this->jobNumber, $this->jobName, $this->title, $this->status, $this->dueOn, $this->plannedFrom, $this->plannedTo, $this->assigneeName, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user