mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge remote-tracking branch 'origin/master' into 106_tasks_to_parcours
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user