예제 #1
0
 public function AjouterCandidatureAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $user = $this->getDoctrine()->getRepository('GenericBundle:User')->find($request->get('_idUser'));
     if ($request->get('formations')) {
         foreach ($request->get('formations') as $idFormation) {
             $formation = $this->getDoctrine()->getRepository('GenericBundle:Formation')->find($idFormation);
             $cand = $this->getDoctrine()->getRepository('GenericBundle:Candidature')->findOneBy(array('user' => $user, 'formation' => $formation));
             if (!$cand) {
                 $candidature = new Candidature();
                 $candidature->setUser($user);
                 $candidature->setFormation($formation);
                 $candidature->setStatut(2);
                 $date = new \DateTime();
                 $candidature->setDatecandidature($date);
                 $em->persist($candidature);
                 $em->flush();
             }
         }
     }
     if ($this->get('security.token_storage')->getToken()->getUser()->hasRole('ROLE_APPRENANT')) {
         return $this->redirect($this->generateUrl('afficher_profil'));
     } else {
         return $this->redirect($this->generateUrl('metier_user_afficheUser', array('id' => $request->get('_idUser'))));
     }
 }
예제 #2
0
 public function AjouterCandidatureSASAction(Request $request)
 {
     $em = $this->getDoctrine()->getEntityManager();
     $importCandidat = $this->getDoctrine()->getRepository('GenericBundle:ImportCandidat')->find($request->get('_idUser'));
     if ($request->get('formations')) {
         foreach ($request->get('formations') as $idFormation) {
             $formation = $this->getDoctrine()->getRepository('GenericBundle:Formation')->find($idFormation);
             $cand = $this->getDoctrine()->getRepository('GenericBundle:Candidature')->findOneBy(array('importcandidat' => $importCandidat, 'formation' => $formation));
             if (!$cand) {
                 $candidature = new Candidature();
                 $candidature->setImportcandidat($importCandidat);
                 $candidature->setFormation($formation);
                 $candidature->setStatut(2);
                 $date = new \DateTime();
                 $candidature->setDatecandidature($date);
                 $em->persist($candidature);
                 $em->flush();
             }
         }
     }
     return $this->redirect($this->generateUrl('Afficher_Sas', array('id' => $request->get('_idUser'))));
 }