diff --git a/app/Resources/views/solicitudes/pida.html.twig b/app/Resources/views/solicitudes/pida.html.twig index 124060e..a2c0323 100644 --- a/app/Resources/views/solicitudes/pida.html.twig +++ b/app/Resources/views/solicitudes/pida.html.twig @@ -36,6 +36,7 @@
+ {% if servicio.idEstatus.id == 2 %}
@@ -51,14 +52,19 @@ - + {{ form_end(form) }}
+ {% endif %} {% if pida %} + {% if servicio.idEstatus.id == 2 %}
+ {% else %} +
+ {% endif %} +
{% endif %} @@ -309,6 +318,30 @@ } }); + $('#finalizarPida').click(function() { + var x = confirm("Desea terminal la edición y Finalizar su pida?"); + if(x) { + $.ajax({ + method: "POST", + url: "{{ url('ajax_finalizar_pida') }}", + async: true, + cache: false, + data: ({finalizar: $(this).attr('data-servicio')}), + success: function (data) { + console.log(data); + location.reload(); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + console.log(errorThrown); + + } + + }); + } + }); + + + $('[id^="estatus"]').click(function() { alert("presionado: " + $(this).attr('data-id')) $("#id_estatus").val($(this).attr('data-id')); diff --git a/src/AppBundle/Controller/AjaxController.php b/src/AppBundle/Controller/AjaxController.php index b08a16a..efbb386 100644 --- a/src/AppBundle/Controller/AjaxController.php +++ b/src/AppBundle/Controller/AjaxController.php @@ -311,6 +311,45 @@ class AjaxController extends Controller { } + + + /** + * @Route("/ajax/finalizar/pida", name="ajax_finalizar_pida") + * @Method({"POST"}) + */ + public function finalizarPidaAction(Request $request){ + + if($request->isXmlHttpRequest()){ + $encoders = array(new JsonEncoder()); + $normalizers = array(new ObjectNormalizer()); + + $serializer = new Serializer($normalizers, $encoders); + + $id = filter_input(INPUT_POST, 'finalizar', FILTER_SANITIZE_SPECIAL_CHARS); + + + $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(); + + + + + $response = new JsonResponse(); + $response->setStatusCode(200); + $response->setData(array( + 'response' => 'success' + )); + + return $response; + + + } + + } + /**