Commit 0fb9bdff02145d44fbebdb8376c018a5393c3767

Authored by Wilmer
1 parent 759689c686
Exists in master

añadido modificar el estatus de las tareas del pida

app/Resources/views/solicitudes/pida.html.twig
... ... @@ -68,12 +68,17 @@
68 68 <th>Tarea Específica</th>
69 69 <th>Plazo</th>
70 70 <th>Estatus</th>
71   - {% for pid in pida %}
  71 + {% for pid in pida | sort %}
72 72 <tr>
73   - <td rowspan="{{ pid.pidaTareaEspecifico | length }}">{{ pid.idPlanHistoricoNacionalEstrategico.nombre }}</td>
74   - <td rowspan="{{ pid.pidaTareaEspecifico | length }}">{{ pid.idActividadDocente.nombre }}</td>
75   -
76   - {% for tarea in pid.pidaTareaEspecifico %}
  73 + <td rowspan="{{ pid.pidaTareaEspecifico | length }}">
  74 + {{ pid.idPlanHistoricoNacionalEstrategico.nombre }}
  75 + <a data-id="{{ pid.id }}" id="delete{{ pid.id }}" class="btn btn-xs btn-danger">-</a>
  76 + </td>
  77 + <td rowspan="{{ pid.pidaTareaEspecifico | length }}">
  78 + {{ pid.idActividadDocente.nombre }}
  79 + </td>
  80 +
  81 + {% for tarea in pid.pidaTareaEspecifico | sort %}
77 82 <td>{{ tarea.pidaTareaEspecifico }}
78 83 {% if loop.index == loop.length %}
79 84 <a data-id="{{ pid.id }}" id="add_actividad{{ pid.id }}" data-toggle="modal" data-target="#nueva_actividad" class="btn btn-xs btn-warning">+</a>
... ... @@ -82,7 +87,10 @@
82 87 {% endif %}
83 88 </td>
84 89 <td>{{ tarea.idPidaPlazo }}</td>
85   - <td>{{ tarea.idPidaEstatus }}</td>
  90 + <td>
  91 + {{ tarea.idPidaEstatus }}
  92 + <a data-id="{{ tarea.id }}" id="estatus{{ tarea.id }}" data-toggle="modal" data-target="#nuevo_estatus" class="btn btn-xs btn-default">.</a>
  93 + </td>
86 94  
87 95 </tr>
88 96 {% endfor %}
... ... @@ -130,6 +138,37 @@
130 138 </div>
131 139 </div>
132 140  
  141 +
  142 + <div class="modal fade" id="nuevo_estatus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  143 + <div class="modal-dialog" role="document">
  144 +
  145 + <div class="modal-content">
  146 + <div class="modal-header">
  147 + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  148 + aria-hidden="true">&times;</span></button>
  149 + <h4 class="modal-title" id="myModalLabel">Nueva Actividad</h4>
  150 + </div>
  151 +
  152 + <div class="modal-body">
  153 + {% form_theme estatusForm 'bootstrap_3_layout.html.twig' %}
  154 + {{ form_start(estatusForm) }}
  155 + {{ form_widget(estatusForm) }}
  156 +
  157 + <input type="hidden" id="id_estatus" name="id_estatus" value="" >
  158 + </div>
  159 + <div class="modal-footer">
  160 + <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
  161 + <button type="submit" class="btn btn-success" name="rechazar" id="rechazar">Añadir Actividad
  162 +
  163 + </button>
  164 + </div>
  165 + {{ form_end(editForm) }}
  166 + </div>
  167 +
  168 + </div>
  169 + </div>
  170 +
  171 +
133 172 {% endblock %}
134 173  
135 174  
... ... @@ -226,6 +265,34 @@
226 265 });
227 266  
228 267  
  268 + $('[id^="delete"]').click(function() {
  269 + var x = confirm("eliminar Labor completa: " + $(this).attr('data-id'));
  270 + if(x) {
  271 + $.ajax({
  272 + method: "POST",
  273 + url: "{{ url('ajax_eliminar_labor') }}",
  274 + async: true,
  275 + cache: false,
  276 + data: ({eliminar: $(this).attr('data-id')}),
  277 + success: function (data) {
  278 + console.log(data);
  279 + location.reload();
  280 + },
  281 + error: function (XMLHttpRequest, textStatus, errorThrown) {
  282 + console.log(errorThrown);
  283 +
  284 + }
  285 +
  286 + });
  287 + }
  288 + });
  289 +
  290 + $('[id^="estatus"]').click(function() {
  291 + alert("presionado: " + $(this).attr('data-id'))
  292 + $("#id_estatus").val($(this).attr('data-id'));
  293 + });
  294 +
  295 +
229 296  
230 297  
231 298  
... ...
src/AppBundle/Controller/AdscripcionController.php
... ... @@ -9,8 +9,10 @@
9 9 namespace AppBundle\Controller;
10 10  
11 11 use AppBundle\Entity\DocumentosVerificados;
  12 +use AppBundle\Entity\PidaEstatus;
