Feat: Implement overridable effective pickup date
This commit is contained in:
@@ -172,13 +172,32 @@ class Assignment implements BlameableEntityInterface, TimestampableEntityInterfa
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTotalPeriod(): CarbonPeriod
|
||||
public function getTotalPeriod(): ?CarbonPeriod
|
||||
{
|
||||
$destination = $this->getDestination();
|
||||
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
|
||||
$dateTo = $this->getDateTo() ?? $destination->getDateTo();
|
||||
if (null !== $destination = $this->getDestination()) {
|
||||
$dateFrom = $this->getDateFrom() ?? $destination->getDateFrom();
|
||||
$dateTo = $this->getDateTo() ?? $destination->getDateTo();
|
||||
|
||||
return new CarbonPeriod($dateFrom, $dateTo);
|
||||
return new CarbonPeriod($dateFrom, $dateTo);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getEffectivePickupDate(): ?\DateTimeImmutable
|
||||
{
|
||||
if (null !== $this->pickupDate) {
|
||||
return $this->pickupDate;
|
||||
}
|
||||
|
||||
if (0 !== (int) $this->pickup && null !== $destination = $this->getDestination()) {
|
||||
return $destination
|
||||
->getDateFrom()
|
||||
->modify('-1 day')
|
||||
;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPickupDate(): ?\DateTimeImmutable
|
||||
|
||||
@@ -53,7 +53,7 @@ class AssignmentType extends AbstractType
|
||||
'required' => false,
|
||||
])
|
||||
->add('pickupDate', DatepickerType::class, [
|
||||
'label' => 'Busabfahrt',
|
||||
'label' => 'abweichende Busabfahrt',
|
||||
'required' => false,
|
||||
])
|
||||
->add('pickup', BpnPickupType::class, [
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<td>
|
||||
{{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }}
|
||||
<br>
|
||||
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }}
|
||||
{{ assignment.effectivePickupDate ? assignment.effectivePickupDate|date('d.m.Y') : '' }}
|
||||
</td>
|
||||
<td>
|
||||
{{ assignment.applications|length }}/{{ assignment.availableDispositions - assignment.dispositions|length }}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<td>
|
||||
{{ assignment.pickup ? assignment.pickup|bpn_pickup_label|default('-') : '-' }}
|
||||
<br>
|
||||
{{ assignment.pickupDate ? assignment.pickupDate|date('d.m.Y') : '' }}
|
||||
{{ assignment.effectivePickupDate ? assignment.effectivePickupDate|date('d.m.Y') : '' }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="flex items-center space-x-1 justify-end">
|
||||
|
||||
Reference in New Issue
Block a user