fix: draw only active placements on the timeline and keep trips overlapping its dates
This commit is contained in:
1 parent
5ca9b812c3
commit
4e50f23558
6 files changed
+216
-32
No files matched your search
@@ -10,11 +10,17 @@ 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;
|
||||
@@ -36,6 +42,8 @@ class TimelineItem
|
||||
->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)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -54,6 +62,10 @@ class TimelineItem
|
||||
->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())
|
||||
;
|
||||
@@ -148,6 +160,18 @@ class TimelineItem
|
||||
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;
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Disposition;
|
||||
use App\Entity\JobProfile;
|
||||
use App\Entity\Teamer;
|
||||
use App\Model\AssignmentFilterDto;
|
||||
use App\Model\TimelineFilterDto;
|
||||
use App\Repository\Traits\QueryHelperTrait;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\Query;
|
||||
@@ -224,16 +225,20 @@ class AssignmentRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
// The timeline draws every trip touching its window, so a team on site is not dropped by a
|
||||
// window starting today; the lists keep only trips lying inside the dates.
|
||||
$overlap = $filterDto instanceof TimelineFilterDto;
|
||||
|
||||
if (null !== $dateFrom = $filterDto->getDateFrom()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->gte('destination.dateFrom', ':dateFrom'))
|
||||
->andWhere($qb->expr()->gte($overlap ? 'destination.dateTo' : 'destination.dateFrom', ':dateFrom'))
|
||||
->setParameter('dateFrom', $dateFrom)
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $dateTo = $filterDto->getDateTo()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->lte('destination.dateTo', ':dateTo'))
|
||||
->andWhere($qb->expr()->lte($overlap ? 'destination.dateFrom' : 'destination.dateTo', ':dateTo'))
|
||||
->setParameter('dateTo', $dateTo)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -40,28 +40,17 @@ class TimelineService
|
||||
$rows[$hotelCode] = [[]];
|
||||
}
|
||||
|
||||
$dispositionsCount = $assignment->getDispositions()->count();
|
||||
$dispositionsAvailable = $assignment->getAvailableDispositions();
|
||||
// called-off dispositions free their slot again
|
||||
$dispositions = $assignment->getActiveDispositions();
|
||||
|
||||
// Handle assignments with no dispositions - create items for all available slots
|
||||
if (0 === $dispositionsCount) {
|
||||
$item = TimelineItem::fromAssignment($assignment);
|
||||
for ($i = 1; $i <= $assignment->getAvailableDispositions(); ++$i) {
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
} else {
|
||||
// Create items for remaining vacant slots if any
|
||||
if ($dispositionsCount < $dispositionsAvailable) {
|
||||
$item = TimelineItem::fromAssignment($assignment);
|
||||
for ($i = 1; $i <= $dispositionsAvailable - $dispositionsCount; ++$i) {
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
}
|
||||
// Create items for actual dispositions
|
||||
foreach ($assignment->getDispositions() as $disposition) {
|
||||
$item = TimelineItem::fromDisposition($disposition);
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
// Create items for the vacant slots, if any
|
||||
$item = TimelineItem::fromAssignment($assignment);
|
||||
for ($i = $dispositions->count(); $i < $assignment->getAvailableDispositions(); ++$i) {
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
// Create items for actual dispositions
|
||||
foreach ($dispositions as $disposition) {
|
||||
$this->addItem($rows[$hotelCode], TimelineItem::fromDisposition($disposition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user