12 13 use AppBundle\Entity\PidaTareaEspecifico;
13 14 use AppBundle\Form\PidaTareaEspecificoType;
  15 +use Symfony\Bridge\Doctrine\Form\Type\EntityType;
14 16 use Symfony\Component\Form\FormError;
15 17 use Symfony\Component\HttpFoundation\File\UploadedFile;
16 18 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
... ... @@ -471,6 +473,16 @@ class AdscripcionController extends Controller
471 473  
472 474 $editForm = $this->createForm('AppBundle\Form\PidaTareaEspecificoType', $tarea);
473 475 $editForm->handleRequest($request);
  476 +
  477 + $estatusPida = new PidaEstatus();
  478 + $Estatusform = $this->createFormBuilder($estatusPida)
  479 + ->add('nombre', EntityType::class, array(
  480 + 'class' => 'AppBundle\Entity\PidaEstatus'
  481 + ))
  482 + ->getForm();
  483 +
  484 + $Estatusform->handleRequest($request);
  485 +
474 486 $em = $this->getDoctrine()->getManager();
475 487 if ($form->isSubmitted() && $form->isValid()) {
476 488 $em = $this->getDoctrine()->getManager();
... ... @@ -520,11 +532,29 @@ class AdscripcionController extends Controller
520 532 }
521 533  
522 534  
  535 + if ($Estatusform->isSubmitted() && $Estatusform->isValid()) {
  536 + $id = filter_input(INPUT_POST, 'id_estatus', FILTER_SANITIZE_SPECIAL_CHARS);
  537 + //var_dump($estatusPida->getNombre()->getNombre()); die;
  538 + if($id) {
  539 + $estatus = $this->getDoctrine()->getRepository("AppBundle:PidaEstatus")->findOneByNombre($estatusPida->getNombre()->getNombre());
  540 + $tarea = $this->getDoctrine()->getRepository("AppBundle:PidaTareaEspecifico")->findOneById($id);
  541 + $tarea->setIdPidaEstatus($estatus);
  542 + $em->persist($tarea);
  543 +
  544 + $em->flush();
  545 +
  546 + return $this->redirectToRoute('solicitud_pida');
  547 + }
  548 +
  549 + }
  550 +
  551 +
523 552 return $this->render('solicitudes/pida.html.twig', array(
524 553 'form' => $form->createView(),
525 554 'pida' => $pid,
526 555 'servicio' => $serv,
527   - 'editForm' => $editForm->createView()
  556 + 'editForm' => $editForm->createView(),
  557 + 'estatusForm' => $Estatusform->createView()
528 558 ));
529 559  
530 560  
... ...
src/AppBundle/Controller/AjaxController.php
... ... @@ -239,7 +239,7 @@ class AjaxController extends Controller {
239 239  
240 240  
241 241 /**
242   - * @Route("/ajax/add/tarea", name="ajax_eliminar_tarea")
  242 + * @Route("/ajax/eliminar/tarea", name="ajax_eliminar_tarea")
243 243 * @Method({"POST"})
244 244 */
245 245 public function eliminarTareaAction(Request $request){
... ... @@ -274,6 +274,43 @@ class AjaxController extends Controller {
274 274  
275 275 }
276 276  
  277 +
  278 + /**
  279 + * @Route("/ajax/eliminar/labor", name="ajax_eliminar_labor")
  280 + * @Method({"POST"})
  281 + */
  282 + public function eliminarLaborAction(Request $request){
  283 +
  284 + if($request->isXmlHttpRequest()){
  285 + $encoders = array(new JsonEncoder());
  286 + $normalizers = array(new ObjectNormalizer());
  287 +
  288 + $serializer = new Serializer($normalizers, $encoders);
  289 +
  290 + $id = filter_input(INPUT_POST, 'eliminar', FILTER_SANITIZE_SPECIAL_CHARS);
  291 +
  292 +
  293 + $em = $this->getDoctrine()->getManager();
  294 + $pida = $em->getRepository("AppBundle:AdscripcionPida")->findOneById($id);
  295 + $em->remove($pida);
  296 + $em->flush();
  297 +
  298 +
  299 +
  300 +
  301 + $response = new JsonResponse();
  302 + $response->setStatusCode(200);
  303 + $response->setData(array(
  304 + 'response' => 'success'
  305 + ));
  306 +
  307 + return $response;
  308 +
  309 +
  310 + }
  311 +
  312 + }
  313 +
277 314  
278 315  
279 316 /**
... ...
src/AppBundle/Entity/PidaEstatus.php
... ... @@ -100,6 +100,12 @@ class PidaEstatus
100 100 {
101 101 return $this->id;
102 102 }
  103 +
  104 + /**
  105 + * Get nombre
  106 + *
  107 + * @return string
  108 + */
103 109  
104 110 public function __toString() {
105 111 return $this->getNombre();
... ...