Commit e81d87503b2d66a06b6e0cc402ed35cb249d3fb5
1 parent
78087d3cc0
Exists in
master
permite eliminar jurados al coordinador del CEA
Showing
2 changed files
with
65 additions
and
4 deletions
Show diff stats
app/Resources/views/cea/ascenso_mostar.html.twig
... | ... | @@ -72,12 +72,12 @@ |
72 | 72 | {% else %} |
73 | 73 | {% set cantidadJurado = cantidadJurado - 1 %} |
74 | 74 | {% endif %} |
75 | - <p class="well"> | |
75 | + <p class="well" id="well_{{tutor.id}}"> | |
76 | 76 | |
77 | 77 | <strong>{{ tutor.nombres }} {{ tutor.apellidos }}:</strong> |
78 | 78 | {{ tutor.institucion }} -> {{ tutor.idEscala.nombre }} |
79 | 79 | <input type="button" class="btn btn-warning btn-xs" value="act" id="actualizar_tutor"> |
80 | - <input type="button" class="btn btn-danger btn-xs" value="cam" id="cambiar_tutor"> | |
80 | + <input type="button" class="btn btn-danger btn-xs eliminar_jurado" value="X" id="{{ tutor.id }}"> | |
81 | 81 | </p> |
82 | 82 | {% endfor %} |
83 | 83 | {% if añadirJurado %} |
... | ... | @@ -273,8 +273,24 @@ |
273 | 273 | <script> |
274 | 274 | var cantidad = $("#falta").data('faltaid'); |
275 | 275 | alert(cantidad); |
276 | - $("#actualizar_tutor").click(function(){ | |
277 | - alert("click"); | |
276 | + $(".eliminar_jurado").click(function(){ | |
277 | + $.ajax({ | |
278 | + method: "POST", | |
279 | + url: "{{ url('ajax_eliminar_tutor') }}", | |
280 | + async: true, | |
281 | + cache: false, | |
282 | + data: ({ eliminar: $(".eliminar_jurado").attr('id'), ascensoId: {{ ascenso.id }} }), | |
283 | + success: function (data) { | |
284 | + console.log(data); | |
285 | + $("#well_" + $(".eliminar_jurado").attr('id')).remove(); | |
286 | + | |
287 | + }, | |
288 | + error: function (XMLHttpRequest, textStatus, errorThrown) { | |
289 | + console.log(errorThrown); | |
290 | + | |
291 | + } | |
292 | + | |
293 | + }); | |
278 | 294 | }); |
279 | 295 | |
280 | 296 | $("#aadd_tutor_tutores_ascenso").on("chosen:ready", function() { | ... | ... |
src/AppBundle/Controller/AjaxController.php
... | ... | @@ -230,4 +230,49 @@ class AjaxController extends Controller { |
230 | 230 | |
231 | 231 | } |
232 | 232 | |
233 | + | |
234 | + /** | |
235 | + * @Route("/ajax/eliminar_tutor", name="ajax_eliminar_tutor") | |
236 | + * @Method({"POST"}) | |
237 | + */ | |
238 | + public function eliminarTutorAction(Request $request){ | |
239 | + | |
240 | + if($request->isXmlHttpRequest()){ | |
241 | + $encoders = array(new JsonEncoder()); | |
242 | + $normalizers = array(new ObjectNormalizer()); | |
243 | + | |
244 | + $serializer = new Serializer($normalizers, $encoders); | |
245 | + | |
246 | + $eliminar = filter_input(INPUT_POST, 'eliminar', FILTER_SANITIZE_SPECIAL_CHARS); | |
247 | + $ascensoId = filter_input(INPUT_POST, 'ascensoId', FILTER_SANITIZE_SPECIAL_CHARS); | |
248 | + | |
249 | + | |
250 | + $ascenso = $this->getDoctrine()->getRepository("AppBundle:Ascenso")->findOneById($ascensoId); | |
251 | + | |
252 | + | |
253 | + $quitarJurado = $this->getDoctrine()->getRepository("AppBundle:TutoresAscenso")->findOneById($eliminar); | |
254 | + $ascenso->removeTutoresAscenso($quitarJurado); | |
255 | + | |
256 | + | |
257 | + | |
258 | + | |
259 | + $em = $this->getDoctrine()->getManager(); | |
260 | + $em->persist($ascenso); | |
261 | + $em->flush(); | |
262 | + | |
263 | + $response = new JsonResponse(); | |
264 | + $response->setStatusCode(200); | |
265 | + $response->setData(array( | |
266 | + 'response' => 'success', | |
267 | + 'jurados' => $quitarJurado, | |
268 | + 'ascenso' => $ascensoId | |
269 | + )); | |
270 | + | |
271 | + return $response; | |
272 | + | |
273 | + | |
274 | + } | |
275 | + | |
276 | + } | |
277 | + | |
233 | 278 | } | ... | ... |