AppController.php
8.22 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Entity\Adscripcion;
use AppBundle\Entity\DocenteServicio;
/**
* Description of DocenteController
*
* @author ubv-cipee
*
* @Route("/ceapp")
*
*/
class AppController extends Controller {
/**
* Pagina principal de inicio de la session Docente.
*
* @Route("/", name="cea_index")
* @Method("GET")
*/
public function indexAction()
{
$adscripcion = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->
findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()->getId());
//si no ha solicitado adscripción regresa a la pagina de adscripcion
if(!$adscripcion) return $this->redirect($this->generateUrl('solicitud_adscripcion'));
//solicitud aprobada está en falso
$adscrito = false;
if($adscripcion->getIdEstatus()->getId() == 1) $adscrito = true;
return $this->render('cea/index.html.twig', array (
'adscrito' => $adscrito
));
}
/**
* Muestra la página Puede ver los estatus de las solicitudes realizadas
* y permite realizar la solicitud
*
* @Route("/servicios/{tipo}/{estatus}", name="cea_servicios")
* @Method({"GET", "POST"})
*/
public function verServiciosAction(Request $request, $tipo="antiguedad", $estatus=2){
if ($tipo == "antiguedad") $tipo_servicio = 1;
if ($request->getMethod() != 'POST') {
$servicios = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findBy(array(
'idEstatus' => $estatus,
'idServicioCe' => $tipo_servicio,
));
switch ($estatus){
case 1:
$mensaje = "activas";
break;
case 2:
$mensaje = "en espera";
break;
case 3:
$mensaje = "rechazadas";
break;
}
}else{
$persona = $this->getDoctrine()->getRepository('AppBundle:Persona')
->findOneByCedulaPasaporte($request->get('docente'));
if (!$persona) {
$this->addFlash('danger', 'Docente ' . $request->get('docente') . ' no Registrado en la Base de Datos del Centro de Estudios.');
return $this->render('cea/index.html.twig', array (
'adscrito' => true
));
}
//1. obtener el rol-institucion-persona
$rol = $this->getDoctrine()->getRepository(
'AppBundle:RolInstitucion')->findOneByIdRol(
$this->getDoctrine()->getRepository(
'AppBundle:Rol')->findOneByIdPersona($persona));
//si no existe el rol del docente, enviar correo al encargado de la región para verificar.
if (!$rol) {
$this->addFlash('danger', 'Docente no Registrado en la Base de Datos del Centro de Estudios. Por Favor');
return $this->render('cea/index.html.twig');
}
$servicios = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findByIdRolInstitucion($rol->getId());
$mensaje = "Busqueda : " . $request->get('docente');
}
return $this->render('cea/servicios.html.twig', array(
'servicios' => $servicios,
'estatus_servicio' => $mensaje,
'tipo' => $tipo
));
}
/**
* Encuentra y muestra una entidad de tipo Servicios Docente.
*
* @Route("/ver_servicio/{id}", name="cea_servicio_show")
* @Method("GET")
*/
public function serviciosShowAction(DocenteServicio $servicio)
{
$adscripcion = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findOneByIdRolInstitucion($servicio->getIdRolInstitucion());
$escala = $this->getDoctrine()->getRepository('AppBundle:DocenteEscala')->findOneBy(array(
'idRolInstitucion' => $servicio->getIdRolInstitucion(),
'idTipoEscala' => 1
));
return $this->render('cea/servicios_mostar.html.twig', array(
'servicio' => $servicio,
'oposicion' => $escala,
'adscripcion' => $adscripcion
));
}
/**
* Muestra la página donde explica brevemente el reconocimiento de Antiguedad
* y permite realizar la solicitud
*
* @Route("/mis_servicios/", name="servicios_index")
* @Method({"GET", "POST"})
*/
public function serviciosIndexAction(){
$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
));
}
/**
* Encuentra y muestra una entidad de tipo Adscripción.
*
* @Route("/servicios/actualizar/{id}/{estatus}", name="cea_servicios_actualizar")
* @Method({"GET", "POST"})
*/
public function serviciosEditAction(DocenteServicio $servicios, $estatus)
{
$servicio = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneById($servicios->getId());
if($estatus == "true") {
$servicio->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(1));
}else{
$servicio->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(3));
}
$em = $this->getDoctrine()->getManager();
$em->persist($servicio);
$em->flush();
$user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($servicio->getIdRolInstitucion());
$message = \Swift_Message::newInstance()
->setSubject('Resultado Adscripcion CEA@UBV')
->setFrom('wilmer.ramones@gmail.com')
->setTo($user->getEmail())
->setBody(
$this->renderView(
'correos/actualizar_adscripcion.html.twig',
array(
'nombres' => $user->getUserName(),
'estatus' => $servicio->getIdEstatus()
)
),
'text/html'
)
;
$this->get('mailer')->send($message);
$this->addFlash('notice', 'Servicio Actualizada Correctamente, hemos enviado un correo al docente notificandole los cambios.');
$escala = $this->getDoctrine()->getRepository('AppBundle:DocenteEscala')->findOneBy(array(
'idRolInstitucion' => $servicio->getIdRolInstitucion(),
'idTipoEscala' => 1
));
$adscripcion = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findOneByIdRolInstitucion($servicio->getIdRolInstitucion());
return $this->render('cea/servicios_mostar.html.twig', array(
'servicio' => $servicio,
'oposicion' => $escala,
'adscripcion' => $adscripcion
));
}
}