mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
add filter residential address at thirdparty of category
This commit is contained in:
parent
2c53f92a2e
commit
b2c1c0ec76
@ -12,15 +12,25 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -28,8 +38,9 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('thirdparty_type', EntityType::class, [
|
$builder->add('thirdparty_cat', EntityType::class, [
|
||||||
'class' => ThirdPartyCategory::class,
|
'class' => ThirdPartyCategory::class,
|
||||||
|
'label' => 'Category',
|
||||||
'choice_label' => function (ThirdPartyCategory $tpc) {
|
'choice_label' => function (ThirdPartyCategory $tpc) {
|
||||||
return $this->translatableStringHelper->localize($tpc->getName());
|
return $this->translatableStringHelper->localize($tpc->getName());
|
||||||
},
|
},
|
||||||
@ -45,19 +56,19 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Query is not finished... not clear what 'catégorie' corresponds with. Cannot get values to appear in table thirdparty_category
|
|
||||||
$qb->resetDQLPart('from');
|
$qb->resetDQLPart('from');
|
||||||
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra');
|
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'ra');
|
||||||
|
|
||||||
$qb->join('ra.person', 'person');
|
$qb->join('ra.person', 'person');
|
||||||
$qb->join('person.center', 'center');
|
$qb->join('person.center', 'center');
|
||||||
$qb->join('ra.hostThirdparty', 'thirdparty');
|
$qb->join('ra.hostThirdParty', 't');
|
||||||
|
$qb->join('t.categories', 'tc');
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->andX(
|
$clause = $qb->expr()->andX(
|
||||||
$qb->expr()->isNotNull('ra.hostThirdparty'),
|
$qb->expr()->isNotNull('ra.hostThirdParty'),
|
||||||
// $qb->expr()->in('thirdparty.categories')
|
$qb->expr()->between(':date', 'ra.startDate', 'ra.endDate'),
|
||||||
|
$qb->expr()->in('tc.id', ':type')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
@ -66,6 +77,8 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$qb->setParameter('type', $data['thirdparty_cat']);
|
||||||
|
$qb->setParameter('date', $data['date_calc']);
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +90,14 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
public function describeAction($data, $format = 'string')
|
||||||
{
|
{
|
||||||
return ['Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%'];
|
return ['Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type% and valid on %date_calc%', [
|
||||||
|
'%thirdparty_type%' => $this->translatableStringHelper->localize($data['thirdparty_cat'][0]->getName()),
|
||||||
|
'%date_calc%' => $data['date_calc']->format('d-m-Y'),
|
||||||
|
],];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Filtered by person\'s who have a residential address located at a thirdparty of type %thirdparty_type%';
|
return 'Filtered by person\'s who have a residential address located at a thirdparty of type';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Export\Filter\PersonFilters;
|
|||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
||||||
class ResidentialAddressAtUserFilter implements FilterInterface
|
class ResidentialAddressAtUserFilter implements FilterInterface
|
||||||
@ -34,7 +35,7 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->isNotNull('ra.hostPerson');
|
$clause = $qb->expr()->isNotNull('ra.hostPerson');
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
|
@ -76,6 +76,13 @@ services:
|
|||||||
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_residential_address_at_thirdparty:
|
||||||
|
class: Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtThirdpartyFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: person_residential_address_at_thirdparty_filter }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
chill.person.export.aggregator_nationality:
|
chill.person.export.aggregator_nationality:
|
||||||
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator
|
class: Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator
|
||||||
|
@ -573,6 +573,8 @@ Group people by marital status: Grouper les personnes par état matrimonial
|
|||||||
Aggregate by household position: Grouper par position dans le ménage
|
Aggregate by household position: Grouper par position dans le ménage
|
||||||
Household position in relation to this date: Position dans le ménage par rapport à cette date
|
Household position in relation to this date: Position dans le ménage par rapport à cette date
|
||||||
Household position: Position dans le ménage
|
Household position: Position dans le ménage
|
||||||
|
Filtered by person's who have a residential address located at a thirdparty of type: Uniquement les usagers qui ont une addresse de résidence chez un tiers de catégorie "xxx"
|
||||||
|
"Filtered by person's who have a residential address located at a thirdparty of type %thirdparty_type% and valid on %date_calc%": "Uniquement les usagers qui ont une addresse de résidence chez un tiers de catégorie %thirdparty_type% et valide sur la date %date_calc%"
|
||||||
|
|
||||||
Aggregate by age: Grouper par âge
|
Aggregate by age: Grouper par âge
|
||||||
Calculate age in relation to this date: Calculer l'âge par rapport à cette date
|
Calculate age in relation to this date: Calculer l'âge par rapport à cette date
|
||||||
|
Loading…
x
Reference in New Issue
Block a user