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]>
40 lines
980 B
PHP
40 lines
980 B
PHP
<?php
|
|
|
|
namespace App\Modules\Dashboard\Presentation\Livewire\Concerns;
|
|
|
|
use App\Modules\Shared\Domain\ValueObjects\Money;
|
|
use DateTimeImmutable;
|
|
|
|
/**
|
|
* Finnish number, money and date formats of the home page, in both UI
|
|
* languages. Amounts may be negative (a loss), which Money does not hold.
|
|
*/
|
|
trait FormatsDashboard
|
|
{
|
|
public function money(int $cents): string
|
|
{
|
|
return ($cents < 0 ? '-' : '').Money::fromCents(abs($cents))->format();
|
|
}
|
|
|
|
/**
|
|
* E.g. 6 quarters → "1,5".
|
|
*/
|
|
public function hours(int $quarters): string
|
|
{
|
|
return rtrim(rtrim(number_format($quarters / 4, 2, ',', "\u{00A0}"), '0'), ',');
|
|
}
|
|
|
|
/**
|
|
* E.g. 0.125 → "12,5 %".
|
|
*/
|
|
public function percent(float $ratio): string
|
|
{
|
|
return number_format($ratio * 100, 1, ',', "\u{00A0}")."\u{00A0}%";
|
|
}
|
|
|
|
public function dateLabel(string $day): string
|
|
{
|
|
return (new DateTimeImmutable($day))->format('j.n.Y');
|
|
}
|
|
}
|