From c07a728f1de57a1eca46b893262ee4deb2fd9e07 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 May 2024 14:35:51 +0200 Subject: [PATCH 1/7] Wip: add jsonb fields to export --- .../ChillJobBundle/src/Entity/CSPerson.php | 6 +- .../Export/AddCSPersonToPersonListHelper.php | 114 ++++++++---------- 2 files changed, 54 insertions(+), 66 deletions(-) diff --git a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php index 579698a64..012cd62c4 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php +++ b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php @@ -113,7 +113,7 @@ class CSPerson 'ASS', 'RSA', 'AAH', - 'autre', +// 'autre', ]; /** @@ -140,7 +140,7 @@ class CSPerson 'referent_RSA', 'mission_locale', 'rqth', - 'autre', +// 'autre', ]; /** @@ -226,7 +226,7 @@ class CSPerson 'scooter', 'velo', 'voiture', - 'autre', +// 'autre', ]; /** diff --git a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php index 34f10a1f9..35a1f9b35 100644 --- a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php +++ b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php @@ -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 = [ -/* CSPerson::RESSOURCES, - CSPerson::MOBILITE_MOYEN_TRANSPORT, - CSPerson::TYPE_CONTRAT, - CSPerson::PERMIS_CONDUIRE, - CSPerson::ACCOMPAGNEMENTS, - CSPerson::SITUATION_PROFESSIONNELLE, - CSPerson::NEET_ELIGIBILITY,*/ - 'findernieremploidate', + 'dateFinDernierEmploi', /* 'prescripteur__name', 'prescripteur__email', 'prescripteur__phone',*/ - 'poleemploiid', - 'cafid', - 'cafinscriptiondate', - 'contratiejdate', - 'cerinscriptiondate', - 'ppaeinscriptiondate', - 'ppaesignataire', - 'cersignataire', - 'neetcommissiondate', - 'fsemademarchecode', + 'poleEmploiId', + 'cafId', + 'cafInscriptionDate', + 'dateContratIEJ', + 'cERInscriptionDate', + 'pPAEInscriptionDate', + 'pPAESignataire', + 'cERSignataire', + 'nEETCommissionDate', + 'fSEMaDemarcheCode', + 'enfantACharge' ]; 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 @@ -63,72 +67,60 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac ->leftJoin(CSPerson::class, 'cs_person', Query\Expr\Join::WITH, 'cs_person.person = person'); foreach (self::CSPERSON_FIELDS as $f) { - switch ($f) { - case 'findernieremploidate': - $qb->addSelect('cs_person.dateFinDernierEmploi AS findernieremploidate'); + $qb->addSelect(sprintf('cs_person.%s as %s', $f, $f)); + } + + 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; - case 'poleemploiid': - $qb->addSelect('cs_person.poleEmploiId AS poleemploiid'); + case in_array($jf, CSPerson::TYPE_CONTRAT): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param) AS ' . $jf) + ->setParameter('param', $jf); break; - case 'cafid': - $qb->addSelect('cs_person.cafId AS cafid'); + case in_array($jf, CSPerson::ACCOMPAGNEMENTS): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param) AS accompagnements_' . $jf) + ->setParameter('param', $jf); break; - case 'cafinscriptiondate': - $qb->addSelect('cs_person.cafInscriptionDate AS cafinscriptiondate'); + case in_array($jf, CSPerson::SITUATION_PROFESSIONNELLE): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.situationProfessionnelle, :param) AS ' . $jf) + ->setParameter('param', $jf); break; - case 'contratiejdate': - $qb->addSelect('cs_person.dateContratIEJ AS contratiejdate'); + case in_array($jf, CSPerson::NEET_ELIGIBILITY): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.nEETEligibilite, :param) AS ' . $jf) + ->setParameter('param', $jf); break; - case 'cerinscriptiondate': - $qb->addSelect('cs_person.cERInscriptionDate AS cerinscriptiondate'); + case in_array($jf, CSPerson::PERMIS_CONDUIRE): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param) AS ' . $jf) + ->setParameter('param', $jf); break; - case 'ppaeinscriptiondate': - $qb->addSelect('cs_person.pPAEInscriptionDate AS ppaeinscriptiondate'); + case in_array($jf, CSPerson::RESSOURCES): + $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param) AS ressources_' . $jf) + ->setParameter('param', $jf); 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 { -// dump('im here'); switch ($key) { case 'cerinscriptiondate': case 'ppaeinscriptiondate': @@ -166,10 +158,6 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac }; 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 return function ($value) use ($key) { if ('_header' === $value) { From 7d309136b174c6d2969f8e0cf402f80cf56295db Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 May 2024 16:02:14 +0200 Subject: [PATCH 2/7] minor last fixes for immersion and remove of dumps --- .../src/ApiHelper/PartenaireRomeAppellation.php | 5 ++--- .../src/Controller/CSCrudReportController.php | 1 - src/Bundle/ChillJobBundle/src/Entity/Immersion.php | 8 ++++---- .../src/migrations/Version20240424095147.php | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index 8126dd2dc..8711a5028 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -83,9 +83,8 @@ class PartenaireRomeAppellation ); } catch (ClientException $e) { -dump($e->getResponse()); -dump($e->getRequest()); dump($e->getResponse()->getBody()->getContents()); -} + dump($e->getResponse()->getBody()->getContents()); + } return Utils::jsonDecode((string) $response->getBody()); diff --git a/src/Bundle/ChillJobBundle/src/Controller/CSCrudReportController.php b/src/Bundle/ChillJobBundle/src/Controller/CSCrudReportController.php index e52f296cc..6f0cc742c 100644 --- a/src/Bundle/ChillJobBundle/src/Controller/CSCrudReportController.php +++ b/src/Bundle/ChillJobBundle/src/Controller/CSCrudReportController.php @@ -79,7 +79,6 @@ class CSCrudReportController extends EntityPersonCRUDController protected function createFormFor(string $action, $entity, ?string $formClass = null, array $formOptions = []): FormInterface { - dump($entity); if ($entity instanceof Immersion) { if ('edit' === $action || 'new' === $action) { return parent::createFormFor($action, $entity, $formClass, [ diff --git a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php index 174375432..1e3b9879e 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php @@ -182,8 +182,8 @@ class Immersion implements \Stringable #[ORM\Column(name: 'savoirEtreNote', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $savoirEtreNote = null; - #[ORM\Column(name: 'noteimmersion', type: \Doctrine\DBAL\Types\Types::TEXT)] - private ?string $noteImmersion = ''; + #[ORM\Column(name: 'noteimmersion', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] + private ?string $noteImmersion = null; #[ORM\Column(name: 'principalesActivites', type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)] private ?string $principalesActivites = null; @@ -524,11 +524,11 @@ class Immersion implements \Stringable /** * Get duration. * - * @return \DateInterval */ public function getDuration() { - return new \DateInterval($this->duration); + return $this->duration; +// return new \DateInterval($this->duration ?? 'P7D'); } public function getDateEndComputed() diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php b/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php index 97b0a376a..4719332d9 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php @@ -57,7 +57,7 @@ final class Version20240424095147 extends AbstractMigration $this->addSql('CREATE TABLE chill_job.cv_formation (id INT NOT NULL, title TEXT NOT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, diplomaObtained VARCHAR(255) DEFAULT NULL, diplomaReconnue VARCHAR(50) DEFAULT NULL, organisme TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_20BE09E2AE1799D8 ON chill_job.cv_formation (CV_id)'); $this->addSql('CREATE TABLE chill_job.frein (id INT NOT NULL, reportDate DATE NOT NULL, freinsPerso JSON NOT NULL, notesPerso TEXT NOT NULL, freinsEmploi JSON NOT NULL, notesEmploi TEXT NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE TABLE chill_job.immersion (id INT NOT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, structureAccEmail TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSON DEFAULT NULL, objectifsAutre TEXT DEFAULT NULL, is_bilan_fullfilled BOOLEAN DEFAULT false NOT NULL, savoirEtre JSON DEFAULT NULL, savoirEtreNote TEXT DEFAULT NULL, noteimmersion TEXT NOT NULL, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, ponctualite_salarie TEXT DEFAULT NULL, ponctualite_salarie_note TEXT DEFAULT NULL, assiduite TEXT DEFAULT NULL, assiduite_note TEXT DEFAULT NULL, interet_activite TEXT DEFAULT NULL, interet_activite_note TEXT DEFAULT NULL, integre_regle TEXT DEFAULT NULL, integre_regle_note TEXT DEFAULT NULL, esprit_initiative TEXT DEFAULT NULL, esprit_initiative_note TEXT DEFAULT NULL, organisation TEXT DEFAULT NULL, organisation_note TEXT DEFAULT NULL, capacite_travail_equipe TEXT DEFAULT NULL, capacite_travail_equipe_note TEXT DEFAULT NULL, style_vestimentaire TEXT DEFAULT NULL, style_vestimentaire_note TEXT DEFAULT NULL, langage_prof TEXT DEFAULT NULL, langage_prof_note TEXT DEFAULT NULL, applique_consigne TEXT DEFAULT NULL, applique_consigne_note TEXT DEFAULT NULL, respect_hierarchie TEXT DEFAULT NULL, respect_hierarchie_note TEXT DEFAULT NULL, structureAccAddress_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.immersion (id INT NOT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, structureAccEmail TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSON DEFAULT NULL, objectifsAutre TEXT DEFAULT NULL, is_bilan_fullfilled BOOLEAN DEFAULT false NOT NULL, savoirEtre JSON DEFAULT NULL, savoirEtreNote TEXT DEFAULT NULL, noteimmersion TEXT, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, ponctualite_salarie TEXT DEFAULT NULL, ponctualite_salarie_note TEXT DEFAULT NULL, assiduite TEXT DEFAULT NULL, assiduite_note TEXT DEFAULT NULL, interet_activite TEXT DEFAULT NULL, interet_activite_note TEXT DEFAULT NULL, integre_regle TEXT DEFAULT NULL, integre_regle_note TEXT DEFAULT NULL, esprit_initiative TEXT DEFAULT NULL, esprit_initiative_note TEXT DEFAULT NULL, organisation TEXT DEFAULT NULL, organisation_note TEXT DEFAULT NULL, capacite_travail_equipe TEXT DEFAULT NULL, capacite_travail_equipe_note TEXT DEFAULT NULL, style_vestimentaire TEXT DEFAULT NULL, style_vestimentaire_note TEXT DEFAULT NULL, langage_prof TEXT DEFAULT NULL, langage_prof_note TEXT DEFAULT NULL, applique_consigne TEXT DEFAULT NULL, applique_consigne_note TEXT DEFAULT NULL, respect_hierarchie TEXT DEFAULT NULL, respect_hierarchie_note TEXT DEFAULT NULL, structureAccAddress_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_FBB3CBB4A4AEAFEA ON chill_job.immersion (entreprise_id)'); $this->addSql('CREATE INDEX IDX_FBB3CBB435E47E35 ON chill_job.immersion (referent_id)'); $this->addSql('CREATE INDEX IDX_FBB3CBB4B5E04267 ON chill_job.immersion (structureAccAddress_id)'); From 2708bafb1fabc9558e7b2fc420fdcde88f7ae473 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 May 2024 15:24:39 +0200 Subject: [PATCH 3/7] Export for list person with cs_person columns fixed --- .../ChillJobBundle/src/Entity/CSPerson.php | 6 +- .../Export/AddCSPersonToPersonListHelper.php | 223 ++++++++++-------- .../Resources/translations/messages.fr.yml | 43 ++++ .../src/migrations/Version20240424095147.php | 10 +- 4 files changed, 179 insertions(+), 103 deletions(-) diff --git a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php index 012cd62c4..579698a64 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php +++ b/src/Bundle/ChillJobBundle/src/Entity/CSPerson.php @@ -113,7 +113,7 @@ class CSPerson 'ASS', 'RSA', 'AAH', -// 'autre', + 'autre', ]; /** @@ -140,7 +140,7 @@ class CSPerson 'referent_RSA', 'mission_locale', 'rqth', -// 'autre', + 'autre', ]; /** @@ -226,7 +226,7 @@ class CSPerson 'scooter', 'velo', 'voiture', -// 'autre', + 'autre', ]; /** diff --git a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php index 35a1f9b35..b05b22be4 100644 --- a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php +++ b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php @@ -28,16 +28,6 @@ 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 = [ 'dateFinDernierEmploi', /* 'prescripteur__name', @@ -53,12 +43,28 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac 'cERSignataire', 'nEETCommissionDate', 'fSEMaDemarcheCode', - 'enfantACharge' + 'enfantACharge', + 'nEETEligibilite', + 'situationProfessionnelle', ]; public function alterKeys(array $existing): array { - return [...$existing, ...self::CSPERSON_FIELDS, ...self::CSPERSON_JSON_FIELDS]; + $ressources = array_map(static fn ($key) => 'ressources__' . $key, CSPerson::RESSOURCES); + $moyenTransport = array_map(static fn ($key) => 'moyen_transport__' . $key, CSPerson::MOBILITE_MOYEN_TRANSPORT); + $accompagnements = array_map(static fn ($key) => 'accompagnements__' . $key, CSPerson::ACCOMPAGNEMENTS); + $permisConduire = array_map(static fn ($key) => 'permis_conduire__' . $key, CSPerson::PERMIS_CONDUIRE); + $typeContrat = array_map(static fn ($key) => 'type_contrat__' . $key, CSPerson::TYPE_CONTRAT); + + return [ + ...$existing, + ...self::CSPERSON_FIELDS, + ...$ressources, + ...$moyenTransport, + ...$accompagnements, + ...$permisConduire, + ...$typeContrat, + ]; } public function alterSelect(QueryBuilder $qb, \DateTimeImmutable $computedDate): void @@ -70,102 +76,129 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac $qb->addSelect(sprintf('cs_person.%s as %s', $f, $f)); } - foreach (self::CSPERSON_JSON_FIELDS as $jf) +/* $qb->addSelect('cs_person.situationProfessionnelle as situation_prof'); + + $qb->addSelect('cs_person.nEETEligibilite as nEETEligibilite');*/ + + $i = 0; + + foreach (CSPerson::RESSOURCES as $key) { - 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; - - case in_array($jf, CSPerson::TYPE_CONTRAT): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param) AS ' . $jf) - ->setParameter('param', $jf); - - break; - - case in_array($jf, CSPerson::ACCOMPAGNEMENTS): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param) AS accompagnements_' . $jf) - ->setParameter('param', $jf); - - break; - - case in_array($jf, CSPerson::SITUATION_PROFESSIONNELLE): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.situationProfessionnelle, :param) AS ' . $jf) - ->setParameter('param', $jf); - - break; - - case in_array($jf, CSPerson::NEET_ELIGIBILITY): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.nEETEligibilite, :param) AS ' . $jf) - ->setParameter('param', $jf); - - break; - - case in_array($jf, CSPerson::PERMIS_CONDUIRE): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param) AS ' . $jf) - ->setParameter('param', $jf); - - break; - - case in_array($jf, CSPerson::RESSOURCES): - $qb->addSelect('JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param) AS ressources_' . $jf) - ->setParameter('param', $jf); - - break; - } - + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param_$i) AS ressources__" . $key) + ->setParameter('param_'.$i, $key); + ++$i; } + + foreach(CSPerson::MOBILITE_MOYEN_TRANSPORT as $key) + { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.mobiliteMoyenDeTransport, :param_$i) AS moyen_transport__" . $key) + ->setParameter('param_'.$i, $key); + ++$i; + } + + foreach(CSPerson::TYPE_CONTRAT as $key) + { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param_$i) AS type_contrat__" . $key) + ->setParameter('param_'.$i, $key); + ++$i; + } + + foreach (CSPerson::ACCOMPAGNEMENTS as $key) + { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param_$i) AS accompagnements__" . $key) + ->setParameter('param_'.$i, $key); + ++$i; + } + + foreach (CSPerson::PERMIS_CONDUIRE as $key) + { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param_$i) AS permis_conduire__" . $key) + ->setParameter('param_'.$i, $key); + ++$i; + } + } public function getLabels(string $key, array $values, array $data): ?callable { - switch ($key) { - case 'cerinscriptiondate': - case 'ppaeinscriptiondate': - case 'neetcommissiondate': - case 'findernieremploidate': - case 'cafinscriptiondate': - case 'contratiejdate': - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } + switch ($key) { + case str_contains($key, '__'): + return function (string|bool|null $value) use ($key): string { + if ('_header' === $value) { + [$domain, $v] = explode('__', $key); + return 'export.list.cs_person.' . $domain . '.' . $v; + } + + if ('1' === $value || true === $value || 1 === $value || 't' === $value) { + return 'x'; + } - if (null === $value) { return ''; - } - // warning: won't work with DateTimeImmutable as we reset time a few lines later - $date = \DateTime::createFromFormat('Y-m-d', $value); - $hasTime = false; + }; + case 'nEETEligibilite': + return function (string|bool|null $value) use ($key): string { + if ('_header' === $value) { + return 'export.list.cs_person.neet_eligibility'; + } - if (false === $date) { - $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); - $hasTime = true; - } + if ('1' === $value || true === $value || 1 === $value || 't' === $value) { + return 'x'; + } - // check that the creation could occur. - if (false === $date) { - throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); - } + return ''; + }; + case 'situationProfessionnelle': + return function ($value) use ($key) { + if ('_header' === $value) { + return 'export.list.cs_person.situation_professionelle'; + } - if (!$hasTime) { - $date->setTime(0, 0, 0); - } + return $value; + }; + case 'cerinscriptiondate': + case 'ppaeinscriptiondate': + case 'neetcommissiondate': + case 'findernieremploidate': + case 'cafinscriptiondate': + case 'contratiejdate': + return function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } - return $date; - }; + if (null === $value) { + return ''; + } + // warning: won't work with DateTimeImmutable as we reset time a few lines later + $date = \DateTime::createFromFormat('Y-m-d', $value); + $hasTime = false; - default: - // for fields which are associated with person - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } + if (false === $date) { + $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); + $hasTime = true; + } - return $value; - }; - } + // check that the creation could occur. + if (false === $date) { + throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); + } + + if (!$hasTime) { + $date->setTime(0, 0, 0); + } + + return $date; + }; + + default: + // for fields which are associated with person + return function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } + + return $value; + }; + } } } diff --git a/src/Bundle/ChillJobBundle/src/Resources/translations/messages.fr.yml b/src/Bundle/ChillJobBundle/src/Resources/translations/messages.fr.yml index 4c8571428..06b35ddcf 100644 --- a/src/Bundle/ChillJobBundle/src/Resources/translations/messages.fr.yml +++ b/src/Bundle/ChillJobBundle/src/Resources/translations/messages.fr.yml @@ -253,3 +253,46 @@ CHILL_JOB_REPORT_CV: Création et modification des rapports emploi (CV uniquemen CHILL_JOB_EXPORTS: Exports emploi JobBundle: Emploi + +export: + list: + cs_person: + ressources: + salaires: 'Ressources: salaires' + ARE: 'Ressources: ARE' + ASS: 'Ressources: ASS' + RSA: 'Ressources: RSA' + AAH: 'Ressources: AAH' + autre: 'Ressources: autre' + moyen_transport: + transport_commun: 'Moyen transport: transport commun' + scooter: 'Moyen transport: scooter' + velo: 'Moyen transport: vélo' + voiture: 'Moyen transport: voiture' + autre: 'Moyen transport: autre' + accompagnements: + plie: 'Accompagnement: plie' + pole_emploi: 'Accompagnement: pôle emploi' + referent_RSA: 'Accompagnement: ' + mission_locale: 'Accompagnement: ' + rqth: 'Accompagnement: ' + autre: 'Accompagnement: ' + permis_conduire: + a: 'Permis de conduire: A' + b: 'Permis de conduire: B' + c: 'Permis de conduire: C' + d: 'Permis de conduire: D' + e: 'Permis de conduire: E' + caces: 'Permis de conduire: caces' + en_cours: 'Permis de conduire: en cours' + pas_de_permis: 'Pas de permis de conduire' + type_contrat: + cdd: 'Type de contrat: cdd' + cdi: 'Type de contrat: cdi' + contrat_interim: 'Type de contrat: interim' + contrat_aide: 'Type de contrat: aide' + cdd_insertion: 'Type de contrat: cdd insertion' + contrat_extra: 'Type de contrat: contrat extra' + service_civique: 'Type de contrat: service civique' + neet_eligibility: 'NEET eligibilité' + situation_professionelle: 'Situation professionelle' diff --git a/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php b/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php index 4719332d9..dd4b98c11 100644 --- a/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php +++ b/src/Bundle/ChillJobBundle/src/migrations/Version20240424095147.php @@ -32,7 +32,7 @@ final class Version20240424095147 extends AbstractMigration $this->addSql('CREATE SEQUENCE chill_job.projet_professionnel_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_job.rome_appellation_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); $this->addSql('CREATE SEQUENCE chill_job.rome_metier_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE chill_job.cs_person (id INT NOT NULL, person_id INT DEFAULT NULL, prescripteur_id INT DEFAULT NULL, situationLogement VARCHAR(255) DEFAULT NULL, situationLogementPrecision TEXT DEFAULT NULL, enfantACharge INT DEFAULT NULL, niveauMaitriseLangue JSON DEFAULT NULL, vehiculePersonnel BOOLEAN DEFAULT NULL, permisConduire JSON DEFAULT NULL, situationProfessionnelle VARCHAR(255) DEFAULT NULL, dateFinDernierEmploi DATE DEFAULT NULL, typeContrat JSON DEFAULT NULL, typeContratAide TEXT DEFAULT NULL, ressources JSON DEFAULT NULL, ressourcesComment TEXT DEFAULT NULL, ressourceDate1Versement DATE DEFAULT NULL, CPFMontant NUMERIC(10, 2) DEFAULT NULL, acomptedif NUMERIC(10, 2) DEFAULT NULL, accompagnement JSON DEFAULT NULL, accompagnementRQTHDate DATE DEFAULT NULL, accompagnementComment VARCHAR(255) DEFAULT NULL, poleEmploiId VARCHAR(255) DEFAULT NULL, poleEmploiInscriptionDate DATE DEFAULT NULL, cafId VARCHAR(255) DEFAULT NULL, cafInscriptionDate DATE DEFAULT NULL, CERInscriptionDate DATE DEFAULT NULL, PPAEInscriptionDate DATE DEFAULT NULL, CERSignataire TEXT DEFAULT NULL, PPAESignataire TEXT DEFAULT NULL, NEETEligibilite VARCHAR(255) DEFAULT NULL, NEETCommissionDate DATE DEFAULT NULL, FSEMaDemarcheCode TEXT DEFAULT NULL, datecontratIEJ DATE DEFAULT NULL, dateavenantIEJ DATE DEFAULT NULL, dispositifs_notes TEXT DEFAULT NULL, handicap BOOLEAN DEFAULT NULL, handicapnotes TEXT DEFAULT NULL, handicapRecommandation VARCHAR(50) DEFAULT NULL, mobilitemoyentransport JSON DEFAULT NULL, mobilitenotes TEXT DEFAULT NULL, handicapAccompagnement_id INT DEFAULT NULL, documentCV_id INT DEFAULT NULL, documentAgrementIAE_id INT DEFAULT NULL, documentRQTH_id INT DEFAULT NULL, documentAttestationNEET_id INT DEFAULT NULL, documentCI_id INT DEFAULT NULL, documentTitreSejour_id INT DEFAULT NULL, documentAttestationFiscale_id INT DEFAULT NULL, documentPermis_id INT DEFAULT NULL, documentAttestationCAAF_id INT DEFAULT NULL, documentContraTravail_id INT DEFAULT NULL, documentAttestationFormation_id INT DEFAULT NULL, documentQuittanceLoyer_id INT DEFAULT NULL, documentFactureElectricite_id INT DEFAULT NULL, documentAttestationSecuriteSociale_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.cs_person (id INT NOT NULL, person_id INT DEFAULT NULL, prescripteur_id INT DEFAULT NULL, situationLogement VARCHAR(255) DEFAULT NULL, situationLogementPrecision TEXT DEFAULT NULL, enfantACharge INT DEFAULT NULL, niveauMaitriseLangue JSONB DEFAULT NULL, vehiculePersonnel BOOLEAN DEFAULT NULL, permisConduire JSONB DEFAULT NULL, situationProfessionnelle VARCHAR(255) DEFAULT NULL, dateFinDernierEmploi DATE DEFAULT NULL, typeContrat JSONB DEFAULT NULL, typeContratAide TEXT DEFAULT NULL, ressources JSONB DEFAULT NULL, ressourcesComment TEXT DEFAULT NULL, ressourceDate1Versement DATE DEFAULT NULL, CPFMontant NUMERIC(10, 2) DEFAULT NULL, acomptedif NUMERIC(10, 2) DEFAULT NULL, accompagnement JSONB DEFAULT NULL, accompagnementRQTHDate DATE DEFAULT NULL, accompagnementComment VARCHAR(255) DEFAULT NULL, poleEmploiId VARCHAR(255) DEFAULT NULL, poleEmploiInscriptionDate DATE DEFAULT NULL, cafId VARCHAR(255) DEFAULT NULL, cafInscriptionDate DATE DEFAULT NULL, CERInscriptionDate DATE DEFAULT NULL, PPAEInscriptionDate DATE DEFAULT NULL, CERSignataire TEXT DEFAULT NULL, PPAESignataire TEXT DEFAULT NULL, NEETEligibilite VARCHAR(255) DEFAULT NULL, NEETCommissionDate DATE DEFAULT NULL, FSEMaDemarcheCode TEXT DEFAULT NULL, datecontratIEJ DATE DEFAULT NULL, dateavenantIEJ DATE DEFAULT NULL, dispositifs_notes TEXT DEFAULT NULL, handicap BOOLEAN DEFAULT NULL, handicapnotes TEXT DEFAULT NULL, handicapRecommandation VARCHAR(50) DEFAULT NULL, mobilitemoyentransport JSONB DEFAULT NULL, mobilitenotes TEXT DEFAULT NULL, handicapAccompagnement_id INT DEFAULT NULL, documentCV_id INT DEFAULT NULL, documentAgrementIAE_id INT DEFAULT NULL, documentRQTH_id INT DEFAULT NULL, documentAttestationNEET_id INT DEFAULT NULL, documentCI_id INT DEFAULT NULL, documentTitreSejour_id INT DEFAULT NULL, documentAttestationFiscale_id INT DEFAULT NULL, documentPermis_id INT DEFAULT NULL, documentAttestationCAAF_id INT DEFAULT NULL, documentContraTravail_id INT DEFAULT NULL, documentAttestationFormation_id INT DEFAULT NULL, documentQuittanceLoyer_id INT DEFAULT NULL, documentFactureElectricite_id INT DEFAULT NULL, documentAttestationSecuriteSociale_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE UNIQUE INDEX UNIQ_10864F31217BBB47 ON chill_job.cs_person (person_id)'); $this->addSql('CREATE INDEX IDX_10864F312654B57D ON chill_job.cs_person (handicapAccompagnement_id)'); $this->addSql('CREATE INDEX IDX_10864F3154866550 ON chill_job.cs_person (documentCV_id)'); @@ -50,19 +50,19 @@ final class Version20240424095147 extends AbstractMigration $this->addSql('CREATE INDEX IDX_10864F31AC39B1B ON chill_job.cs_person (documentFactureElectricite_id)'); $this->addSql('CREATE INDEX IDX_10864F3172A75B6D ON chill_job.cs_person (documentAttestationSecuriteSociale_id)'); $this->addSql('CREATE INDEX IDX_10864F31D486E642 ON chill_job.cs_person (prescripteur_id)'); - $this->addSql('CREATE TABLE chill_job.cv (id INT NOT NULL, person_id INT DEFAULT NULL, reportDate DATE NOT NULL, formationLevel VARCHAR(255) DEFAULT NULL, formationType VARCHAR(255) DEFAULT NULL, spokenLanguages JSON DEFAULT NULL, notes TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.cv (id INT NOT NULL, person_id INT DEFAULT NULL, reportDate DATE NOT NULL, formationLevel VARCHAR(255) DEFAULT NULL, formationType VARCHAR(255) DEFAULT NULL, spokenLanguages JSONB DEFAULT NULL, notes TEXT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_3F24F812217BBB47 ON chill_job.cv (person_id)'); $this->addSql('CREATE TABLE chill_job.cv_experience (id INT NOT NULL, poste TEXT DEFAULT NULL, structure TEXT DEFAULT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, contratType VARCHAR(100) NOT NULL, notes TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_102A1262AE1799D8 ON chill_job.cv_experience (CV_id)'); $this->addSql('CREATE TABLE chill_job.cv_formation (id INT NOT NULL, title TEXT NOT NULL, startDate DATE DEFAULT NULL, endDate DATE DEFAULT NULL, diplomaObtained VARCHAR(255) DEFAULT NULL, diplomaReconnue VARCHAR(50) DEFAULT NULL, organisme TEXT DEFAULT NULL, CV_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_20BE09E2AE1799D8 ON chill_job.cv_formation (CV_id)'); - $this->addSql('CREATE TABLE chill_job.frein (id INT NOT NULL, reportDate DATE NOT NULL, freinsPerso JSON NOT NULL, notesPerso TEXT NOT NULL, freinsEmploi JSON NOT NULL, notesEmploi TEXT NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE TABLE chill_job.immersion (id INT NOT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, structureAccEmail TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSON DEFAULT NULL, objectifsAutre TEXT DEFAULT NULL, is_bilan_fullfilled BOOLEAN DEFAULT false NOT NULL, savoirEtre JSON DEFAULT NULL, savoirEtreNote TEXT DEFAULT NULL, noteimmersion TEXT, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, ponctualite_salarie TEXT DEFAULT NULL, ponctualite_salarie_note TEXT DEFAULT NULL, assiduite TEXT DEFAULT NULL, assiduite_note TEXT DEFAULT NULL, interet_activite TEXT DEFAULT NULL, interet_activite_note TEXT DEFAULT NULL, integre_regle TEXT DEFAULT NULL, integre_regle_note TEXT DEFAULT NULL, esprit_initiative TEXT DEFAULT NULL, esprit_initiative_note TEXT DEFAULT NULL, organisation TEXT DEFAULT NULL, organisation_note TEXT DEFAULT NULL, capacite_travail_equipe TEXT DEFAULT NULL, capacite_travail_equipe_note TEXT DEFAULT NULL, style_vestimentaire TEXT DEFAULT NULL, style_vestimentaire_note TEXT DEFAULT NULL, langage_prof TEXT DEFAULT NULL, langage_prof_note TEXT DEFAULT NULL, applique_consigne TEXT DEFAULT NULL, applique_consigne_note TEXT DEFAULT NULL, respect_hierarchie TEXT DEFAULT NULL, respect_hierarchie_note TEXT DEFAULT NULL, structureAccAddress_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.frein (id INT NOT NULL, reportDate DATE NOT NULL, freinsPerso JSONB NOT NULL, notesPerso TEXT NOT NULL, freinsEmploi JSONB NOT NULL, notesEmploi TEXT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.immersion (id INT NOT NULL, entreprise_id INT DEFAULT NULL, referent_id INT DEFAULT NULL, domaineActivite TEXT DEFAULT NULL, tuteurName TEXT DEFAULT NULL, tuteurFonction TEXT DEFAULT NULL, tuteurPhoneNumber TEXT DEFAULT NULL, structureAccName TEXT DEFAULT NULL, structureAccPhonenumber TEXT DEFAULT NULL, structureAccEmail TEXT DEFAULT NULL, posteDescriptif TEXT DEFAULT NULL, posteTitle TEXT DEFAULT NULL, posteLieu TEXT DEFAULT NULL, debutDate DATE DEFAULT NULL, duration INTERVAL DEFAULT NULL, horaire TEXT DEFAULT NULL, objectifs JSONB DEFAULT NULL, objectifsAutre TEXT DEFAULT NULL, is_bilan_fullfilled BOOLEAN DEFAULT false NOT NULL, savoirEtre JSONB DEFAULT NULL, savoirEtreNote TEXT DEFAULT NULL, noteimmersion TEXT, principalesActivites TEXT DEFAULT NULL, competencesAcquises TEXT DEFAULT NULL, competencesADevelopper TEXT DEFAULT NULL, noteBilan TEXT DEFAULT NULL, ponctualite_salarie TEXT DEFAULT NULL, ponctualite_salarie_note TEXT DEFAULT NULL, assiduite TEXT DEFAULT NULL, assiduite_note TEXT DEFAULT NULL, interet_activite TEXT DEFAULT NULL, interet_activite_note TEXT DEFAULT NULL, integre_regle TEXT DEFAULT NULL, integre_regle_note TEXT DEFAULT NULL, esprit_initiative TEXT DEFAULT NULL, esprit_initiative_note TEXT DEFAULT NULL, organisation TEXT DEFAULT NULL, organisation_note TEXT DEFAULT NULL, capacite_travail_equipe TEXT DEFAULT NULL, capacite_travail_equipe_note TEXT DEFAULT NULL, style_vestimentaire TEXT DEFAULT NULL, style_vestimentaire_note TEXT DEFAULT NULL, langage_prof TEXT DEFAULT NULL, langage_prof_note TEXT DEFAULT NULL, applique_consigne TEXT DEFAULT NULL, applique_consigne_note TEXT DEFAULT NULL, respect_hierarchie TEXT DEFAULT NULL, respect_hierarchie_note TEXT DEFAULT NULL, structureAccAddress_id INT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE INDEX IDX_FBB3CBB4A4AEAFEA ON chill_job.immersion (entreprise_id)'); $this->addSql('CREATE INDEX IDX_FBB3CBB435E47E35 ON chill_job.immersion (referent_id)'); $this->addSql('CREATE INDEX IDX_FBB3CBB4B5E04267 ON chill_job.immersion (structureAccAddress_id)'); $this->addSql('COMMENT ON COLUMN chill_job.immersion.duration IS \'(DC2Type:dateinterval)\''); - $this->addSql('CREATE TABLE chill_job.projet_professionnel (id INT NOT NULL, reportDate DATE NOT NULL, domaineActiviteSouhait TEXT DEFAULT NULL, typeContrat JSON DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, volumeHoraire JSON DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, domaineActiviteValide TEXT DEFAULT NULL, valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE TABLE chill_job.projet_professionnel (id INT NOT NULL, reportDate DATE NOT NULL, domaineActiviteSouhait TEXT DEFAULT NULL, typeContrat JSONB DEFAULT NULL, typeContratNotes TEXT DEFAULT NULL, volumeHoraire JSONB DEFAULT NULL, volumeHoraireNotes TEXT DEFAULT NULL, idee TEXT DEFAULT NULL, enCoursConstruction TEXT DEFAULT NULL, domaineActiviteValide TEXT DEFAULT NULL, valideNotes TEXT DEFAULT NULL, projetProfessionnelNote TEXT DEFAULT NULL, PRIMARY KEY(id))'); $this->addSql('CREATE TABLE chill_job.projetprofessionnel_souhait (projetprofessionnel_id INT NOT NULL, appellation_id INT NOT NULL, PRIMARY KEY(projetprofessionnel_id, appellation_id))'); $this->addSql('CREATE INDEX IDX_3280B96DB87BF7B5 ON chill_job.projetprofessionnel_souhait (projetprofessionnel_id)'); $this->addSql('CREATE INDEX IDX_3280B96D7CDE30DD ON chill_job.projetprofessionnel_souhait (appellation_id)'); From 2895638f3bc9b06f4b2b2fb122ddce84cd85bd80 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 May 2024 15:26:23 +0200 Subject: [PATCH 4/7] php cs fixes --- .../src/ApiHelper/ApiWrapper.php | 1 - .../ApiHelper/PartenaireRomeAppellation.php | 20 +- .../ChillJobBundle/src/Entity/Immersion.php | 5 +- .../src/Entity/ProjetProfessionnel.php | 2 +- .../Export/AddCSPersonToPersonListHelper.php | 215 +++++++++--------- .../ChillJobBundle/src/Export/ListCV.php | 2 +- .../ChillJobBundle/src/Export/ListFrein.php | 2 +- .../src/Export/ListProjetProfessionnel.php | 2 +- 8 files changed, 119 insertions(+), 130 deletions(-) diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php index a293b7712..513050a2a 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/ApiWrapper.php @@ -49,7 +49,6 @@ class ApiWrapper return $data->access_token; } - try { $response = $this->client->post('', [ 'query' => ['realm' => '/partenaire'], diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index 8711a5028..533e8d274 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -75,17 +75,15 @@ class PartenaireRomeAppellation ], ]; try { - $response = $this->handleRequest( - $request, - $parameters, - $this->client, - $this->logger - ); - - } catch (ClientException $e) { - dump($e->getResponse()->getBody()->getContents()); - } - + $response = $this->handleRequest( + $request, + $parameters, + $this->client, + $this->logger + ); + } catch (ClientException $e) { + dump($e->getResponse()->getBody()->getContents()); + } return Utils::jsonDecode((string) $response->getBody()); } diff --git a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php index 1e3b9879e..225c4c1a1 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/Immersion.php +++ b/src/Bundle/ChillJobBundle/src/Entity/Immersion.php @@ -43,7 +43,7 @@ class Immersion implements \Stringable * @Assert\NotNull() */ #[ORM\ManyToOne(targetEntity: Person::class)] - private ?\Chill\PersonBundle\Entity\Person $person = null; + private ?Person $person = null; /** * @Assert\NotNull() @@ -523,12 +523,11 @@ class Immersion implements \Stringable /** * Get duration. - * */ public function getDuration() { return $this->duration; -// return new \DateInterval($this->duration ?? 'P7D'); + // return new \DateInterval($this->duration ?? 'P7D'); } public function getDateEndComputed() diff --git a/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php b/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php index 44dd6b412..58a1fca41 100644 --- a/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php +++ b/src/Bundle/ChillJobBundle/src/Entity/ProjetProfessionnel.php @@ -36,7 +36,7 @@ class ProjetProfessionnel implements \Stringable * @Assert\NotNull() */ #[ORM\ManyToOne(targetEntity: Person::class)] - private ?\Chill\PersonBundle\Entity\Person $person = null; + private ?Person $person = null; /** * @Assert\NotNull() diff --git a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php index b05b22be4..5436158f6 100644 --- a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php +++ b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php @@ -24,37 +24,35 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterface { - public function __construct(private readonly TranslatorInterface $translator) - { - } + public function __construct(private readonly TranslatorInterface $translator) {} private const CSPERSON_FIELDS = [ - 'dateFinDernierEmploi', -/* 'prescripteur__name', + 'dateFinDernierEmploi', + /* 'prescripteur__name', 'prescripteur__email', 'prescripteur__phone',*/ - 'poleEmploiId', - 'cafId', - 'cafInscriptionDate', - 'dateContratIEJ', - 'cERInscriptionDate', - 'pPAEInscriptionDate', - 'pPAESignataire', - 'cERSignataire', - 'nEETCommissionDate', - 'fSEMaDemarcheCode', - 'enfantACharge', - 'nEETEligibilite', - 'situationProfessionnelle', + 'poleEmploiId', + 'cafId', + 'cafInscriptionDate', + 'dateContratIEJ', + 'cERInscriptionDate', + 'pPAEInscriptionDate', + 'pPAESignataire', + 'cERSignataire', + 'nEETCommissionDate', + 'fSEMaDemarcheCode', + 'enfantACharge', + 'nEETEligibilite', + 'situationProfessionnelle', ]; public function alterKeys(array $existing): array { - $ressources = array_map(static fn ($key) => 'ressources__' . $key, CSPerson::RESSOURCES); - $moyenTransport = array_map(static fn ($key) => 'moyen_transport__' . $key, CSPerson::MOBILITE_MOYEN_TRANSPORT); - $accompagnements = array_map(static fn ($key) => 'accompagnements__' . $key, CSPerson::ACCOMPAGNEMENTS); - $permisConduire = array_map(static fn ($key) => 'permis_conduire__' . $key, CSPerson::PERMIS_CONDUIRE); - $typeContrat = array_map(static fn ($key) => 'type_contrat__' . $key, CSPerson::TYPE_CONTRAT); + $ressources = array_map(static fn ($key) => 'ressources__'.$key, CSPerson::RESSOURCES); + $moyenTransport = array_map(static fn ($key) => 'moyen_transport__'.$key, CSPerson::MOBILITE_MOYEN_TRANSPORT); + $accompagnements = array_map(static fn ($key) => 'accompagnements__'.$key, CSPerson::ACCOMPAGNEMENTS); + $permisConduire = array_map(static fn ($key) => 'permis_conduire__'.$key, CSPerson::PERMIS_CONDUIRE); + $typeContrat = array_map(static fn ($key) => 'type_contrat__'.$key, CSPerson::TYPE_CONTRAT); return [ ...$existing, @@ -76,129 +74,124 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac $qb->addSelect(sprintf('cs_person.%s as %s', $f, $f)); } -/* $qb->addSelect('cs_person.situationProfessionnelle as situation_prof'); + /* $qb->addSelect('cs_person.situationProfessionnelle as situation_prof'); - $qb->addSelect('cs_person.nEETEligibilite as nEETEligibilite');*/ + $qb->addSelect('cs_person.nEETEligibilite as nEETEligibilite');*/ $i = 0; - foreach (CSPerson::RESSOURCES as $key) - { - $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param_$i) AS ressources__" . $key) + foreach (CSPerson::RESSOURCES as $key) { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.ressources, :param_{$i}) AS ressources__".$key) ->setParameter('param_'.$i, $key); ++$i; } - foreach(CSPerson::MOBILITE_MOYEN_TRANSPORT as $key) - { - $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.mobiliteMoyenDeTransport, :param_$i) AS moyen_transport__" . $key) + foreach (CSPerson::MOBILITE_MOYEN_TRANSPORT as $key) { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.mobiliteMoyenDeTransport, :param_{$i}) AS moyen_transport__".$key) ->setParameter('param_'.$i, $key); ++$i; } - foreach(CSPerson::TYPE_CONTRAT as $key) - { - $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param_$i) AS type_contrat__" . $key) + foreach (CSPerson::TYPE_CONTRAT as $key) { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.typeContrat, :param_{$i}) AS type_contrat__".$key) ->setParameter('param_'.$i, $key); ++$i; } - foreach (CSPerson::ACCOMPAGNEMENTS as $key) - { - $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param_$i) AS accompagnements__" . $key) + foreach (CSPerson::ACCOMPAGNEMENTS as $key) { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.accompagnement, :param_{$i}) AS accompagnements__".$key) ->setParameter('param_'.$i, $key); ++$i; } - foreach (CSPerson::PERMIS_CONDUIRE as $key) - { - $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param_$i) AS permis_conduire__" . $key) + foreach (CSPerson::PERMIS_CONDUIRE as $key) { + $qb->addSelect("JSONB_EXISTS_IN_ARRAY(cs_person.permisConduire, :param_{$i}) AS permis_conduire__".$key) ->setParameter('param_'.$i, $key); ++$i; } - } public function getLabels(string $key, array $values, array $data): ?callable { - switch ($key) { - case str_contains($key, '__'): - return function (string|bool|null $value) use ($key): string { - if ('_header' === $value) { - [$domain, $v] = explode('__', $key); - return 'export.list.cs_person.' . $domain . '.' . $v; - } + switch ($key) { + case str_contains($key, '__'): + return function (string|bool|null $value) use ($key): string { + if ('_header' === $value) { + [$domain, $v] = explode('__', $key); - if ('1' === $value || true === $value || 1 === $value || 't' === $value) { - return 'x'; - } + return 'export.list.cs_person.'.$domain.'.'.$v; + } + if ('1' === $value || true === $value || 1 === $value || 't' === $value) { + return 'x'; + } + + return ''; + }; + case 'nEETEligibilite': + return function (string|bool|null $value): string { + if ('_header' === $value) { + return 'export.list.cs_person.neet_eligibility'; + } + + if ('1' === $value || true === $value || 1 === $value || 't' === $value) { + return 'x'; + } + + return ''; + }; + case 'situationProfessionnelle': + return function ($value) { + if ('_header' === $value) { + return 'export.list.cs_person.situation_professionelle'; + } + + return $value; + }; + case 'cerinscriptiondate': + case 'ppaeinscriptiondate': + case 'neetcommissiondate': + case 'findernieremploidate': + case 'cafinscriptiondate': + case 'contratiejdate': + return function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } + + if (null === $value) { return ''; - }; - case 'nEETEligibilite': - return function (string|bool|null $value) use ($key): string { - if ('_header' === $value) { - return 'export.list.cs_person.neet_eligibility'; - } + } + // warning: won't work with DateTimeImmutable as we reset time a few lines later + $date = \DateTime::createFromFormat('Y-m-d', $value); + $hasTime = false; - if ('1' === $value || true === $value || 1 === $value || 't' === $value) { - return 'x'; - } + if (false === $date) { + $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); + $hasTime = true; + } - return ''; - }; - case 'situationProfessionnelle': - return function ($value) use ($key) { - if ('_header' === $value) { - return 'export.list.cs_person.situation_professionelle'; - } + // check that the creation could occur. + if (false === $date) { + throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); + } - return $value; - }; - case 'cerinscriptiondate': - case 'ppaeinscriptiondate': - case 'neetcommissiondate': - case 'findernieremploidate': - case 'cafinscriptiondate': - case 'contratiejdate': - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } + if (!$hasTime) { + $date->setTime(0, 0, 0); + } - if (null === $value) { - return ''; - } - // warning: won't work with DateTimeImmutable as we reset time a few lines later - $date = \DateTime::createFromFormat('Y-m-d', $value); - $hasTime = false; + return $date; + }; - if (false === $date) { - $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); - $hasTime = true; - } + default: + // for fields which are associated with person + return function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } - // check that the creation could occur. - if (false === $date) { - throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); - } - - if (!$hasTime) { - $date->setTime(0, 0, 0); - } - - return $date; - }; - - default: - // for fields which are associated with person - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } - - return $value; - }; - } + return $value; + }; + } } } diff --git a/src/Bundle/ChillJobBundle/src/Export/ListCV.php b/src/Bundle/ChillJobBundle/src/Export/ListCV.php index aea1c7217..896c7db01 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListCV.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListCV.php @@ -92,7 +92,7 @@ class ListCV implements ListInterface, ExportElementValidatedInterface ->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, -// 'choices_as_values' => true, + // 'choices_as_values' => true, 'label' => 'Fields to include in export', 'choices' => array_combine($this->getFields(), $this->getFields()), 'data' => array_combine($this->getFields(), $this->getFields()), diff --git a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php index 51354e1fb..8e3a64294 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListFrein.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListFrein.php @@ -105,7 +105,7 @@ class ListFrein implements ListInterface, ExportElementValidatedInterface ->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, -// 'choices_as_values' => true, + // 'choices_as_values' => true, 'label' => 'Fields to include in export', 'choices' => array_combine($this->getFields(), $this->getFields()), 'data' => array_combine($this->getFields(), $this->getFields()), diff --git a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php index 54cd2b3a5..0a1eeb753 100644 --- a/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php +++ b/src/Bundle/ChillJobBundle/src/Export/ListProjetProfessionnel.php @@ -110,7 +110,7 @@ class ListProjetProfessionnel implements ListInterface, ExportElementValidatedIn ->add('fields', ChoiceType::class, [ 'multiple' => true, 'expanded' => true, -// 'choices_as_values' => true, + // 'choices_as_values' => true, 'label' => 'Fields to include in export', 'choice_label' => fn ($key) => str_replace('__', '.', (string) $key), 'choices' => array_combine($this->getFields(), $this->getFields()), From 9ce1788a14dc648432b29d0513701c001e2f7ab2 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 May 2024 16:42:47 +0200 Subject: [PATCH 5/7] phpstan en rector fixes --- .../CustomFields/CustomFieldInterface.php | 4 - .../CustomFields/CustomFieldsChoiceTest.php | 2 - .../Controller/EventTypeController.php | 1 - .../Controller/RoleController.php | 1 - .../Controller/StatusController.php | 1 - .../ApiHelper/PartenaireRomeAppellation.php | 6 +- .../DependencyInjection/ChillJobExtension.php | 3 - .../Export/AddCSPersonToPersonListHelper.php | 143 ++++++++---------- .../CRUD/Controller/CRUDController.php | 2 - .../Controller/PermissionsGroupController.php | 2 - .../Export/AggregatorInterface.php | 1 - .../ExportElementValidatedInterface.php | 2 - .../Export/ExportInterface.php | 1 - .../ChillMainBundle/Export/ExportManager.php | 6 - .../ChillMainBundle/Search/SearchProvider.php | 6 +- .../Authorization/AuthorizationHelper.php | 1 - 16 files changed, 75 insertions(+), 107 deletions(-) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php index 7ba5cff74..2f4cfd1e4 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php @@ -49,17 +49,13 @@ interface CustomFieldInterface /** * Return if the value can be considered as empty. - * - * @param mixed $value the value passed throug the deserialize function */ public function isEmptyValue(mixed $value, CustomField $customField); /** * Return a repsentation of the value of the CustomField. * - * @param mixed $value the raw value, **not deserialized** (= as stored in the db) * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField - * * @return string an html representation of the value */ public function render(mixed $value, CustomField $customField, $documentType = 'html'); diff --git a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php index b9d00d052..6f6ba394e 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php +++ b/src/Bundle/ChillCustomFieldsBundle/Tests/CustomFields/CustomFieldsChoiceTest.php @@ -399,8 +399,6 @@ final class CustomFieldsChoiceTest extends KernelTestCase /** * @dataProvider emptyDataProvider - * - * @param mixed $data deserialized data */ public function testIsEmptyValueEmpty(mixed $data) { diff --git a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php index 881f7a135..d5ea7901b 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php @@ -201,7 +201,6 @@ class EventTypeController extends AbstractController /** * Creates a form to delete a EventType entity by id. * - * @param mixed $id The entity id * * @return \Symfony\Component\Form\Form The form */ diff --git a/src/Bundle/ChillEventBundle/Controller/RoleController.php b/src/Bundle/ChillEventBundle/Controller/RoleController.php index e1d94389a..fe6c60a85 100644 --- a/src/Bundle/ChillEventBundle/Controller/RoleController.php +++ b/src/Bundle/ChillEventBundle/Controller/RoleController.php @@ -201,7 +201,6 @@ class RoleController extends AbstractController /** * Creates a form to delete a Role entity by id. * - * @param mixed $id The entity id * * @return \Symfony\Component\Form\Form The form */ diff --git a/src/Bundle/ChillEventBundle/Controller/StatusController.php b/src/Bundle/ChillEventBundle/Controller/StatusController.php index 77f6d4279..446fb476e 100644 --- a/src/Bundle/ChillEventBundle/Controller/StatusController.php +++ b/src/Bundle/ChillEventBundle/Controller/StatusController.php @@ -201,7 +201,6 @@ class StatusController extends AbstractController /** * Creates a form to delete a Status entity by id. * - * @param mixed $id The entity id * * @return \Symfony\Component\Form\Form The form */ diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index 533e8d274..5c32033ad 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -16,6 +16,7 @@ use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Utils; use Psr\Log\LoggerInterface; +use Symfony\Component\HttpFoundation\Response; /** * Queries for ROME partenaires api. @@ -81,11 +82,14 @@ class PartenaireRomeAppellation $this->client, $this->logger ); + + return Utils::jsonDecode((string) $response->getBody()); + } catch (ClientException $e) { dump($e->getResponse()->getBody()->getContents()); } - return Utils::jsonDecode((string) $response->getBody()); + return new Response('No appellation found'); } public function getAppellation($code) diff --git a/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php b/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php index 165b5e557..110e5d8df 100644 --- a/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php +++ b/src/Bundle/ChillJobBundle/src/DependencyInjection/ChillJobExtension.php @@ -51,9 +51,6 @@ class ChillJobExtension extends Extension implements PrependExtensionInterface $loader->load('services/export.yml'); $loader->load('services/menu.yml'); $loader->load('services/security.yml'); - - // exports: list_CSperson override list_person - $container->setAlias('chill.person.export.list_person', \Chill\JobBundle\Export\ListCSPerson::class); } public function prepend(ContainerBuilder $container): void diff --git a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php index 5436158f6..4d53722c0 100644 --- a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php +++ b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php @@ -113,85 +113,76 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac public function getLabels(string $key, array $values, array $data): ?callable { - switch ($key) { - case str_contains($key, '__'): - return function (string|bool|null $value) use ($key): string { - if ('_header' === $value) { - [$domain, $v] = explode('__', $key); + if (str_contains($key, '__')) + { + return function (string|bool|null $value) use ($key): string { + if ('_header' === $value) { + [$domain, $v] = explode('__', $key); - return 'export.list.cs_person.'.$domain.'.'.$v; - } + return 'export.list.cs_person.'.$domain.'.'.$v; + } - if ('1' === $value || true === $value || 1 === $value || 't' === $value) { - return 'x'; - } + if ('1' === $value || true === $value || 't' === $value) { + return 'x'; + } - return ''; - }; - case 'nEETEligibilite': - return function (string|bool|null $value): string { - if ('_header' === $value) { - return 'export.list.cs_person.neet_eligibility'; - } - - if ('1' === $value || true === $value || 1 === $value || 't' === $value) { - return 'x'; - } - - return ''; - }; - case 'situationProfessionnelle': - return function ($value) { - if ('_header' === $value) { - return 'export.list.cs_person.situation_professionelle'; - } - - return $value; - }; - case 'cerinscriptiondate': - case 'ppaeinscriptiondate': - case 'neetcommissiondate': - case 'findernieremploidate': - case 'cafinscriptiondate': - case 'contratiejdate': - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } - - if (null === $value) { - return ''; - } - // warning: won't work with DateTimeImmutable as we reset time a few lines later - $date = \DateTime::createFromFormat('Y-m-d', $value); - $hasTime = false; - - if (false === $date) { - $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); - $hasTime = true; - } - - // check that the creation could occur. - if (false === $date) { - throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); - } - - if (!$hasTime) { - $date->setTime(0, 0, 0); - } - - return $date; - }; - - default: - // for fields which are associated with person - return function ($value) use ($key) { - if ('_header' === $value) { - return $this->translator->trans($key); - } - - return $value; - }; + return ''; + }; } + return match ($key) { + 'nEETEligibilite' => function (string|bool|null $value): string { + if ('_header' === $value) { + return 'export.list.cs_person.neet_eligibility'; + } + + if ('1' === $value || true === $value || 't' === $value) { + return 'x'; + } + + return ''; + }, + 'situationProfessionnelle' => function ($value) { + if ('_header' === $value) { + return 'export.list.cs_person.situation_professionelle'; + } + + return $value; + }, + 'cerinscriptiondate', 'ppaeinscriptiondate', 'neetcommissiondate', 'findernieremploidate', 'cafinscriptiondate', 'contratiejdate' => function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } + + if (null === $value) { + return ''; + } + // warning: won't work with DateTimeImmutable as we reset time a few lines later + $date = \DateTime::createFromFormat('Y-m-d', $value); + $hasTime = false; + + if (false === $date) { + $date = \DateTime::createFromFormat('Y-m-d H:i:s', $value); + $hasTime = true; + } + + // check that the creation could occur. + if (false === $date) { + throw new \Exception(sprintf('The value %s could not be converted to %s', $value, \DateTime::class)); + } + + if (!$hasTime) { + $date->setTime(0, 0, 0); + } + + return $date; + }, + default => function ($value) use ($key) { + if ('_header' === $value) { + return $this->translator->trans($key); + } + + return $value; + }, + }; } } diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index f4c9538c7..ada07eb7b 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -725,10 +725,8 @@ class CRUDController extends AbstractController * and view. * * @param string $action - * @param mixed $entity the entity for the current request, or an array of entities * * @return string the path to the template - * * @throws \LogicException if no template are available */ protected function getTemplateFor($action, mixed $entity, Request $request) diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php index fc5d7d061..ec28d3040 100644 --- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php +++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php @@ -442,8 +442,6 @@ final class PermissionsGroupController extends AbstractController /** * Creates a form to delete a link to roleScope. - * - * @param mixed $permissionsGroup The entity id */ private function createDeleteRoleScopeForm( PermissionsGroup $permissionsGroup, diff --git a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php index 28c168893..e849dec07 100644 --- a/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php +++ b/src/Bundle/ChillMainBundle/Export/AggregatorInterface.php @@ -73,7 +73,6 @@ interface AggregatorInterface extends ModifierInterface * * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm` * * @return \Closure where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ diff --git a/src/Bundle/ChillMainBundle/Export/ExportElementValidatedInterface.php b/src/Bundle/ChillMainBundle/Export/ExportElementValidatedInterface.php index ea9094687..d4f58a570 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportElementValidatedInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportElementValidatedInterface.php @@ -30,8 +30,6 @@ interface ExportElementValidatedInterface /** * validate the form's data and, if required, build a contraint * violation on the data. - * - * @param mixed $data the data, as returned by the user */ public function validateForm(mixed $data, ExecutionContextInterface $context); } diff --git a/src/Bundle/ChillMainBundle/Export/ExportInterface.php b/src/Bundle/ChillMainBundle/Export/ExportInterface.php index 39e265153..a9d3efd13 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportInterface.php +++ b/src/Bundle/ChillMainBundle/Export/ExportInterface.php @@ -96,7 +96,6 @@ interface ExportInterface extends ExportElementInterface * * @param string $key The column key, as added in the query * @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR') - * @param mixed $data The data from the export's form (as defined in `buildForm`) * * @return (callable(string|int|float|'_header'|null $value): string|int|\DateTimeInterface) where the first argument is the value, and the function should return the label to show in the formatted file. Example : `function($countryCode) use ($countries) { return $countries[$countryCode]->getName(); }` */ diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index 159b90b6b..eb59c4ae2 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -552,9 +552,7 @@ class ExportManager * * This function check the acl. * - * @param mixed $data the data under the initial 'filters' data * @param \Chill\MainBundle\Entity\Center[] $centers the picked centers - * * @throw UnauthorizedHttpException if the user is not authorized */ private function handleFilters( @@ -615,9 +613,6 @@ class ExportManager return $usedTypes; } - /** - * @param mixed $data the data from the filter key of the ExportType - */ private function retrieveUsedFilters(mixed $data): iterable { if (null === $data) { @@ -634,7 +629,6 @@ class ExportManager /** * Retrieve the filter used in this export. * - * @param mixed $data the data from the `filters` key of the ExportType * * @return array an array with types */ diff --git a/src/Bundle/ChillMainBundle/Search/SearchProvider.php b/src/Bundle/ChillMainBundle/Search/SearchProvider.php index e239b872d..73c48f4cf 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchProvider.php +++ b/src/Bundle/ChillMainBundle/Search/SearchProvider.php @@ -257,10 +257,10 @@ class SearchProvider $this->mustBeExtracted[] = $matches[0][$key]; // strip parenthesis if ( - '"' === mb_substr((string) $match, 0, 1) - && '"' === mb_substr((string) $match, mb_strlen((string) $match) - 1) + '"' === mb_substr($match, 0, 1) + && '"' === mb_substr($match, mb_strlen($match) - 1) ) { - $match = trim(mb_substr((string) $match, 1, mb_strlen((string) $match) - 2)); + $match = trim(mb_substr($match, 1, mb_strlen($match) - 2)); } $terms[$matches[1][$key]] = $match; } diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 9ca1bdc0b..04d9f30f0 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -198,7 +198,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface * if the entity implements Chill\MainBundle\Entity\HasScopeInterface, * the scope is taken into account. * - * @param mixed $entity the entity may also implement HasScopeInterface * * @return bool true if the user has access */ From dddb6d66bc4f03f10ac7aec359ffd1d7ff239e6d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 May 2024 16:44:02 +0200 Subject: [PATCH 6/7] php cs fixes after merge --- .../CustomFields/CustomFieldInterface.php | 1 + .../ChillEventBundle/Controller/EventTypeController.php | 1 - src/Bundle/ChillEventBundle/Controller/RoleController.php | 1 - src/Bundle/ChillEventBundle/Controller/StatusController.php | 1 - .../src/ApiHelper/PartenaireRomeAppellation.php | 1 - .../src/Export/AddCSPersonToPersonListHelper.php | 4 ++-- src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php | 1 + src/Bundle/ChillMainBundle/Export/ExportManager.php | 2 +- .../Security/Authorization/AuthorizationHelper.php | 1 - .../GeographicalUnitStatAggregator.php | 3 +-- .../AccompanyingCourseFilters/GeographicalUnitStatFilter.php | 3 +-- 11 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php index 2f4cfd1e4..eb2d3b011 100644 --- a/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php +++ b/src/Bundle/ChillCustomFieldsBundle/CustomFields/CustomFieldInterface.php @@ -56,6 +56,7 @@ interface CustomFieldInterface * Return a repsentation of the value of the CustomField. * * @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField + * * @return string an html representation of the value */ public function render(mixed $value, CustomField $customField, $documentType = 'html'); diff --git a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php index d5ea7901b..5706dbe19 100644 --- a/src/Bundle/ChillEventBundle/Controller/EventTypeController.php +++ b/src/Bundle/ChillEventBundle/Controller/EventTypeController.php @@ -201,7 +201,6 @@ class EventTypeController extends AbstractController /** * Creates a form to delete a EventType entity by id. * - * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(mixed $id) diff --git a/src/Bundle/ChillEventBundle/Controller/RoleController.php b/src/Bundle/ChillEventBundle/Controller/RoleController.php index fe6c60a85..24e4f2121 100644 --- a/src/Bundle/ChillEventBundle/Controller/RoleController.php +++ b/src/Bundle/ChillEventBundle/Controller/RoleController.php @@ -201,7 +201,6 @@ class RoleController extends AbstractController /** * Creates a form to delete a Role entity by id. * - * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(mixed $id) diff --git a/src/Bundle/ChillEventBundle/Controller/StatusController.php b/src/Bundle/ChillEventBundle/Controller/StatusController.php index 446fb476e..286408b0b 100644 --- a/src/Bundle/ChillEventBundle/Controller/StatusController.php +++ b/src/Bundle/ChillEventBundle/Controller/StatusController.php @@ -201,7 +201,6 @@ class StatusController extends AbstractController /** * Creates a form to delete a Status entity by id. * - * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(mixed $id) diff --git a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php index 5c32033ad..cb40311b6 100644 --- a/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php +++ b/src/Bundle/ChillFranceTravailApiBundle/src/ApiHelper/PartenaireRomeAppellation.php @@ -84,7 +84,6 @@ class PartenaireRomeAppellation ); return Utils::jsonDecode((string) $response->getBody()); - } catch (ClientException $e) { dump($e->getResponse()->getBody()->getContents()); } diff --git a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php index 4d53722c0..0c27bdb32 100644 --- a/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php +++ b/src/Bundle/ChillJobBundle/src/Export/AddCSPersonToPersonListHelper.php @@ -113,8 +113,7 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac public function getLabels(string $key, array $values, array $data): ?callable { - if (str_contains($key, '__')) - { + if (str_contains($key, '__')) { return function (string|bool|null $value) use ($key): string { if ('_header' === $value) { [$domain, $v] = explode('__', $key); @@ -129,6 +128,7 @@ class AddCSPersonToPersonListHelper implements CustomizeListPersonHelperInterfac return ''; }; } + return match ($key) { 'nEETEligibilite' => function (string|bool|null $value): string { if ('_header' === $value) { diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index ada07eb7b..2384e32b4 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -727,6 +727,7 @@ class CRUDController extends AbstractController * @param string $action * * @return string the path to the template + * * @throws \LogicException if no template are available */ protected function getTemplateFor($action, mixed $entity, Request $request) diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index eb59c4ae2..9cb2a54ba 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -553,6 +553,7 @@ class ExportManager * This function check the acl. * * @param \Chill\MainBundle\Entity\Center[] $centers the picked centers + * * @throw UnauthorizedHttpException if the user is not authorized */ private function handleFilters( @@ -629,7 +630,6 @@ class ExportManager /** * Retrieve the filter used in this export. * - * * @return array an array with types */ private function retrieveUsedFiltersType(mixed $data): iterable diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 04d9f30f0..098b741e6 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -198,7 +198,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface * if the entity implements Chill\MainBundle\Entity\HasScopeInterface, * the scope is taken into account. * - * * @return bool true if the user has access */ public function userHasAccess(UserInterface $user, mixed $entity, string $attribute): bool diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php index 0a861d64c..ffa5501dd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -32,8 +32,7 @@ final readonly class GeographicalUnitStatAggregator implements AggregatorInterfa private GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private TranslatableStringHelperInterface $translatableStringHelper, private RollingDateConverterInterface $rollingDateConverter - ) { - } + ) {} public function addRole(): ?string { diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php index d84745403..7adf03d13 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php @@ -38,8 +38,7 @@ class GeographicalUnitStatFilter implements FilterInterface private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter - ) { - } + ) {} public function addRole(): ?string { From cb5ade3d148e0c27b9e5877109b42f0c1ff05320 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 22 May 2024 16:49:45 +0200 Subject: [PATCH 7/7] add changie for module emploi --- .changes/unreleased/Feature-20240522-164933.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Feature-20240522-164933.yaml diff --git a/.changes/unreleased/Feature-20240522-164933.yaml b/.changes/unreleased/Feature-20240522-164933.yaml new file mode 100644 index 000000000..947c6589f --- /dev/null +++ b/.changes/unreleased/Feature-20240522-164933.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: Add job bundle (module emploi) +time: 2024-05-22T16:49:33.730465146+02:00 +custom: + Issue: ""