mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
Merge branch '111_exports_suite' of gitlab.com:Chill-Projet/chill-bundles into 111_exports_suite
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -23,9 +24,9 @@ class ByActionNumberAggregator implements AggregatorInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb->addSelect('AS acp_by_action_number_aggregator')
|
||||
$qb->addSelect('(SELECT COUNT(acp_by_action_action.id) FROM ' . AccompanyingPeriodWork::class . ' acp_by_action_action WHERE acp_by_action_action.accompanyingPeriod = acp) AS acp_by_action_number_aggregator')
|
||||
->addGroupBy('acp_by_action_number_aggregator');
|
||||
}
|
||||
|
||||
@@ -34,17 +35,23 @@ class ByActionNumberAggregator implements AggregatorInterface
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return static function ($value): string {
|
||||
return static function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.course.by_number_of_action.Number of actions';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -14,10 +14,23 @@ namespace Chill\PersonBundle\Export\Aggregator\EvaluationAggregators;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class ByStartDateAggregator implements AggregatorInterface
|
||||
{
|
||||
private const CHOICES = [
|
||||
'by month' => 'month',
|
||||
'by week' => 'week',
|
||||
'by year' => 'year',
|
||||
];
|
||||
|
||||
private const DEFAULT_CHOICE = 'year';
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
@@ -25,8 +38,29 @@ class ByStartDateAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('AS eval_by_start_date_aggregator')
|
||||
->addGroupBy('eval_by_start_date_aggregator');
|
||||
switch ($data['frequency']) {
|
||||
case 'month':
|
||||
$fmt = 'YYYY-MM';
|
||||
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$fmt = 'YYYY-IW';
|
||||
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$fmt = 'YYYY';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException(sprintf("The frequency data '%s' is invalid.", $data['frequency']));
|
||||
}
|
||||
|
||||
$qb->addSelect(sprintf("TO_CHAR(workeval.startDate, '%s') AS eval_by_start_date_aggregator", $fmt));
|
||||
$qb->addGroupBy(' eval_by_start_date_aggregator');
|
||||
$qb->addOrderBy(' eval_by_start_date_aggregator', 'ASC');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -36,15 +70,27 @@ class ByStartDateAggregator implements AggregatorInterface
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// No form needed
|
||||
$builder->add('frequency', ChoiceType::class, [
|
||||
'choices' => self::CHOICES,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
'empty_data' => self::DEFAULT_CHOICE,
|
||||
'data' => self::DEFAULT_CHOICE,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.eval.by_start_date_period.Start date period';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,6 +101,6 @@ class ByStartDateAggregator implements AggregatorInterface
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by start date evaluations';
|
||||
return 'export.aggregator.eval.by_start_date_period.Group by start date evaluations';
|
||||
}
|
||||
}
|
||||
|
@@ -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';
|
||||
}
|
||||
}
|
||||
|
@@ -16,19 +16,27 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class CurrentActionAggregator implements AggregatorInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb
|
||||
->addSelect('
|
||||
(CASE true WHEN acpw.startDate IS NULL ELSE false END)
|
||||
(CASE WHEN acpw.endDate IS NULL THEN true ELSE false END)
|
||||
AS acpw_current_action_aggregator
|
||||
')
|
||||
->addGroupBy('acpw_current_action_aggregator');
|
||||
@@ -39,24 +47,24 @@ class CurrentActionAggregator implements AggregatorInterface
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return static function ($value): string {
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return '';
|
||||
return 'export.aggregator.course_work.by_current_action.Current action ?';
|
||||
}
|
||||
|
||||
switch ($value) {
|
||||
case true:
|
||||
return 'Current action';
|
||||
return $this->translator->trans('export.aggregator.course_work.by_current_action.Current action');
|
||||
|
||||
case false:
|
||||
return 'Not current action';
|
||||
return $this->translator->trans('export.aggregator.course_work.by_current_action.Not current action');
|
||||
|
||||
default:
|
||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
||||
@@ -71,6 +79,6 @@ class CurrentActionAggregator implements AggregatorInterface
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by current actions';
|
||||
return 'export.aggregator.course_work.by_current_action.Group by current actions';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user