/**
  * @param Event $event
  *
  * @return Unregistration[]
  */
 public function getUnprocessedUnregistrations(Event $event)
 {
     $rsm = new ResultSetMappingBuilder($this->_em);
     $rsm->addRootEntityFromClassMetadata('BCRM\\BackendBundle\\Entity\\Event\\Unregistration', 'u');
     $eventId = $event->getId();
     $unregistrations = "SELECT MAX(id) FROM unregistration WHERE confirmed = 1 AND event_id = {$eventId} AND processed = 0 GROUP BY event_id, email ORDER BY created ASC, id ASC";
     $sql = "SELECT * FROM unregistration WHERE id IN ({$unregistrations})";
     $query = $this->_em->createNativeQuery($sql, $rsm);
     return $query->getResult();
 }
 /**
  * {@inheritDocs}
  */
 public function getNextVipRegistrations(Event $event, $day)
 {
     $rsm = new ResultSetMappingBuilder($this->_em);
     $rsm->addRootEntityFromClassMetadata('BCRM\\BackendBundle\\Entity\\Event\\Registration', 'r');
     $types = join(',', array(Registration::TYPE_SPONSOR, Registration::TYPE_VIP));
     $eventId = $event->getId();
     $dayName = $day == Ticket::DAY_SATURDAY ? 'saturday' : 'sunday';
     $registrations = "SELECT MAX(id) FROM registration WHERE confirmed = 1 AND type IN ({$types}) AND event_id = {$eventId} GROUP BY event_id, email ORDER BY created ASC, id ASC";
     $sql = "SELECT * FROM registration WHERE id IN ({$registrations}) AND email NOT IN (SELECT email FROM ticket WHERE day = {$day} AND event_id = {$eventId}) AND {$dayName} = 1";
     $query = $this->_em->createNativeQuery($sql, $rsm);
     return $query->getResult();
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $bcrm13 = new Event();
     $bcrm13->setCapacity(3);
     $bcrm13->setName('BarCamp RheinMain 2013 Dieburg 23./24.11.2013');
     $bcrm13->setRegistrationStart(new \DateTime('2013-10-14T08:00:00+02:00'));
     $regEnd = new \DateTime();
     $regEnd->modify('+1 day');
     $bcrm13->setRegistrationEnd($regEnd);
     // During our tests we will simulate the sunday
     $start = new \DateTime();
     $start->setTime(8, 0, 0);
     $start->modify('-1day');
     $bcrm13->setStart($start);
     $manager->persist($bcrm13);
     $manager->flush();
 }
 /**
  * @param Event $event
  * @param       $day
  *
  * @return integer
  */
 public function getCapacity(Event $event, $day)
 {
     return $this->createQueryBuilder('e')->select('e.capacity - COUNT(t.id) as capacity')->leftJoin('e.tickets', 't')->andWhere('t.day = :day')->setParameter('day', $day)->andWhere('t.type = :type')->setParameter('type', Registration::TYPE_NORMAL)->andWhere('e.id = :event')->setParameter('event', $event->getId())->getQuery()->getSingleScalarResult();
 }