Commit 4ac6daf9d129b3bfef58f1e86d1ba8e7cc86aff0
1 parent
5aba8e1d05
Exists in
master
verifica que se le haya asignado caducidad al PIDA antes de poder finalizarlo
Showing
2 changed files
with
31 additions
and
11 deletions
Show diff stats
app/Resources/views/solicitudes/pida.html.twig
| ... | ... | @@ -98,11 +98,15 @@ |
| 98 | 98 | <h4 class="no-screen">PIDA del Docente: {{ app.user.idRolinstitucion.idRol.idPersona }}</h4> |
| 99 | 99 | <h4 class="no-print">Mi PIDA</h4><span class="small" style="float: right;"> Estatus: {{ servicio.idEstatus }}</span> |
| 100 | 100 | </div> |
| 101 | - <div class="panel-body"> | |
| 102 | 101 | |
| 102 | + <div class="panel-body"> | |
| 103 | 103 | |
| 104 | 104 | {% if not caduca %} |
| 105 | + <div class="row"> | |
| 106 | + <a class="alert alert-info">Es importante que le asigne duración al PIDA.</a> | |
| 107 | + </div> | |
| 105 | 108 | {% form_theme caducidadForm 'bootstrap_3_layout.html.twig' %} |
| 109 | + <br> | |
| 106 | 110 | {{ form_start(caducidadForm) }} |
| 107 | 111 | <div class="row"> |
| 108 | 112 | <div class="col-lg-5"> |
| ... | ... | @@ -370,8 +374,13 @@ |
| 370 | 374 | cache: false, |
| 371 | 375 | data: ({finalizar: $(this).attr('data-servicio')}), |
| 372 | 376 | success: function (data) { |
| 373 | - console.log(data); | |
| 374 | - location.reload(); | |
| 377 | + if (data.response == "caducidad"){ | |
| 378 | + alert("No se puede finalizar un PIDA sin antes asignarle Caducidad"); | |
| 379 | + $(".btn").button('reset'); | |
| 380 | + }else { | |
| 381 | + console.log(data); | |
| 382 | + location.reload(); | |
| 383 | + } | |
| 375 | 384 | }, |
| 376 | 385 | error: function (XMLHttpRequest, textStatus, errorThrown) { |
| 377 | 386 | console.log(errorThrown); | ... | ... |
src/AppBundle/Controller/AjaxController.php
| ... | ... | @@ -373,18 +373,29 @@ class AjaxController extends Controller { |
| 373 | 373 | |
| 374 | 374 | $em = $this->getDoctrine()->getManager(); |
| 375 | 375 | $servicio = $em->getRepository("AppBundle:DocenteServicio")->findOneById($id); |
| 376 | - $servicio->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(4)); | |
| 377 | - $em->persist($servicio); | |
| 378 | - $em->flush(); | |
| 376 | + $caducidad = $em->getRepository("AppBundle:PidaCaducidad")->findOneByIdDocenteServicio($servicio); | |
| 377 | + if($caducidad) { | |
| 378 | + $servicio->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(4)); | |
| 379 | + $em->persist($servicio); | |
| 380 | + $em->flush(); | |
| 381 | + $response = new JsonResponse(); | |
| 382 | + $response->setStatusCode(200); | |
| 383 | + $response->setData(array( | |
| 384 | + 'response' => 'success' | |
| 385 | + )); | |
| 386 | + }else{ | |
| 387 | + $response = new JsonResponse(); | |
| 388 | + $response->setStatusCode(200); | |
| 389 | + $response->setData(array( | |
| 390 | + 'response' => 'caducidad' | |
| 391 | + )); | |
| 392 | + } | |
| 393 | + | |
| 394 | + | |
| 379 | 395 | |
| 380 | 396 | |
| 381 | 397 | |
| 382 | 398 | |
| 383 | - $response = new JsonResponse(); | |
| 384 | - $response->setStatusCode(200); | |
| 385 | - $response->setData(array( | |
| 386 | - 'response' => 'success' | |
| 387 | - )); | |
| 388 | 399 | |
| 389 | 400 | return $response; |
| 390 | 401 | ... | ... |