From 813b9ff312c0f221faa1864c6536e21382edbdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 19 Nov 2024 10:33:09 +0100 Subject: [PATCH] query fix (#1426) --- app/Model/Program/Repositories/BlockRepository.php | 7 ++++--- app/Model/Program/Repositories/ProgramRepository.php | 7 ++++--- app/Model/User/Repositories/UserRepository.php | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/Model/Program/Repositories/BlockRepository.php b/app/Model/Program/Repositories/BlockRepository.php index c992250a9..57a2045d1 100644 --- a/app/Model/Program/Repositories/BlockRepository.php +++ b/app/Model/Program/Repositories/BlockRepository.php @@ -145,16 +145,17 @@ public function findUserAllowed(User $user, bool $paidOnly): Collection ->leftJoin('c.registerableRoles', 'r') ->leftJoin('r.users', 'u1') ->join('b.subevent', 's') - ->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid') + ->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered') ->join('sa.user', 'u2', 'WITH', 'u2.approved = TRUE') ->where('c IS NULL OR u1 = :user') ->andWhere('u2 = :user') ->setParameter('user', $user) ->setParameter('stateCanceled', ApplicationState::CANCELED) - ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID); + ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID) + ->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED); if ($paidOnly) { - $qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment') + $qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment') ->join('ra.roles', 'rar') ->andWhere('sa.state != :stateWaitingForPayment') ->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT); diff --git a/app/Model/Program/Repositories/ProgramRepository.php b/app/Model/Program/Repositories/ProgramRepository.php index 542331111..e7986aa9c 100644 --- a/app/Model/Program/Repositories/ProgramRepository.php +++ b/app/Model/Program/Repositories/ProgramRepository.php @@ -87,16 +87,17 @@ public function findUserAllowed(User $user, bool $paidOnly): Collection ->leftJoin('c.registerableRoles', 'r') ->leftJoin('r.users', 'u1') ->join('b.subevent', 's') - ->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid') + ->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered') ->join('sa.user', 'u2', 'WITH', 'u2.approved = TRUE') ->where('c IS NULL OR u1 = :user') ->andWhere('u2 = :user') ->setParameter('user', $user) ->setParameter('stateCanceled', ApplicationState::CANCELED) - ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID); + ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID) + ->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED); if ($paidOnly) { - $qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment') + $qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment') ->join('ra.roles', 'rar') ->andWhere('sa.state != :stateWaitingForPayment') ->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT); diff --git a/app/Model/User/Repositories/UserRepository.php b/app/Model/User/Repositories/UserRepository.php index 2415bcc09..a263b8e29 100644 --- a/app/Model/User/Repositories/UserRepository.php +++ b/app/Model/User/Repositories/UserRepository.php @@ -307,13 +307,14 @@ public function remove(User $user): void public function blockAllowedQuery(Block $block, bool $paidOnly): QueryBuilder { $qb = $this->createQueryBuilder('u') - ->join('u.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid') + ->join('u.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered') ->join('sa.subevents', 's') ->where('u.approved = true') ->andWhere('s = :subevent') ->setParameter('subevent', $block->getSubevent()) ->setParameter('stateCanceled', ApplicationState::CANCELED) - ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID); + ->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID) + ->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED); if ($block->getCategory() !== null) { $qb = $qb->join('u.roles', 'r') @@ -323,7 +324,7 @@ public function blockAllowedQuery(Block $block, bool $paidOnly): QueryBuilder } if ($paidOnly) { - $qb = $qb->join('u.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment') + $qb = $qb->join('u.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment') ->join('ra.roles', 'rar') ->andWhere('sa.state != :stateWaitingForPayment') ->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT);