Example #1
0
 /**
  * Get all events intersecting [$start, $end] and affected to the user's organisation
  * 
  * @param unknown $user            
  * @param unknown $start
  *            DateTime
  * @param unknown $end
  *            DateTime
  * @param unknown $exclude
  * @param array $status
  */
 public function getAllEvents($user, $start, $end, $exclude = false, $status = null)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select(array('e, c'))->from('Application\\Entity\\Event', 'e')->innerJoin('e.category', 'c')->andWhere($qb->expr()->isNull('e.parent'))->andWhere($qb->expr()->orX($qb->expr()->andX($qb->expr()->isNull('e.enddate'), $qb->expr()->eq('e.punctual', 'false'), $qb->expr()->lte('e.startdate', '?2')), $qb->expr()->andX($qb->expr()->isNotNull('e.enddate'), $qb->expr()->eq('e.punctual', 'false'), $qb->expr()->lte('e.startdate', '?2'), $qb->expr()->gte('e.enddate', '?1')), $qb->expr()->andX($qb->expr()->eq('e.punctual', 'true'), $qb->expr()->gte('e.startdate', '?1'), $qb->expr()->lte('e.startdate', '?2'))));
     //restriction sur le statut
     if ($status) {
         $qb->andWhere($qb->expr()->in('e.status', $status));
     }
     //exclusion des catégories pour rapport IPO
     if ($exclude) {
         $qb->andWhere($qb->expr()->eq('c.exclude', '?3'));
         $parameters[3] = false;
     }
     if ($user !== null && $user->hasIdentity()) {
         $org = $user->getIdentity()->getOrganisation();
         $qb->andWhere($qb->expr()->eq('e.organisation', $org->getId()));
         $parameters[1] = $start->format("Y-m-d H:i:s");
         $parameters[2] = $end->format("Y-m-d H:i:s");
         $qb->setParameters($parameters);
         $query = $qb->getQuery();
         return $query->getResult();
     } else {
         return array();
     }
 }
Example #2
0
 /**
  * Get all events intersecting [$start, $end] and affected to the user's organisation
  * 
  * @param unknown $user            
  * @param unknown $start
  *            DateTime
  * @param unknown $end
  *            DateTime
  */
 public function getAllEvents($user, $start, $end)
 {
     $qb = $this->getEntityManager()->createQueryBuilder();
     $qb->select(array('e'))->from('Application\\Entity\\Event', 'e')->andWhere($qb->expr()->isNull('e.parent'))->andWhere($qb->expr()->orX($qb->expr()->andX($qb->expr()->isNull('e.enddate'), $qb->expr()->eq('e.punctual', 'false'), $qb->expr()->lte('e.startdate', '?2')), $qb->expr()->andX($qb->expr()->isNotNull('e.enddate'), $qb->expr()->eq('e.punctual', 'false'), $qb->expr()->lte('e.startdate', '?2'), $qb->expr()->gte('e.enddate', '?1')), $qb->expr()->andX($qb->expr()->eq('e.punctual', 'true'), $qb->expr()->gte('e.startdate', '?1'), $qb->expr()->lte('e.startdate', '?2'))));
     if ($user !== null && $user->hasIdentity()) {
         $org = $user->getIdentity()->getOrganisation();
         $qb->andWhere($qb->expr()->eq('e.organisation', $org->getId()));
         $parameters[1] = $start->format("Y-m-d H:i:s");
         $parameters[2] = $end->format("Y-m-d H:i:s");
         $qb->setParameters($parameters);
         $query = $qb->getQuery();
         return $query->getResult();
     } else {
         return array();
     }
 }