concerned parties, split in activity model persons associated or not

This commit is contained in:
Mathieu Jaumotte 2021-06-03 20:20:56 +02:00
parent 987815471c
commit 4ace2fef99
4 changed files with 39 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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 },
] %}

View File

@ -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