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