Merge branch '258-centers-parcours-export' into 'master'

In the accompanying period list, add person's centers and duration

Closes #258

See merge request Chill-Projet/chill-bundles!661
This commit is contained in:
Julien Fastré 2024-03-14 21:35:00 +00:00
commit dfe780f0f5
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,6 @@
kind: Feature
body: In the list of accompangying period, add the list of person's centers and the
duration of the course
time: 2024-03-14T22:26:34.103648729+01:00
custom:
Issue: "258"

View File

@ -16,10 +16,12 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Export\Helper\DateTimeHelper; use Chill\MainBundle\Export\Helper\DateTimeHelper;
use Chill\MainBundle\Export\Helper\ExportAddressHelper; use Chill\MainBundle\Export\Helper\ExportAddressHelper;
use Chill\MainBundle\Export\Helper\UserHelper; use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Repository\CenterRepository;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress; use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -39,6 +41,8 @@ final readonly class ListAccompanyingPeriodHelper
'stepSince', 'stepSince',
'openingDate', 'openingDate',
'closingDate', 'closingDate',
'duration',
'centers',
'referrer', 'referrer',
'referrerSince', 'referrerSince',
'acpParticipantPersons', 'acpParticipantPersons',
@ -83,6 +87,7 @@ final readonly class ListAccompanyingPeriodHelper
private TranslatorInterface $translator, private TranslatorInterface $translator,
private UserHelper $userHelper, private UserHelper $userHelper,
private LabelPersonHelper $labelPersonHelper, private LabelPersonHelper $labelPersonHelper,
private CenterRepository $centerRepository
) { ) {
} }
@ -202,6 +207,25 @@ final readonly class ListAccompanyingPeriodHelper
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
default => $value, default => $value,
}, },
'centers' => function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.'.$key;
}
if (null === $value || '' === $value || !json_validate((string) $value)) {
return '';
}
return implode(
'|',
array_map(
fn ($cid) => $this->centerRepository->find($cid)->getName(),
array_unique(
json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR)
)
)
);
},
default => static function ($value) use ($key) { default => static function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.list.acp.'.$key; return 'export.list.acp.'.$key;
@ -315,6 +339,19 @@ final readonly class ListAccompanyingPeriodHelper
// social issues // social issues
->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM '.SocialIssue::class.' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues'); ->addSelect('(SELECT AGGREGATE(socialIssue.id) FROM '.SocialIssue::class.' socialIssue WHERE socialIssue MEMBER OF acp.socialIssues) AS socialIssues');
// duration
$qb->addSelect('DATE_DIFF(COALESCE(acp.closingDate, :calcDate), acp.openingDate) AS duration');
// centers
$qb->addSelect(
'(SELECT AGGREGATE(IDENTITY(cppch.center))
FROM '.AccompanyingPeriodParticipation::class.' part
JOIN '.PersonCenterHistory::class." cppch
WITH IDENTITY(cppch.person) = IDENTITY(part.person)
AND OVERLAPSI (cppch.startDate, cppch.endDate), (part.startDate, part.endDate) = 'TRUE'
WHERE part.accompanyingPeriod = acp
) AS centers"
);
// add parameter // add parameter
$qb->setParameter('calcDate', $calcDate); $qb->setParameter('calcDate', $calcDate);
} }

View File

@ -1346,6 +1346,8 @@ export:
requestorThirdParty: Demandeur (tiers) requestorThirdParty: Demandeur (tiers)
acpParticipantPersons: Usagers concernés acpParticipantPersons: Usagers concernés
acpParticipantPersonsIds: Usagers concernés (identifiants) acpParticipantPersonsIds: Usagers concernés (identifiants)
duration: Durée du parcours (en jours)
centers: Centres des usagers
eval: eval:
List of evaluations: Liste des évaluations List of evaluations: Liste des évaluations