mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
month year aggregator working
This commit is contained in:
parent
f3ceee7485
commit
cf642d2783
@ -19,15 +19,16 @@ class MonthYearAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getLabels($key, array $values, $data): Closure
|
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 strftime('%B %G', mktime(0, 0, 0, $month, '1', $year));
|
||||||
|
|
||||||
return static function (string $value) use ($labels): string {
|
|
||||||
return $labels[$value];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
@ -47,10 +48,8 @@ class MonthYearAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->addSelect('MONTH(:startDate), YEAR(:startDate) as month_year_aggregator');
|
$qb->addSelect("to_char(cal.startDate, 'MM-YYYY') AS month_year_aggregator");
|
||||||
// $qb->addSelect('YEAR(cal.startDate) as year_aggregator');
|
// $qb->addSelect("extract(month from age(cal.startDate, cal.endDate)) AS month_aggregator");
|
||||||
|
|
||||||
$qb->setParameter('startDate', 'cal.startDate');
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
if (!empty($groupBy)) {
|
||||||
|
@ -96,9 +96,9 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: cancel_reason_aggregator }
|
- { 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
|
class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator
|
||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: month_year_aggregator }
|
- { name: chill.export_aggregator, alias: month_aggregator }
|
@ -70,3 +70,4 @@ Scope: Service
|
|||||||
Job: Métier
|
Job: Métier
|
||||||
Location type: Type de localisation
|
Location type: Type de localisation
|
||||||
Location: Lieu de rendez-vous
|
Location: Lieu de rendez-vous
|
||||||
|
by month and year: Par mois et année
|
||||||
|
Loading…
x
Reference in New Issue
Block a user