diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index 163c318c5..2a0215e82 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -10,6 +10,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; /** * Les regroupements seront un nombre de mois, arrondi à l'unité la plus proche (donc @@ -22,23 +23,33 @@ use Symfony\Component\Form\FormBuilderInterface; */ class DurationAggregator implements AggregatorInterface { + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } /** * @inheritDoc */ public function getLabels($key, array $values, $data) { - dump($key, $values, $data); - return function ($value) use ($data): string { + if ($value === '_header') { - return 'Duration'; + return $this->translator->trans('Rounded month duration'); } + if ($value === null) { - return 'current'; // when closingDate is null + return $this->translator->trans('current duration'); // when closingDate is null } - return $value; - //sprintf("%02d", $value) . ' days'; + + if ($value === 0) { + return $this->translator->trans("duration 0 month"); + } + + return ''. $value . $this->translator->trans(' months'); }; } @@ -81,7 +92,10 @@ class DurationAggregator implements AggregatorInterface { $qb // OUI - ->addSelect('(acp.closingDate - acp.openingDate) AS duration_aggregator') + ->addSelect(' + (acp.closingDate - acp.openingDate +15) *12/365 + AS duration_aggregator' + ) //->addSelect('DATE_DIFF(acp.closingDate, acp.openingDate) AS duration_aggregator') //->addSelect('EXTRACT(month FROM acp.openingDate) AS duration_aggregator') //->addSelect("DATE_SUB(acp.openingDate, 6, 'day') AS duration_aggregator") diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index fdddd5c6c..e105dd45f 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -570,6 +570,10 @@ Group by number of children: Grouper les ménages par nombre d'enfants ## persons aggregators Group by duration: Grouper par durée du parcours +Rounded month duration: Durée en mois (arrondie) +current duration: en cours +duration 0 month: 0 mois (<15 jours) +' months': ' mois' Group people by nationality: Grouper les personnes par nationalités Group by level: Grouper par niveau Group by continents: Grouper par continent