From 4a2ade5a310df77c4d5526b02a8c1533657a1662 Mon Sep 17 00:00:00 2001 From: Wilmer Date: Fri, 24 Mar 2017 09:18:38 -0400 Subject: [PATCH] =?UTF-8?q?creado=20el=20poder=20a=C3=B1adir=20mas=20activ?= =?UTF-8?q?idades=20a=20la=20labor=20ya=20creada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Resources/views/solicitudes/pida.html.twig | 54 +++++++++++++++++++++- src/AppBundle/Controller/AdscripcionController.php | 27 +++++++++-- src/AppBundle/Controller/AjaxController.php | 44 ++++++++++++++++++ 3 files changed, 121 insertions(+), 4 deletions(-) diff --git a/app/Resources/views/solicitudes/pida.html.twig b/app/Resources/views/solicitudes/pida.html.twig index acfc8ed..f9a3780 100644 --- a/app/Resources/views/solicitudes/pida.html.twig +++ b/app/Resources/views/solicitudes/pida.html.twig @@ -74,9 +74,14 @@ {{ pid.idActividadDocente.nombre }} {% for tarea in pid.pidaTareaEspecifico %} - {{ tarea.pidaTareaEspecifico }} + {{ tarea.pidaTareaEspecifico }} + {% if loop.index == loop.length %} + + + {% endif %} + {{ tarea.idPidaPlazo }} {{ tarea.idPidaEstatus }} + {% endfor %} @@ -90,6 +95,39 @@ + + + + {% endblock %} @@ -153,5 +191,19 @@ } + $('#nueva_actividad').on('hidden.bs.modal', function (e) { + $(".btn").button('reset'); + }); + + var buttonpressed; + $('[id^="add_"]').click(function() { + alert("presionado: " + $(this).attr('data-id')) + $("#id_pida").val($(this).attr('data-id')); + }); + + + + + {% endblock %} diff --git a/src/AppBundle/Controller/AdscripcionController.php b/src/AppBundle/Controller/AdscripcionController.php index f3d39aa..f66cca7 100644 --- a/src/AppBundle/Controller/AdscripcionController.php +++ b/src/AppBundle/Controller/AdscripcionController.php @@ -10,6 +10,7 @@ namespace AppBundle\Controller; use AppBundle\Entity\DocumentosVerificados; use AppBundle\Entity\PidaTareaEspecifico; +use AppBundle\Form\PidaTareaEspecificoType; use Symfony\Component\Form\FormError; use Symfony\Component\HttpFoundation\File\UploadedFile; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; @@ -464,10 +465,13 @@ class AdscripcionController extends Controller } $pida = new AdscripcionPida(); + $tarea = new PidaTareaEspecifico(); $form = $this->createForm('AppBundle\Form\PidaType', $pida); $form->handleRequest($request); - - + + $editForm = $this->createForm('AppBundle\Form\PidaTareaEspecificoType', $tarea); + $editForm->handleRequest($request); + $em = $this->getDoctrine()->getManager(); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); //Crear la solicitud de Servicio @@ -499,11 +503,28 @@ class AdscripcionController extends Controller } + if ($editForm->isSubmitted() && $editForm->isValid()) { + $id = filter_input(INPUT_POST, 'id_pida', FILTER_SANITIZE_SPECIAL_CHARS); + if($id) { + + $pida = $this->getDoctrine()->getRepository("AppBundle:AdscripcionPida")->findOneById($id); + $tarea->setAdscripcionPidaId($pida); + $pida->addPidaTareaEspecifico($tarea); + $em->persist($pida); + + $em->flush(); + + return $this->redirectToRoute('solicitud_pida'); + } + + } + return $this->render('solicitudes/pida.html.twig', array( 'form' => $form->createView(), 'pida' => $pid, - 'servicio' => $serv + 'servicio' => $serv, + 'editForm' => $editForm->createView() )); diff --git a/src/AppBundle/Controller/AjaxController.php b/src/AppBundle/Controller/AjaxController.php index 44dcfc1..07eb571 100644 --- a/src/AppBundle/Controller/AjaxController.php +++ b/src/AppBundle/Controller/AjaxController.php @@ -235,6 +235,50 @@ class AjaxController extends Controller { } } + + + + /** + * @Route("/ajax/add/tarea", name="ajax_add_tarea") + * @Method({"POST"}) + */ + public function addTareaAction(Request $request){ + + if($request->isXmlHttpRequest()){ + $encoders = array(new JsonEncoder()); + $normalizers = array(new ObjectNormalizer()); + + $serializer = new Serializer($normalizers, $encoders); + + $pida = filter_input(INPUT_POST, 'pida', FILTER_SANITIZE_SPECIAL_CHARS); + + + $em = $this->getDoctrine()->getManager(); + $pida = $em->getRepository("AppBundle:AdscripcionPida")->findOneById($pida); + var_dump($request->request); exit; + $pida->addPidaTareaEspecifico($tarea); + $em->persist($pida); + $em->flush(); + + + $response = new JsonResponse(); + $response->setStatusCode(200); + $response->setData(array( + 'response' => 'success', + 'jurados' => $jurados, + 'adicionar_nombres' => $nuevos_nombres, + 'adicionar_institucion' => $nuevos_institucion, + 'adicionar_id' => $nuevos_id, + 'ascenso' => $ascensoId + )); + + return $response; + + + } + + } + /** -- 2.0.0