Commit 27205cddf7b8de9bc3e48edca2d5795cc05c0614
1 parent
3c2af6088a
Exists in
master
crea el combo dependiente entre el eje y el estado asociado en el portal a la ho…
…ra del registro y lo actualiza en la base de datos
Showing
5 changed files
with
96 additions
and
1 deletions
Show diff stats
app/Resources/views/portal/index.html.twig
... | ... | @@ -320,6 +320,34 @@ |
320 | 320 | <script type="text/javascript"> |
321 | 321 | smoothScroll.init(); |
322 | 322 | |
323 | + $(function() { | |
324 | + $("#solicitar_eje").change(function(){ | |
325 | + | |
326 | + var data = { | |
327 | + eje_id: this.value | |
328 | + }; | |
329 | + console.log(data); | |
330 | + $.ajax({ | |
331 | + type: 'post', | |
332 | + url: '{{ path("ajax_select_parroquias") }}', | |
333 | + data: data, | |
334 | + success: function(data) { | |
335 | + estados = jQuery.parseJSON(data.estados); | |
336 | + console.log(estados); | |
337 | + var $parroquia_selector = $('#solicitar_eje_parroquia'); | |
338 | + | |
339 | + $parroquia_selector.html('<option>Seleccione Estado del Eje</option>'); | |
340 | + | |
341 | + for (var i=0, total = estados.length; i < total; i++) { | |
342 | + $parroquia_selector.append('<option value="' + estados[i].id + '">' + estados[i].idParroquia.idMunicipio.idEstado.nombre + '</option>'); | |
343 | + } | |
344 | + | |
345 | + } | |
346 | + }); | |
347 | + | |
348 | + }); | |
349 | + }); | |
350 | + | |
323 | 351 | $('.btn').on('click', function() { |
324 | 352 | var $this = $(this); |
325 | 353 | $this.button('loading'); | ... | ... |
src/AppBundle/Controller/AjaxController.php
... | ... | @@ -246,6 +246,42 @@ class AjaxController extends Controller { |
246 | 246 | |
247 | 247 | |
248 | 248 | /** |
249 | + * @Route("/ajax/buscar/parroquias", name="ajax_select_parroquias") | |
250 | + * @Method({"POST"}) | |
251 | + */ | |
252 | + public function buscarParroquiasAction(Request $request){ | |
253 | + | |
254 | + if($request->isXmlHttpRequest()){ | |
255 | + $encoders = array(new JsonEncoder()); | |
256 | + $normalizers = array(new ObjectNormalizer()); | |
257 | + | |
258 | + $serializer = new Serializer($normalizers, $encoders); | |
259 | + | |
260 | + | |
261 | + $eje = filter_input(INPUT_POST, 'eje_id', FILTER_SANITIZE_SPECIAL_CHARS); | |
262 | + $eje = $this->getDoctrine()->getRepository("AppBundle:Eje")->findOneById($eje); | |
263 | + $estados = $this->getDoctrine()->getRepository("AppBundle:EjeParroquia")->findByIdEje($eje); | |
264 | + | |
265 | + | |
266 | + | |
267 | + $response = new JsonResponse(); | |
268 | + $response->setStatusCode(200); | |
269 | + $response->setData(array( | |
270 | + 'response' => 'success', | |
271 | + 'eje' => $eje, | |
272 | + 'estados' => $serializer->serialize($estados, 'json') | |
273 | + )); | |
274 | + | |
275 | + return $response; | |
276 | + | |
277 | + | |
278 | + } | |
279 | + | |
280 | + } | |
281 | + | |
282 | + | |
283 | + | |
284 | + /** | |
249 | 285 | * @Route("/ajax/eliminar/tarea", name="ajax_eliminar_tarea") |
250 | 286 | * @Method({"POST"}) |
251 | 287 | */ | ... | ... |
src/AppBundle/Controller/PortalController.php
... | ... | @@ -38,7 +38,11 @@ class PortalController extends Controller |
38 | 38 | $this->addFlash('danger', 'Hay un problema con el registro y asignaciรณn del Rol del Docente. Por Favor consulte con el Coordinador Regional del CEA'); |
39 | 39 | return $this->redirect($this->generateUrl('homepage').'#adscripcion'); |
40 | 40 | } |
41 | - | |
41 | + $em = $this->getDoctrine()->getManager(); | |
42 | + $ejeParroquia = $form->get('eje_parroquia')->getData(); | |
43 | + $institucion = $this->getDoctrine()->getRepository("AppBundle:Institucion")->findOneByIdEjeParroquia($ejeParroquia); | |
44 | + $rol->setIdInstitucion($institucion); | |
45 | + $em->persist($rol); | |
42 | 46 | //si el docente existe, crea el nombre de usuario. |
43 | 47 | $usuario = mb_strtolower($rol->getIdRol()->getIdPersona()->getPrimerNombre()[0] .$rol->getIdRol()->getIdPersona()->getPrimerApellido()); |
44 | 48 | //busca en la base de datos para ver si ese nombre de usuario ya existe | ... | ... |
src/AppBundle/Entity/EjeParroquia.php
... | ... | @@ -106,4 +106,17 @@ class EjeParroquia |
106 | 106 | { |
107 | 107 | return $this->idEje; |
108 | 108 | } |
109 | + | |
110 | + | |
111 | + /** | |
112 | + * Get nombre | |
113 | + * | |
114 | + * @return string | |
115 | + */ | |
116 | + public function __toString() | |
117 | + { | |
118 | + // TODO: Implement __toString() method. | |
119 | + return $this->getIdParroquia()->getNombre(); | |
120 | + } | |
121 | + | |
109 | 122 | } |
110 | 123 | \ No newline at end of file | ... | ... |
src/AppBundle/Form/SolicitarType.php
... | ... | @@ -16,6 +16,7 @@ use Symfony\Component\Form\Extension\Core\Type\NumberType; |
16 | 16 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
17 | 17 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
18 | 18 | |
19 | + | |
19 | 20 | use Symfony\Component\Validator\Constraints\Email; |
20 | 21 | use Symfony\Component\Validator\Constraints\Length; |
21 | 22 | use Symfony\Component\Validator\Constraints\NotBlank; |
... | ... | @@ -85,6 +86,17 @@ class SolicitarType extends AbstractType |
85 | 86 | new NotBlank() |
86 | 87 | ) |
87 | 88 | )) |
89 | + | |
90 | + ->add('eje_parroquia', EntityType::class, array( | |
91 | + 'placeholder' => 'Seleccione Estado del Eje', | |
92 | + 'label' => 'Estado', | |
93 | + 'class' => 'AppBundle:EjeParroquia', | |
94 | + | |
95 | + 'constraints' => array( | |
96 | + new NotBlank() | |
97 | + ) | |
98 | + )) | |
99 | + | |
88 | 100 | ->add('send', SubmitType::class, array( |
89 | 101 | 'label' => 'Enviar Solicitud', |
90 | 102 | 'attr' => array( |
... | ... | @@ -92,6 +104,8 @@ class SolicitarType extends AbstractType |
92 | 104 | 'data-loading-text' => "<i class='fa fa-circle-o-notch fa-spin'></i> Enviando Solicitud..." |
93 | 105 | ) |
94 | 106 | )); |
107 | + | |
108 | + | |
95 | 109 | } |
96 | 110 | |
97 | 111 | ... | ... |