diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 1dae24464..c5159526f 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -237,6 +237,11 @@ class ActivityController extends AbstractController if (!$entity) { throw $this->createNotFoundException('Unable to find Activity entity.'); } + + if (null !== $accompanyingPeriod) { + $entity->personsAssociated = $entity->getPersonsAssociated(); + $entity->personsNotAssociated = $entity->getPersonsNotAssociated(); + } // TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity); diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 53fd679e5..c0a25395c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -419,6 +419,34 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this->persons; } + public function getPersonsAssociated(): array + { + if (null !== $this->accompanyingPeriod) { + $personsAssociated = []; + foreach ($this->accompanyingPeriod->getParticipations() as $participation) { + if ($this->persons->contains($participation->getPerson())) { + $personsAssociated[] = $participation->getPerson(); + } + } + return $personsAssociated; + } + return []; + } + + public function getPersonsNotAssociated(): array + { + if (null !== $this->accompanyingPeriod) { + $personsNotAssociated = []; + foreach ($this->persons as $person) { + if (!in_array($person, $this->getPersonsAssociated())) { + $personsNotAssociated[] = $person; + } + } + return $personsNotAssociated; + } + return []; + } + public function setPersons(?Collection $persons): self { $this->persons = $persons; diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig index ee63aed54..6181784da 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig @@ -1,13 +1,13 @@ {% if context == 'person' %} {% set blocs = [ - { 'title': 'Persons associated'|trans, 'items': entity.persons }, - { 'title': 'ThirdParties'|trans, 'items': entity.thirdParties }, + { 'title': 'Others persons'|trans, 'items': entity.persons }, + { 'title': 'Third parties'|trans, 'items': entity.thirdParties }, { 'title': 'Users concerned'|trans, 'items': entity.users }, ] %} {% else %} {% set blocs = [ - { 'title': 'Persons in accompanying course'|trans, 'items': entity.persons }, - { 'title': 'Third persons'|trans, 'items': entity.persons }, + { 'title': 'Persons in accompanying course'|trans, 'items': entity.personsAssociated }, + { 'title': 'Third persons'|trans, 'items': entity.personsNotAssociated }, { 'title': 'ThirdParties'|trans, 'items': entity.thirdParties }, { 'title': 'Users concerned'|trans, 'items': entity.users }, ] %} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 793cb582a..532f25cf4 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -64,8 +64,8 @@ Choose a type: Choisir un type Concerned groups: Parties concernées Persons in accompanying course: Usagers du parcours Third persons: Tiers non-pro. -Persons associated: Usagers -ThirdParties: Tiers professionnels +Others persons: Usagers +Third parties: Tiers professionnels Users concerned: T(M)S