Commit 4a2ade5a310df77c4d5526b02a8c1533657a1662
1 parent
d7251b487b
Exists in
master
creado el poder añadir mas actividades a la labor ya creada
Showing
3 changed files
with
121 additions
and
4 deletions
Show diff stats
app/Resources/views/solicitudes/pida.html.twig
| @@ -74,9 +74,14 @@ | @@ -74,9 +74,14 @@ | ||
| 74 | <td rowspan="{{ pid.pidaTareaEspecifico | length }}">{{ pid.idActividadDocente.nombre }}</td> | 74 | <td rowspan="{{ pid.pidaTareaEspecifico | length }}">{{ pid.idActividadDocente.nombre }}</td> |
| 75 | 75 | ||
| 76 | {% for tarea in pid.pidaTareaEspecifico %} | 76 | {% for tarea in pid.pidaTareaEspecifico %} |
| 77 | - <td>{{ tarea.pidaTareaEspecifico }}</td> | 77 | + <td>{{ tarea.pidaTareaEspecifico }} |
| 78 | + {% if loop.index == loop.length %} | ||
| 79 | + <a data-id="{{ pid.id }}" id="add_actividad{{ pid.id }}" data-toggle="modal" data-target="#nueva_actividad" class="btn btn-xs btn-warning">+</a> | ||
| 80 | + {% endif %} | ||
| 81 | + </td> | ||
| 78 | <td>{{ tarea.idPidaPlazo }}</td> | 82 | <td>{{ tarea.idPidaPlazo }}</td> |
| 79 | <td>{{ tarea.idPidaEstatus }}</td> | 83 | <td>{{ tarea.idPidaEstatus }}</td> |
| 84 | + | ||
| 80 | </tr> | 85 | </tr> |
| 81 | {% endfor %} | 86 | {% endfor %} |
| 82 | 87 | ||
| @@ -90,6 +95,39 @@ | @@ -90,6 +95,39 @@ | ||
| 90 | 95 | ||
| 91 | </div> | 96 | </div> |
| 92 | 97 | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + <div class="modal fade" id="nueva_actividad" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | ||
| 101 | + <div class="modal-dialog" role="document"> | ||
| 102 | + | ||
| 103 | + <div class="modal-content"> | ||
| 104 | + <div class="modal-header"> | ||
| 105 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span | ||
| 106 | + aria-hidden="true">×</span></button> | ||
| 107 | + <h4 class="modal-title" id="myModalLabel">Nueva Actividad</h4> | ||
| 108 | + </div> | ||
| 109 | + | ||
| 110 | + <div class="modal-body"> | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + {% form_theme editForm 'bootstrap_3_layout.html.twig' %} | ||
| 114 | + {{ form_start(editForm) }} | ||
| 115 | + {{ form_widget(editForm) }} | ||
| 116 | + | ||
| 117 | + <input type="hidden" id="id_pida" name="id_pida" value="" > | ||
| 118 | + </div> | ||
| 119 | + <div class="modal-footer"> | ||
| 120 | + <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> | ||
| 121 | + <button type="submit" class="btn btn-success" name="rechazar" id="rechazar">Añadir Actividad | ||
| 122 | + | ||
| 123 | + </button> | ||
| 124 | + </div> | ||
| 125 | + {{ form_end(editForm) }} | ||
| 126 | + </div> | ||
| 127 | + | ||
| 128 | + </div> | ||
| 129 | + </div> | ||
| 130 | + | ||
| 93 | {% endblock %} | 131 | {% endblock %} |
| 94 | 132 | ||
| 95 | 133 | ||
| @@ -153,5 +191,19 @@ | @@ -153,5 +191,19 @@ | ||
| 153 | 191 | ||
| 154 | } | 192 | } |
| 155 | 193 | ||
| 194 | + $('#nueva_actividad').on('hidden.bs.modal', function (e) { | ||
| 195 | + $(".btn").button('reset'); | ||
| 196 | + }); | ||
| 197 | + | ||
| 198 | + var buttonpressed; | ||
| 199 | + $('[id^="add_"]').click(function() { | ||
| 200 | + alert("presionado: " + $(this).attr('data-id')) | ||
| 201 | + $("#id_pida").val($(this).attr('data-id')); | ||
| 202 | + }); | ||
| 203 | + | ||
| 204 | + | ||
| 205 | + | ||
| 206 | + | ||
| 207 | + | ||
| 156 | </script> | 208 | </script> |
| 157 | {% endblock %} | 209 | {% endblock %} |
src/AppBundle/Controller/AdscripcionController.php
| @@ -10,6 +10,7 @@ namespace AppBundle\Controller; | @@ -10,6 +10,7 @@ namespace AppBundle\Controller; | ||
| 10 | 10 | ||
| 11 | use AppBundle\Entity\DocumentosVerificados; | 11 | use AppBundle\Entity\DocumentosVerificados; |
| 12 | use AppBundle\Entity\PidaTareaEspecifico; | 12 | use AppBundle\Entity\PidaTareaEspecifico; |
| 13 | +use AppBundle\Form\PidaTareaEspecificoType; | ||
| 13 | use Symfony\Component\Form\FormError; | 14 | use Symfony\Component\Form\FormError; |
| 14 | use Symfony\Component\HttpFoundation\File\UploadedFile; | 15 | use Symfony\Component\HttpFoundation\File\UploadedFile; |
| 15 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | 16 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
| @@ -464,10 +465,13 @@ class AdscripcionController extends Controller | @@ -464,10 +465,13 @@ class AdscripcionController extends Controller | ||
| 464 | } | 465 | } |
| 465 | 466 | ||
| 466 | $pida = new AdscripcionPida(); | 467 | $pida = new AdscripcionPida(); |
| 468 | + $tarea = new PidaTareaEspecifico(); | ||
| 467 | $form = $this->createForm('AppBundle\Form\PidaType', $pida); | 469 | $form = $this->createForm('AppBundle\Form\PidaType', $pida); |
| 468 | $form->handleRequest($request); | 470 | $form->handleRequest($request); |
| 469 | - | ||
| 470 | - | 471 | + |
| 472 | + $editForm = $this->createForm('AppBundle\Form\PidaTareaEspecificoType', $tarea); | ||
| 473 | + $editForm->handleRequest($request); | ||
| 474 | + $em = $this->getDoctrine()->getManager(); | ||
| 471 | if ($form->isSubmitted() && $form->isValid()) { | 475 | if ($form->isSubmitted() && $form->isValid()) { |
| 472 | $em = $this->getDoctrine()->getManager(); | 476 | $em = $this->getDoctrine()->getManager(); |
| 473 | //Crear la solicitud de Servicio | 477 | //Crear la solicitud de Servicio |
| @@ -499,11 +503,28 @@ class AdscripcionController extends Controller | @@ -499,11 +503,28 @@ class AdscripcionController extends Controller | ||
| 499 | 503 | ||
| 500 | } | 504 | } |
| 501 | 505 | ||
| 506 | + if ($editForm->isSubmitted() && $editForm->isValid()) { | ||
| 507 | + $id = filter_input(INPUT_POST, 'id_pida', FILTER_SANITIZE_SPECIAL_CHARS); | ||
| 508 | + if($id) { | ||
| 509 | + | ||
| 510 | + $pida = $this->getDoctrine()->getRepository("AppBundle:AdscripcionPida")->findOneById($id); | ||
| 511 | + $tarea->setAdscripcionPidaId($pida); | ||
| 512 | + $pida->addPidaTareaEspecifico($tarea); | ||
| 513 | + $em->persist($pida); | ||
| 514 | + | ||
| 515 | + $em->flush(); | ||
| 516 | + | ||
| 517 | + return $this->redirectToRoute('solicitud_pida'); | ||
| 518 | + } | ||
| 519 | + | ||
| 520 | + } | ||
| 521 | + | ||
| 502 | 522 | ||
| 503 | return $this->render('solicitudes/pida.html.twig', array( | 523 | return $this->render('solicitudes/pida.html.twig', array( |
| 504 | 'form' => $form->createView(), | 524 | 'form' => $form->createView(), |
| 505 | 'pida' => $pid, | 525 | 'pida' => $pid, |
| 506 | - 'servicio' => $serv | 526 | + 'servicio' => $serv, |
| 527 | + 'editForm' => $editForm->createView() | ||
| 507 | )); | 528 | )); |
| 508 | 529 | ||
| 509 | 530 |
src/AppBundle/Controller/AjaxController.php
| @@ -235,6 +235,50 @@ class AjaxController extends Controller { | @@ -235,6 +235,50 @@ class AjaxController extends Controller { | ||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | } | 237 | } |
| 238 | + | ||
| 239 | + | ||
| 240 | + | ||
| 241 | + /** | ||
| 242 | + * @Route("/ajax/add/tarea", name="ajax_add_tarea") | ||
| 243 | + * @Method({"POST"}) | ||
| 244 | + */ | ||
| 245 | + public function addTareaAction(Request $request){ | ||
| 246 | + | ||
| 247 | + if($request->isXmlHttpRequest()){ | ||
| 248 | + $encoders = array(new JsonEncoder()); | ||
| 249 | + $normalizers = array(new ObjectNormalizer()); | ||
| 250 | + | ||
| 251 | + $serializer = new Serializer($normalizers, $encoders); | ||
| 252 | + | ||
| 253 | + $pida = filter_input(INPUT_POST, 'pida', FILTER_SANITIZE_SPECIAL_CHARS); | ||
| 254 | + | ||
| 255 | + | ||
| 256 | + $em = $this->getDoctrine()->getManager(); | ||
| 257 | + $pida = $em->getRepository("AppBundle:AdscripcionPida")->findOneById($pida); | ||
| 258 | + var_dump($request->request); exit; | ||
| 259 | + $pida->addPidaTareaEspecifico($tarea); | ||
| 260 | + $em->persist($pida); | ||
| 261 | + $em->flush(); | ||
| 262 | + | ||
| 263 | + | ||
| 264 | + $response = new JsonResponse(); | ||
| 265 | + $response->setStatusCode(200); | ||
| 266 | + $response->setData(array( | ||
| 267 | + 'response' => 'success', | ||
| 268 | + 'jurados' => $jurados, | ||
| 269 | + 'adicionar_nombres' => $nuevos_nombres, | ||
| 270 | + 'adicionar_institucion' => $nuevos_institucion, | ||
| 271 | + 'adicionar_id' => $nuevos_id, | ||
| 272 | + 'ascenso' => $ascensoId | ||
| 273 | + )); | ||
| 274 | + | ||
| 275 | + return $response; | ||
| 276 | + | ||
| 277 | + | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + } | ||
| 281 | + | ||
| 238 | 282 | ||
| 239 | 283 | ||
| 240 | /** | 284 | /** |