Exemplo n.º 1
0
 /**
  * @Security("has_role('ROLE_ADMIN')")
  */
 public function addAction($id, Request $request)
 {
     // On récupère l'EntityManager
     $em = $this->getDoctrine()->getManager();
     $registration = $em->getRepository('GSFestivalBundle:Registration')->find($id);
     if ($registration === null) {
         throw $this->createNotFoundException("L'inscription d'id " . $id . " n'existe pas.");
     }
     $payment = new Payment();
     $payment->setAmount($registration->getRemainingPayment());
     $form = $this->createForm(PaymentType::class, $payment);
     if ($form->handleRequest($request)->isValid()) {
         $registration->addPayment($payment);
         $em->flush();
         $request->getSession()->getFlashBag()->add('success', 'Paiement ajouté.');
         return $this->redirectToRoute('gs_level_view', array('id' => $registration->getLevel()->getId()));
     }
     return $this->render('GSFestivalBundle:Payment:add.html.twig', array('form' => $form->createView(), 'levelId' => $registration->getLevel()->getId()));
 }
Exemplo n.º 2
0
 /**
  * Add payment
  *
  * @param \GS\FestivalBundle\Entity\Payment $payment
  *
  * @return Registration
  */
 public function addPayment(\GS\FestivalBundle\Entity\Payment $payment)
 {
     $this->payments[] = $payment;
     $payment->setRegistration($this);
     $this->remainingPayment -= $payment->getAmount();
     if ($this->remainingPayment <= 0.0) {
         $this->status = 'pre_paid';
     }
     return $this;
 }