public function userModifAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $user = $em->getRepository('GenericBundle:User')->findOneBy(array('id' => $request->get('_ID')));
     $user->setCivilite($request->get('_Civilite'));
     $user->setNom($request->get('_Nom'));
     $user->setPrenom($request->get('_Prenom'));
     if ($_FILES && $_FILES['_Photos']['size'] > 0) {
         $user->setPhotos(file_get_contents($_FILES['_Photos']['tmp_name']));
         $em->flush();
     }
     $user->setTelephone($request->get('_Tel'));
     $user->setUsername($request->get('_Username'));
     $user->setEmail($request->get('_Mail'));
     $em->flush();
     if ($user->hasRole('ROLE_APPRENANT')) {
         $info = $em->getRepository('GenericBundle:infocomplementaire')->find(array('id' => $request->get('_IdInfo')));
         if ($info) {
             $info->setDatenaissance(date_create_from_format('d/m/Y', $request->get('_Datenaissance')));
             $info->setCpnaissance($request->get('_Cpnaissance'));
             $info->setLieunaissance($request->get('_Lieunaissance'));
             $info->setAdresse($request->get('_Adresse'));
             $info->setFacebook($request->get('_Facebook'));
             $info->setLinkedin($request->get('_Linkedin'));
             $info->setMobilite($request->get('_Mobilite'));
             $info->setFratrie($request->get('_Fratrie'));
             $em->flush();
         } else {
             $info = new Infocomplementaire();
             $info->setDatenaissance(date_create_from_format('d/m/Y', $request->get('_Datenaissance')));
             $info->setCpnaissance($request->get('_Cpnaissance'));
             $info->setLieunaissance($request->get('_Lieunaissance'));
             $info->setAdresse($request->get('_Adresse'));
             $info->setFacebook($request->get('_Facebook'));
             $info->setLinkedin($request->get('_Linkedin'));
             $info->setMobilite($request->get('_Mobilite'));
             $info->setFratrie($request->get('_Fratrie'));
             $em->persist($info);
             $em->flush();
         }
     }
     return $this->redirect($this->generateUrl('metier_user_afficheUser', array('id' => $request->get('_ID'))));
 }
Exemple #2
0
 public function SASModifAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $ImportCandidat = $em->getRepository('GenericBundle:ImportCandidat')->findOneBy(array('id' => $request->get('_ID')));
     $ImportCandidat->setCivilite($request->get('_Civilite'));
     $ImportCandidat->setNom($request->get('_Nom'));
     $ImportCandidat->setPrenom($request->get('_Prenom'));
     if ($_FILES && $_FILES['_Photos']['size'] > 0) {
         $ImportCandidat->setPhotos(file_get_contents($_FILES['_Photos']['tmp_name']));
         $em->flush();
     }
     $ImportCandidat->setTelephone($request->get('_Tel'));
     $ImportCandidat->setEmail($request->get('_Mail'));
     $em->flush();
     $info = $em->getRepository('GenericBundle:infocomplementaire')->find(array('id' => $request->get('_IdInfo')));
     if ($info) {
         if ($request->get('_Datenaissance')) {
             $info->setDatenaissance(date_create($request->get('_Datenaissance')));
         }
         $info->setCpnaissance($request->get('_Cpnaissance'));
         $info->setLieunaissance($request->get('_Lieunaissance'));
         $info->setAdresse($request->get('_Adresse'));
         $info->setFacebook($request->get('_Facebook'));
         $info->setLinkedin($request->get('_Linkedin'));
         if ($request->get('_Mobilite')) {
             $info->setMobilite($request->get('_Mobilite'));
         }
         if ($request->get('_Fratrie')) {
             $info->setFratrie($request->get('_Fratrie'));
         }
         $em->flush();
     } else {
         $info = new Infocomplementaire();
         if ($request->get('_Datenaissance')) {
             $info->setDatenaissance(date_create_from_format('d/m/Y', $request->get('_Datenaissance')));
         }
         $info->setCpnaissance($request->get('_Cpnaissance'));
         $info->setLieunaissance($request->get('_Lieunaissance'));
         $info->setAdresse($request->get('_Adresse'));
         $info->setFacebook($request->get('_Facebook'));
         $info->setLinkedin($request->get('_Linkedin'));
         if ($request->get('_Mobilite')) {
             $info->setMobilite($request->get('_Mobilite'));
         }
         if ($request->get('_Fratrie')) {
             $info->setFratrie($request->get('_Fratrie'));
         }
         $em->persist($info);
         $em->flush();
     }
     return $this->forward('UserBundle:SAS:affichageUserSAS', array('id' => $request->get('_ID')));
 }