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,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Dashboard\Infrastructure\Adapters;
|
||||
|
||||
use App\Modules\Billing\Application\Contracts\BillingQueries;
|
||||
use App\Modules\Billing\Domain\Enums\ExportStatus;
|
||||
use App\Modules\Dashboard\Application\Contracts\DashboardAdmin;
|
||||
use App\Modules\Sales\Application\Contracts\QuickSaleQueries;
|
||||
use App\Modules\Shared\Application\UseCases\HolidayCalendar;
|
||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||
use App\Modules\Users\Domain\Enums\Role;
|
||||
|
||||
/**
|
||||
* Billing drafts, cash days, people and holidays for the management panel
|
||||
* through the Billing, Sales, Users and Shared modules.
|
||||
*/
|
||||
class AdminForDashboard implements DashboardAdmin
|
||||
{
|
||||
public function __construct(
|
||||
private BillingQueries $billing,
|
||||
private QuickSaleQueries $sales,
|
||||
private UserAccountQueries $users,
|
||||
private HolidayCalendar $holidays,
|
||||
) {}
|
||||
|
||||
public function openDraftId(): ?int
|
||||
{
|
||||
foreach ($this->billing->exports() as $export) {
|
||||
if ($export->status === ExportStatus::Draft) {
|
||||
return $export->id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function unclosedCashDaysBefore(string $day): array
|
||||
{
|
||||
return $this->sales->unclosedDaysBefore($day);
|
||||
}
|
||||
|
||||
public function staff(): array
|
||||
{
|
||||
$staff = [];
|
||||
|
||||
foreach ($this->users->activeUserOptions() as $user) {
|
||||
if ($user->role !== Role::Subcontractor) {
|
||||
$staff[$user->id] = $user->name;
|
||||
}
|
||||
}
|
||||
|
||||
return $staff;
|
||||
}
|
||||
|
||||
public function holidaysBetween(string $from, string $to): array
|
||||
{
|
||||
return $this->holidays->activeDatesBetween($from, $to);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user