189 lines
4.6 KiB
PHP
189 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
use App\Entity\Assignment;
|
|
use App\Entity\Disposition;
|
|
|
|
class TimelineItem
|
|
{
|
|
public const TYPE_ASSIGNMENT = 'assignment';
|
|
public const TYPE_DISPOSITION = 'disposition';
|
|
|
|
private ?string $assignmentUuid = null;
|
|
private ?string $dispositionUuid = null;
|
|
private ?\DateTimeImmutable $dateFrom = null;
|
|
private ?\DateTimeImmutable $dateTo = null;
|
|
private ?string $status = null;
|
|
private ?string $dateRange = null;
|
|
private ?string $jobProfile = null;
|
|
private ?string $teamerName = null;
|
|
private ?string $teamerUuid = null;
|
|
|
|
public function __construct(private readonly string $type)
|
|
{
|
|
}
|
|
|
|
public static function fromAssignment(Assignment $assignment): static
|
|
{
|
|
$dateFrom = $assignment->getDestination()->getDateFrom();
|
|
$dateTo = $assignment->getDestination()->getDateTo();
|
|
|
|
return (new static(static::TYPE_ASSIGNMENT))
|
|
->setAssignmentUuid($assignment->getUuid())
|
|
->setDateFrom($dateFrom)
|
|
->setDateTo($dateTo)
|
|
->setJobProfile($assignment->getJobProfile()->getName())
|
|
->setDateRange(sprintf('%s - %s', $dateFrom->format('d.m.Y'), $dateTo->format('d.m.Y')))
|
|
->setStatus($assignment->getStaffingStatus())
|
|
;
|
|
}
|
|
|
|
public static function fromDisposition(Disposition $disposition): static
|
|
{
|
|
$assignment = $disposition->getAssignment();
|
|
|
|
$dateFrom = $assignment->getDestination()->getDateFrom();
|
|
$dateTo = $assignment->getDestination()->getDateTo();
|
|
|
|
return (new static(static::TYPE_DISPOSITION))
|
|
->setAssignmentUuid($assignment->getUuid())
|
|
->setDispositionUuid($disposition->getUuid())
|
|
->setDateFrom($dateFrom)
|
|
->setDateTo($dateTo)
|
|
->setJobProfile($assignment->getJobProfile()->getName())
|
|
->setDateRange(sprintf('%s - %s', $dateFrom->format('d.m.Y'), $dateTo->format('d.m.Y')))
|
|
->setStatus($disposition->getStatus())
|
|
->setTeamerName($disposition->getTeamer()->getFullName())
|
|
->setTeamerUuid($disposition->getTeamer()->getUuid())
|
|
;
|
|
}
|
|
|
|
public function getType(): ?string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function getAssignmentUuid(): ?string
|
|
{
|
|
return $this->assignmentUuid;
|
|
}
|
|
|
|
public function setAssignmentUuid(?string $assignmentUuid): static
|
|
{
|
|
$this->assignmentUuid = $assignmentUuid;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDispositionUuid(): ?string
|
|
{
|
|
return $this->dispositionUuid;
|
|
}
|
|
|
|
public function setDispositionUuid(?string $dispositionUuid): static
|
|
{
|
|
$this->dispositionUuid = $dispositionUuid;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateFrom(): ?\DateTimeImmutable
|
|
{
|
|
return $this->dateFrom;
|
|
}
|
|
|
|
public function setDateFrom(?\DateTimeImmutable $dateFrom): static
|
|
{
|
|
$this->dateFrom = $dateFrom;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateTo(): ?\DateTimeImmutable
|
|
{
|
|
return $this->dateTo;
|
|
}
|
|
|
|
public function setDateTo(?\DateTimeImmutable $dateTo): static
|
|
{
|
|
$this->dateTo = $dateTo;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDateRange(): ?string
|
|
{
|
|
return $this->dateRange;
|
|
}
|
|
|
|
public function setDateRange(?string $dateRange): static
|
|
{
|
|
$this->dateRange = $dateRange;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getJobProfile(): ?string
|
|
{
|
|
return $this->jobProfile;
|
|
}
|
|
|
|
public function setJobProfile(?string $jobProfile): static
|
|
{
|
|
$this->jobProfile = $jobProfile;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus(): ?string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(?string $status): static
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTeamerName(): ?string
|
|
{
|
|
return $this->teamerName;
|
|
}
|
|
|
|
public function setTeamerName(?string $teamerName): static
|
|
{
|
|
$this->teamerName = $teamerName;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTeamerUuid(): ?string
|
|
{
|
|
return $this->teamerUuid;
|
|
}
|
|
|
|
public function setTeamerUuid(?string $teamerUuid): static
|
|
{
|
|
$this->teamerUuid = $teamerUuid;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getKey(): ?string
|
|
{
|
|
return $this->getDateFrom()?->format('Ymd');
|
|
}
|
|
|
|
public function getNumberOfDays(): int
|
|
{
|
|
if (null === $this->getDateFrom() || null === $this->getDateTo()) {
|
|
return 1;
|
|
}
|
|
|
|
return $this->getDateFrom()->diff($this->getDateTo())->days + 1;
|
|
}
|
|
}
|