diff --git a/app/Resources/views/solicitudes/pida.html.twig b/app/Resources/views/solicitudes/pida.html.twig index 932fa4a..d947032 100644 --- a/app/Resources/views/solicitudes/pida.html.twig +++ b/app/Resources/views/solicitudes/pida.html.twig @@ -98,11 +98,15 @@

PIDA del Docente: {{ app.user.idRolinstitucion.idRol.idPersona }}

Mi PIDA

Estatus: {{ servicio.idEstatus }} -
+
{% if not caduca %} + {% form_theme caducidadForm 'bootstrap_3_layout.html.twig' %} +
{{ form_start(caducidadForm) }}
@@ -370,8 +374,13 @@ cache: false, data: ({finalizar: $(this).attr('data-servicio')}), success: function (data) { - console.log(data); - location.reload(); + if (data.response == "caducidad"){ + alert("No se puede finalizar un PIDA sin antes asignarle Caducidad"); + $(".btn").button('reset'); + }else { + console.log(data); + location.reload(); + } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(errorThrown); diff --git a/src/AppBundle/Controller/AjaxController.php b/src/AppBundle/Controller/AjaxController.php index 0dd109c..ede82f7 100644 --- a/src/AppBundle/Controller/AjaxController.php +++ b/src/AppBundle/Controller/AjaxController.php @@ -373,18 +373,29 @@ class AjaxController extends Controller { $em = $this->getDoctrine()->getManager(); $servicio = $em->getRepository("AppBundle:DocenteServicio")->findOneById($id); - $servicio->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(4)); - $em->persist($servicio); - $em->flush(); + $caducidad = $em->getRepository("AppBundle:PidaCaducidad")->findOneByIdDocenteServicio($servicio); + if($caducidad) { + $servicio->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(4)); + $em->persist($servicio); + $em->flush(); + $response = new JsonResponse(); + $response->setStatusCode(200); + $response->setData(array( + 'response' => 'success' + )); + }else{ + $response = new JsonResponse(); + $response->setStatusCode(200); + $response->setData(array( + 'response' => 'caducidad' + )); + } + + - $response = new JsonResponse(); - $response->setStatusCode(200); - $response->setData(array( - 'response' => 'success' - )); return $response;