feat: complete jobcard management workflows and UI
This commit is contained in:
@@ -29,12 +29,33 @@ final class ClientHistoryService
|
||||
return $this->filter($rows, $criteria);
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
public function validateForClient(mixed $clientId, array $rows, array $criteria = []): array
|
||||
{
|
||||
$id = $this->positiveId($clientId);
|
||||
if ($id === null) return ['valid' => false, 'client_id' => null, 'timeline' => [], 'errors' => ['client_id' => 'Client ID must be a positive integer.']];
|
||||
return ['valid' => true, 'client_id' => $id, 'timeline' => $this->forClient($rows, $id, $criteria), 'errors' => []];
|
||||
}
|
||||
|
||||
/** Controller-ready client history timeline command. */
|
||||
public function timeline(array $rows, mixed $clientId, array $criteria = []): array
|
||||
{
|
||||
return $this->validateForClient($clientId, $rows, $criteria);
|
||||
}
|
||||
|
||||
/** @return list<array<string,mixed>> */
|
||||
public function history(array $rows, array|\ReportFilters|null $criteria = null): array { return $this->filter($rows, $criteria); }
|
||||
/** @return list<array<string,mixed>> */
|
||||
public function query(array $rows, array|\ReportFilters|null $criteria = null): array { return $this->filter($rows, $criteria); }
|
||||
/** @return list<array<string,mixed>> */
|
||||
public function getHistory(array $rows, array|\ReportFilters|null $criteria = null): array { return $this->filter($rows, $criteria); }
|
||||
|
||||
private function positiveId(mixed $value): ?int
|
||||
{
|
||||
if (is_int($value) && $value > 0) return $value;
|
||||
if (is_string($value) && preg_match('/^[1-9]\\d*$/', trim($value)) === 1) { $id = filter_var(trim($value), FILTER_VALIDATE_INT); return $id === false ? null : $id; }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user