/** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(['type']); $resolver->addAllowedTypes(['type' => ['string']]); $resolver->setAllowedValues(['type' => Participant::getAllTypes()]); $resolver->setDefaults(['data_class' => Participant::class]); }
/** * Solo el usuario creador de la inscripción podrá descargar la factura si: * - Está pagada. * - Están publicadas. * - Tiene número de factura. * * @param string $attribute * @param Participant $object * @param UserInterface|string $user * * @return bool */ protected function isGranted($attribute, $object, $user = null) { if (!$user instanceof UserInterface) { return false; } $registration = $object->getRegistration(); if ($registration->getStatus() !== Registration::STATUS_PAID) { return false; } if (!$registration->getConvention()->isPublishedInvoices()) { return false; } if (empty($object->getInvoiceNumber())) { return false; } return $user == $registration->getUser(); }
public function generateInvoice(Participant $participant, &$filename) { $filename = sprintf('factura-%s-%d-%s.pdf', $participant->getRegistration()->getConvention()->getSlug(), $participant->getRegistration()->getId(), $participant->getSlug()); $html = $this->twig->render('themes/invoice/invoice.html.twig', array('participant' => $participant, 'registration' => $participant->getRegistration())); return $this->loggableGenerator->getOutputFromHtml($html); }
/** * @Route("/{id}/certificate", name="acreditation_download") */ public function downloadAcreditationAction(Participant $participant) { $registration = $participant->getRegistration(); $this->denyAccessUnlessGranted('REGISTRATION_OWNER', $registration); return new Response($this->get('ritsiga.business.document_generator')->generateCredentials($participant, $filename), 200, array('Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $filename . '"')); }
/** * @Route("/descargar_acreditacion/{participant}", name="acreditation_download") */ public function downloadAcreditationAction(Participant $participant) { $this->get('kernel')->getRootDir(); $fileToDownload = $this->get('kernel')->getRootDir() . '/../private/documents/acreditations/' . $participant->getId() . '.pdf'; $response = new BinaryFileResponse($fileToDownload); $response->trustXSendfileTypeHeader(); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $participant->getName() . $participant->getLastName() . '_acreditacion.pdf', iconv('UTF-8', 'ASCII//TRANSLIT', $participant->getId())); return $response; }
/** * @Route("/borrar_inscripcion/{id}", name="participant_delete") * Borra la inscripción enviada por argumento */ public function deleteParticipantAction(Participant $participant) { $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)); if ($registration->getStatus() == Registration::STATUS_OPEN && $participant->getRegistration() == $registration) { $em = $this->getDoctrine()->getManager(); $em->remove($participant); $em->flush(); } return $this->redirectToRoute('registration'); }
public function fillQuestionnaire($questionnaire, Request $request) { $data = json_decode($request->getContent(), true); $ip = $request->getClientIp(); $qb = $this->getDoctrine()->getManager()->createQueryBuilder(); $qb->select('count(p.id)')->from('AppBundle:Participant', 'p')->join('p.questionnaire', 'q')->where('q.id = ?1')->andWhere('p.ip = ?2')->setParameter(1, $questionnaire->getId())->setParameter(2, $ip); $count = $qb->getQuery()->getSingleScalarResult(); // Construct participant. $participant = new Participant(new \DateTime()); // Did this participant come from an url? if (isset($data['urlId'])) { $url = $this->getUrl($data['urlId']); // Already filled out or url is null. if ($url == null || $url->getParticipant() != null) { return null; } $participant->setUrl($url); } else { if ($count >= 1) { // Do not save repeating ip's return null; } } if (isset($data['answers'])) { $fullAnswers = array(); // Iterate over the questionnaire data. foreach ($questionnaire->getQuestions() as $question) { $other = false; foreach ($question->getAnswers() as $answer) { if ($other) { break; } $constructed = new ParticipantAnswer($participant, $answer, $question); foreach ($data['answers'] as $participantAnswer) { if (isset($participantAnswer['other']) && $question->getId() == $participantAnswer['questionId']) { $constructed->setOpinion($participantAnswer['other']); $other = true; break; } else { if (isset($participantAnswer['questionId']) && $question->getType() == 'OPEN' && $question->getId() == $participantAnswer['questionId']) { $constructed->setTextAnswer($participantAnswer['textAnswer']); break; } else { if (isset($participantAnswer['id']) && $answer->getId() == $participantAnswer['id']) { $constructed->setChecked($participantAnswer['checked']); break; } } } } array_push($fullAnswers, $constructed); } } $participant->setQuestionnaire($questionnaire); $participant->setIp($ip); $participant->setAnswers($fullAnswers); // Persist participant. $em = $this->getDoctrine()->getManager(); $em->persist($participant); $em->flush(); } return null; }
/** * @param Participant $publisher * @return Artwork */ public function addPublisher(Participant $publisher) { $publisher->setType(Participant::TYPE_PUBLISHER); $publisher->setArtwork($this); $this->participants->add($publisher); return $this; }