Commit 710fe7d4000e173533ef11b7909648b64ff7fa76

Authored by Wilmer Ramones
1 parent c23d5dc948
Exists in master

creada la solicitudes ajax para ver las solicitudes en espera y corregido el bug…

… al solicitar ascenso daba error al no actualizar el estatus
app/Resources/views/base_app.html.twig
... ... @@ -110,7 +110,7 @@
110 110  
111 111  
112 112 <li class="dropdown"><a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown">
113   - <i class="fa fa-group"></i><span>Solicitudes</span> <b class="caret"></b></a>
  113 + <i class="fa fa-group"><span class="badge" id="contador_solicitudes"></span></i><span>Solicitudes</span> <b class="caret"></b></a>
114 114 <ul class="dropdown-menu">
115 115 <li> <a data-toggle="modal" data-target="#buscarServicios">Buscar Servicios</a></li>
116 116 <li><a href="{{ path('cea_servicios', {'tipo' : 'antiguedad'})}}">En espera de Aprobación</a></li>
... ... @@ -141,6 +141,55 @@
141 141 {% block javascripts %}
142 142 <script type="text/javascript" src="{{ asset('assets/vendor/jquery/dist/jquery.min.js') }}"></script>
143 143 <script type="text/javascript" src="{{ asset('assets/vendor/bootstrap/dist/js/bootstrap.min.js') }}" ></script>
  144 +
  145 + <script>
  146 +
  147 + function waitForMsg() {
  148 +
  149 +
  150 +
  151 + $.ajax({
  152 + method: "GET",
  153 + url: "{{ url('ajax_contador_solicitudes') }}",
  154 + async: true,
  155 + cache: false,
  156 + timeout: 50000,
  157 + success: function (data) {
  158 +
  159 + var posts = JSON.parse(data.posts);
  160 + console.log(posts);
  161 + /*if(posts.length > 0)
  162 + {
  163 + var html = "";
  164 + for(d in posts)
  165 + {
  166 + html += "<p>" + JSON.stringify(posts[d]) + "</p>";
  167 + }
  168 + $("#contador_solicitudes").append(html);
  169 + }*/
  170 + $("#contador_solicitudes").html(posts);
  171 + setTimeout(waitForMsg, 10000);
  172 + },
  173 + error: function (XMLHttpRequest, textStatus, errorThrown) {
  174 + console.log(errorThrown);
  175 + setTimeout(waitForMsg, 15000);
  176 +
  177 + }
  178 +
  179 + });
  180 +
  181 + };
  182 +
  183 +
  184 +
  185 + $(document).ready(function () {
  186 +
  187 + waitForMsg();
  188 +
  189 + });
  190 +
  191 +</script>
  192 +
144 193 {% endblock %}
145 194  
146 195  
... ...
src/AppBundle/Controller/AjaxController.php
... ... @@ -0,0 +1,60 @@
  1 +<?php
  2 +
  3 +/*
  4 + * To change this license header, choose License Headers in Project Properties.
  5 + * To change this template file, choose Tools | Templates
  6 + * and open the template in the editor.
  7 + */
  8 +
  9 +namespace AppBundle\Controller;
  10 +use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  11 +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  12 +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  13 +use Symfony\Component\HttpFoundation\JsonResponse;
  14 +
  15 +use Symfony\Component\Serializer\Serializer;
  16 +use Symfony\Component\Serializer\Encoder\XmlEncoder;
  17 +use Symfony\Component\Serializer\Encoder\JsonEncoder;
  18 +use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  19 +use Symfony\Component\HttpFoundation\Request;
  20 +
  21 +
  22 +
  23 +/**
  24 + * Description of AjaxController
  25 + *
  26 + * @author ubv-cipee
  27 + *
  28 + *
  29 + */
  30 +
  31 +class AjaxController extends Controller {
  32 +
  33 + /**
  34 + * @Route("/ajax/contador_solicitudes", name="ajax_contador_solicitudes")
  35 + * @Method({"GET"})
  36 + */
  37 + public function contadorAction(Request $request){
  38 + if($request->isXmlHttpRequest()){
  39 + $encoders = array(new JsonEncoder());
  40 + $normalizers = array(new ObjectNormalizer());
  41 +
  42 + $serializer = new Serializer($normalizers, $encoders);
  43 +
  44 + $em = $this->getDoctrine()->getManager();
  45 + $posts = $em->getRepository('AppBundle:DocenteServicio')->findBy(array(
  46 + 'idEstatus' => 2
  47 + ));
  48 + $cuenta = count($posts);
  49 + $response = new JsonResponse();
  50 + $response->setStatusCode(200);
  51 + $response->setData(array(
  52 + 'response' => 'success',
  53 + 'posts' => $serializer->serialize($cuenta, 'json')
  54 + ));
  55 + return $response;
  56 + }
  57 +
  58 + }
  59 +
  60 +}
