feat: show available/open assignments in timeline
This commit is contained in:
@@ -25,10 +25,21 @@ class TimelineService
|
||||
$rows[$hotelCode] = [[]];
|
||||
}
|
||||
|
||||
if (0 === $assignment->getDispositions()->count()) {
|
||||
$dispositionsCount = $assignment->getDispositions()->count();
|
||||
$dispositionsAvailable = $assignment->getAvailableDispositions();
|
||||
|
||||
if (0 === $dispositionsCount) {
|
||||
$item = TimelineItem::fromAssignment($assignment);
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
for ($i = 1; $i <= $assignment->getAvailableDispositions(); $i++) {
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
} else {
|
||||
if ($dispositionsCount < $dispositionsAvailable) {
|
||||
$item = TimelineItem::fromAssignment($assignment);
|
||||
for ($i = 1; $i <= $dispositionsAvailable - $dispositionsCount; $i++) {
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
}
|
||||
}
|
||||
foreach ($assignment->getDispositions() as $disposition) {
|
||||
$item = TimelineItem::fromDisposition($disposition);
|
||||
$this->addItem($rows[$hotelCode], $item);
|
||||
@@ -42,12 +53,16 @@ class TimelineService
|
||||
private function addItem(array &$rows, TimelineItem $item): void
|
||||
{
|
||||
$rowIndex = 0;
|
||||
$fitsRow = false;
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
$fitsRow = true;
|
||||
foreach ($row as $entry) {
|
||||
/** @var TimelineItem $entry */
|
||||
if ($entry->getDateTo() >= $item->getDateFrom() && $entry->getDateFrom() <= $item->getDateTo()) {
|
||||
if (
|
||||
isset($row[$item->getKey()]) ||
|
||||
$entry->getDateTo() >= $item->getDateFrom() && $entry->getDateFrom() <= $item->getDateTo()
|
||||
) {
|
||||
$fitsRow = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user