mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-09 01:09:51 +00:00
exports: fix resetDQLPart('from') issue (632)
https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/632
This commit is contained in:
parent
eafe68973a
commit
ef7a388f38
@ -23,17 +23,15 @@ Goal::class,,,goal
|
|||||||
,Result::class,goal.results,goalresult
|
,Result::class,goal.results,goalresult
|
||||||
Person::class,,,person
|
Person::class,,,person
|
||||||
,Center::class,person.center,center
|
,Center::class,person.center,center
|
||||||
,HouseholdMember::class,partperson.householdParticipations,member
|
,HouseholdMember::class,partperson.householdParticipations,householdmember
|
||||||
,MaritalStatus::class,person.maritalStatus,personmarital
|
,MaritalStatus::class,person.maritalStatus,personmarital
|
||||||
ResidentialAddress::class,,,resaddr
|
ResidentialAddress::class,,,resaddr
|
||||||
,Person::class,resaddr.person,resaddrperson
|
|
||||||
,Center::class,resaddrperson.center,resaddrcenter
|
|
||||||
,ThirdParty::class,resaddr.hostThirdParty,tparty
|
,ThirdParty::class,resaddr.hostThirdParty,tparty
|
||||||
ThirdParty::class,,,tparty
|
ThirdParty::class,,,tparty
|
||||||
,ThirdPartyCategory::class,tparty.categories,tpartycat
|
,ThirdPartyCategory::class,tparty.categories,tpartycat
|
||||||
HouseholdMember::class,,,member
|
HouseholdMember::class,,,householdmember
|
||||||
,Household::class,member.household,household
|
,Household::class,householdmember.household,household
|
||||||
,Person::class,member.person,memberperson
|
,Person::class,householdmember.person,memberperson
|
||||||
,,memberperson.center,membercenter
|
,,memberperson.center,membercenter
|
||||||
Household::class,,,household
|
Household::class,,,household
|
||||||
,HouseholdComposition::class,household.compositions,composition
|
,HouseholdComposition::class,household.compositions,composition
|
||||||
|
|
@ -31,17 +31,15 @@ These are alias conventions :
|
|||||||
| | Result::class | goal.results | goalresult |
|
| | Result::class | goal.results | goalresult |
|
||||||
| Person::class | | | person |
|
| Person::class | | | person |
|
||||||
| | Center::class | person.center | center |
|
| | Center::class | person.center | center |
|
||||||
| | HouseholdMember::class | partperson.householdParticipations | member |
|
| | HouseholdMember::class | partperson.householdParticipations | householdmember |
|
||||||
| | MaritalStatus::class | person.maritalStatus | personmarital |
|
| | MaritalStatus::class | person.maritalStatus | personmarital |
|
||||||
| ResidentialAddress::class | | | resaddr |
|
| ResidentialAddress::class | | | resaddr |
|
||||||
| | Person::class | resaddr.person | resaddrperson |
|
|
||||||
| | Center::class | resaddrperson.center | resaddrcenter |
|
|
||||||
| | ThirdParty::class | resaddr.hostThirdParty | tparty |
|
| | ThirdParty::class | resaddr.hostThirdParty | tparty |
|
||||||
| ThirdParty::class | | | tparty |
|
| ThirdParty::class | | | tparty |
|
||||||
| | ThirdPartyCategory::class | tparty.categories | tpartycat |
|
| | ThirdPartyCategory::class | tparty.categories | tpartycat |
|
||||||
| HouseholdMember::class | | | member |
|
| HouseholdMember::class | | | householdmember |
|
||||||
| | Household::class | member.household | household |
|
| | Household::class | householdmember.household | household |
|
||||||
| | Person::class | member.person | memberperson |
|
| | Person::class | householdmember.person | memberperson |
|
||||||
| | | memberperson.center | membercenter |
|
| | | memberperson.center | membercenter |
|
||||||
| Household::class | | | household |
|
| Household::class | | | household |
|
||||||
| | HouseholdComposition::class | household.compositions | composition |
|
| | HouseholdComposition::class | household.compositions | composition |
|
||||||
|
@ -16,8 +16,10 @@ use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
@ -31,8 +33,11 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
|
|||||||
|
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator, TranslatableStringHelper $translatableStringHelper, PositionRepository $positionRepository)
|
public function __construct(
|
||||||
{
|
TranslatorInterface $translator,
|
||||||
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
|
PositionRepository $positionRepository
|
||||||
|
) {
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->positionRepository = $positionRepository;
|
$this->positionRepository = $positionRepository;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
@ -45,28 +50,25 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
if (!in_array('householdmember', $qb->getAllAliases(), true)) {
|
||||||
$qb->from(HouseholdMember::class, 'member');
|
$qb->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person');
|
||||||
|
|
||||||
if (!in_array('memberperson', $qb->getAllAliases(), true)) {
|
|
||||||
$qb->join('member.person', 'memberperson');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('membercenter', $qb->getAllAliases(), true)) {
|
if (!in_array('center', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('memberperson.center', 'membercenter');
|
$qb->join('person.center', 'center');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->andWhere($qb->expr()->andX(
|
$qb->andWhere($qb->expr()->andX(
|
||||||
$qb->expr()->lte('member.startDate', ':date'),
|
$qb->expr()->lte('householdmember.startDate', ':date'),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull('member.endDate'),
|
$qb->expr()->isNull('householdmember.endDate'),
|
||||||
$qb->expr()->gte('member.endDate', ':date')
|
$qb->expr()->gte('householdmember.endDate', ':date')
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$qb->setParameter('date', $data['date_position']);
|
$qb->setParameter('date', $data['date_position']);
|
||||||
|
|
||||||
$qb->addSelect('IDENTITY(member.position) AS household_position_aggregator');
|
$qb->addSelect('IDENTITY(householdmember.position) AS household_position_aggregator');
|
||||||
|
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ final class HouseholdPositionAggregator implements AggregatorInterface, ExportEl
|
|||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
return 'person';
|
return Declarations::PERSON_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
@ -11,10 +11,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
@ -39,14 +41,8 @@ class ActivityTypeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// One2many between activity and accompanyingperiod is not reversed !
|
if (!in_array('activity', $qb->getAllAliases(), true)) {
|
||||||
// we replace indicator 'from' clause by 'act', and put 'acp' in a join
|
$qb->join(Activity::class, 'activity', Expr\Join::WITH, 'activity.accompanyingPeriod = acp');
|
||||||
|
|
||||||
$qb->resetDQLPart('from');
|
|
||||||
$qb->from('ChillActivityBundle:Activity', 'activity');
|
|
||||||
|
|
||||||
if (!in_array('actacp', $qb->getAllAliases(), true)) {
|
|
||||||
$qb->join('activity.accompanyingPeriod', 'actacp');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('acttype', $qb->getAllAliases(), true)) {
|
if (!in_array('acttype', $qb->getAllAliases(), true)) {
|
||||||
|
@ -14,6 +14,7 @@ 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\Form\Type\ChillDateType;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@ -38,15 +39,12 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
if (!in_array('resaddr', $qb->getAllAliases(), true)) {
|
||||||
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr');
|
$qb->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = person');
|
||||||
|
|
||||||
if (!in_array('resaddrperson', $qb->getAllAliases(), true)) {
|
|
||||||
$qb->join('resaddr.person', 'resaddrperson');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('resaddrcenter', $qb->getAllAliases(), true)) {
|
if (!in_array('center', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('resaddrperson.center', 'resaddrcenter');
|
$qb->join('person.center', 'center');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('tparty', $qb->getAllAliases(), true)) {
|
if (!in_array('tparty', $qb->getAllAliases(), true)) {
|
||||||
|
@ -12,7 +12,9 @@ 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\PersonBundle\Entity\Person\ResidentialAddress;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
|
||||||
@ -25,15 +27,12 @@ class ResidentialAddressAtUserFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$qb->resetDQLPart('from');
|
if (!in_array('resaddr', $qb->getAllAliases(), true)) {
|
||||||
$qb->from('ChillPersonBundle:Person\ResidentialAddress', 'resaddr');
|
$qb->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = person');
|
||||||
|
|
||||||
if (!in_array('resaddrperson', $qb->getAllAliases(), true)) {
|
|
||||||
$qb->join('resaddr.person', 'resaddrperson');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('resaddrcenter', $qb->getAllAliases(), true)) {
|
if (!in_array('center', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('resaddrperson.center', 'resaddrcenter');
|
$qb->join('person.center', 'center');
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user