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]>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Dashboard\Infrastructure\Adapters;
|
|
|
|
use App\Modules\Dashboard\Application\Contracts\DashboardTime;
|
|
use App\Modules\Dashboard\Application\DTOs\PendingApproval;
|
|
use App\Modules\Dashboard\Application\DTOs\WeekHours;
|
|
use App\Modules\TimeTracking\Application\Contracts\TimeEntryQueries;
|
|
|
|
/**
|
|
* Hours for the home page through the TimeTracking module.
|
|
*/
|
|
class TimeForDashboard implements DashboardTime
|
|
{
|
|
public function __construct(private TimeEntryQueries $entries) {}
|
|
|
|
public function week(int $userId, string $monday): WeekHours
|
|
{
|
|
$sheet = $this->entries->week($userId, $monday);
|
|
|
|
return new WeekHours($monday, $sheet->dayTotals, $sheet->totalQuarters, $sheet->unapprovedQuarters);
|
|
}
|
|
|
|
public function pendingApprovals(): array
|
|
{
|
|
$people = [];
|
|
|
|
foreach ($this->entries->pendingWeeks() as $week) {
|
|
$current = $people[$week->userId] ?? new PendingApproval($week->userId, $week->userName, 0, 0);
|
|
$people[$week->userId] = new PendingApproval($week->userId, $week->userName, $current->quarters + $week->quarters, $current->weekCount + 1);
|
|
}
|
|
|
|
$people = array_values($people);
|
|
usort($people, fn (PendingApproval $a, PendingApproval $b): int => strnatcasecmp($a->name, $b->name));
|
|
|
|
return $people;
|
|
}
|
|
}
|