add methods to get travel info
This commit is contained in:
parent
7b4da30342
commit
178f44fd2d
@ -6,6 +6,8 @@ use App\Entity\CaseItinerary;
|
||||
use App\Entity\MemberCase;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserCase;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@ -21,8 +23,6 @@ class CaseItineraryRepository extends ServiceEntityRepository
|
||||
|
||||
public function getRecentTravel(User $user, ?array $params = null): ?array
|
||||
{
|
||||
//dd($params);
|
||||
|
||||
$query = $this->createQueryBuilder('ci')
|
||||
->leftJoin(UserCase::class, 'uc', 'WITH', 'uc.memberCase = ci.memberCase')
|
||||
->andWhere('uc.user = :user')
|
||||
@ -49,6 +49,40 @@ class CaseItineraryRepository extends ServiceEntityRepository
|
||||
return $query->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getYTDTravel(User $user): ?array
|
||||
{
|
||||
$startDate = new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
|
||||
|
||||
$query = $this->createQueryBuilder('ci')
|
||||
->leftJoin(UserCase::class, 'uc', 'WITH', 'uc.memberCase = ci.memberCase')
|
||||
->andWhere('uc.user = :user')
|
||||
->setParameter('user', $user->getId()->toBinary())
|
||||
->andWhere('ci.date >= :from')
|
||||
->setParameter('from', $startDate->format('Y-01-01'))
|
||||
->orderBy('ci.date', 'DESC')
|
||||
->addOrderBy('ci.arrival', 'DESC')
|
||||
;
|
||||
|
||||
return $query->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function getTravelLast30Days(User $user): ?array
|
||||
{
|
||||
$startDate = new DateTime('now', new DateTimeZone($_ENV['COMPANY_TIMEZONE']));
|
||||
|
||||
$query = $this->createQueryBuilder('ci')
|
||||
->leftJoin(UserCase::class, 'uc', 'WITH', 'uc.memberCase = ci.memberCase')
|
||||
->andWhere('uc.user = :user')
|
||||
->setParameter('user', $user->getId()->toBinary())
|
||||
->andWhere('ci.date >= :from')
|
||||
->setParameter('from', $startDate->modify('-30 days')->format('Y-m-d'))
|
||||
->orderBy('ci.date', 'DESC')
|
||||
->addOrderBy('ci.arrival', 'DESC')
|
||||
;
|
||||
|
||||
return $query->getQuery()->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return CaseLocation[] Returns an array of CaseLocation objects
|
||||
// */
|
||||
|
Loading…
Reference in New Issue
Block a user