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