Merge remote-tracking branch 'origin/master' into 106_tasks_to_parcours

This commit is contained in:
2021-10-22 17:52:57 +02:00
315 changed files with 9928 additions and 3472 deletions

View File

@@ -214,7 +214,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
private $scopes;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodRequested")
* @ORM\JoinColumn(nullable=true)
*/
private $requestorPerson;
@@ -514,6 +514,44 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
);
}
/**
* Return an array with open participations sorted by household
* [
* [
* "household" => Household x,
* "members" => [
* Participation y , Participation z, ...
* ]
* ],
* ]
*
*/
public function actualParticipationsByHousehold(): array
{
$participations = $this->getOPenParticipations()->toArray();
$households = [];
foreach ($participations as $p) {
$households[] = $p->getPerson()->getCurrentHousehold();
}
$households = array_unique($households, SORT_REGULAR);
$array = [];
foreach ($households as $household) {
$members = [];
foreach ($participations as $p) {
if ($household === $p->getPerson()->getCurrentHousehold()) {
$members[] = array_shift($participations);
} else {
$participations[] = array_shift($participations);
}
}
$array[] = [ 'household' => $household, 'members' => $members ];
}
return $array;
}
/**
* Return true if the accompanying period contains a person.
*