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