first impl

This commit is contained in:
2021-05-20 17:41:37 +02:00
parent 6bd7a0105d
commit 6a62b46dec
19 changed files with 729 additions and 17 deletions

View File

@@ -417,6 +417,31 @@ class Person implements HasCenterInterface
return $this->accompanyingPeriodParticipations;
}
/**
* Return a collection of participation, where the participation
* is still opened, not a draft, and the period is still opened
*/
public function getOpenedParticipations(): Collection
{
// create a criteria for filtering easily
$criteria = Criteria::create();
$criteria
->andWhere(Criteria::expr()->eq('endDate', NULL))
->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now')))
;
return $this->getAccompanyingPeriodParticipations()
->matching($criteria)
->filter(function (AccompanyingPeriodParticipation $app) {
$period = $app->getAccompanyingPeriod();
return (
NULL === $period->getClosingDate()
|| new \DateTime('now') < $period->getClosingDate()
)
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
});
}
/**
* Get the accompanying periods of a give person with the chronological order.
*/