mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
vendee filters and aggregators moved to root folder
This commit is contained in:
parent
97ec921a0a
commit
2c7a128348
@ -1,90 +0,0 @@
|
|||||||
<?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 App\Repository\VendeePerson\SituationProfessionelleRepository;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
|
|
||||||
// todo FIX ERROR AND MOVE TO VENDEE ROOT FOLDER
|
|
||||||
|
|
||||||
final class ProfessionalSituationAggregator implements AggregatorInterface
|
|
||||||
{
|
|
||||||
private SituationProfessionelleRepository $professionalSituationRepository;
|
|
||||||
|
|
||||||
private TranslatableStringHelper $translatableStringHelper;
|
|
||||||
|
|
||||||
public function __construct(SituationProfessionelleRepository $professionalSituationRepository, TranslatableStringHelper $translatableStringHelper)
|
|
||||||
{
|
|
||||||
$this->professionalSituationRepository = $professionalSituationRepository;
|
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
|
||||||
{
|
|
||||||
$qb->resetDQLPart('from');
|
|
||||||
$qb->from('App:VendeePerson', 'vp');
|
|
||||||
$qb->join('vp.person', 'person');
|
|
||||||
$qb->join('person.center', 'center');
|
|
||||||
|
|
||||||
$qb->join('vp.situationProfessionelle', 'sp');
|
|
||||||
$qb->addSelect('sp.id as professional_situation_aggregator');
|
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('professional_situation_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('professional_situation_aggregator');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applyOn()
|
|
||||||
{
|
|
||||||
return Declarations::PERSON_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
|
||||||
{
|
|
||||||
return function ($value): string {
|
|
||||||
if ('_header' === $value) {
|
|
||||||
return 'Professional situation';
|
|
||||||
}
|
|
||||||
|
|
||||||
$g = $this->professionalSituationRepository->find($value);
|
|
||||||
|
|
||||||
return $this->translatableStringHelper->localize($g->getName());;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
|
||||||
{
|
|
||||||
return ['professional_situation_aggregator'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Group people by their professional situation';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
<?php
|
|
||||||
// TODO move to vendee root folder
|
|
||||||
/**
|
|
||||||
* 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\Filter\PersonFilters;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
|
|
||||||
class EntrustedChildFilter implements FilterInterface
|
|
||||||
{
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
|
||||||
{
|
|
||||||
$qb->resetDQLPart('from');
|
|
||||||
$qb->from('App:VendeePersonMineur', 'vpm');
|
|
||||||
|
|
||||||
$qb->join('vpm.person', 'person');
|
|
||||||
$qb->join('person.center', 'center');
|
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
|
||||||
$clause = $qb->expr()->eq('vpm.enfantConfie', 'true');
|
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
|
||||||
$where->add($clause);
|
|
||||||
} else {
|
|
||||||
$where = $qb->expr()->andX($clause);
|
|
||||||
}
|
|
||||||
|
|
||||||
$qb->add('where', $where);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applyOn()
|
|
||||||
{
|
|
||||||
return Declarations::PERSON_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
// No form needed
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
|
||||||
{
|
|
||||||
return ['Filtered by entrusted child status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Filter by entrusted child status';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
<?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.
|
|
||||||
*/
|
|
||||||
// TODO move to vendee root folder
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
|
||||||
|
|
||||||
class NomadicFilter implements FilterInterface
|
|
||||||
{
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
|
||||||
{
|
|
||||||
$qb->resetDQLPart('from');
|
|
||||||
$qb->from('App:VendeePerson', 'vp');
|
|
||||||
|
|
||||||
$qb->join('vp.person', 'person');
|
|
||||||
$qb->join('person.center', 'center');
|
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
|
||||||
$clause = $qb->expr()->eq('vp.gensDuVoyage', 'true');
|
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
|
||||||
$where->add($clause);
|
|
||||||
} else {
|
|
||||||
$where = $qb->expr()->andX($clause);
|
|
||||||
}
|
|
||||||
|
|
||||||
$qb->add('where', $where);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function applyOn()
|
|
||||||
{
|
|
||||||
return Declarations::PERSON_TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
// No form needed
|
|
||||||
}
|
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
|
||||||
{
|
|
||||||
return ['Filtered by nomadic status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Filter by nomadic status';
|
|
||||||
}
|
|
||||||
}
|
|
@ -68,20 +68,6 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: person_residential_address_at_user_filter }
|
- { name: chill.export_filter, alias: person_residential_address_at_user_filter }
|
||||||
|
|
||||||
chill.person.export.filter_entrusted_child:
|
|
||||||
class: Chill\PersonBundle\Export\Filter\PersonFilters\EntrustedChildFilter
|
|
||||||
autowire: true
|
|
||||||
autoconfigure: true
|
|
||||||
tags:
|
|
||||||
- { name: chill.export_filter, alias: person_entrusted_child_filter }
|
|
||||||
|
|
||||||
chill.person.export.filter_nomadic:
|
|
||||||
class: Chill\PersonBundle\Export\Filter\PersonFilters\NomadicFilter
|
|
||||||
autowire: true
|
|
||||||
autoconfigure: true
|
|
||||||
tags:
|
|
||||||
- { name: chill.export_filter, alias: person_nomadic_filter }
|
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
chill.person.export.aggregator_nationality:
|
chill.person.export.aggregator_nationality:
|
||||||
@ -118,10 +104,3 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: person_marital_status_aggregator }
|
- { name: chill.export_aggregator, alias: person_marital_status_aggregator }
|
||||||
|
|
||||||
# chill.person.export.aggregator_professional_situation:
|
|
||||||
# class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\ProfessionalSituationAggregator
|
|
||||||
# autowire: true
|
|
||||||
# autoconfigure: true
|
|
||||||
# tags:
|
|
||||||
# - { name: chill.export_aggregator, alias: person_professional_situation_aggregator }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user