mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Feature: [export][evaluation] Adding group by evaluation having end date
This commit is contained in:
@@ -16,9 +16,17 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class HavingEndDateAggregator implements AggregatorInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
@@ -27,10 +35,7 @@ class HavingEndDateAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb
|
||||
->addSelect('
|
||||
CASE true WHEN workeval.endDAte IS NULL ELSE false END
|
||||
AS eval_enddate_aggregator
|
||||
')
|
||||
->addSelect('CASE WHEN workeval.endDate IS NULL THEN true ELSE false END AS eval_enddate_aggregator')
|
||||
->addGroupBy('eval_enddate_aggregator');
|
||||
}
|
||||
|
||||
@@ -46,17 +51,17 @@ class HavingEndDateAggregator implements AggregatorInterface
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return static function ($value): string {
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return '';
|
||||
return 'export.aggregator.eval.by_end_date.Has end date ?';
|
||||
}
|
||||
|
||||
switch ($value) {
|
||||
case true:
|
||||
return 'enddate is specified';
|
||||
return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is specified');
|
||||
|
||||
case false:
|
||||
return 'enddate is not specified';
|
||||
return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is not specified');
|
||||
|
||||
default:
|
||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
||||
@@ -71,6 +76,6 @@ class HavingEndDateAggregator implements AggregatorInterface
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group evaluations having end date';
|
||||
return 'export.aggregator.eval.by_end_date.Group evaluations having end date';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user