feat: review received form submissions in the admin ui
This commit is contained in:
1 parent
f073a2014d
commit
cb2d64f2cd
19 files changed
+999
-7
No files matched your search
@@ -3,7 +3,11 @@
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ApplicationFormSubmission;
|
||||
use App\Model\ApplicationFormSubmissionFilterDto;
|
||||
use App\Repository\Traits\QueryHelperTrait;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -16,8 +20,48 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
*/
|
||||
class ApplicationFormSubmissionRepository extends ServiceEntityRepository
|
||||
{
|
||||
use QueryHelperTrait;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ApplicationFormSubmission::class);
|
||||
}
|
||||
|
||||
public function getListQuery(ApplicationFormSubmissionFilterDto $filterDto): Query
|
||||
{
|
||||
$qb = $this->createQueryBuilder('submission');
|
||||
|
||||
$this->applyFilterCriteria($qb, $filterDto);
|
||||
|
||||
return $qb->getQuery();
|
||||
}
|
||||
|
||||
private function applyFilterCriteria(QueryBuilder $qb, ApplicationFormSubmissionFilterDto $filterDto): void
|
||||
{
|
||||
if (null !== $name = $filterDto->getName()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->orX(
|
||||
$qb->expr()->like('submission.firstName', ':name'),
|
||||
$qb->expr()->like('submission.lastName', ':name')
|
||||
))
|
||||
->setParameter('name', '%'.$this->escapeLikeWildcards($name).'%')
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $dateFrom = $filterDto->getDateFrom()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->gte('submission.submittedAt', ':dateFrom'))
|
||||
->setParameter('dateFrom', $dateFrom)
|
||||
;
|
||||
}
|
||||
|
||||
if (null !== $dateTo = $filterDto->getDateTo()) {
|
||||
// The datepicker hands over midnight and submittedAt carries a time, so a plain
|
||||
// lte would drop everything that arrived during the last day of the range.
|
||||
$qb
|
||||
->andWhere($qb->expr()->lte('submission.submittedAt', ':dateTo'))
|
||||
->setParameter('dateTo', $dateTo->setTime(23, 59, 59))
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user