mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: DurationAggregator with approximative(*) date interval
(*) for more precise, we need dql interval function
This commit is contained in:
parent
e1ec2dc25c
commit
f5baa2c152
@ -10,6 +10,7 @@ use Doctrine\ORM\QueryBuilder;
|
|||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Les regroupements seront un nombre de mois, arrondi à l'unité la plus proche (donc
|
* 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
|
class DurationAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
dump($key, $values, $data);
|
|
||||||
|
|
||||||
return function ($value) use ($data): string {
|
return function ($value) use ($data): string {
|
||||||
|
|
||||||
if ($value === '_header') {
|
if ($value === '_header') {
|
||||||
return 'Duration';
|
return $this->translator->trans('Rounded month duration');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value === null) {
|
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
|
$qb
|
||||||
// OUI
|
// 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('DATE_DIFF(acp.closingDate, acp.openingDate) AS duration_aggregator')
|
||||||
//->addSelect('EXTRACT(month FROM acp.openingDate) AS duration_aggregator')
|
//->addSelect('EXTRACT(month FROM acp.openingDate) AS duration_aggregator')
|
||||||
//->addSelect("DATE_SUB(acp.openingDate, 6, 'day') AS duration_aggregator")
|
//->addSelect("DATE_SUB(acp.openingDate, 6, 'day') AS duration_aggregator")
|
||||||
|
@ -570,6 +570,10 @@ Group by number of children: Grouper les ménages par nombre d'enfants
|
|||||||
|
|
||||||
## persons aggregators
|
## persons aggregators
|
||||||
Group by duration: Grouper par durée du parcours
|
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 people by nationality: Grouper les personnes par nationalités
|
||||||
Group by level: Grouper par niveau
|
Group by level: Grouper par niveau
|
||||||
Group by continents: Grouper par continent
|
Group by continents: Grouper par continent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user