231 lines
5.7 KiB
PHP
231 lines
5.7 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';
|
|
|
|
// what the bar shows: a vacancy nobody applied for, one in progress, or a placed teamer
|
|
public const STATE_OPEN = 'open';
|
|
public const STATE_PENDING = 'pending';
|
|
public const STATE_STAFFED = 'staffed';
|
|
|
|
private ?string $assignmentUuid = null;
|
|
private ?string $dispositionUuid = null;
|
|
private ?\DateTimeImmutable $dateFrom = null;
|
|
private ?\DateTimeImmutable $dateTo = null;
|
|
private ?string $status = null;
|
|
private ?string $state = null;
|
|
private ?string $dateRange = null;
|
|
private ?string $jobProfile = null;
|
|
private ?string $teamerName = null;
|
|
private ?string $teamerUuid = null;
|
|
private int $column = 1;
|
|
private int $span = 1;
|
|
|
|
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())
|
|
// applications are removed when a teamer is placed, so the valid ones are unplaced
|
|
->setState(0 < $assignment->getValidApplications()->count() ? static::STATE_PENDING : static::STATE_OPEN)
|
|
;
|
|
}
|
|
|
|
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())
|
|
->setState(match ($disposition->getStatus()) {
|
|
Disposition::STATUS_NEW, Disposition::STATUS_CHECKING_CONTRACT => static::STATE_PENDING,
|
|
default => static::STATE_STAFFED,
|
|
})
|
|
->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 getState(): ?string
|
|
{
|
|
return $this->state;
|
|
}
|
|
|
|
public function setState(?string $state): static
|
|
{
|
|
$this->state = $state;
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* The first day column of the bar, counted from 1.
|
|
*/
|
|
public function getColumn(): int
|
|
{
|
|
return $this->column;
|
|
}
|
|
|
|
public function setColumn(int $column): static
|
|
{
|
|
$this->column = $column;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* The number of day columns the bar covers.
|
|
*/
|
|
public function getSpan(): int
|
|
{
|
|
return $this->span;
|
|
}
|
|
|
|
public function setSpan(int $span): static
|
|
{
|
|
$this->span = $span;
|
|
|
|
return $this;
|
|
}
|
|
}
|