mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
bootstrap fake sms from cli
This commit is contained in:
@@ -13,8 +13,10 @@ namespace Chill\CalendarBundle\Repository;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
class CalendarRepository implements ObjectRepository
|
||||
@@ -67,6 +69,21 @@ class CalendarRepository implements ObjectRepository
|
||||
);
|
||||
}
|
||||
|
||||
public function findByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
$qb = $this->queryByNotificationAvailable($startDate, $endDate)->select('c');
|
||||
|
||||
if (null !== $limit) {
|
||||
$qb->setMaxResults($limit);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
$qb->setFirstResult($offset);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria): ?Calendar
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
@@ -76,4 +93,26 @@ class CalendarRepository implements ObjectRepository
|
||||
{
|
||||
return Calendar::class;
|
||||
}
|
||||
|
||||
private function queryByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('c');
|
||||
|
||||
$qb->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->eq('c.sendSMS', "'TRUE'"),
|
||||
$qb->expr()->gte('c.startDate', ':startDate'),
|
||||
$qb->expr()->lt('c.startDate', ':endDate'),
|
||||
$qb->expr()->in('c.smsStatus', ':statuses')
|
||||
)
|
||||
);
|
||||
|
||||
$qb->setParameters([
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
'statuses' => [Calendar::SMS_PENDING, Calendar::SMS_CANCEL_PENDING],
|
||||
]);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user