50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Machines\Application\DTOs;
|
|
|
|
/**
|
|
* A job's task as a machine's work list shows it, read from the Jobs and
|
|
* Catalog modules. $status and $priority are Jobs' enum keys; $priorityRank
|
|
* orders priorities (higher first). $allowedServiceUnitIds are the service
|
|
* units using stock whose machines may make the task: the task's work
|
|
* type's unit, or for a shared work type the job's units.
|
|
*/
|
|
final readonly class MachineTaskInfo
|
|
{
|
|
/**
|
|
* @param list<int> $allowedServiceUnitIds
|
|
*/
|
|
public function __construct(
|
|
public int $taskId,
|
|
public int $jobId,
|
|
public string $jobNumber,
|
|
public string $jobName,
|
|
public string $customerName,
|
|
public string $title,
|
|
public ?string $description,
|
|
public ?string $instructions,
|
|
public string $status,
|
|
public string $priority,
|
|
public int $priorityRank,
|
|
public ?string $dueOn,
|
|
public ?string $plannedFrom,
|
|
public ?string $plannedTo,
|
|
public ?string $estimatedHours,
|
|
public array $allowedServiceUnitIds,
|
|
public bool $isDone,
|
|
) {}
|
|
|
|
/**
|
|
* Whether making the task on the day is outside its schedule or after
|
|
* its due date (spec 19.4: shown as a note, not prevented).
|
|
*/
|
|
public function isOutsidePlan(string $day): bool
|
|
{
|
|
return ($this->plannedFrom !== null && $day < $this->plannedFrom)
|
|
|| ($this->plannedTo !== null && $day > $this->plannedTo)
|
|
|| ($this->dueOn !== null && $day > $this->dueOn);
|
|
}
|
|
}
|