Commit 4f04c720caa249e5b4374e0fe44da1c91cf15d62

Authored by Wilmer
1 parent 532c8a5785
Exists in master

pasada la validación y el formulario a syfmony del reconocmiento de Escala

app/Resources/views/cea/reconocimiento_escala_mostrar.html.twig
... ... @@ -123,7 +123,8 @@
123 123 </div>
124 124  
125 125 </div>
126   - <form name="input" action="{{ path('cea_escala_actualizar', { 'id': servicio.id, 'escala': 'escalafones', 'estatus' : 'true' }) }}" method="post">
  126 + {% form_theme form 'bootstrap_3_layout.html.twig' %}
  127 + {{ form_start(form, {'attr': {'novalidate': 'novalidate'}}) }}
127 128 <div class="row">
128 129  
129 130 <div class="col-md-6">
... ... @@ -173,8 +174,18 @@
173 174 <input type="text" value="{{ escalafones }}" readonly />
174 175 <input type="hidden" name="escala" value="{{ escalafones.id }}" />
175 176 {% endif %}
176   - <br><label for="fecha_escala"> Fecha de Escalafón: </label> <input type="date" name="fecha_escala" />
177   - <br><button type="submit" class="btn btn-success btn-sm" ><span class="fa fa-check"></span>&nbsp;Aprobar</button>
  177 + <br>
  178 +
  179 + {{ form_widget(form) }}
  180 +
  181 + {% if servicio.idEstatus.id == 3 %}
  182 + <button class="btn btn-success btn-sm" type="submit" name="aprobado" id="aprobado" ><span class="fa fa-check" ></span>&nbsp;Aprobar</button>
  183 + {% elseif servicio.idEstatus.id == 2 %}
  184 + <button class="btn btn-success btn-sm" type="submit" name="aprobado" id="aprobado" ><span class="fa fa-check" ></span>&nbsp;Aprobar</button>
  185 + <a id="modal_rechazo" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#motivo_rechazo" ><span class="fa fa-close"></span>&nbsp;Rechazar</a>
  186 + {% endif %}
  187 +
  188 +
178 189  
179 190  
180 191 {% endif %}
... ... @@ -182,7 +193,10 @@
182 193 </div>
183 194  
184 195 </div>
185   -
  196 +
  197 +
  198 +
  199 +
186 200 <div class="col-md-5">
187 201 <h3>Documentos Consignados</h3>
188 202 <div class="widget-content">
... ... @@ -229,14 +243,43 @@
229 243 </div>
230 244  
231 245 </div>
  246 +
  247 +
232 248  
233 249  
234 250  
235 251 </div>
236   - </form>
  252 +
  253 +
  254 + <div class="modal fade" id="motivo_rechazo" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  255 + <div class="modal-dialog" role="document">
  256 + <div class="modal-content">
  257 + <div class="modal-header">
  258 + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  259 + <h4 class="modal-title" id="myModalLabel">Rechazo de Solicitud</h4>
  260 + </div>
  261 +
  262 + <div class="modal-body">
  263 +
  264 +
  265 + <div class="form-group">
  266 + <label for="message-text" class="control-label">Mensaje:</label>
  267 + <textarea class="form-control" id="message-text" name="message-text"></textarea>
  268 + </div>
  269 +
  270 + </div>
  271 + <div class="modal-footer">
  272 + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
  273 + <button type="submit" name="rechazar" id="rechazar" class="btn btn-primary">Enviar Rechazo</button>
  274 + </div>
  275 + </div>
  276 +
  277 + </div>
  278 + </div>
237 279 </div>
238 280  
239 281 </div>
  282 + {{ form_end(form) }}
240 283  
241 284 {% endblock %}
242 285  
... ... @@ -244,4 +287,48 @@
244 287 {% block javascripts %}
245 288 {{ parent() }}
246 289 <script type="text/javascript" src="{{ asset('assets/vendor/lightbox2/dist/js/lightbox.min.js') }}"></script>
  290 + <script>
  291 + var buttonpressed;
  292 + $('#aprobado').click(function() {
  293 + //alert("click"); return false;
  294 + buttonpressed = $(this).attr('name')
  295 + });
  296 +
  297 + $('#rechazar').click(function() {
  298 + buttonpressed = $(this).attr('name')
  299 + });
  300 +
  301 +
  302 + $('form').submit(function() {
  303 + console.log($(':radio:checked', this).length);
  304 + for (var i = 0; i < $(':radio:checked', this).length; i ++){
  305 + console.log($(':radio:checked', this)[i]);
  306 + if ( ($(':radio:checked', this)[i].value == "")) {
  307 + alert('Debes revisar todos los documentos para poder enviar la solicitud!');
  308 + $("#aprobado").button('reset');
  309 + return false;
  310 + }
  311 +
  312 + }
  313 +
  314 + if (buttonpressed == "aprobado") {
  315 + for (var i = 0; i < $(':radio:checked', this).length; i++) {
  316 + console.log($(':radio:checked', this)[i]);
  317 + if (($(':radio:checked', this)[i].value == "3")) {
  318 + alert('No puedes aprobar una solicitud con documentos en estatus de rechazado');
  319 + $("#aprobado").button('reset');
  320 + return false;
  321 + }
  322 +
  323 + }
  324 + }
  325 +
  326 +
  327 + });
  328 +
  329 + $('#motivo_rechazo').on('hidden.bs.modal', function (e) {
  330 + $("#modal_rechazo").button('reset');
  331 + $('#rechazar').button('reset');
  332 + })
  333 + </script>
247 334 {% endblock %}
248 335 \ No newline at end of file
... ...
src/AppBundle/Controller/AscensoController.php
... ... @@ -10,6 +10,8 @@ namespace AppBundle\Controller;
10 10  
11 11  
12 12 use AppBundle\Entity\DocumentosVerificados;
  13 +use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
  14 +use Symfony\Component\Form\Extension\Core\Type\DateType;
