mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
fix cs
This commit is contained in:
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
class AdministrativeLocationAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -13,11 +13,8 @@ namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -63,7 +60,7 @@ class ClosingMotiveAggregator implements AggregatorInterface
|
||||
return 'Closing motive';
|
||||
}
|
||||
|
||||
if (NULL === $value) {
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
@@ -11,12 +20,13 @@ use Chill\MainBundle\Repository\GeographicalUnitLayerRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use UnexpectedValueException;
|
||||
use function in_array;
|
||||
|
||||
final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -32,91 +42,11 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'acp_geog_agg_unitname':
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitname';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
case 'acp_geog_agg_unitrefid':
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitrefid';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
default:
|
||||
throw new \UnexpectedValueException('this value should not happens');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['acp_geog_agg_unitname', 'acp_geog_agg_unitrefid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', ChillDateType::class, [
|
||||
'label' => 'Compute geographical location at date',
|
||||
'required' => true,
|
||||
'data' => new \DateTimeImmutable('today'),
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('level', EntityType::class, [
|
||||
'label' => 'Geographical layer',
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function(GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by geographical unit';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acp_geog_agg_location_history', $qb->getAllAliases(), true)) {
|
||||
@@ -181,15 +111,75 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
->addSelect('acp_geog_units.unitName AS acp_geog_agg_unitname')
|
||||
->addSelect('acp_geog_units.unitRefId AS acp_geog_agg_unitrefid')
|
||||
->addGroupBy('acp_geog_agg_unitname')
|
||||
->addGroupBy('acp_geog_agg_unitrefid')
|
||||
;
|
||||
->addGroupBy('acp_geog_agg_unitrefid');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', ChillDateType::class, [
|
||||
'label' => 'Compute geographical location at date',
|
||||
'required' => true,
|
||||
'data' => new DateTimeImmutable('today'),
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('level', EntityType::class, [
|
||||
'label' => 'Geographical layer',
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function (GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'acp_geog_agg_unitname':
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitname';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
case 'acp_geog_agg_unitrefid':
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitrefid';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('this value should not happens');
|
||||
}
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['acp_geog_agg_unitname', 'acp_geog_agg_unitrefid'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group by geographical unit';
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class JobAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -19,6 +19,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class OriginAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -1,25 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class ReferrerScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
|
||||
private const SCOPE_KEY = 'acp_agg_refscope_user_history_ref_scope_name';
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private ScopeRepositoryInterface $scopeRepository;
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
ScopeRepositoryInterface $scopeRepository,
|
||||
TranslatableStringHelperInterface $translatableStringHelper
|
||||
@@ -28,9 +37,56 @@ class ReferrerScopeAggregator implements AggregatorInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$userHistory = 'acp_agg_refscope_user_history';
|
||||
$ref = 'acp_agg_refscope_user_history_ref';
|
||||
$scopeName = self::SCOPE_KEY;
|
||||
$dateCalc = 'acp_agg_refscope_user_history_date_calc';
|
||||
|
||||
$qb
|
||||
->leftJoin('acp.userHistories', $userHistory)
|
||||
->leftJoin($userHistory . '.user', $ref)
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($userHistory),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte($userHistory . '.startDate', ':' . $dateCalc),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($userHistory . '.endDate'),
|
||||
$qb->expr()->lt($userHistory . '.endDate', ':' . $dateCalc)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter($dateCalc, $data['date_calc']);
|
||||
|
||||
// add groups
|
||||
$qb
|
||||
->addSelect('IDENTITY(' . $ref . '.mainScope) AS ' . $scopeName)
|
||||
->addGroupBy($scopeName);
|
||||
}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_calc', ChillDateType::class, [
|
||||
'input' => 'datetime_immutable',
|
||||
'data' => new DateTimeImmutable('now'),
|
||||
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value) {
|
||||
@@ -45,89 +101,20 @@ class ReferrerScopeAggregator implements AggregatorInterface
|
||||
$scope = $this->scopeRepository->find($value);
|
||||
|
||||
if (null === $scope) {
|
||||
throw new \LogicException('no scope found with this id: ' . $value);
|
||||
throw new LogicException('no scope found with this id: ' . $value);
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize($scope->getName());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return [self::SCOPE_KEY];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_calc', ChillDateType::class, [
|
||||
'input' => 'datetime_immutable',
|
||||
'data' => new \DateTimeImmutable('now'),
|
||||
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return 'export.aggregator.course.by_user_scope.Group course by referrer\'s scope';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$userHistory = 'acp_agg_refscope_user_history';
|
||||
$ref = 'acp_agg_refscope_user_history_ref';
|
||||
$scopeName = self::SCOPE_KEY;
|
||||
$dateCalc = 'acp_agg_refscope_user_history_date_calc';
|
||||
|
||||
$qb
|
||||
->leftJoin('acp.userHistories', $userHistory)
|
||||
->leftJoin($userHistory.'.user', $ref)
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($userHistory),
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte($userHistory.'.startDate', ':'.$dateCalc),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull($userHistory.'.endDate'),
|
||||
$qb->expr()->lt($userHistory.'.endDate', ':'.$dateCalc)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter($dateCalc, $data['date_calc']);
|
||||
|
||||
// add groups
|
||||
$qb
|
||||
->addSelect('IDENTITY('.$ref.'.mainScope) AS '.$scopeName)
|
||||
->addGroupBy($scopeName)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class SocialIssueAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -63,7 +63,7 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE);
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
@@ -17,7 +17,6 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@@ -73,7 +72,7 @@ class ChildrenNumberAggregator implements AggregatorInterface
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value): string {
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'Number of children';
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ use Chill\PersonBundle\Repository\Household\HouseholdCompositionTypeRepository;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\GeographicalUnit;
|
||||
@@ -9,8 +18,10 @@ use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Repository\GeographicalUnitLayerRepositoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -28,93 +39,11 @@ class GeographicalUnitAggregator implements AggregatorInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'geog_unit_name':
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitname';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
case 'geog_unit_key':
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitrefid';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
default:
|
||||
throw new \LogicException('key not supported');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return ['geog_unit_name', 'geog_unit_key'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', ChillDateType::class, [
|
||||
'label' => 'Address valid at this date',
|
||||
'required' => true,
|
||||
'data' => new \DateTimeImmutable('today'),
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('level', EntityType::class, [
|
||||
'label' => 'Geographical layer',
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function(GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Group people by geographical unit based on his address';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb
|
||||
@@ -144,20 +73,80 @@ class GeographicalUnitAggregator implements AggregatorInterface
|
||||
->addSelect('person_geog_agg_geog_unit.unitName AS geog_unit_name')
|
||||
->addSelect('person_geog_agg_geog_unit.unitRefId AS geog_unit_key')
|
||||
->addGroupBy('geog_unit_name')
|
||||
->addGroupBy('geog_unit_key')
|
||||
;
|
||||
->addGroupBy('geog_unit_key');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_calc', ChillDateType::class, [
|
||||
'label' => 'Address valid at this date',
|
||||
'required' => true,
|
||||
'data' => new DateTimeImmutable('today'),
|
||||
'input' => 'datetime_immutable',
|
||||
])
|
||||
->add('level', EntityType::class, [
|
||||
'label' => 'Geographical layer',
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function (GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getDefaultAlias(): string
|
||||
{
|
||||
return 'person_geog_agg';
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
switch ($key) {
|
||||
case 'geog_unit_name':
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitname';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
case 'geog_unit_key':
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'acp_geog_agg_unitrefid';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
|
||||
default:
|
||||
throw new LogicException('key not supported');
|
||||
}
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
return ['geog_unit_name', 'geog_unit_key'];
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Group people by geographical unit based on his address';
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function in_array;
|
||||
|
||||
final class HouseholdPositionAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\MaritalStatusRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class MaritalStatusAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ActionTypeAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class GoalAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators;
|
||||
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
@@ -8,14 +17,16 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
|
||||
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
class GoalResultAggregator implements AggregatorInterface
|
||||
{
|
||||
private ResultRepository $resultRepository;
|
||||
|
||||
private GoalRepository $goalRepository;
|
||||
|
||||
private ResultRepository $resultRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
@@ -28,86 +39,11 @@ class GoalResultAggregator implements AggregatorInterface
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value) use ($key): string {
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'goal_aggregator':
|
||||
|
||||
if ('_header' === $value) {
|
||||
return 'Goal Type';
|
||||
}
|
||||
|
||||
$g = $this->goalRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$g->getTitle()
|
||||
);
|
||||
|
||||
case 'result_aggregator':
|
||||
|
||||
if ('_header' === $value) {
|
||||
return 'Result Type';
|
||||
}
|
||||
|
||||
$r = $this->resultRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$r->getTitle()
|
||||
);
|
||||
|
||||
default:
|
||||
throw new \LogicException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [
|
||||
'goal_aggregator',
|
||||
'result_aggregator'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group social work actions by goal and result';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('goal', $qb->getAllAliases(), true)) {
|
||||
@@ -123,11 +59,62 @@ class GoalResultAggregator implements AggregatorInterface
|
||||
$qb->addGroupBy('goal_aggregator')->addGroupBy('result_aggregator');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::SOCIAL_WORK_ACTION_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return function ($value) use ($key): string {
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'goal_aggregator':
|
||||
if ('_header' === $value) {
|
||||
return 'Goal Type';
|
||||
}
|
||||
|
||||
$g = $this->goalRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$g->getTitle()
|
||||
);
|
||||
|
||||
case 'result_aggregator':
|
||||
if ('_header' === $value) {
|
||||
return 'Result Type';
|
||||
}
|
||||
|
||||
$r = $this->resultRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$r->getTitle()
|
||||
);
|
||||
|
||||
default:
|
||||
throw new LogicException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [
|
||||
'goal_aggregator',
|
||||
'result_aggregator',
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group social work actions by goal and result';
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class JobAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ReferrerAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ResultAggregator implements AggregatorInterface
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final class ScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
|
Reference in New Issue
Block a user