diff --git a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php index fa83d8398..71a0e75bb 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php +++ b/src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php @@ -19,15 +19,16 @@ class MonthYearAggregator implements AggregatorInterface public function getLabels($key, array $values, $data): Closure { + return function($value): string { + if ($value === '_header') { + return 'by month and year'; + } - dump($values); + $month = substr($value,0, 2); + $year = substr($value, 3, 4); - $labels = []; - - return static function (string $value) use ($labels): string { - return $labels[$value]; + return strftime('%B %G', mktime(0, 0, 0, $month, '1', $year)); }; - } public function buildForm(FormBuilderInterface $builder) @@ -47,10 +48,8 @@ class MonthYearAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->addSelect('MONTH(:startDate), YEAR(:startDate) as month_year_aggregator'); -// $qb->addSelect('YEAR(cal.startDate) as year_aggregator'); - - $qb->setParameter('startDate', 'cal.startDate'); + $qb->addSelect("to_char(cal.startDate, 'MM-YYYY') AS month_year_aggregator"); + // $qb->addSelect("extract(month from age(cal.startDate, cal.endDate)) AS month_aggregator"); $groupBy = $qb->getDQLPart('groupBy'); if (!empty($groupBy)) { diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index 0f9ed1a49..56580dba1 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -96,9 +96,9 @@ services: tags: - { name: chill.export_aggregator, alias: cancel_reason_aggregator } - chill.calendar.export.month_year_aggregator: + chill.calendar.export.month_aggregator: class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator autowire: true autoconfigure: true tags: - - { name: chill.export_aggregator, alias: month_year_aggregator } \ No newline at end of file + - { name: chill.export_aggregator, alias: month_aggregator } \ No newline at end of file diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index 48f17be76..11937d2b7 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -70,3 +70,4 @@ Scope: Service Job: Métier Location type: Type de localisation Location: Lieu de rendez-vous +by month and year: Par mois et année