Skip to content

Commit

Permalink
Year fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Feb 13, 2020
1 parent 7b4af1b commit b42bc74
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions api/src/Repository/RequestRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ public function __construct(ManagerRegistry $registry)
*/
public function getNextReferenceId($organization, $date = null)
{
if(!$date){
$date = New \Datetime;
}
//if(!$date){
$start = new \DateTime('first day of January this year');
$end = new \DateTime('last day of December this year');
//}

$result = $this->createQueryBuilder('r')
->select('MAX(r.referenceId) AS reference_id')
->andWhere(':organisation MEMBER OF r.organizations')
->setParameter('organisation', $organization)
//->andWhere('YEAR(r.dateCreated) = YEAR(:date)')
//->setParameter('date', $date)
->andWhere('r.dateCreated >= :start')
->setParameter('start', $start)
->andWhere('r.dateCreated <= :end')
->setParameter('end', $end)
->getQuery()
->getOneOrNullResult()
;
Expand Down

0 comments on commit b42bc74

Please sign in to comment.