/**
  * @Route("/edit/{id}")
  * @Template()
  */
 public function editAction(\Club\BookingBundle\Entity\Plan $plan)
 {
     if (!count($plan->getPlanRepeats())) {
         $repeat = new \Club\BookingBundle\Entity\PlanRepeat();
         $repeat->setPlan($plan);
         $plan->addPlanRepeat($repeat);
     }
     $form = $this->createForm(new \Club\BookingBundle\Form\Plan(), $plan);
     if ($this->getRequest()->getMethod() == 'POST') {
         $form->bind($this->getRequest());
         if ($form->isValid()) {
             $em = $this->getDoctrine()->getManager();
             $em = $this->getDoctrine()->getManager();
             $em->persist($plan);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.'));
             return $this->redirect($this->generateUrl('club_booking_adminplan_index'));
         }
     }
     return array('plan' => $plan, 'form' => $form->createView());
 }
    private function addEvent(\Club\BookingBundle\Entity\Plan $plan)
    {
        $ics = <<<EOF
BEGIN:VEVENT
UID:{$plan->getIcsUid()}
DTSTAMP:{$plan->getCreatedAt()->format('Ymd\\THis')}
DTSTART:{$plan->getStart()->format('Ymd\\THis')}
DTEND:{$plan->getEnd()->format('Ymd\\THis')}
SUMMARY:{$plan->getName()}
END:VEVENT

EOF;
        return $ics;
    }
 /**
  * @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'))));
 }