Commit 5a97a98bd411e38a6fc5be1311637f93cf369726
1 parent
92ab0f314d
Exists in
master
creado el calculo de tiempo necesario para poder solicitar ascenso
Showing
1 changed file
with
53 additions
and
0 deletions
Show diff stats
src/AppBundle/Controller/AscensoController.php
| @@ -54,6 +54,53 @@ class AscensoController extends Controller | @@ -54,6 +54,53 @@ class AscensoController extends Controller | ||
| 54 | return $this->redirect($this->generateUrl('cea_index')); | 54 | return $this->redirect($this->generateUrl('cea_index')); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | + $escalafones = $this->getDoctrine()->getRepository("AppBundle:Escalafones")->findOneById($escala->getIdEscala()->getId() + 1); //tiempo para el proximo escalafon | ||
| 58 | + $tiempoProxEscalafon = $escala->getFechaEscala()->diff(new \DateTime("now")); | ||
| 59 | + | ||
| 60 | + //si no cumple el tiempo para solicitar ascenso | ||
| 61 | + if($tiempoProxEscalafon->y < $escalafones->getTiempo()){ | ||
| 62 | + //preguntar si tiene activa una solicitud de antiguedad | ||
| 63 | + $servicioAntiguedad = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneBy(array( | ||
| 64 | + 'idRolInstitucion' => $escala->getIdRolInstitucion(), | ||
| 65 | + 'idServicioCe' => 1 | ||
| 66 | + )); | ||
| 67 | + | ||
| 68 | + //si tiene solicitud vamos a decirle al usuario que vamos a utlizarla para ver si le alcanza | ||
| 69 | + if($servicioAntiguedad){ | ||
| 70 | + //obtenemos la fecha de concurso de oposición | ||
| 71 | + $oposicion = $this->getDoctrine()->getRepository("AppBundle:DocenteEscala")->findOneBy(array( | ||
| 72 | + 'idTipoEscala' => 1, | ||
| 73 | + 'idRolInstitucion' => $escala->getIdRolInstitucion() | ||
| 74 | + )); | ||
| 75 | + //obtenemos su fecha de ingreso | ||
| 76 | + $adscripcion = $this->getDoctrine()->getRepository("AppBundle:Adscripcion")->findOneByIdRolInstitucion($escala->getIdRolInstitucion()); | ||
| 77 | + //calculamos su antiguedad | ||
| 78 | + $tiempoAntiguedad = $adscripcion->getFechaIngreso()->diff($oposicion->getFechaEscala()); | ||
| 79 | + | ||
| 80 | + //calculamos el nuevo tiempo que tiene con el tiempo en años mas lo que se le debe | ||
| 81 | + $y = new \DateTime(); | ||
| 82 | + $f = clone $y; | ||
| 83 | + $y->add($tiempoProxEscalafon); | ||
| 84 | + $y->add($tiempoAntiguedad); | ||
| 85 | + //tenemos el total de tiempo que tiene el docente | ||
| 86 | + $nuevoTiempo = $f->diff($y); | ||
| 87 | + | ||
| 88 | + //si todavía no cumple el tiempo | ||
| 89 | + if($nuevoTiempo->y < $escalafones->getTiempo()){ | ||
| 90 | + $this->addFlash('danger', 'Estimado Docente, Incluyendo la antiguedad que se le adeuda, Todavía no cumple el tiempo para solicitar el ascenso.'); | ||
| 91 | + return $this->redirect($this->generateUrl('cea_index')); | ||
| 92 | + }else{ | ||
| 93 | + $formalizarTiempo = true; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + //si no tiene antiguedad | ||
| 98 | + }else{ | ||
| 99 | + $this->addFlash('danger', 'Estimado Docente, Todavía no cumple el tiempo para solicitar el ascenso.'); | ||
| 100 | + return $this->redirect($this->generateUrl('cea_index')); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 57 | $siguiente = $escala->getIdEscala()->getId() + 1; | 104 | $siguiente = $escala->getIdEscala()->getId() + 1; |
| 58 | $ascenso = new Ascenso(); | 105 | $ascenso = new Ascenso(); |
| 59 | if($siguiente < 6){ | 106 | if($siguiente < 6){ |
| @@ -172,6 +219,12 @@ class AscensoController extends Controller | @@ -172,6 +219,12 @@ class AscensoController extends Controller | ||
| 172 | 219 | ||
| 173 | $em->persist($servicios); | 220 | $em->persist($servicios); |
| 174 | $em->persist($ascenso); | 221 | $em->persist($ascenso); |
| 222 | + | ||
| 223 | + if($formalizarTiempo){ | ||
| 224 | + $servicioAntiguedad->setIdEstatus(4); | ||
| 225 | + $em->persist($servicioAntiguedad); | ||
| 226 | + $this->addFlash('warning', 'Para Registrar la solicitud, fue necesaria la formalización de su Solicitud de Antiguedad'); | ||
| 227 | + } | ||
| 175 | 228 | ||
| 176 | $em->flush(); //guarda en la base de datos | 229 | $em->flush(); //guarda en la base de datos |
| 177 | 230 |