/**
  * @Route("/new/{id}")
  * @Template()
  */
 public function newAction(\Club\BookingBundle\Entity\Plan $plan)
 {
     $exception = new \Club\BookingBundle\Entity\PlanException();
     $exception->setUser($this->getUser());
     $exception->setPlan($plan);
     $form = $this->createForm(new \Club\BookingBundle\Form\PlanException(), $exception);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $em->persist($exception);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.'));
             return $this->redirect($this->generateUrl('club_booking_adminplanexception_index', array('id' => $plan->getId())));
         }
     }
     return array('form' => $form->createView(), 'plan' => $plan);
 }
 /**
  * @Template()
  * @Route("/book/exclude/{id}/{datetime}")
  */
 public function excludeAction(\Club\BookingBundle\Entity\Plan $plan, \DateTime $datetime)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_BOOKING_ADMIN')) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getManager();
     if (!$plan->getRepeating()) {
         $em->remove($plan);
     } else {
         $exception = new \Club\BookingBundle\Entity\PlanException();
         $exception->setExcludeDate($datetime);
         $exception->setPlan($plan);
         $exception->setUser($this->getUser());
         $em->persist($exception);
     }
     $em->flush();
     $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.'));
     return $this->redirect($this->generateUrl('club_booking_overview_index', array('date' => $datetime->format('Y-m-d'))));
 }