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

This commit is contained in:
LenaertsJ 2024-03-14 21:35:00 +00:00 committed by Julien Fastré
parent 18c0b6a47f
commit dd056efa0d
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\ExportAddressHelper;
use Chill\MainBundle\Export\Helper\UserHelper;
use Chill\MainBundle\Repository\CenterRepository;
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\Person\PersonCenterHistory;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
@ -39,6 +41,8 @@ final readonly class ListAccompanyingPeriodHelper
'stepSince',
'openingDate',
'closingDate',
'duration',
'centers',
'referrer',
'referrerSince',
'acpParticipantPersons',
@ -83,6 +87,7 @@ final readonly class ListAccompanyingPeriodHelper
private TranslatorInterface $translator,
private UserHelper $userHelper,
private LabelPersonHelper $labelPersonHelper,
private CenterRepository $centerRepository
) {
}
@ -202,6 +207,25 @@ final readonly class ListAccompanyingPeriodHelper
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
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) {
if ('_header' === $value) {
return 'export.list.acp.'.$key;
@ -315,6 +339,19 @@ final readonly class ListAccompanyingPeriodHelper
// social issues
->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
$qb->setParameter('calcDate', $calcDate);
}

View File

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