Commit cb50e57168381417c9e3db756167ea6d64bc2b71
1 parent
95ba595828
Exists in
master
se incluyo en adscripcionController todo lo que tiene que ver con adscripcion
Showing
1 changed file
with
142 additions
and
0 deletions
Show diff stats
src/AppBundle/Controller/AdscripcionController.php
| ... | ... | @@ -15,6 +15,8 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
| 15 | 15 | use Symfony\Component\HttpFoundation\Request; |
| 16 | 16 | use AppBundle\Entity\Adscripcion; |
| 17 | 17 | use AppBundle\Entity\DocenteEscala; |
| 18 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | |
| 19 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | |
| 18 | 20 | |
| 19 | 21 | class AdscripcionController extends Controller |
| 20 | 22 | { |
| ... | ... | @@ -208,6 +210,146 @@ class AdscripcionController extends Controller |
| 208 | 210 | array('form' => $form->createView()) |
| 209 | 211 | ); |
| 210 | 212 | } |
| 213 | + | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Muestra las Solicitudes de Adscripción. Por defecto las creadas (estatus = 2) | |
| 217 | + * | |
| 218 | + * @Route("/solicitudes/adscripcion/{estatus}", name="cea_adscripciones") | |
| 219 | + * @Method({"GET", "POST"}) | |
| 220 | + * @Security("has_role('ROLE_COORDINADOR')") | |
| 221 | + */ | |
| 222 | + public function verSolicitudesAdscripcionAction($estatus = 2, Request $request) | |
| 223 | + { | |
| 224 | + | |
| 225 | + if ($request->getMethod() != 'POST') { | |
| 226 | + $adscripciones = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findBy(array('idEstatus' => $estatus)); | |
| 227 | + switch ($estatus){ | |
| 228 | + case 1: | |
| 229 | + $mensaje = "activas"; | |
| 230 | + break; | |
| 231 | + case 2: | |
| 232 | + $mensaje = "en espera"; | |
| 233 | + break; | |
| 234 | + case 3: | |
| 235 | + $mensaje = "rechazadas"; | |
| 236 | + break; | |
| 237 | + } | |
| 238 | + }else{ | |
| 239 | + | |
| 240 | + $persona = $this->getDoctrine()->getRepository('AppBundle:Persona') | |
| 241 | + ->findOneByCedulaPasaporte($request->get('docente')); | |
| 242 | + | |
| 243 | + if (!$persona) { | |
| 244 | + $this->addFlash('danger', 'Docente ' . $request->get('docente') . ' no Registrado en la Base de Datos del Centro de Estudios.'); | |
| 245 | + return $this->render('cea/index.html.twig', array ( | |
| 246 | + 'adscrito' => true | |
| 247 | + )); | |
| 248 | + } | |
| 249 | + | |
| 250 | + //1. obtener el rol-institucion-persona | |
| 251 | + $rol = $this->getDoctrine()->getRepository( | |
| 252 | + 'AppBundle:RolInstitucion')->findOneByIdRol( | |
| 253 | + $this->getDoctrine()->getRepository( | |
| 254 | + 'AppBundle:Rol')->findOneByIdPersona($persona)); | |
| 255 | + | |
| 256 | + //si no existe el rol del docente, enviar correo al encargado de la región para verificar. | |
| 257 | + if (!$rol) { | |
| 258 | + $this->addFlash('danger', 'Docente no Registrado en la Base de Datos del Centro de Estudios. Por Favor'); | |
| 259 | + return $this->render('cea/index.html.twig'); | |
| 260 | + } | |
| 261 | + | |
| 262 | + | |
| 263 | + $adscripciones = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findByIdRolInstitucion($rol->getId()); | |
| 264 | + $mensaje = "Busqueda : " . $request->get('docente'); | |
| 265 | + } | |
| 266 | + return $this->render('cea/solicitudes.html.twig', array( | |
| 267 | + 'adscripciones' => $adscripciones, | |
| 268 | + 'estatus_adscripciones' => $mensaje | |
| 269 | + )); | |
| 270 | + } | |
| 271 | + | |
| 272 | + /** | |
| 273 | + * Encuentra y muestra una entidad de tipo Adscripción. | |
| 274 | + * | |
| 275 | + * @Route("/solicitudes/{id}", name="cea_solicitudes_show") | |
| 276 | + * @Method("GET") | |
| 277 | + * @Security("has_role('ROLE_COORDINADOR')") | |
| 278 | + */ | |
| 279 | + public function solicitudesAdscripcionShowAction(Adscripcion $adscripcion) | |
| 280 | + { | |
| 281 | + //$deleteForm = $this->createDeleteForm($usuario); | |
| 282 | + $escala = $this->getDoctrine()->getRepository('AppBundle:DocenteEscala')->findBy(array( | |
| 283 | + 'idRolInstitucion' => $adscripcion->getIdRolInstitucion()->getId() | |
| 284 | + )); | |
| 285 | + | |
| 286 | + return $this->render('cea/solicitudes_mostar.html.twig', array( | |
| 287 | + 'adscripcion' => $adscripcion, | |
| 288 | + 'escalas' => $escala | |
| 289 | + )); | |
| 290 | + } | |
| 291 | + | |
| 292 | + | |
| 293 | + /** | |
| 294 | + * Encuentra y muestra una entidad de tipo Adscripción. | |
| 295 | + * | |
| 296 | + * @Route("/solicitudes/actualizar/{id}/{estatus}", name="cea_solicitudes_actualizar") | |
| 297 | + * @Method({"GET", "POST"}) | |
| 298 | + * @Security("has_role('ROLE_COORDINADOR')") | |
| 299 | + */ | |
| 300 | + public function solicitudesAdscripcionEditAction(Adscripcion $adscripcion, $estatus) | |
| 301 | + { | |
| 302 | + | |
| 303 | + $adscripciones = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findOneById($adscripcion->getId()); | |
| 304 | + | |
| 305 | + if($estatus == "true") { | |
| 306 | + $adscripciones->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(1)); | |
| 307 | + $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($adscripcion->getIdRolInstitucion()); | |
| 308 | + $user->addRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_ADSCRITO")); | |
| 309 | + | |
| 310 | + }else{ | |
| 311 | + $adscripciones->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(3)); | |
| 312 | + $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($adscripcion->getIdRolInstitucion()); | |
| 313 | + $user->removeRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_ADSCRITO")); | |
| 314 | + } | |
| 315 | + | |
| 316 | + $em = $this->getDoctrine()->getManager(); | |
| 317 | + $em->persist($adscripciones); | |
| 318 | + $em->persist($user); | |
| 319 | + $em->flush(); | |
| 320 | + | |
| 321 | + $message = \Swift_Message::newInstance() | |
| 322 | + ->setSubject('Resultado Adscripcion CEA@UBV') | |
| 323 | + ->setFrom('wilmer.ramones@gmail.com') | |
| 324 | + ->setTo($user->getEmail()) | |
| 325 | + ->setBody( | |
| 326 | + $this->renderView( | |
| 327 | + 'correos/actualizar_adscripcion.html.twig', | |
| 328 | + array( | |
| 329 | + 'nombres' => $user->getUsername(), | |
| 330 | + 'estatus' => $adscripciones->getIdEstatus() | |
| 331 | + ) | |
| 332 | + ), | |
| 333 | + 'text/html' | |
| 334 | + ) | |
| 335 | + ; | |
| 336 | + $this->get('mailer')->send($message); | |
| 337 | + | |
| 338 | + $this->addFlash('notice', 'Solicitud Actualizada Correctamente, hemos enviado un correo al docente notificandole los cambios.'); | |
| 339 | + | |
| 340 | + $escala = $this->getDoctrine()->getRepository('AppBundle:DocenteEscala')->findBy(array( | |
| 341 | + 'idRolInstitucion' => $adscripciones->getIdRolInstitucion()->getId() | |
| 342 | + )); | |
| 343 | + | |
| 344 | + return $this->render('cea/solicitudes_mostar.html.twig', array( | |
| 345 | + 'adscripcion' => $adscripciones, | |
| 346 | + 'escalas' => $escala | |
| 347 | + )); | |
| 348 | + | |
| 349 | + } | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 211 | 353 | } |
| 212 | 354 | |
| 213 | 355 | /*funcion para crear miniaturas de las imagenes y carga más rapido la página */ | ... | ... |