Commit 7c64c6581f145aca04e7962ca9535a6aaa8a02e2
1 parent
3522f897ea
Exists in
master
se creo el formulario de la caducidad y se añadio a la vista de la solicitud de PIDA
Showing
3 changed files
with
117 additions
and
3 deletions
Show diff stats
app/Resources/views/solicitudes/pida.html.twig
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | </h4> | 36 | </h4> |
37 | </div> | 37 | </div> |
38 | <div class="row"> | 38 | <div class="row"> |
39 | - <div class="col-md-5"> | 39 | + <div class="col-md-4"> |
40 | 40 | ||
41 | 41 | ||
42 | <div class="account-container register"> | 42 | <div class="account-container register"> |
@@ -58,10 +58,32 @@ | @@ -58,10 +58,32 @@ | ||
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | {% if pida %} | 60 | {% if pida %} |
61 | - <div class="col-md-6"> | 61 | + <div class="col-md-7"> |
62 | <div class="account-container register"> | 62 | <div class="account-container register"> |
63 | <div class="content clearfix"> | 63 | <div class="content clearfix"> |
64 | <h2>Mi pida <span class="small" style="float: right;"> Estatus: {{ servicio.idEstatus }}</span></h2> | 64 | <h2>Mi pida <span class="small" style="float: right;"> Estatus: {{ servicio.idEstatus }}</span></h2> |
65 | + | ||
66 | + {% if not caduca %} | ||
67 | + {% form_theme caducidadForm 'bootstrap_3_layout.html.twig' %} | ||
68 | + {{ form_start(caducidadForm) }} | ||
69 | + <div class="row"> | ||
70 | + <div class="col-lg-5"> | ||
71 | + {{ form_row(caducidadForm.fechaInicio) }} | ||
72 | + </div> | ||
73 | + <div class="col-lg-5"> | ||
74 | + {{ form_row(caducidadForm.fechaFinal) }} | ||
75 | + </div> | ||
76 | + {% if servicio %} | ||
77 | + <div class="col-lg-2"> | ||
78 | + <button type="submit"> Asignar</button> | ||
79 | + </div> | ||
80 | + {% endif %} | ||
81 | + </div> | ||
82 | + {{ form_end(caducidadForm) }} | ||
83 | + {% else %} | ||
84 | + PIDA válido desde: {{ caduca.fechaInicio | date('d-m-Y')}} hasta: {{ caduca.fechaFinal | date('m-d-Y') }}. vigencia de ( {% if caducaAnos > 0 %} %} y {{ caducaAnos }} años {% endif %}{{ caducaMeses }} meses con {{ caducaDias }} días ) | ||
85 | + | ||
86 | + {% endif %} | ||
65 | <table class="table table-bordered"> | 87 | <table class="table table-bordered"> |
66 | <th>Objetivo Histórico</th> | 88 | <th>Objetivo Histórico</th> |
67 | <th>Actividad Docente</th> | 89 | <th>Actividad Docente</th> |
src/AppBundle/Controller/AdscripcionController.php
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | namespace AppBundle\Controller; | 9 | namespace AppBundle\Controller; |
10 | 10 | ||
11 | use AppBundle\Entity\DocumentosVerificados; | 11 | use AppBundle\Entity\DocumentosVerificados; |
12 | +use AppBundle\Entity\PidaCaducidad; | ||
12 | use AppBundle\Entity\PidaEstatus; | 13 | use AppBundle\Entity\PidaEstatus; |
13 | use AppBundle\Entity\PidaTareaEspecifico; | 14 | use AppBundle\Entity\PidaTareaEspecifico; |
14 | use AppBundle\Form\PidaTareaEspecificoType; | 15 | use AppBundle\Form\PidaTareaEspecificoType; |
@@ -549,13 +550,44 @@ class AdscripcionController extends Controller | @@ -549,13 +550,44 @@ class AdscripcionController extends Controller | ||
549 | 550 | ||
550 | } | 551 | } |
551 | 552 | ||
553 | + $caducidad = new PidaCaducidad(); | ||
554 | + $caducidadForm = $this->createForm('AppBundle\Form\PidaCaducidadType', $caducidad); | ||
555 | + $caducidadForm->handleRequest($request); | ||
556 | + $days = $months = $years = 0; | ||
557 | + if(!$this->getDoctrine()->getRepository("AppBundle:PidaCaducidad")->findOneByidDocenteServicio($serv)) { | ||
558 | + $caduca = false; | ||
559 | + }else{ | ||
560 | + $caduca = $this->getDoctrine()->getRepository("AppBundle:PidaCaducidad")->findOneByidDocenteServicio($serv); | ||
561 | + $interval = $caduca->getFechaInicio()->diff($caduca->getFechaFinal()); | ||
562 | + $years = $interval->format('%y'); | ||
563 | + $months = $interval->format('%m'); | ||
564 | + $days = $interval->format('%d'); | ||
565 | + } | ||
566 | + | ||
567 | + | ||
568 | + if ($caducidadForm->isSubmitted() && $caducidadForm->isValid()) { | ||
569 | + //var_dump($estatusPida->getNombre()->getNombre()); die; | ||
570 | + $caducidad->setIdDocenteServicio($serv); | ||
571 | + $em->persist($caducidad); | ||
572 | + | ||
573 | + $em->flush(); | ||
574 | + | ||
575 | + return $this->redirectToRoute('solicitud_pida'); | ||
576 | + | ||
577 | + } | ||
552 | 578 | ||
553 | return $this->render('solicitudes/pida.html.twig', array( | 579 | return $this->render('solicitudes/pida.html.twig', array( |
554 | 'form' => $form->createView(), | 580 | 'form' => $form->createView(), |
555 | 'pida' => $pid, | 581 | 'pida' => $pid, |
556 | 'servicio' => $serv, | 582 | 'servicio' => $serv, |
557 | 'editForm' => $editForm->createView(), | 583 | 'editForm' => $editForm->createView(), |
558 | - 'estatusForm' => $Estatusform->createView() | 584 | + 'estatusForm' => $Estatusform->createView(), |
585 | + 'caduca' => $caduca, | ||
586 | + 'caducidad' => $caducidad, | ||
587 | + 'caducaAnos' => $years, | ||
588 | + 'caducaMeses' => $months, | ||
589 | + 'caducaDias' => $days, | ||
590 | + 'caducidadForm' => $caducidadForm->createView() | ||
559 | )); | 591 | )); |
560 | 592 | ||
561 | 593 |
src/AppBundle/Form/PidaCaducidadType.php
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +<?php | ||
2 | + | ||
3 | +namespace AppBundle\Form; | ||
4 | + | ||
5 | +use Symfony\Component\Form\AbstractType; | ||
6 | +use Symfony\Component\Form\Extension\Core\Type\DateTimeType; | ||
7 | +use Symfony\Component\Form\Extension\Core\Type\DateType; | ||
8 | +use Symfony\Component\Form\FormBuilderInterface; | ||
9 | +use Symfony\Component\OptionsResolver\OptionsResolver; | ||
10 | +use Symfony\Component\Validator\Constraints\Date; | ||
11 | +use Symfony\Component\Validator\Constraints\NotBlank; | ||
12 | + | ||
13 | +class PidaCaducidadType extends AbstractType | ||
14 | +{ | ||
15 | + /** | ||
16 | + * @param FormBuilderInterface $builder | ||
17 | + * @param array $options | ||
18 | + */ | ||
19 | + public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | + { | ||
21 | + $builder | ||
22 | + ->add('fechaInicio',DateType::class, array( | ||
23 | + 'widget' => 'choice', | ||
24 | + 'label' => 'Pida inicia desde', | ||
25 | + 'label_attr' => array('class' => 'form-group'), | ||
26 | + 'years' => range(date("Y")-4, date("Y")), | ||
27 | + 'placeholder' => array( | ||
28 | + 'year' => 'Año', 'month' => 'Mes', 'day' => 'Día', | ||
29 | + ), | ||
30 | + 'constraints' => array( | ||
31 | + new NotBlank(), | ||
32 | + new Date() | ||
33 | + ) | ||
34 | + )) | ||
35 | + ->add('fechaFinal',DateType::class, array( | ||
36 | + 'widget' => 'choice', | ||
37 | + 'label' => 'Pida inicia desde', | ||
38 | + 'label_attr' => array('class' => 'form-group'), | ||
39 | + 'years' => range(date("Y")-4, date("Y")+4), | ||
40 | + 'placeholder' => array( | ||
41 | + 'year' => 'Año', 'month' => 'Mes', 'day' => 'Día', | ||
42 | + ), | ||
43 | + 'constraints' => array( | ||
44 | + new NotBlank(), | ||
45 | + new Date() | ||
46 | + ) | ||
47 | + )) | ||
48 | + ; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * @param OptionsResolver $resolver | ||
53 | + */ | ||
54 | + public function configureOptions(OptionsResolver $resolver) | ||
55 | + { | ||
56 | + $resolver->setDefaults(array( | ||
57 | + 'data_class' => 'AppBundle\Entity\PidaCaducidad' | ||
58 | + )); | ||
59 | + } | ||
60 | +} |