Exemplo n.º 1
0
 /**
  * @Route("/nueva-inscripcion/{participanttype}", name="participant_new")
  * Muestra pantalla de nueva inscripción
  */
 public function newParticipantAction(Request $request, \AppBundle\Entity\ParticipantType $participanttype)
 {
     $siteManager = $this->container->get('ritsiga.site.manager');
     $convention = $siteManager->getCurrentSite();
     $user = $this->getUser();
     $registration = $this->getDoctrine()->getRepository('AppBundle:Registration')->findOneBy(array('user' => $user, 'convention' => $convention));
     $user = $this->getUser();
     if (!$registration) {
         return $this->redirectToRoute('sylius_flow_start', array('scenarioAlias' => 'asamblea'));
     }
     if ($registration->getStatus() != Registration::STATUS_OPEN) {
         return $this->redirectToRoute('registration');
     }
     $participant = new Participant();
     $participant->setRegistration($registration);
     $form = $this->createForm($this->get('ritsiga.participant.form.type'), $participant);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $num_participants = $this->getDoctrine()->getRepository('AppBundle:Participant')->getNumParticipationsTypesAvailables($registration, $participanttype);
         if ($participanttype && $participanttype->getNumParticipants() > $num_participants) {
             $participant->setParticipantType($participanttype);
             $em = $this->getDoctrine()->getManager();
             $em->persist($participant);
             $em->flush();
             return $this->redirectToRoute('registration');
         } else {
             $this->addFlash('warning', $this->get('translator')->trans('Sorry, the seats are already occupied'));
             return $this->redirectToRoute('registration');
         }
     }
     return $this->render(':frontend/registration:participant.html.twig', array('user' => $user, 'registration' => $registration, 'form' => $form->createView()));
 }
 /**
  * @Route("/new/{ticket}/ticket", name="participant_new")
  * Muestra pantalla de nueva inscripción
  */
 public function newParticipantAction(Request $request, Ticket $ticket)
 {
     $registration = $this->getRegistration();
     if (!$registration) {
         return $this->redirectToRoute('sylius_flow_start', array('scenarioAlias' => 'asamblea'));
     }
     if ($registration->getStatus() != Registration::STATUS_OPEN) {
         return $this->redirectToRoute('registration');
     }
     $this->denyAccessUnlessGranted(['SEATS_AVAILABLE', 'REGISTRATION_OPEN'], $ticket);
     $participant = new Participant();
     $participant->setRegistration($registration);
     $form = $this->createForm($this->get('ritsiga.participant.form.type'), $participant);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $participant->setTicket($ticket);
         $em = $this->getDoctrine()->getManager();
         $em->persist($participant);
         $em->flush();
         return $this->redirectToRoute('registration');
     }
     return $this->render(':frontend/registration:participant.html.twig', array('registration' => $registration, 'form' => $form->createView()));
 }
Exemplo n.º 3
0
 /**
  * @Route("/registro", name="registration")
  * Muestra pantalla de edición del registro
  */
 public function registrationAction(Request $request)
 {
     $siteManager = $this->container->get('ritsiga.site.manager');
     $convention = $siteManager->getCurrentSite();
     $registration = $this->getRegistration();
     $user = $this->getUser();
     if (!$registration) {
         return $this->redirectToRoute('sylius_flow_start', array('scenarioAlias' => 'asamblea'));
     }
     $participant = new Participant();
     $types = $this->getDoctrine()->getRepository('AppBundle:ParticipantType')->findParticipationsTypesAvailables($convention);
     $types_availables = array();
     if ($types) {
         foreach ($types as $type) {
             $num_participants = $this->getDoctrine()->getRepository('AppBundle:Participant')->getNumParticipationsTypesAvailables($registration, $type);
             if ($type && $type->getNumParticipants() > $num_participants) {
                 array_push($types_availables, $type);
             }
         }
     }
     $participant = new Participant();
     $participant->setRegistration($registration);
     $form = $this->createForm($this->get('ritsiga.participant.form.type'), $participant);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $participant_type = $this->getDoctrine()->getRepository('AppBundle:ParticipantType')->findOneBy(array('id' => $form["participant_type"]->getData()));
         $num_participants = $this->getDoctrine()->getRepository('AppBundle:Participant')->getNumParticipationsTypesAvailables($registration, $participant_type);
         if ($participant_type && $participant_type->getNumParticipants() > $num_participants) {
             $participant->setParticipantType($participant_type);
             $em = $this->getDoctrine()->getManager();
             $em->persist($participant);
             $em->flush();
         } else {
             $this->addFlash('warning', $this->get('translator')->trans('Sorry, the seats are already occupied'));
         }
     }
     if ($registration->getStatus() == Registration::STATUS_OPEN) {
         return $this->render(':frontend/registration/status:registration_open.html.twig', array('user' => $user, 'registration' => $registration, 'types' => $types_availables, 'form' => $form->createView()));
     }
     if ($registration->getStatus() == Registration::STATUS_CONFIRMED) {
         return $this->render(':frontend/registration/status:registration_confirmed.html.twig', array('user' => $user, 'registration' => $registration, 'entity_bank' => $this->container->getParameter('entity_bank'), 'organization' => $this->container->getParameter('organization'), 'iban' => $this->container->getParameter('iban'), 'amount' => $registration->getAmount()));
     }
     if ($registration->getStatus() == Registration::STATUS_CANCELLED) {
         return $this->render(':frontend/registration/status:registration_cancelled.html.twig', array('user' => $user, 'registration' => $registration));
     }
     if ($registration->getStatus() == Registration::STATUS_PAID) {
         $this->addFlash('info', $this->get('translator')->trans('El registro se encuentra pagado y confirmado'));
         return $this->render(':frontend/registration/status:registration_paid.html.twig', array('user' => $user, 'registration' => $registration, 'entity_bank' => $this->container->getParameter('entity_bank'), 'organization' => $this->container->getParameter('organization'), 'iban' => $this->container->getParameter('iban'), 'amount' => $registration->getAmount()));
     }
 }