templates/prog_solicitud/programado.html.twig line 1

Open in your IDE?
  1. {# Plantilla de Twig #}
  2. {% block stylesheets %}
  3.     <link rel="stylesheet" href="{{ asset('plugins/toastr/toastr.min.css') }}">
  4. {% endblock %}
  5. <!-- Modal with form -->
  6. <!-- div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true" -->
  7. <div class="modal-dialog modal-xl" role="document">
  8.     <div class="modal-content p-4">
  9.         <div class="modal-header">
  10.             <h5 class="modal-title" id="exampleModalLabel"><b>Solicitudes programadas</b> <b><span class="text-success">{% if info is defined %} {{ info.tipoEquipo }} {% endif %}</span></b><small>Mantenimiento {% if info is defined %} {{ info.tipoMantenimiento }} {% endif %}</small></h5>
  11.             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  12.                 <span aria-hidden="true">&times;</span>
  13.             </button>
  14.         </div>
  15.         <div class="modal-body">
  16.             <div class="table-responsive">
  17.                 <table class="table table-hover">
  18.                     <thead>
  19.                     <tr>
  20.                         <th>Usuario</th>
  21.                         <th>Equipo</th>
  22.                     </tr>
  23.                     </thead>
  24.                     <tbody>
  25.                         <tr>
  26.                         {% if solicitud[0] is defined %}
  27.                             <td>{{solicitud[0].u_nombre}} {{solicitud[0].u_papellido}} {{solicitud[0].u_sapellido}}</td>
  28.                             <td>Marbete: <b>{{solicitud[0].marbete}}</b></br>Descripción: <b>{{solicitud[0].descripcion}}</b></br>Marca: <b>{{solicitud[0].marca}}</b></br>Modelo: <b>{{solicitud[0].modelo}}</b></br>Ubicación: <b>{{solicitud[0].n_ubicacion}}</b></br>Unidad Administrativa: <b>{{solicitud[0].n_unidad}}</b></td>
  29.                         {% endif %}
  30.                         </tr>
  31.                     </tbody>
  32.                 </table>
  33.             </div>
  34.             <div class="table-responsive">
  35.                 <form id="form-editar-solicitud">
  36.                     <table class="table table-hover">
  37.                         <thead>
  38.                         <tr>
  39.                             <th>Id. Solicitud</th>
  40.                             <th>Fecha de registro</th>
  41.                             <th>Fecha de atención</th>
  42.                             <th>Acción a realizar</th>
  43.                             <th>Tipo de mantenimiento</th>
  44.                             <th>Estatus</th>
  45.                             <th>Accion</th>
  46.                         </tr>
  47.                         </thead>
  48.                         <tbody>
  49.                         {% for s in solicitud %}
  50.                             <tr id="modal-table-{{ s.id_sol }}">
  51.                                 <th>{{ s.id_sol }}</th>
  52.                                 <td class="fregistro">
  53.                                     {% if s.fregistro != "" %}
  54.                                         {{ s.fregistro|format_datetime('medium', 'none', locale='es') }}
  55.                                     {% endif %}
  56.                                 </td>
  57.                                 <td>
  58.                                     {% if s.fatencion != "" %}
  59.                                         {{ s.fatencion|format_datetime('medium', 'none', locale='es') }}
  60.                                     {% endif %}
  61.                                 </td>
  62.                                 <td class="falla">{{ s.falla }}</td>
  63.                                 <td>
  64.                                     {% if s.tipo_mantenimiento == "MP" %}
  65.                                         Preventivo
  66.                                     {% endif %}
  67.                                     {% if s.tipo_mantenimiento == "MC" %}
  68.                                         Correctivo
  69.                                     {% endif %}
  70.                                 </td>
  71.                                 <td>
  72.                                     {% if s.estatus == 1 %}
  73.                                         <div class="badge bg-gradient-warning text-white" style="width: 6rem;">Pendiente</div>
  74.                                     {% elseif s.estatus == 2 %}
  75.                                         <div class="badge bg-gradient-danger" style="width: 6rem;">En proceso</div>
  76.                                     {% elseif s.estatus == 3 %}
  77.                                         <div class="badge bg-gradient-primary" style="width: 6rem;">Atendido</div>
  78.                                     {% elseif s.estatus == 4 %}
  79.                                         <div class="badge bg-gradient-success" style="width: 6rem;">Evaluado</div>
  80.                                     {% endif %}
  81.                                 </td>
  82.                                 <td>
  83.                                     {% if s.fregistro > date('-15days') %}
  84.                                         {# do something #}
  85.                                         {% if s is defined %}
  86.                                             {% if info.tipo_mantenimiento == 'Preventivo' %}
  87.                                                 <a class="text-success" data-toggle="collapse" data-target="#collapseExample-{{ s.id_sol }}" role="button" aria-expanded="false" aria-controls="collapseExample-{{s.id_sol}}">
  88.                                                     <i class="fa fa-calendar" data-toggle="tooltip" title="Reprogramar mantenimiento"></i>
  89.                                                 </a>
  90.                                             {% endif %}
  91.                                             {% if info.tipo_mantenimiento == 'Correctivo' %}
  92.                                                 <a href="{{ path('prog_correctivo_evaluacion', {'idSol': s.id_sol}) }}">
  93.                                                     <i class="fa fa-check-circle text-primary" data-toggle="tooltip" title="Evaluar mantenimiento"></i>
  94.                                                 </a>
  95.                                             {% endif %}
  96.                                         {% endif %}
  97.                                     {% endif %}
  98.                                 </td>
  99.                             </tr>
  100.                             <tr class="collapse" id="collapseExample-{{ s.id_sol }}">
  101.                                 <th colspan="6">
  102.                                     <label for="">Acción a realizar</label>
  103.                                     <input type="textarea" class="form-control" name="{{ s.id_sol }}-falla" value="{{ s.falla }}" required />
  104.                                     <label for="">Fecha de atención</label>
  105.                                     <input type="date" class="form-control" name="{{ s.id_sol }}-fregistro" value="{{ s.fatencion|date('Y-m-d') }}" required />
  106.                                 </th>
  107.                                 <th>
  108.                                     <button type="button" class="btn btn-primary pull-right" id="actualizar-solicitud-{{ s.id_sol }}" onclick="solicitudReprogramar('{{ path('prog_preventivo_reprogramar', {'id': s.id_sol}) }}', {{ s.id_sol }})">Actualizar</button>
  109.                                 </th>
  110.                             </tr>
  111.                         {% else %}
  112.                             <tr>
  113.                                 <th class="text-center" colspan="7">No existen registros de servicios programados</th>
  114.                             </tr>
  115.                         {% endfor %}
  116.                         </tbody>
  117.                     </table>
  118.                 </form>
  119.             </div>
  120.         </div>
  121.         <div class="modal-footer">
  122.             <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
  123.         </div>
  124.     </div>
  125. </div>
  126. <!-- /div -->
  127. {% block javascripts %}
  128.     <script src="{{ asset('plugins/toastr/toastr.min.js') }}"></script>
  129.     <script type="text/javascript">
  130.         function solicitudReprogramar(url, id){
  131.             let send = $("#actualizar-solicitud-" + id);
  132.             let formData = new FormData(document.getElementById("form-editar-solicitud"));
  133.             $.ajax({
  134.                 type: "POST",
  135.                 url: url,
  136.                 data: formData, // Adjuntar los campos del formulario enviado.
  137.                 dataType: "html",
  138.                 cache: false,
  139.                 contentType: false,
  140.                 processData: false,
  141.                 beforeSend: function () {
  142.                     send.text(""); // Para input de tipo button
  143.                     send.append("<i class='fa fa-spinner fa-spin' style='font-size:16px'></i>");
  144.                     send.prop("disabled", true);
  145.                 },
  146.                 success: function (data) {
  147.                     let datos = jQuery.parseJSON(data);
  148.                     console.log(datos.mensaje);
  149.                     $(document).Toasts('create', {
  150.                         autohide: true,
  151.                         delay: 5000,
  152.                         class: 'bg-success',
  153.                         title: 'Edición de programación',
  154.                         subtitle: 'Éxito',
  155.                         body: datos.mensaje
  156.                     });
  157.                     let row = $('#modal-table-' + datos.idsol);
  158.                     row.find('.falla').html('<p class="text-primary"><b>' + datos.falla + '</b></p>');
  159.                     /*row.find('.fregistro').html('<p class="text-primary"><b>' + datos.fregistro + '</b></p>');*/
  160.                 },
  161.                 error: function (data, text, error) {
  162.                 },
  163.                 complete: function () {
  164.                     setTimeout(function(){
  165.                         send.text("Actualizar"); // Para input de tipo button
  166.                         send.append("<i></i>");
  167.                         send.prop("disabled", false);
  168.                     }, 5000);
  169.                 }
  170.             });
  171.             return false; // Evitar ejecutar el submit del formulario.
  172.         }
  173.     </script>
  174. {% endblock %}