/**
  * @Security("has_role('ROLE_GESTIONNAIRE')")
  */
 public function codificationAction($id, Request $request)
 {
     $etudiant = new Etudiant();
     $etudiant = $this->getDoctrine()->getManager()->getRepository("SMBLoyerBundle:Etudiant")->find($id);
     //on recupère le registre courant
     $session = $request->getSession();
     $id_registre = $session->get('id_registre_courant');
     $registre = new Registre();
     $registre = $this->getDoctrine()->getManager()->getRepository("SMB\\LoyerBundle\\Entity\\Registre")->find($id_registre);
     $codification = new Codification();
     $codification->setEtudiant($etudiant);
     $codification->setRegistre($registre);
     $form = $this->get('form.factory')->create(new CodificationType(), $codification);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($codification);
         $em->flush();
         return $this->redirect($this->generateUrl("smb_loyer_view_etudiant", array('id' => $id)));
     }
     return $this->render("SMBLoyerBundle:Loyer:codification.html.twig", array('etudiant' => $etudiant, 'form' => $form->createView()));
 }
Exemplo n.º 2
0
 /**
  * Set codification
  *
  * @param \SMB\LoyerBundle\Entity\Codification $codification
  * @return Paiement
  */
 public function setCodification(\SMB\LoyerBundle\Entity\Codification $codification)
 {
     $this->codification = $codification;
     $codification->addPaiement($this);
     return $this;
 }
 public function deleteAction($id, Request $request)
 {
     //si nous avons une requête ajax, elle sera traité ici
     if ($request->isXmlHttpRequest()) {
         //on recupère la liste des codifications à supprimer
         $listCodifications = json_decode($request->request->get('listCodifications'));
         $nbre = $request->request->get('nbre');
         for ($i = 0; $i < $nbre; $i++) {
             $ident = $listCodifications[$i];
             $this->getDoctrine()->getManager()->getRepository("SMBLoyerBundle:Codification")->supprimer_codification($ident);
         }
         //on retourne la liste de tous les codifications
         $listCodification = Codification::listCodifications($this);
         return $this->render("SMBLoyerBundle:Codification:index.html.twig", array('listCodifications' => $listCodification));
     } else {
         throw new \Exception("Pas de requête!", 1);
     }
 }