13 15 use Symfony\Component\Form\FormError;
14 16 use Symfony\Component\HttpFoundation\File\UploadedFile;
15 17 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
... ... @@ -24,6 +26,8 @@ use AppBundle\Entity\TutoresAscenso;
24 26  
25 27 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
26 28 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  29 +use Symfony\Component\Validator\Constraints\Date;
  30 +use Symfony\Component\Validator\Constraints\NotBlank;
27 31  
28 32 class AscensoController extends Controller
29 33 {
... ... @@ -525,10 +529,10 @@ class AscensoController extends Controller
525 529 * Encuentra y muestra una entidad de tipo Adscripción.
526 530 *
527 531 * @Route("/reconocimientoEscala/{id}", name="cea_reconocimientoEscala_show")
528   - * @Method("GET")
  532 + * @Method({"GET", "POST"})
529 533 * @Security("has_role('ROLE_COORDINADOR_REGIONAL')")
530 534 */
531   - public function reconocimientoEscalaShowAction(DocenteServicio $servicio)
  535 + public function reconocimientoEscalaShowAction(DocenteServicio $servicio, Request $request)
532 536 {
533 537 $em = $this->getDoctrine()->getManager();
534 538 $docente = $em->getRepository("AppBundle:RolInstitucion")->findOneById($servicio->getIdRolInstitucion()->getId());
... ... @@ -552,9 +556,81 @@ class AscensoController extends Controller
552 556 }else{
553 557 $escalafones = $this->getDoctrine()->getRepository('AppBundle:Escalafones')->findOneById($ascenso->getIdEscalafones()->getId());
554 558 }
555   -
556   -
557   -
  559 +
  560 +
  561 + $form = $this->createFormBuilder()
  562 +
  563 + ->add('fechaAscenso', BirthdayType::class, array(
  564 + 'widget' => 'choice',
  565 + 'label' => 'Fecha de Ascenso',
  566 + 'years' => range(2003, date("Y")),
  567 + 'placeholder' => array(
  568 + 'year' => 'Año', 'month' => 'Mes', 'day' => 'Día',
  569 + ),
  570 + 'constraints' => array(
  571 + new NotBlank(),
  572 + new Date()
  573 + )
  574 + ))
  575 + ->getForm();
  576 + $form->handleRequest($request);
  577 +
  578 + if($form->isSubmitted() && $form->isValid()){
  579 + $parametros = $request->request->all();
  580 + $verificado = $this->getDoctrine()->getRepository("AppBundle:DocumentosVerificados")->findOneByIdServicio($servicio);
  581 + $ServicioAscenso = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneBy(array(
  582 + 'idRolInstitucion' => $servicio->getIdRolInstitucion(),
  583 + 'idServicioCe' => 5,
  584 + 'idEstatus' => 1
  585 + ));
  586 +
  587 +
  588 + $ascenso = $this->getDoctrine()->getRepository('AppBundle:Ascenso')->findOneBy(array(
  589 + 'idRolInstitucion' => $servicio->getIdRolInstitucion(),
  590 + 'idEstatus' => 1
  591 + ));
  592 + if(isset($parametros['aprobado'])) {
  593 + $verificado->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(1));
  594 + $escala_docente = new DocenteEscala();
  595 + $escala_docente->setIdRolInstitucion($servicio->getIdRolInstitucion());
  596 + $escala_docente->setidEscala($this->getDoctrine()->getRepository('AppBundle:Escalafones')->findOneById($this->get('request')->request->get('escala')));
  597 + $escala_docente->setFechaEscala(new \DateTime($this->get('request')->request->get('fecha_escala')));
  598 + $escala_docente->setIdTipoEscala($this->getDoctrine()->getRepository('AppBundle:TipoAscenso')->findOneById($this->get('request')->request->get('tipo')));
  599 + $em->persist($escala_docente);
  600 +
  601 +
  602 + $servicio->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(4));
  603 +
  604 +
  605 + $ServicioAscenso->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(4));
  606 + $ascenso->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(4));
  607 +
  608 + }else{
  609 + //$mensaje = $request->request->get('message-text');
  610 + $verificado->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(3));
  611 + $servicio->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(3));
  612 + $ascenso = $this->getDoctrine()->getRepository('AppBundle:Ascenso')->findOneBy(array(
  613 + 'idRolInstitucion' => $servicio->getIdRolInstitucion(),
  614 + 'idEstatus' => 1
  615 + ));
  616 +
  617 + $servicio->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(3));
  618 +
  619 +
  620 + $ServicioAscenso->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(4));
  621 + $ascenso->setIdEstatus($this->getDoctrine()->getRepository('AppBundle:Estatus')->findOneById(4));
  622 + }
  623 +
  624 + $em->persist($ServicioAscenso);
  625 + $em->persist($ascenso);
  626 + $em->persist($verificado);
  627 + $em->flush();
  628 + $this->addFlash('success', 'Escala Agregada Satisfactoriamente');
  629 + return $this->redirect($this->generateUrl('cea_index'));
  630 +
  631 + }
  632 +
  633 +
558 634 return $this->render('cea/reconocimiento_escala_mostrar.html.twig', array(
559 635 'ascenso' => $ascenso,
560 636 'adscripcion' => $adscripcion,
... ... @@ -562,7 +638,8 @@ class AscensoController extends Controller
562 638 'escalas' => $escala,
563 639 'pida' => $pida,
564 640 'escalafones' => $escalafones,
565   - 'docente' => $docente
  641 + 'docente' => $docente,
  642 + 'form' => $form->createView()
566 643  
567 644 ));
568 645 }
... ...