Commit 93f193716f2de9f8b8b0a7ddf7ae8c9ff929dfa0
1 parent
3f6825ec7e
Exists in
master
Separado lo que tiene que ver con la antiguedad de AppController hacia este AntiguedadController
Showing
1 changed file
with
170 additions
and
0 deletions
Show diff stats
src/AppBundle/Controller/AntiguedadController.php
| ... | ... | @@ -0,0 +1,170 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * Copyright (C) 2016 ubv-cipee | |
| 5 | + * | |
| 6 | + * This program is free software: you can redistribute it and/or modify | |
| 7 | + * it under the terms of the GNU General Public License as published by | |
| 8 | + * the Free Software Foundation, either version 3 of the License, or | |
| 9 | + * (at your option) any later version. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU General Public License | |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +namespace AppBundle\Controller; | |
| 21 | + | |
| 22 | +use AppBundle\Entity\Adscripcion; | |
| 23 | +use AppBundle\Entity\DocenteEscala; | |
| 24 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | |
| 25 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; | |
| 26 | +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
| 27 | + | |
| 28 | +use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
| 29 | +use Symfony\Component\HttpFoundation\Request; | |
| 30 | +use AppBundle\Entity\Memorando; | |
| 31 | +use AppBundle\Entity\DocenteServicio; | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * Description of AntiguedadController | |
| 35 | + * | |
| 36 | + * @author ubv-cipee | |
| 37 | + */ | |
| 38 | +class AntiguedadController extends Controller { | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Muestra la página donde explica brevemente el reconocimiento de Antiguedad | |
| 42 | + * y permite realizar la solicitud | |
| 43 | + * | |
| 44 | + * @Route("/servicios/antiguedad/", name="cea_solicitudes_recocimiento_antiguedad") | |
| 45 | + * @Method({"GET", "POST"}) | |
| 46 | + */ | |
| 47 | + public function serviciosAntiguedadIndexAction(){ | |
| 48 | + | |
| 49 | + $servicio = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 50 | + | |
| 51 | + if(!$servicio){ | |
| 52 | + return $this->render('solicitudes/reconocimiento_antiguedad.html.twig'); | |
| 53 | + }else{ | |
| 54 | + $this->addFlash('notice', 'Ya usted ha realizado la solicitud de reconocimiento de antiguedad.'); | |
| 55 | + return $this->redirect($this->generateUrl('servicios_index')); | |
| 56 | + } | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + } | |
| 61 | + | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Muestra la página donde explica brevemente el reconocimiento de Antiguedad | |
| 65 | + * y permite realizar la solicitud | |
| 66 | + * | |
| 67 | + * @Route("/mis_servicios/antiguedad/imprimir/{id}", name="servicio_antiguedad_imprimir") | |
| 68 | + * @Method({"GET", "POST"}) | |
| 69 | + */ | |
| 70 | + public function serviciosAntiguedadImprimirAction(){ | |
| 71 | + | |
| 72 | + $antiguedad = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 73 | + | |
| 74 | + if($antiguedad->getIdEstatus()->getId() == 1){ | |
| 75 | + $adscripcion = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findOneByIdRolInstitucion($antiguedad->getIdRolInstitucion()); | |
| 76 | + $escala = $this->getDoctrine()->getRepository('AppBundle:DocenteEscala')->findOneByIdRolInstitucion($antiguedad->getIdRolInstitucion()); | |
| 77 | + $idRol = $escala->getIdRolInstitucion()->getId(); | |
| 78 | + $stmt = $this->getDoctrine()->getManager() | |
| 79 | + ->getConnection() | |
| 80 | + ->prepare("select age(e.fecha_escala, a.fecha_ingreso), | |
| 81 | + date_part('year',age(e.fecha_escala, a.fecha_ingreso)) as anos, | |
| 82 | + date_part('month',age(e.fecha_escala, a.fecha_ingreso)) as meses, | |
| 83 | + date_part('day',age(e.fecha_escala, a.fecha_ingreso)) as dias | |
| 84 | + FROM docente_escala as e | |
| 85 | + INNER JOIN solicitud_adscripcion as a | |
| 86 | + ON a.id_rol_institucion = e.id_rol_institucion | |
| 87 | + WHERE e.id_tipo_escala = '1' AND a.id_rol_institucion = $idRol"); | |
| 88 | + $stmt->execute(); | |
| 89 | + $result = $stmt->fetchAll(); | |
| 90 | + $recon = $result[0]['anos'] . " años " . $result[0]['meses'] . " meses y " . $result[0]['dias'] . " días."; | |
| 91 | + | |
| 92 | + $correlativo = $this->getDoctrine()->getRepository('AppBundle:Memorando')->findOneByIdDocenteServicio($antiguedad->getId()); | |
| 93 | + | |
| 94 | + if(!$correlativo){ | |
| 95 | + $correlativo = $this->getDoctrine()->getRepository('AppBundle:Memorando')->findOneBy( | |
| 96 | + array('ano'=> date("Y")), | |
| 97 | + array('id' => 'DESC') | |
| 98 | + ); | |
| 99 | + $numero = 1; | |
| 100 | + if ($correlativo) $numero = $correlativo->getCorrelativo() + 1; | |
| 101 | + | |
| 102 | + $memo = new Memorando(); | |
| 103 | + $memo->setCorrelativo($numero); | |
| 104 | + $memo->setIdDocenteServicio($antiguedad); | |
| 105 | + $memo->setAno(date("Y")); | |
| 106 | + $memo->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(1)); | |
| 107 | + | |
| 108 | + $em = $this->getDoctrine()->getManager(); | |
| 109 | + $em->persist($memo); | |
| 110 | + $em->flush(); | |
| 111 | + $memorando = $memo->getCorrelativo() . "-" . $memo->getAno(); | |
| 112 | + }else{ | |
| 113 | + $memorando = $correlativo->getCorrelativo() . "-" . $correlativo->getAno(); | |
| 114 | + } | |
| 115 | + | |
| 116 | + return $this->render('memorando/antiguedad.html.twig', array( | |
| 117 | + 'antiguedad' => $antiguedad, | |
| 118 | + 'adscripcion' => $adscripcion, | |
| 119 | + 'escala' => $escala, | |
| 120 | + 'diferencia' => $recon, | |
| 121 | + 'correlativo' => $memorando | |
| 122 | + )); | |
| 123 | + | |
| 124 | + | |
| 125 | + }else{ | |
| 126 | + | |
| 127 | + } | |
| 128 | + | |
| 129 | + $this->addFlash('danger', 'No Puede Imprimir el reconocimiento de Antiguedad hasta que esté aprobado por el coordinador del CEA.'); | |
| 130 | + | |
| 131 | + $servicios = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 132 | + $adscripcion = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 133 | + | |
| 134 | + | |
| 135 | + return $this->render('solicitudes/index.html.twig', array( | |
| 136 | + 'servicios' => $servicios, | |
| 137 | + 'adscripcion' => $adscripcion | |
| 138 | + )); | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + /** | |
| 146 | + * Muestra la página donde explica brevemente el reconocimiento de Antiguedad | |
| 147 | + * y permite realizar la solicitud | |
| 148 | + * | |
| 149 | + * @Route("/solicitudes/antiguedad/crear/", name="cea_crear_servicio_antiguedad") | |
| 150 | + * @Method({"GET", "POST"}) | |
| 151 | + */ | |
| 152 | + public function solicitudesAntiguedadCrearAction(){ | |
| 153 | + | |
| 154 | + $servicios = new DocenteServicio(); | |
| 155 | + | |
| 156 | + $servicios->setIdRolInstitucion($this->getUser()->getIdRolInstitucion()); | |
| 157 | + $servicios->setIdServicioCe($this->getDoctrine()->getRepository('AppBundle:ServiciosCe')->findOneById(1)); | |
| 158 | + $servicios->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:estatus')->findOneById(2)); | |
| 159 | + | |
| 160 | + $em = $this->getDoctrine()->getManager(); | |
| 161 | + $em->persist($servicios); | |
| 162 | + $em->flush(); | |
| 163 | + | |
| 164 | + $this->addFlash('notice', 'Solicitud Creada Correctamente, en lo que la solicitud sea aprobada, se le notificará por correo.'); | |
| 165 | + | |
| 166 | + return $this->render('solicitudes/reconocimiento_antiguedad.html.twig'); | |
| 167 | + | |
| 168 | + } | |
| 169 | + //put your code here | |
| 170 | +} | ... | ... |