Merge branch 'add-module-emploi' of gitlab.com:Chill-Projet/chill-bundles into add-module-emploi

This commit is contained in:
Julie Lenaerts 2024-05-22 08:40:46 +02:00
commit 82d3ec4d6f
2 changed files with 54 additions and 66 deletions

View File

@ -113,7 +113,7 @@ class CSPerson
'ASS', 'ASS',
'RSA', 'RSA',
'AAH', 'AAH',
'autre', // 'autre',
]; ];
/** /**
@ -140,7 +140,7 @@ class CSPerson
'referent_RSA', 'referent_RSA',
'mission_locale', 'mission_locale',
'rqth', 'rqth',
'autre', // 'autre',
]; ];
/** /**
@ -226,7 +226,7 @@ class CSPerson
'scooter', 'scooter',
'velo', 'velo',
'voiture', 'voiture',
'autre', // 'autre',
]; ];
/** /**

View File

@ -28,33 +28,37 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac
{ {
} }
private const CSPERSON_JSON_FIELDS = [
...CSPerson::RESSOURCES,
...CSPerson::MOBILITE_MOYEN_TRANSPORT,
...CSPerson::TYPE_CONTRAT,
...CSPerson::PERMIS_CONDUIRE,
...CSPerson::ACCOMPAGNEMENTS,
...CSPerson::SITUATION_PROFESSIONNELLE,
...CSPerson::NEET_ELIGIBILITY,
];
private const CSPERSON_FIELDS = [ private const CSPERSON_FIELDS = [
/* CSPerson::RESSOURCES, 'dateFinDernierEmploi',
CSPerson::MOBILITE_MOYEN_TRANSPORT,
CSPerson::TYPE_CONTRAT,
CSPerson::PERMIS_CONDUIRE,
CSPerson::ACCOMPAGNEMENTS,
CSPerson::SITUATION_PROFESSIONNELLE,
CSPerson::NEET_ELIGIBILITY,*/
'findernieremploidate',
/* 'prescripteur__name', /* 'prescripteur__name',
'prescripteur__email', 'prescripteur__email',
'prescripteur__phone',*/ 'prescripteur__phone',*/
'poleemploiid', 'poleEmploiId',
'cafid', 'cafId',
'cafinscriptiondate', 'cafInscriptionDate',
'contratiejdate', 'dateContratIEJ',
'cerinscriptiondate', 'cERInscriptionDate',
'ppaeinscriptiondate', 'pPAEInscriptionDate',
'ppaesignataire', 'pPAESignataire',
'cersignataire', 'cERSignataire',
'neetcommissiondate', 'nEETCommissionDate',
'fsemademarchecode', 'fSEMaDemarcheCode',
'enfantACharge'
]; ];
public function alterKeys(array $existing): array public function alterKeys(array $existing): array
{ {
return [...$existing, ...self::CSPERSON_FIELDS]; return [...$existing, ...self::CSPERSON_FIELDS, ...self::CSPERSON_JSON_FIELDS];
} }
public function alterSelect(QueryBuilder $qb, \DateTimeImmutable $computedDate): void public function alterSelect(QueryBuilder $qb, \DateTimeImmutable $computedDate): void
@ -63,72 +67,60 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac
->leftJoin(CSPerson::class, 'cs_person', Query\Expr\Join::WITH, 'cs_person.person = person'); ->leftJoin(CSPerson::class, 'cs_person', Query\Expr\Join::WITH, 'cs_person.person = person');
foreach (self::CSPERSON_FIELDS as $f) { foreach (self::CSPERSON_FIELDS as $f) {
switch ($f) { $qb->addSelect(sprintf('cs_person.%s as %s', $f, $f));
case 'findernieremploidate': }
$qb->addSelect('cs_person.dateFinDernierEmploi AS findernieremploidate');
foreach (self::CSPERSON_JSON_FIELDS as $jf)
{
switch ($jf) {
case in_array($jf, CSPerson::MOBILITE_MOYEN_TRANSPORT):
$qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.mobiliteMoyenDeTransport, :param) AS mobilite_' . $jf)
->setParameter('param', $jf);
break; break;
case 'poleemploiid': case in_array($jf, CSPerson::TYPE_CONTRAT):
$qb->addSelect('cs_person.poleEmploiId AS poleemploiid'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param) AS ' . $jf)
->setParameter('param', $jf);
break; break;
case 'cafid': case in_array($jf, CSPerson::ACCOMPAGNEMENTS):
$qb->addSelect('cs_person.cafId AS cafid'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param) AS accompagnements_' . $jf)
->setParameter('param', $jf);
break; break;
case 'cafinscriptiondate': case in_array($jf, CSPerson::SITUATION_PROFESSIONNELLE):
$qb->addSelect('cs_person.cafInscriptionDate AS cafinscriptiondate'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.situationProfessionnelle, :param) AS ' . $jf)
->setParameter('param', $jf);
break; break;
case 'contratiejdate': case in_array($jf, CSPerson::NEET_ELIGIBILITY):
$qb->addSelect('cs_person.dateContratIEJ AS contratiejdate'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.nEETEligibilite, :param) AS ' . $jf)
->setParameter('param', $jf);
break; break;
case 'cerinscriptiondate': case in_array($jf, CSPerson::PERMIS_CONDUIRE):
$qb->addSelect('cs_person.cERInscriptionDate AS cerinscriptiondate'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param) AS ' . $jf)
->setParameter('param', $jf);
break; break;
case 'ppaeinscriptiondate': case in_array($jf, CSPerson::RESSOURCES):
$qb->addSelect('cs_person.pPAEInscriptionDate AS ppaeinscriptiondate'); $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param) AS ressources_' . $jf)
->setParameter('param', $jf);
break; break;
case 'ppaesignataire':
$qb->addSelect('cs_person.pPAESignataire AS ppaesignataire');
break;
case 'cersignataire':
$qb->addSelect('cs_person.cERSignataire AS cersignataire');
break;
case 'neetcommissiondate':
$qb->addSelect('cs_person.nEETCommissionDate AS neetcommissiondate');
break;
case 'fsemademarchecode':
$qb->addSelect('cs_person.fSEMaDemarcheCode AS fsemademarchecode');
break;
default:
$qb->addSelect(sprintf('person.%s as %s', $f, $f));
} }
} }
} }
public function getLabels(string $key, array $values, array $data): ?callable public function getLabels(string $key, array $values, array $data): ?callable
{ {
// dump('im here');
switch ($key) { switch ($key) {
case 'cerinscriptiondate': case 'cerinscriptiondate':
case 'ppaeinscriptiondate': case 'ppaeinscriptiondate':
@ -166,10 +158,6 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac
}; };
default: default:
/* if (!\in_array($key, $this->getAllKeys(), true)) {
throw new \RuntimeException("this key is not supported by this helper: {$key}");
}*/
// for fields which are associated with person // for fields which are associated with person
return function ($value) use ($key) { return function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {