From 2fce8b3cfd4a2cabec294d69f0be91a968ed3d8b Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 11 Jul 2014 20:04:43 +0200 Subject: [PATCH] Show events for today --- .../Bundle/CalciferBundle/Controller/EventController.php | 4 +++- .../Bundle/CalciferBundle/Controller/LocationController.php | 5 ++++- .../Bundle/CalciferBundle/Controller/TagController.php | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php index 20f3c6d..1b0d649 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php @@ -34,13 +34,15 @@ class EventController extends Controller { $em = $this->getDoctrine()->getManager(); + $now = new \DateTime(); + $now->setTime(0,0,0); /** @var QueryBuilder $qb */ $qb = $em->createQueryBuilder(); $qb ->select(array('e')) ->from('CalciferBundle:Event', 'e') ->where('e.startdate >= :startdate') ->orderBy('e.startdate') - ->setParameter('startdate',new \DateTime()); + ->setParameter('startdate',$now); $entities = $qb->getQuery()->execute(); return array( diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php index 7924376..87f460d 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/LocationController.php @@ -56,6 +56,9 @@ class LocationController extends Controller $em = $this->getDoctrine()->getManager(); + $now = new \DateTime(); + $now->setTime(0,0,0); + /** @var QueryBuilder $qb */ $qb = $em->createQueryBuilder(); $qb ->select(array('e')) @@ -63,7 +66,7 @@ class LocationController extends Controller ->where('e.startdate >= :startdate') ->andWhere('e.locations_id = :location') ->orderBy('e.startdate') - ->setParameter('startdate',new \DateTime()) + ->setParameter('startdate',$now) ->setParameter('location',$location->getId()); $entities = $qb->getQuery()->execute(); diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php index 6d0a55e..88261b8 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/TagController.php @@ -54,6 +54,9 @@ class TagController extends Controller throw $this->createNotFoundException('Unable to find tag entity.'); } + $now = new \DateTime(); + $now->setTime(0,0,0); + /** @var QueryBuilder $qb */ $qb = $em->createQueryBuilder(); $qb ->select(array('e')) @@ -61,7 +64,7 @@ class TagController extends Controller ->join('e.tags', 't', 'WITH', $qb->expr()->in('t.id', $tag->getId())) ->where('e.startdate >= :startdate') ->orderBy('e.startdate') - ->setParameter('startdate',new \DateTime()); + ->setParameter('startdate',$now); $entities = $qb->getQuery()->execute(); return array(