Commit 26d06cf947bfa7c19b92d9708c6adcd7d10f3f5a
1 parent
cd280b1e95
Exists in
master
comenzado a crear la vista solicitando los tutores junto con el AJAX que busca en la Base de datos
Showing
5 changed files
with
220 additions
and
9 deletions
Show diff stats
app/Resources/views/solicitudes/ascenso.html.twig
@@ -45,11 +45,45 @@ | @@ -45,11 +45,45 @@ | ||
45 | </div> | 45 | </div> |
46 | 46 | ||
47 | </div> | 47 | </div> |
48 | + | ||
49 | + <!-- Ventanas Modales --> | ||
50 | + | ||
51 | + <!-- Ventana de buscar adscripcion --> | ||
52 | + <div class="modal fade bs-example-modal-sm" id="buscarTutores" tabindex="-1" role="dialog"> | ||
53 | + <div class="modal-dialog" role="document"> | ||
54 | + <div class="modal-content"> | ||
55 | + <div class="modal-header"> | ||
56 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
57 | + <h4 class="modal-title" id="myModalLabel">El tutor debe tener la escala de {{ nueva_escala.nombre }} o superior</h4> | ||
58 | + </div> | ||
59 | + <div class="modal-body"> | ||
60 | + | ||
61 | + <h2>Introduzla la cedula y presione buscar</h2> | ||
62 | + {% form_theme tutorForm 'bootstrap_3_layout.html.twig' %} | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + {{ form_start(tutorForm) }} | ||
67 | + | ||
68 | + {{ form_widget(tutorForm) }} | ||
69 | + {{ form_end(tutorForm) }} | ||
70 | + | ||
71 | + </div> | ||
72 | + <div class="modal-footer"> | ||
73 | + <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> | ||
74 | + <button class="btn btn-primary" type="submit">Buscar Adscripcion</button> | ||
75 | + </div> | ||
76 | + </div> | ||
77 | + </div> | ||
78 | + </div><!-- Fin de la ventanta modal buscar adscripcion --> | ||
48 | 79 | ||
49 | 80 | ||
50 | {% endblock %} | 81 | {% endblock %} |
51 | 82 | ||
52 | 83 | ||
84 | + | ||
85 | + | ||
86 | + | ||
53 | 87 | ||
54 | 88 | ||
55 | {% block javascripts %} | 89 | {% block javascripts %} |
@@ -59,7 +93,40 @@ | @@ -59,7 +93,40 @@ | ||
59 | 93 | ||
60 | $('.esc_oposicion')[this.checked ? "show" : "hide"](); | 94 | $('.esc_oposicion')[this.checked ? "show" : "hide"](); |
61 | 95 | ||
62 | - }); | 96 | + }); |
97 | + | ||
98 | + $( "#tutores_ascenso_buscarTutor" ).click(function() { | ||
99 | + if($("#tutores_ascenso_cedulaPasaporte").val() == ""){ | ||
100 | + alert("cedula no puede estar vacia"); | ||
101 | + return false; | ||
102 | + } | ||
103 | + $.ajax({ | ||
104 | + method: "GET", | ||
105 | + url: "{{ url('ajax_buscar_tutor') }}", | ||
106 | + async: true, | ||
107 | + cache: false, | ||
108 | + data: ({cedula: $("#tutores_ascenso_cedulaPasaporte").val(), documento: $("#tutores_ascenso_idDocumentoIdentidad").val()}), | ||
109 | + success: function (data) { | ||
110 | + | ||
111 | + var posts = JSON.parse(data.posts); | ||
112 | + console.log(posts); | ||
113 | + if (posts == ""){ | ||
114 | + $('.oculto').removeClass('hidden'); | ||
115 | + }else{ | ||
116 | + $('#ascenso_tutores_asignados').append($('<option>', { | ||
117 | + value: 1, | ||
118 | + text: 'My option' | ||
119 | + })); | ||
120 | + } | ||
121 | + | ||
122 | + }, | ||
123 | + error: function (XMLHttpRequest, textStatus, errorThrown) { | ||
124 | + console.log(errorThrown); | ||
125 | + | ||
126 | + } | ||
127 | + | ||
128 | + }); | ||
129 | + }); | ||
63 | 130 | ||
64 | </script> | 131 | </script> |
65 | {% endblock %} | 132 | {% endblock %} |
src/AppBundle/Controller/AjaxController.php
@@ -35,7 +35,7 @@ class AjaxController extends Controller { | @@ -35,7 +35,7 @@ class AjaxController extends Controller { | ||
35 | * @Method({"GET"}) | 35 | * @Method({"GET"}) |
36 | */ | 36 | */ |
37 | public function contadorAction(Request $request){ | 37 | public function contadorAction(Request $request){ |
38 | - if($request->isXmlHttpRequest()){ | 38 | + if($request->isXmlHttpRequest()){ |
39 | $encoders = array(new JsonEncoder()); | 39 | $encoders = array(new JsonEncoder()); |
40 | $normalizers = array(new ObjectNormalizer()); | 40 | $normalizers = array(new ObjectNormalizer()); |
41 | 41 | ||
@@ -71,4 +71,40 @@ class AjaxController extends Controller { | @@ -71,4 +71,40 @@ class AjaxController extends Controller { | ||
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | + | ||
75 | + /** | ||
76 | + * @Route("/ajax/buscar_tutor", name="ajax_buscar_tutor") | ||
77 | + * @Method({"GET"}) | ||
78 | + */ | ||
79 | + public function buscarTutorAction(Request $request){ | ||
80 | + if($request->isXmlHttpRequest()){ | ||
81 | + $encoders = array(new JsonEncoder()); | ||
82 | + $normalizers = array(new ObjectNormalizer()); | ||
83 | + | ||
84 | + $serializer = new Serializer($normalizers, $encoders); | ||
85 | + $cedula = filter_input(INPUT_GET, 'cedula', FILTER_SANITIZE_SPECIAL_CHARS); | ||
86 | + $documento = filter_input(INPUT_GET, 'documento', FILTER_SANITIZE_SPECIAL_CHARS); | ||
87 | + | ||
88 | + | ||
89 | + $repository = $this->getDoctrine() | ||
90 | + ->getRepository('AppBundle:TutoresAscenso'); | ||
91 | + $query = $repository->createQueryBuilder('p') | ||
92 | + ->where('p.cedulaPasaporte = :cedula') | ||
93 | + ->andWhere('p.institucion = :documento') | ||
94 | + ->setParameters(array('cedula'=> $cedula, 'documento' => $documento)) | ||
95 | + ->getQuery(); | ||
96 | + | ||
97 | + $posts = $query->getResult(); | ||
98 | + | ||
99 | + $response = new JsonResponse(); | ||
100 | + $response->setStatusCode(200); | ||
101 | + $response->setData(array( | ||
102 | + 'response' => 'success', | ||
103 | + 'posts' => $serializer->serialize($posts, 'json') | ||
104 | + )); | ||
105 | + return $response; | ||
106 | + } | ||
107 | + | ||
108 | + } | ||
109 | + | ||
74 | } | 110 | } |
src/AppBundle/Controller/AscensoController.php
@@ -122,8 +122,9 @@ class AscensoController extends Controller | @@ -122,8 +122,9 @@ class AscensoController extends Controller | ||
122 | 122 | ||
123 | 123 | ||
124 | $form = $this->createForm('AppBundle\Form\AscensoType'); | 124 | $form = $this->createForm('AppBundle\Form\AscensoType'); |
125 | + $tutorForm = $this->createForm('AppBundle\Form\TutoresAscensoType'); | ||
125 | $form->handleRequest($request); | 126 | $form->handleRequest($request); |
126 | - | 127 | + |
127 | 128 | ||
128 | if ($form->isSubmitted() && $form->isValid()) { | 129 | if ($form->isSubmitted() && $form->isValid()) { |
129 | 130 | ||
@@ -245,6 +246,7 @@ class AscensoController extends Controller | @@ -245,6 +246,7 @@ class AscensoController extends Controller | ||
245 | 'solicitudes/ascenso.html.twig', | 246 | 'solicitudes/ascenso.html.twig', |
246 | array( | 247 | array( |
247 | 'form' => $form->createView(), | 248 | 'form' => $form->createView(), |
249 | + 'tutorForm' => $tutorForm->createView(), | ||
248 | 'ultima_escala' => $escala, | 250 | 'ultima_escala' => $escala, |
249 | 'nueva_escala' => $nueva_escala, | 251 | 'nueva_escala' => $nueva_escala, |
250 | 'antiguedad' => $formalizarTiempo | 252 | 'antiguedad' => $formalizarTiempo |
src/AppBundle/Form/AscensoType.php
@@ -15,7 +15,7 @@ use Symfony\Component\Validator\Constraints\NotBlank; | @@ -15,7 +15,7 @@ use Symfony\Component\Validator\Constraints\NotBlank; | ||
15 | use Symfony\Component\Form\AbstractType; | 15 | use Symfony\Component\Form\AbstractType; |
16 | use Symfony\Component\Form\FormBuilderInterface; | 16 | use Symfony\Component\Form\FormBuilderInterface; |
17 | use Symfony\Component\Form\Extension\Core\Type\TextType; | 17 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
18 | -use Symfony\Component\Form\Extension\Core\Type\BirthdayType; | 18 | +use Symfony\Component\Form\Extension\Core\Type\ButtonType; |
19 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; | 19 | use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
20 | use Symfony\Component\Form\Extension\Core\Type\FileType; | 20 | use Symfony\Component\Form\Extension\Core\Type\FileType; |
21 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | 21 | use Symfony\Component\Form\Extension\Core\Type\SubmitType; |
@@ -111,7 +111,20 @@ class AscensoType extends AbstractType | @@ -111,7 +111,20 @@ class AscensoType extends AbstractType | ||
111 | ->add('tutores_asignados', EntityType::class, array( | 111 | ->add('tutores_asignados', EntityType::class, array( |
112 | 'placeholder' => 'Añadir Tutores...', | 112 | 'placeholder' => 'Añadir Tutores...', |
113 | 'class' => 'AppBundle:TutoresAscenso', | 113 | 'class' => 'AppBundle:TutoresAscenso', |
114 | - 'label' => false | 114 | + 'label' => false, |
115 | + 'multiple' => true, | ||
116 | + 'attr' => array( | ||
117 | + 'disabled' => 'true', | ||
118 | + ) | ||
119 | + )) | ||
120 | + | ||
121 | + ->add('añadir_tutor', ButtonType::class, array( | ||
122 | + 'label' => 'Añadir Tutor', | ||
123 | + 'attr' => array( | ||
124 | + 'class' => 'btn btn-success btn-sm', | ||
125 | + 'data-toggle' => "modal", | ||
126 | + 'data-target' => "#buscarTutores" | ||
127 | + ) | ||
115 | )) | 128 | )) |
116 | 129 | ||
117 | 130 | ||
@@ -165,10 +178,10 @@ class AscensoType extends AbstractType | @@ -165,10 +178,10 @@ class AscensoType extends AbstractType | ||
165 | 178 | ||
166 | 179 | ||
167 | 180 | ||
168 | - ->add('send', SubmitType::class, array( | ||
169 | - 'label' => 'Crear Solicitud de Ascenso', | ||
170 | - 'attr' => array('class' => 'btn btn-success btn-block') | ||
171 | - )) | 181 | + ->add('send', SubmitType::class, array( |
182 | + 'label' => 'Crear Solicitud de Ascenso', | ||
183 | + 'attr' => array('class' => 'btn btn-success btn-block') | ||
184 | + )) | ||
172 | 185 | ||
173 | 186 | ||
174 | ; | 187 | ; |
src/AppBundle/Form/TutoresAscensoType.php
@@ -0,0 +1,93 @@ | @@ -0,0 +1,93 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace AppBundle\Form; | ||
4 | + | ||
5 | +use Symfony\Component\Form\AbstractType; | ||
6 | +use Symfony\Component\Form\FormBuilderInterface; | ||
7 | +use Symfony\Component\OptionsResolver\OptionsResolver; | ||
8 | +use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||
9 | +use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
10 | +use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||
11 | +use Symfony\Component\Form\Extension\Core\Type\ButtonType; | ||
12 | + | ||
13 | + | ||
14 | +class TutoresAscensoType extends AbstractType | ||
15 | +{ | ||
16 | + /** | ||
17 | + * @param FormBuilderInterface $builder | ||
18 | + * @param array $options | ||
19 | + */ | ||
20 | + public function buildForm(FormBuilderInterface $builder, array $options) | ||
21 | + { | ||
22 | + $builder | ||
23 | + ->add('idDocumentoIdentidad', EntityType::class, array( | ||
24 | + 'label' => false, | ||
25 | + 'placeholder' => 'Tipo Documento...', | ||
26 | + 'class' => 'AppBundle:DocumentoIdentidad', | ||
27 | + 'attr' => array( | ||
28 | + 'class' => 'col-lg-4', | ||
29 | + ) | ||
30 | + )) | ||
31 | + ->add('cedulaPasaporte', TextType::class, array( | ||
32 | + 'label' => false, | ||
33 | + 'attr' => array( | ||
34 | + 'placeholder' => 'introudzca la cédula', | ||
35 | + 'class' => 'col-lg-4 form-control', | ||
36 | + ) | ||
37 | + )) | ||
38 | + | ||
39 | + ->add('buscarTutor', ButtonType::class, array( | ||
40 | + 'label' => 'Añadir', | ||
41 | + 'attr' => array('class' => 'btn btn-primary col-lg-4'), | ||
42 | + )) | ||
43 | + | ||
44 | + ->add('etiqueta', TextType::class, array( | ||
45 | + 'label' => false, | ||
46 | + 'data' => "Tutor no Encontrado, por favor Registre al nuevo Tutor", | ||
47 | + 'attr' => array( | ||
48 | + 'placeholder' => 'Nombres del tutor...', | ||
49 | + 'class' => 'alert alert-warning col-lg-12 hidden oculto', | ||
50 | + ) | ||
51 | + )) | ||
52 | + | ||
53 | + | ||
54 | + ->add('nombres', TextType::class, array( | ||
55 | + 'label' => 'nombres', | ||
56 | + 'label_attr' => array('class' => 'hidden oculto'), | ||
57 | + 'attr' => array( | ||
58 | + 'class' => 'col-lg-6 form-control hidden oculto', | ||
59 | + ) | ||
60 | + )) | ||
61 | + | ||
62 | + ->add('apellidos', TextType::class, array( | ||
63 | + 'label' => false, | ||
64 | + 'attr' => array( | ||
65 | + 'placeholder' => 'apellidos del tutor...', | ||
66 | + 'class' => 'col-lg-3 form-control hidden oculto', | ||
67 | + ) | ||
68 | + )) | ||
69 | + /*->add('correoElectronico', EmailType::class, array( | ||
70 | + 'label' => false, | ||
71 | + 'attr' => array( | ||
72 | + 'placeholder' => 'introudzca correo Electrónico del tutor', | ||
73 | + 'class' => 'col-lg-6 form-group', | ||
74 | + ) | ||
75 | + )) | ||
76 | + ->add('nombres') | ||
77 | + ->add('apellidos') | ||
78 | + ->add('institucion') | ||
79 | + ->add('idEscala')*/ | ||
80 | + //->add('ascenso') | ||
81 | + ; | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * @param OptionsResolver $resolver | ||
86 | + */ | ||
87 | + public function configureOptions(OptionsResolver $resolver) | ||
88 | + { | ||
89 | + $resolver->setDefaults(array( | ||
90 | + 'data_class' => 'AppBundle\Entity\TutoresAscenso' | ||
91 | + )); | ||
92 | + } | ||
93 | +} |