Ejemplo n.º 1
0
 public function onCheckinUser(\Club\CheckinBundle\Event\FilterCheckinEvent $event)
 {
     if (!$this->container->getParameter('club_team.penalty_enabled')) {
         return;
     }
     $checkin = $event->getCheckin();
     $before = new \DateTime();
     $i = new \DateInterval('PT' . $this->container->getParameter('club_team.minutes_before_schedule') . 'M');
     $before->add($i);
     $after = new \DateTime();
     $i = new \DateInterval('PT' . $this->container->getParameter('club_team.minutes_after_schedule') . 'M');
     $after->sub($i);
     $schedules = $this->em->createQueryBuilder()->select('su')->from('ClubTeamBundle:ScheduleUser', 'su')->leftJoin('su.schedule', 's')->leftJoin('s.users', 'u')->where('u.user = :user')->andWhere('s.first_date < :before')->andWhere('s.first_date > :after')->setParameter('user', $checkin->getUser()->getId())->setParameter('before', $before)->setParameter('after', $after)->getQuery()->getResult();
     foreach ($schedules as $schedule) {
         $schedule->setConfirmed(true);
         $this->em->persist($schedule);
     }
     $this->em->flush();
 }
Ejemplo n.º 2
0
 public function onCheckinUser(\Club\CheckinBundle\Event\FilterCheckinEvent $event)
 {
     if (!$this->container->getParameter('club_booking.cancel_without_checkin')) {
         return;
     }
     $checkin = $event->getCheckin();
     $before = new \DateTime();
     $i = new \DateInterval('PT' . $this->container->getParameter('club_booking.confirm_minutes_before') . 'M');
     $before->add($i);
     $after = new \DateTime();
     $i = new \DateInterval('PT' . $this->container->getParameter('club_booking.confirm_minutes_after') . 'M');
     $after->sub($i);
     $bookings = $this->em->createQueryBuilder()->select('b')->from('ClubBookingBundle:Booking', 'b')->leftJoin('b.users', 'u')->where('b.user = :user OR u.id = :user')->andWhere('b.first_date < :before')->andWhere('b.first_date > :after')->setParameter('user', $checkin->getUser()->getId())->setParameter('before', $before)->setParameter('after', $after)->getQuery()->getResult();
     foreach ($bookings as $booking) {
         $booking->setStatus(\Club\BookingBundle\Entity\Booking::CHECKIN);
         $this->em->persist($booking);
     }
     $this->em->flush();
 }