Commit 5ae328a10c64971625b027b4dfff7a91398dd560

Authored by Wilmer Ramones
1 parent af6b31b344
Exists in master

Primero se pregunta si la persona existe y luego realiza el registro, así como t…

…ambién se crean los mensajes de información de acuerdo a los errores o exitos del registro
Showing 1 changed file with 24 additions and 15 deletions   Show diff stats
src/AppBundle/Controller/DefaultController.php
... ... @@ -20,18 +20,27 @@ class DefaultController extends Controller
20 20  
21 21 if ($form->isSubmitted() && $form->isValid()) {
22 22  
  23 + $persona = $this->getDoctrine()->getRepository('AppBundle:Persona')
  24 + ->findOneByCedulaPasaporte($form->get('cedula')->getData());
  25 +
  26 + if (!$persona) {
  27 + $this->addFlash('danger', 'Docente no Registrado en la Base de Datos del Centro de Estudios. Por Favor');
  28 + return $this->redirect(
  29 + sprintf('%s#%s', '/', 'adscripcion')
  30 + );
  31 + }
  32 +
23 33 //1. obtener el rol-institucion-persona
24 34 $rol = $this->getDoctrine()->getRepository(
25 35 'AppBundle:RolInstitucion')->findOneByIdRol(
26 36 $this->getDoctrine()->getRepository(
27   - 'AppBundle:Rol')->findOneByIdPersona(
28   - $this->getDoctrine()->getRepository('AppBundle:Persona')
29   - ->findOneByCedulaPasaporte($form->get('cedula')->getData())->getId()));
  37 + 'AppBundle:Rol')->findOneByIdPersona($persona));
30 38  
31 39 //si no existe el rol del docente, enviar correo al encargado de la región para verificar.
32 40 if (!$rol) {
33   - throw $this->createNotFoundException(
34   - 'Docente no registrado en la UBV '. $form->get('cedula')->getData()
  41 + $this->addFlash('danger', 'Docente no Registrado en la Base de Datos del Centro de Estudios. Por Favor');
  42 + return $this->redirect(
  43 + sprintf('%s#%s', '/', 'adscripcion')
35 44 );
36 45 }
37 46  
... ... @@ -60,6 +69,8 @@ class DefaultController extends Controller
60 69 $em->persist($actualizarRol);
61 70  
62 71 $em->flush(); //guarda en la base de datos
  72 +
  73 + $this->addFlash('notice', 'Datos enviados Satisfactoriamente. Hemos enviado un correo a la dirección suministrada con los datos para el ingreso');
63 74  
64 75  
65 76 $message = \Swift_Message::newInstance()
... ... @@ -87,22 +98,20 @@ class DefaultController extends Controller
87 98 array('name' => $name)
88 99 ),
89 100 'text/plain'
90   - )
91   - */
  101 + )*/
  102 +
92 103 ;
93   - $this->get('mailer')->send($message);
94   -
  104 + $this->get('mailer')->send($message);
95 105  
96 106  
97 107 }else{
98   - throw $this->createNotFoundException(
99   - 'Ya tiene usuario y contraseña '. $form->get('cedula')->getData()
100   - );
  108 + $this->addFlash('notice', 'Ya ha solicitado datos de ingreso. Revise la dirección de correo suministrada o Contáctenos a través de: cea.ubv@gmail.com');
  109 +
101 110 }
102   - throw $this->createNotFoundException(
103   - 'Docente Encontrado '. $form->get('cedula')->getData()
104   - );
105 111  
  112 + return $this->redirect(
  113 + sprintf('%s#%s', '/', 'adscripcion')
  114 + );
106 115 //$request->getSession()->getFlashBag()->add('success', 'Your email has been sent! Thanks!');
107 116 }
108 117  
... ...