[activity][export] Fixed: fixed inconsistencies with date filters

This commit is contained in:
2022-09-21 12:08:55 +02:00
parent 8b64933565
commit 4e82126bed
3 changed files with 6 additions and 28 deletions

View File

@@ -29,24 +29,9 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
$clause = "OVERLAPSI (acp.openingDate, acp.closingDate), (:datefrom, :dateto) = 'TRUE'";
$clause = $qb->expr()->orX(
$qb->expr()->lt('(acp.openingDate + 1)', ':dateto'),
$qb->expr()->andX(
$qb->expr()->lt('acp.openingDate', ':datefrom'),
$qb->expr()->isNull('acp.closingDate')
),
$qb->expr()->gt('(acp.closingDate - 1)', ':datefrom')
);
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->andWhere($clause);
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
}

View File

@@ -29,20 +29,12 @@ class OpenBetweenDatesFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->andX(
$qb->expr()->lt('acp.openingDate', ':datefrom'),
$qb->expr()->gt('acp.closingDate', ':dateto')
$qb->expr()->gte('acp.openingDate', ':datefrom'),
$qb->expr()->lte('acp.openingDate', ':dateto')
);
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->andWhere($clause);
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
}