... ...
src/AppBundle/Controller/AscensoController.php
... ... @@ -200,13 +200,11 @@ class AscensoController extends Controller
200 200  
201 201 //si ya tiene una solicitud en espera, enviarlo a la pagina de los servicios
202 202 $solicitud = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneBy(
203   - array('idRolInstitucion' => $this->getUser()->getIdRolInstitucion(), 'idServicioCe' => 6)
  203 + array('idRolInstitucion' => $this->getUser()->getIdRolInstitucion(), 'idServicioCe' => 5, 'idEstatus' => 1)
204 204 );
205   - if($solicitud){
206   - if($solicitud->getIdEstatus()->getId() != 4 ){
207   - return $this->redirect($this->generateUrl('servicios_index'));
208   - }
209   - }
  205 +
  206 +
  207 +
210 208  
211 209 $concurso = $this->getDoctrine()->getRepository('AppBundle:Adscripcion')->findOneBy(
212 210 array('idRolInstitucion' => $this->getUser()->getIdRolInstitucion())
... ... @@ -219,6 +217,8 @@ class AscensoController extends Controller
219 217 'idEstatus' => 1
220 218 )
221 219 );
  220 +
  221 +
222 222  
223 223 $form = $this->createForm('AppBundle\Form\ReconocimientoEscalaType');
224 224 $form->handleRequest($request);
... ... @@ -329,6 +329,7 @@ class AscensoController extends Controller
329 329 'idEstatus' => 2
330 330 ));
331 331  
  332 +
332 333 $pida = $this->getDoctrine()->getRepository('AppBundle:AdscripcionPida')->findOneByIdRolInstitucion($servicio->getIdRolInstitucion());
333 334 $antiguedad = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneBy(array(
334 335 'idRolInstitucion' => $this->getUser()->getIdRolInstitucion(),
... ... @@ -494,8 +495,8 @@ class AscensoController extends Controller
494 495 if ($this->get('request')->request->get('tipo') == 2 ){
495 496 $ServicioAscenso = $this->getDoctrine()->getRepository('AppBundle:DocenteServicio')->findOneBy(array(
496 497 'idRolInstitucion' => $this->getUser()->getIdRolInstitucion(),
497   - 'idServicioCe' => 5,
498   - 'idEstatus' => 1
  498 + 'idServicioCe' => 6,
  499 + 'idEstatus' => 2
499 500 ));
500 501  
501 502  
... ...
web/assets/vendor/AppBundle/main.css
... ... @@ -437,4 +437,19 @@ h6.bigstats{
437 437 font-weight: bold;
438 438 color: #545454;
439 439 line-height: 1em;
  440 +}
  441 +
  442 +.badge {
  443 + display: inline;
  444 + min-width: 10px;
  445 + padding: 3px 7px;
  446 + font-size: 10px;
  447 + font-weight: 100;
  448 + line-height: 0;
  449 + color: #fff;
  450 + text-align: center;
  451 + white-space: nowrap;
  452 + vertical-align: middle;
  453 + background-color: #3b8341;
  454 + border-radius: 10px;
440 455 }
441 456 \ No newline at end of file
... ...