mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
first impl
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user