diff --git a/.changes/unreleased/Feature-20240122-124849.yaml b/.changes/unreleased/Feature-20240122-124849.yaml new file mode 100644 index 000000000..82703bd2c --- /dev/null +++ b/.changes/unreleased/Feature-20240122-124849.yaml @@ -0,0 +1,6 @@ +kind: Feature +body: '[Export][List of accompanyign period] Add two columns: the list of persons + participating to the period, and their ids' +time: 2024-01-22T12:48:49.824833412+01:00 +custom: + Issue: "241" diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php index 9b8902ba6..2c2bc1d02 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListAccompanyingPeriodHelper.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Export\Helper\ExportAddressHelper; use Chill\MainBundle\Export\Helper\UserHelper; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Repository\PersonRepository; @@ -40,6 +41,8 @@ final readonly class ListAccompanyingPeriodHelper 'closingDate', 'referrer', 'referrerSince', + 'acpParticipantPersons', + 'acpParticipantPersonsIds', 'administrativeLocation', 'locationIsPerson', 'locationIsTemp', @@ -79,6 +82,7 @@ final readonly class ListAccompanyingPeriodHelper private TranslatableStringHelperInterface $translatableStringHelper, private TranslatorInterface $translator, private UserHelper $userHelper, + private LabelPersonHelper $labelPersonHelper, ) { } @@ -110,7 +114,20 @@ final readonly class ListAccompanyingPeriodHelper return $this->translatableStringHelper->localize(json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR)); }, 'acpCreatedBy', 'acpUpdatedBy', 'referrer' => $this->userHelper->getLabel($key, $values, 'export.list.acp.'.$key), - 'acpParticipantsPersons' => function ($value) { + + 'acpParticipantPersons' => $this->labelPersonHelper->getLabelMulti($key, $values, 'export.list.acp.'.$key), + 'acpParticipantPersonsIds' => function ($value) use ($key): string { + if ('_header' === $value) { + return 'export.list.acp.'.$key; + } + + if (null === $value || '' === $value) { + return ''; + } + + $keys = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR); + + return implode('|', $keys); }, 'locationPersonName', 'requestorPerson' => function ($value) use ($key) { if ('_header' === $value) { @@ -224,6 +241,11 @@ final readonly class ListAccompanyingPeriodHelper ->addSelect(sprintf('%s_t.%s AS %s', $entity, $field, $entity)); } + // persons + $qb + ->addSelect(sprintf('(SELECT AGGREGATE(IDENTITY(participant_persons_n.person)) FROM %s participant_persons_n WHERE participant_persons_n.accompanyingPeriod = acp) AS acpParticipantPersons', AccompanyingPeriodParticipation::class)) + ->addSelect(sprintf('(SELECT AGGREGATE(IDENTITY(participant_persons_ids.person)) FROM %s participant_persons_ids WHERE participant_persons_ids.accompanyingPeriod = acp) AS acpParticipantPersonsIds', AccompanyingPeriodParticipation::class)); + // step at date $qb ->addSelect('stepHistory.step AS step') diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 82c538c69..60dd6b09b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1296,6 +1296,8 @@ export: socialIssues: Problématiques sociales requestorPerson: Demandeur (personne) requestorThirdParty: Demandeur (tiers) + acpParticipantPersons: Usagers concernés + acpParticipantPersonsIds: Usagers concernés (identifiants) eval: List of evaluations: Liste des évaluations