templates/equipo/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% form_theme form 'bootstrap_4_layout.html.twig' %}
  3. {% block stylesheets %}
  4.     <link rel="stylesheet" href="{{ asset('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css') }}">
  5.     <link rel="stylesheet" href="{{ asset('plugins/datatables-responsive/css/responsive.bootstrap4.min.css') }}">
  6.     <link rel="stylesheet" href="{{ asset('plugins/datatables-buttons/css/buttons.bootstrap4.min.css')}}">
  7.     <link rel="stylesheet" href="{{ asset('plugins/toastr/toastr.min.css') }}">
  8.     <style>
  9.         td.descripcion {
  10.             max-width: 300px !important;
  11.             text-overflow: ellipsis;
  12.             white-space: nowrap;
  13.             overflow: hidden;
  14.         }
  15.         label {
  16.             margin-right: 1rem;
  17.         }
  18.     </style>
  19. {% endblock %}
  20. {% block title %} - Eq. cómputo{% endblock %}
  21. {% block body %}
  22.     <div class="content-wrapper">
  23.         <!-- Content Header (Page header) -->
  24.         <section class="content-header">
  25.             <div class="card">
  26.                 <div class="card-header">
  27.                     <h1 class="card-title">Equipos de Cómputo</h1>
  28.                     <div class="card-tools">
  29.                         <ol class="breadcrumb float-sm-right">
  30.                             <li class="breadcrumb-item">Inicio</li>
  31.                             <li class="breadcrumb-item active">Equipos</li>
  32.                         </ol>
  33.                     </div>
  34.                 </div>
  35.             </div>
  36.         </section>
  37.         <!-- Main content -->
  38.         <section class="content">
  39.             <!-- Default box -->
  40.             <div class="card">
  41.                 {% if not unidadActiva and (rol == 3 or rol == 4) %}
  42.                     <div class="alert alert-warning alert-dismissible fade show" role="alert">
  43.                         En este momento no tiene privilegios para editar sus inventarios, si lo requiere, por favor solicítelo al Administrador.
  44.                         <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  45.                             <span aria-hidden="true">&times;</span>
  46.                         </button>
  47.                     </div>
  48.                 {% endif %}
  49.                 <div class="card-header">
  50.                     <div class="row">
  51.                         {{ form_start(form, {'attr': {'class': 'form-inline col-md-auto', 'id': 'form_unidad_filtro'}}) }}
  52.                         {{ form_row(form.filtro) }}
  53.                         {% if form.unidad is defined %}
  54.                             {{ form_row(form.unidad) }}
  55.                         {% endif %}
  56.                         {{ form_end(form) }}
  57.                         <a href="#" id="enviar" style = 'margin-left: 20px;' class="btn bg-blue mr-2">Aplicar filtro</a>
  58.                         <div class="col text-right">
  59.                             <button id="descargar_excel" type="button" class="btn btn-outline-success mr-2" onclick="descargarExcel()">
  60.                                 <i class="fas fa-file-excel mr-2"></i> Descargar
  61.                             </button>
  62.                             <button id="descargar_pdf" type="button" class="btn btn-outline-danger mr-2" onclick="descargarPDF()">
  63.                                 <i class="fas fa-file-pdf mr-2"></i> Formato CE-1
  64.                             </button>
  65.                             {% if nivel == 1 and unidadActiva %}
  66.                                 <a href="{{ path('app_equipo_new') }}" class="btn btn-outline-success">
  67.                                     <i class="fas fa-plus-circle mr-2"></i> Agregar
  68.                                 </a>
  69.                                 {# <a href="{{ path('app_upload_equipo_excel') }}" class="btn btn-outline-success">
  70.                                 <i class="fas fa-plus-circle mr-2"></i> Agregar equipos
  71.                             </a> #}
  72.                             {% endif %}
  73.                         </div>
  74.                     </div>
  75.                 </div>
  76.                 <div class="card-body">
  77.                     <table class="table table-striped w-100" id="table-equipo">
  78.                         <thead>
  79.                         <tr>
  80.                             <th>Marbete</th>
  81.                             <th>Descripción</th>
  82.                             <th>Marca</th>
  83.                             <th>Modelo</th>
  84.                             <th>Uso</th>
  85.                             <th>Estatus</th>
  86.                             <th>Emhv</th>
  87.                             <th>Unidad</th>
  88.                             <th>Usuario</th>
  89.                             <th>Ubicación</th>
  90.                             <th>Acciones</th>
  91.                         </tr>
  92.                         </thead>
  93.                         <tbody>
  94.                         {% set filteredEquipos = equipos|filter(equipo => equipo.estatus != 5) %}
  95.                         {% if filteredEquipos is not empty %}
  96.                             {% for equipo in filteredEquipos %}
  97.                                 <tr id="idEqu-{{ equipo.idEqu }}">
  98.                                     <td class="marbete">{{ equipo.marbete }}</td>
  99.                                     <td class="descripcion">{{ equipo.descripcion }}</td>
  100.                                     <td class="marca">{{ equipo.marca }}</td>
  101.                                     <td class="modelo">{{ equipo.modelo }}</td>
  102.                                     <td class="uso">
  103.                                         {% if equipo.uso == 1 %}
  104.                                             <span>Educativo</span>
  105.                                         {% elseif equipo.uso == 2 %}
  106.                                             <span>Docente</span>
  107.                                         {% elseif equipo.uso == 3 %}
  108.                                             <span>Administrativo</span>
  109.                                         {% endif %}
  110.                                     </td>
  111.                                     <td class="estatus">
  112.                                         {% if equipo.estatus == 1 %}
  113.                                             <span class="badge bg-gradient-green d-block">En operación</span>
  114.                                         {% elseif equipo.estatus == 2 %}
  115.                                             <span class="badge bg-gradient-orange d-block">Descompuesto</span>
  116.                                         {% elseif equipo.estatus == 3 %}
  117.                                             <span class="badge bg-gradient-primary d-block">Sin instalar</span>
  118.                                         {% elseif equipo.estatus == 4 %}
  119.                                             <span class="badge bg-gradient-yellow d-block">En proceso de baja</span>
  120.                                         {% elseif equipo.estatus == 5 %}
  121.                                             <span class="badge bg-gradient-danger d-block">Baja</span>
  122.                                         {% endif %}
  123.                                     </td>
  124.                                     <td class="emhv">
  125.                                         {% if equipo.emhv == 1 %}
  126.                                             <span class="badge bg-gradient-green d-block">Cumple</span>
  127.                                         {% elseif equipo.emhv == 0 %}
  128.                                             <span class="badge bg-gradient-orange d-block">No Cumple</span>
  129.                                         {% endif %}
  130.                                     </td>
  131.                                     <td class="unidad">{{ equipo.unidad.nombre }}</td>
  132.                                     <td class="usuario">{% if equipo.usuario.nombre is defined %}{{ equipo.usuario.nombre }} {{ equipo.usuario.papellido }} {{ equipo.usuario.sapellido }}{% endif %}</td>
  133.                                     <td class="ubicacion">{{ equipo.unidad.idUni|slice(3, 3) }} - {{ equipo.ubicacion}}</td> {# area #}
  134.                                     <td class="text-right">
  135.                                         {# <button class="btn btn-sm" style="background-color: transparent; border: none;" onclick="descargarPDF1('{{ equipo.idEqu }}')">
  136.                                             <i class="fas fa-file-pdf" style="color: red;">dpdf</i>
  137.                                         </button>
  138.                                         | #}
  139.                                         <!-- Botón para descargar PDF de resguardatario -->
  140.                                         <a href="#" onclick="postPdfRequest('{{ equipo.idEqu }}'); return false;" title="Generar resguardatario">
  141.                                             <i class="fas fa-file-pdf mr-2"></i>
  142.                                         </a>
  143.                                         &nbsp;
  144.                                         <a href="javascript: void(0)" data-id="{{ equipo.idEqu }}" class="btn-redirect" title="Ver equipo"><i class="fas fa-eye"></i></a>
  145.                                         {% if nivel in [1, 2] and unidadActiva%}
  146.                                             &nbsp;&nbsp;
  147.                                             <a href="#editar-equipo" onclick="editarInfoEquipo('{{ path('app_equipo_edit', {'idEqu': equipo.idEqu}) }}')" data-toggle="modal" title="Editar equipo"><i class="fas fa-pen"></i></a>
  148.                                             {# &nbsp;&nbsp;
  149.                                             <a href="#editar-equiporefaccion" onclick="editarInfoEquipoRefaccion('{{ path('app_equipo_editrefaccion', {'idEqu': equipo.idEqu}) }}')" data-toggle="modal" title="Agregar refacción"><i class="fas fa-solid fa-business-time"></i></a> #}
  150.                                         {% endif %}
  151.                                         {% if nivel in [1, 2] and not unidadActiva%}
  152.                                             &nbsp;&nbsp;
  153.                                             <a href="#editar-equiporesguardo" onclick="editarInfoEquipoResguardo('{{ path('app_equipo_edit_resguardo', {'idEqu': equipo.idEqu}) }}')" data-toggle="modal" title="Editar equipo"><i class="fas fa-pen"></i></a>
  154.                                         {% endif %}
  155.                                         {% if nivel in [2] %}
  156.                                             &nbsp;&nbsp;
  157.                                             <!-- Botón para mostrar el modal de confirmación -->
  158.                                             <button type="button" onclick="confirmDelete('{{ path('app_equipo_delete', {'idEqu': equipo.idEqu}) }}', '{{ csrf_token('delete' ~ equipo.idEqu) }}')" class="btn btn-link text-danger p-0" title="Eliminar equipo">
  159.                                                 <i class="fas fa-trash-alt"></i>
  160.                                             </button>
  161.                                         {% endif %}
  162.                                     </td>
  163.                                 </tr>
  164.                             {% endfor %}
  165.                         {% else %}
  166.                             <tr>
  167.                                 <td colspan="11" class="text-center">Ningún dato disponible en esta tabla</td>
  168.                                 <td style="display: none;"></td>
  169.                                 <td style="display: none;"></td>
  170.                                 <td style="display: none;"></td>
  171.                                 <td style="display: none;"></td>
  172.                                 <td style="display: none;"></td>
  173.                                 <td style="display: none;"></td>
  174.                                 <td style="display: none;"></td>
  175.                                 <td style="display: none;"></td>
  176.                                 <td style="display: none;"></td>
  177.                                 <td style="display: none;"></td>
  178.                             </tr>
  179.                         {% endif %}
  180.                         </tbody>
  181.                     </table>
  182.                 </div>
  183.                 <!-- /.card-body -->
  184.             </div>
  185.             <!-- /.card -->
  186.         </section>
  187.         <!-- /.content -->
  188.     </div>
  189.     <div class="modal fade" id="confirmDeleteModal" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteModalLabel" aria-hidden="true">
  190.         <div class="modal-dialog" role="document">
  191.             <div class="modal-content">
  192.                 <div class="modal-header">
  193.                     <h5 class="modal-title" id="confirmDeleteModalLabel">Confirmar Eliminación</h5>
  194.                     <button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
  195.                         <span aria-hidden="true">&times;</span>
  196.                     </button>
  197.                 </div>
  198.                 <div class="modal-body">
  199.                     ¿Estás seguro de que deseas eliminar este registro?
  200.                 </div>
  201.                 <div class="modal-footer">
  202.                     <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>
  203.                     <!-- Botón para confirmar eliminación -->
  204.                     <form id="deleteForm" method="post">
  205.                         <input type="hidden" name="_token" id="csrfToken" value="">
  206.                         <button type="submit" class="btn btn-danger">Eliminar</button>
  207.                     </form>
  208.                 </div>
  209.             </div>
  210.         </div>
  211.     </div>
  212.     <div class="modal hide" id="editar-equipo"></div>
  213.     <div class="modal hide" id="editar-equiporefaccion"></div>
  214.     <div class="modal hide" id="editar-equiporesguardo"></div>
  215. {% endblock %}
  216. {% block javascripts %}
  217.     <script src="{{ asset('plugins/datatables/jquery.dataTables.min.js') }}"></script>
  218.     <script src="{{ asset('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js') }}"></script>
  219.     <script src="{{ asset('plugins/datatables-responsive/js/dataTables.responsive.min.js') }}"></script>
  220.     <script src="{{ asset('plugins/datatables-responsive/js/responsive.bootstrap4.min.js') }}"></script>
  221.     <script src="{{ asset('plugins/datatables-buttons/js/dataTables.buttons.min.js') }}"></script>
  222.     <script src="{{ asset('plugins/datatables-buttons/js/buttons.bootstrap4.min.js') }}"></script>
  223.     <script src="{{ asset('plugins/jszip/jszip.min.js') }}"></script>
  224.     <script src="{{ asset('plugins/pdfmake/pdfmake.min.js') }}"></script>
  225.     <script src="{{ asset('plugins/pdfmake/vfs_fonts.js') }}"></script>
  226.     <script src="{{ asset('plugins/datatables-buttons/js/buttons.html5.min.js') }}"></script>
  227.     <script src="{{ asset('plugins/datatables-buttons/js/buttons.print.min.js') }}"></script>
  228.     <script src="{{ asset('plugins/datatables-buttons/js/buttons.colVis.min.js') }}"></script>
  229.     <script src="{{ asset('plugins/toastr/toastr.min.js') }}"></script>
  230.     <script src="https://cdn.jsdelivr.net/gh/mgalante/jquery.redirect@master/jquery.redirect.js"></script>
  231.     <script type="text/javascript">
  232.         // Menu lateral
  233.         $("#catalogo").addClass("menu-open");
  234.         $("#catalogo").find('.nav-link:first').addClass("active");
  235.         $("#computo").addClass("active");
  236.         $(function () {
  237.             // DataTable
  238.             $('#table-equipo').DataTable({
  239.                 "aaSorting": [],
  240.                 orderCellsTop: true,
  241.                 {# Define un valor predeterminado para LengthChange #}
  242.                 "pageLength": 50,
  243.                 "scrollX": true,
  244.                 {# sDom: 'lrtip', #}
  245.                 "bLengthChange" : true,
  246.                 language: {
  247.                     url: 'https://cdn.datatables.net/plug-ins/1.10.22/i18n/Spanish.json'
  248.                 },
  249.             });
  250.             {% if form.unidad is defined %}
  251.                 $("#enviar").on('click', function () {
  252.                     aplicarFiltro();
  253.                 });
  254.             {% endif %}
  255.         });
  256.         // Se envia el valor del id_equ
  257.         function postPdfRequest(idEqu) {
  258.             const form = document.createElement('form');
  259.             form.method = 'POST';
  260.             form.action = '{{ path('app_resguardo_equipo_pdf') }}';
  261.             form.target = '_blank';
  262.             const input = document.createElement('input');
  263.             input.type = 'hidden';
  264.             input.name = 'idEqu';
  265.             input.value = idEqu;
  266.             form.appendChild(input);
  267.             document.body.appendChild(form);
  268.             form.submit();
  269.         }
  270.         function aplicarFiltro() {
  271.             $("#table-equipo").find($("tbody")).html("<tr><td colspan='11' class='text-center'><i class='fas fa-spinner fa-pulse'></i></td></tr>");
  272.             let formData = new FormData(document.getElementById("form_unidad_filtro"));
  273.             $.ajax({
  274.                 type: "POST",
  275.                 url: '{{ path('app_equipo_index') }}',
  276.                 data: formData, // Adjuntar los campos del formulario enviado.
  277.                 dataType: "html",
  278.                 cache: false,
  279.                 contentType: false,
  280.                 processData: false,
  281.                 success: function (data) {
  282.                     let datos = jQuery.parseJSON(data);
  283.                     actualizarEquipo(datos);
  284.                 },
  285.                 error: function (data, text, error) {
  286.                     let datos = jQuery.parseJSON(data.responseText);
  287.                 }
  288.             });
  289.         }
  290.         function descargarExcel() {
  291.             let btn = $("#descargar_excel");
  292.             let formData = new FormData(document.getElementById("form_unidad_filtro"));
  293.             $.ajax({
  294.                 type: "POST",
  295.                 url: '{{ path('app_reporte_equipo_excel') }}',
  296.                 data: formData, // Adjuntar los campos del formulario enviado.
  297.                 cache: false,
  298.                 contentType: false,
  299.                 processData: false,
  300.                 xhrFields: {
  301.                     responseType: 'blob'
  302.                 },
  303.                 beforeSend: function () {
  304.                     btn.prop('disabled', true);
  305.                     btn.html("<i class='fas fa-spinner fa-pulse'></i> Descargar");
  306.                 },
  307.                 success: function (data) {
  308.                     let a = document.createElement('a');
  309.                     a.href = window.URL.createObjectURL(data);
  310.                     a.download = "ReporteEquipoCómputo.xlsx"
  311.                     a.click();
  312.                 },
  313.                 complete: function () {
  314.                     btn.prop('disabled', false);
  315.                     btn.html("<i class='fas fa-file-excel mr-2'></i> Descargar");
  316.                 },
  317.                 error: function (xhr) {
  318.                     toastr.warning(xhr?.statusText); 
  319.                 },
  320.             });
  321.         }
  322.         function descargarPDF() {
  323.             {% if form.unidad is defined %}
  324.             if ($("#unidad_filtro_unidad").val() === "") {
  325.                 toastr.warning('Se debe seleccionar una Unidad administrativa');
  326.                 return false;
  327.             }
  328.             {% endif %}
  329.             let btn = $("#descargar_pdf");
  330.             let formData = new FormData(document.getElementById("form_unidad_filtro"));
  331.             $.ajax({
  332.                 type: "POST",
  333.                 url: '{{ path('app_reporte_equipo_pdf') }}',
  334.                 data: formData, // Adjuntar los campos del formulario enviado.
  335.                 cache: false,
  336.                 contentType: false,
  337.                 processData: false,
  338.                 xhrFields: {
  339.                     responseType: 'blob'
  340.                 },
  341.                 beforeSend: function () {
  342.                     btn.prop('disabled', true);
  343.                     btn.html("<i class='fas fa-spinner fa-pulse'></i> Formato CE-1");
  344.                 },
  345.                 success: function (data) {
  346.                     let a = document.createElement('a');
  347.                     a.href = window.URL.createObjectURL(data);
  348.                     a.download = "ReporteEquipoCómputo.pdf"
  349.                     a.click();
  350.                 },
  351.                 complete: function () {
  352.                     btn.prop('disabled', false);
  353.                     btn.html("<i class='fas fa-file-pdf mr-2'></i> Formato CE-1");
  354.                 },
  355.                 error: function (xhr) {
  356.                     toastr.warning(xhr?.statusText); 
  357.                 },
  358.             });
  359.         }
  360.         function descargarPDF1(idEquipo) {
  361.             let btn = $("#descargar_pdf");
  362.             let formData = new FormData();
  363.             formData.append('idEquipo', idEquipo); // Agregar el idEquipo al FormData
  364.             $.ajax({
  365.                 type: "POST",
  366.                 url: '{{ path('app_resguardo_equipo_pdf') }}',
  367.                 data: formData,
  368.                 cache: false,
  369.                 contentType: false,
  370.                 processData: false,
  371.                 beforeSend: function () {
  372.                     btn.prop('disabled', true);
  373.                     btn.html("<i class='fas fa-spinner fa-pulse'></i> Formato CE-1");
  374.                 },
  375.                 success: function (response) {
  376.                     if (response.success) {
  377.                         // Descargar el PDF utilizando el enlace proporcionado
  378.                         window.location.href = response.pdfUrl;
  379.                     } else {
  380.                         alert('Error al generar el PDF. Por favor, intenta nuevamente.');
  381.                     }
  382.                 },
  383.                 error: function (xhr, status, error) {
  384.                     alert('Se produjo un error al intentar generar el PDF. Por favor, intenta nuevamente.');
  385.                 },
  386.                 complete: function () {
  387.                     btn.prop('disabled', false);
  388.                     btn.html("<i class='fas fa-file-pdf mr-2'></i> Formato CE-1");
  389.                 }
  390.             });
  391.         }
  392.         function editarInfoEquipo(url){
  393.             $('#editar-equipo').load(url, function ()
  394.             {
  395.                 // configuración del Modal
  396.                 $("#editar-equipo").on('hide.bs.modal', function () {
  397.                     $(this).html('Cargando');
  398.                 });
  399.                 $(".modal-dialog").draggable;
  400.                 editarInfoEquipoAjax(url)
  401.             })
  402.         }
  403.         function editarInfoEquipoResguardo(url){
  404.             $('#editar-equiporesguardo').load(url, function ()
  405.             {
  406.                 // configuración del Modal
  407.                 $("#editar-equiporesguardo").on('hide.bs.modal', function () {
  408.                     $(this).html('Cargando');
  409.                 });
  410.                 $(".modal-dialog").draggable;
  411.                 editarInfoEquipoResguardoAjax(url)
  412.             })
  413.         }
  414.         function editarInfoEquipoRefaccion(url){
  415.             $('#editar-equiporefaccion').load(url, function ()
  416.             {
  417.                 // configuración del Modal
  418.                 $("#editar-equiporefaccion").on('hide.bs.modal', function () {
  419.                     $(this).html('Cargando');
  420.                 });
  421.                 $(".modal-dialog").draggable;
  422.                 editarInfoEquipoRefaccionAjax(url)
  423.             })
  424.         }
  425.         function editarInfoEquipoAjax(url){
  426.             let send = $("#btn_equipo_guardar");
  427.             $('#btn_equipo_guardar').on('click', function () {
  428.                 let formData = new FormData(document.getElementById("form-editar-equipo"));
  429.                 var html = "";
  430.                 var btnCerrar = "";
  431.                 var tituloE= "";
  432.                 $.ajax({
  433.                     type: "POST",
  434.                     url: url,
  435.                     data: formData, // Adjuntar los campos del formulario enviado.
  436.                     dataType: "json",
  437.                     cache: false,
  438.                     contentType: false,
  439.                     processData: false,
  440.                     beforeSend: function () {
  441.                         send.text("Actualizando "); // Para input de tipo button
  442.                         send.append("<i class='fa fa-spinner fa-spin' style='font-size:16px'></i>");
  443.                         send.prop("disabled", true);
  444.                     },
  445.                     success: function (data) {
  446.                         let datos = data;
  447.                         let row = $('#idEqu-' + datos.idEqu);
  448.                         row.find('.marbete').html(datos.marbete);
  449.                         row.find('.descripcion').html(datos.descripcion);
  450.                         row.find('.marca').html(datos.marca);
  451.                         row.find('.modelo').html(datos.modelo);
  452.                         /*row.find('.serie').html(datos.serie);
  453.                         row.find('.tipo').html(datos.tipo);
  454.                         row.find('.uso').html(datos.uso);*/
  455.                         //row.find('.uso').html(datos.unidad.getNombre);
  456.                         //row.find('.activo').html(datos.estatus);
  457.                         if (datos.estatus === "En operacion") {
  458.                             row.find('.estatus').html('<div class="badge bg-gradient-green d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  459.                         }
  460.                         if(datos.estatus === "Descompuesto") {
  461.                             row.find('.estatus').html('<div class="badge bg-gradient-orange d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  462.                         }
  463.                         if (datos.estatus === "Sin instalar") {
  464.                             row.find('.estatus').html('<div class="badge bg-gradient-primary d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  465.                         }
  466.                         if(datos.estatus === "En proceso de baja") {
  467.                             row.find('.estatus').html('<div class="badge bg-gradient-yellow d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  468.                         }
  469.                         if(datos.estatus === "Baja") {
  470.                             row.find('.estatus').html('<div class="badge bg-gradient-danger d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  471.                         }
  472.                         row.find('.emhv').html(datos.emhv);
  473.                         row.find('.usuario').html(datos.usuario);
  474.                         row.find('.ubicacion').html(datos.ubicacion);
  475.                         if(datos.solicitudes.idSolicitud === 0){
  476.                             $("#editar-equipo").modal('hide');
  477.                         }else{
  478.                             $('.infoEquipo').html('').css('display', 'none');
  479.                             $('.tituloEquipo').html('').css('display', 'none');
  480.                             tituloE = '<h5 class="modal-title" id="exampleModalLabel"><b>Modificación  <small class="text-secondary">de Usuario a las solicitudes</small></b></h5>';
  481.                             html += '<strong><p>Se a modificado el usuario de las siguientes solicitudes que pertenecen al marbete: '+ datos.marbete+ '</p></strong><br>'+
  482.                                 '<table class="table table-hover">'+
  483.                                     '<thead> '+
  484.                                         '<tr><th>Número de solicitud</th><th>Estatus</th><th>Usuario anterior</th><th>Usuario nuevo</th></tr>'+
  485.                                     '</thead>'+
  486.                                     '<tbody>';
  487.                             for(let i = 0; i < datos.solicitudes.length; i++){
  488.                                 html += 
  489.                                     '<tr><td>' + datos.solicitudes[i].idSolicitud +'</td>'+
  490.                                     '<td>' + datos.solicitudes[i].estatus +'</td>'+
  491.                                     '<td>' + datos.solicitudes[i].usuAnterior +'</td>'+
  492.                                     '<td>' + datos.solicitudes[i].usuNuevo +'</td> </tr>'
  493.                                 ;
  494.                             }
  495.                                 html += '</tbody>'+
  496.                                         '</table>';
  497.                             btnCerrar =
  498.                                     '<div class="row">'+
  499.                                         '<div class="col" style="text-align: right;">'+
  500.                                             '<button type="button" class="btn btn-outline-primary" data-dismiss="modal" aria-label="Close">'+
  501.                                                 'Cerrar'+
  502.                                             '</button>'+
  503.                                         '</div>'+
  504.                                     '</div>'
  505.                                 ;
  506.                             $(".tituloSolicitudes").html(tituloE);
  507.                             $(".infoSolicitudes").html(html);
  508.                             $(".btnCerrar").html(btnCerrar);
  509.                         }
  510.                     },
  511.                     error: function (data, text, error) {
  512.                         let datos = data.responseJSON;
  513.                         $("#editar-equipo").html(datos.form);
  514.                         editarInfoEquipoAjax(url);
  515.                     },
  516.                     complete: function (data) {
  517.                         // Se ejecuta al termino de la petición
  518.                     }
  519.                 });
  520.                 return false; // Evitar ejecutar el submit del formulario.
  521.             });
  522.         }
  523.         function editarInfoEquipoResguardoAjax(url){
  524.             let send = $("#btn_equipo_guardar");
  525.             $('#btn_equipo_guardar').on('click', function () {
  526.                 let formData = new FormData(document.getElementById("form-editar-equipo"));
  527.                 $.ajax({
  528.                     type: "POST",
  529.                     url: url,
  530.                     data: formData, // Adjuntar los campos del formulario enviado.
  531.                     dataType: "json",
  532.                     cache: false,
  533.                     contentType: false,
  534.                     processData: false,
  535.                     beforeSend: function () {
  536.                         send.text("Actualizando "); // Para input de tipo button
  537.                         send.append("<i class='fa fa-spinner fa-spin' style='font-size:16px'></i>");
  538.                         send.prop("disabled", true);
  539.                     },
  540.                     success: function (data) {
  541.                         let datos = data;
  542.                         let row = $('#idEqu' + datos.idEqu);
  543.                         row.find('.marbete').html(datos.marbete);
  544.                         row.find('.descripcion').html(datos.descripcion);
  545.                         row.find('.marca').html(datos.marca);
  546.                         row.find('.modelo').html(datos.modelo);
  547.                         /*row.find('.serie').html(datos.serie);
  548.                         row.find('.tipo').html(datos.tipo);
  549.                         row.find('.uso').html(datos.uso);*/
  550.                         //row.find('.uso').html(datos.unidad.getNombre);
  551.                         //row.find('.activo').html(datos.estatus);+
  552.                         if (datos.estatus === "En operacion") {
  553.                             console.log(1)
  554.                             row.find('.estatus').html('<div class="badge bg-gradient-green d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  555.                         }
  556.                         if(datos.estatus === "Descompuesto") {
  557.                             console.log(2)
  558.                             row.find('.estatus').html('<div class="badge bg-gradient-orange d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  559.                         }
  560.                         if (datos.estatus === "Sin instalar") {
  561.                             console.log(3)
  562.                             row.find('.estatus').html('<div class="badge bg-gradient-primary d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  563.                         }
  564.                         if(datos.estatus === "En proceso de baja") {
  565.                             console.log(4)
  566.                             row.find('.estatus').html('<div class="badge bg-gradient-yellow d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  567.                         }
  568.                         if(datos.estatus === "Baja") {
  569.                             console.log(5)
  570.                             row.find('.estatus').html('<div class="badge bg-gradient-danger d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  571.                         }
  572.                         row.find('.emhv').html(datos.emhv);
  573.                         row.find('.usuario').html(datos.usuario);
  574.                         row.find('.ubicacion').html(datos.ubicacion);
  575.                         $("#editar-equiporesguardo").modal('hide');
  576.                     },
  577.                     error: function (data, text, error) {
  578.                         let datos = data.responseJSON;
  579.                         $("#editar-equiporesguardo").html(datos.form);
  580.                         editarInfoEquipoResguardoAjax(url);
  581.                     },
  582.                     complete: function (data) {
  583.                         // Se ejecuta al termino de la petición
  584.                     }
  585.                 });
  586.                 return false; // Evitar ejecutar el submit del formulario.
  587.             });
  588.         }
  589.         function editarInfoEquipoRefaccionAjax(url){
  590.             let send = $("#btn_equipo_guardar");
  591.             $('#btn_equipo_guardar').on('click', function () {
  592.                 let formData = new FormData(document.getElementById("form-editar-equipo"));
  593.                 $.ajax({
  594.                     type: "POST",
  595.                     url: url,
  596.                     data: formData, // Adjuntar los campos del formulario enviado.
  597.                     dataType: "json",
  598.                     cache: false,
  599.                     contentType: false,
  600.                     processData: false,
  601.                     beforeSend: function () {
  602.                         send.text("Actualizando "); // Para input de tipo button
  603.                         send.append("<i class='fa fa-spinner fa-spin' style='font-size:16px'></i>");
  604.                         send.prop("disabled", true);
  605.                     },
  606.                     success: function (data) {
  607.                         let datos = data;
  608.                         let row = $('#idEqu-' + datos.idEqu);
  609.                         row.find('.marbete').html(datos.marbete);
  610.                         row.find('.descripcion').html(datos.descripcion);
  611.                         row.find('.marca').html(datos.marca);
  612.                         row.find('.modelo').html(datos.modelo);
  613.                         /*row.find('.serie').html(datos.serie);
  614.                         row.find('.tipo').html(datos.tipo);
  615.                         row.find('.uso').html(datos.uso);*/
  616.                         //row.find('.uso').html(datos.unidad.getNombre);
  617.                         //row.find('.activo').html(datos.estatus);
  618.                         if (datos.estatus === "En operacion") {
  619.                             row.find('.estatus').html('<div class="badge bg-gradient-green d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  620.                         }
  621.                         if(datos.estatus === "Descompuesto") {
  622.                             row.find('.estatus').html('<div class="badge bg-gradient-orange d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  623.                         }
  624.                         if (datos.estatus === "Sin instalar") {
  625.                             row.find('.estatus').html('<div class="badge bg-gradient-primary d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  626.                         }
  627.                         if(datos.estatus === "En proceso de baja") {
  628.                             row.find('.estatus').html('<div class="badge bg-gradient-yellow d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  629.                         }
  630.                         if(datos.estatus === "Baja") {
  631.                             row.find('.estatus').html('<div class="badge bg-gradient-danger d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  632.                         }
  633.                         row.find('.emhv').html(datos.emhv);
  634.                         row.find('.usuario').html(datos.usuario);
  635.                         row.find('.ubicacion').html(datos.ubicacion);
  636.                         $("#editar-equiporefaccion").hide('hide');
  637.                         $('.modal-backdrop').remove();
  638.                     },
  639.                     error: function (data, text, error) {
  640.                         let datos = data.responseJSON;
  641.                         $("#editar-equiporefaccion").html(datos.form);
  642.                         editarInfoEquipoRefaccionAjax(url);
  643.                     },
  644.                     complete: function (data) {
  645.                         // Se ejecuta al termino de la petición
  646.                     }
  647.                 });
  648.                 return false; // Evitar ejecutar el submit del formulario.
  649.             });
  650.         }
  651.         <!-- Actualizar tabla de bitácora -->
  652.         function actualizarEquipo(data) {
  653.             $("#table-equipo").dataTable().fnClearTable();
  654.             $("#table-equipo").dataTable().fnDestroy();
  655.             var edit = "";
  656.             var downpdf = "";
  657.             var html = "";
  658.             $.each(data, function (key, equipo) {
  659.                 {# Para edición del equipo #}
  660.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'true' : 'false' }}) {
  661.                     edit = '&nbsp;&nbsp;<a href="#editar-equipo" onclick="editarInfoEquipo(\'' + equipo.editar + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  662.                 }
  663.                 {# Solo para edición de estatus y reguardatario #}
  664.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'false' : 'true' }}) {
  665.                     edit = '&nbsp;&nbsp;<a href="#editar-equiporesguardo" onclick="editarInfoEquipoResguardo(\'' + equipo.editar_resguardo + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  666.                 }
  667.                 html +=
  668.                     '<tr id="idEqu' + equipo.idEqu + '">' +
  669.                         '<td class="marbete">' + equipo.marbete + '</td>' +
  670.                         '<td class="descripcion">' + equipo.descripcion + '</td>' +
  671.                         '<td class="marca">' + equipo.marca + '</td>' +
  672.                         '<td class="modelo">' + equipo.modelo + '</td>' +
  673.                         '<td class="uso">' + equipo.uso + '</td>' +
  674.                         '<td class="estatus">' + equipo.estatus + '</td>' +
  675.                         '<td class="emhv">' + equipo.emhv + '</td>' +
  676.                         '<td class="unidad">' + equipo.unidad + '</td>' +
  677.                         '<td class="usuario">' + equipo.usuario + '</td>' +
  678.                         '<td class="ubicacion">' + equipo.ubicacion + '</td>' +
  679.                         '<td class="text-right">' +
  680.                             '<a href="#" onclick="postPdfRequest(' + equipo.idEqu + '); return false;" title="Generar resguardatario">' +
  681.                             '<i class="fas fa-file-pdf mr-2"></i>' +
  682.                             '</a>' +
  683.                             '<a href="javascript: void(0)" data-id="' + equipo.idEqu + '" class="btn-redirect" title="Ver equipo"><i class="fas fa-eye"></i></a>' +
  684.                             edit +
  685.                         '</td>' +
  686.                     '</tr>';
  687.                 //cambiarEstatus('estatus/' + equipo.idEqu, 'estatus');
  688.             });
  689.             $("#table-equipo").find($("tbody")).html(html);
  690.             $('#table-equipo').DataTable({
  691.                 "aaSorting": [],
  692.                 orderCellsTop: true,
  693.                 {# Define un valor predeterminado para LengthChange #}
  694.                 "pageLength": 50,
  695.                 "scrollX": true,
  696.                 {# sDom: 'lrtip', #}
  697.                 "bLengthChange" : true,
  698.                 language: {
  699.                     url: 'https://cdn.datatables.net/plug-ins/1.10.22/i18n/Spanish.json'
  700.                 },
  701.             });
  702.         }
  703.         function actualizarEquipoResguardo(data) {
  704.             $("#table-equipo").dataTable().fnClearTable();
  705.             $("#table-equipo").dataTable().fnDestroy();
  706.             var edit = "";
  707.             var downpdf = "";
  708.             var html = "";
  709.             $.each(data, function (key, equipo) {
  710.                 {# Para edición del equipo #}
  711.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'true' : 'false' }}) {
  712.                     edit = '&nbsp;&nbsp;<a href="#editar-equipo" onclick="editarInfoEquipo(\'' + equipo.editar + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  713.                 }
  714.                 {# Solo para edición de estatus y reguardatario #}
  715.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'false' : 'true' }}) {
  716.                     edit = '&nbsp;&nbsp;<a href="#editar-equiporesguardo" onclick="editarInfoEquipoResguardo(\'' + equipo.editar_resguardo + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  717.                 }
  718.                 html +=
  719.                     '<tr id="idEqu' + equipo.idEqu + '">' +
  720.                     '<td class="marbete">' + equipo.marbete + '</td>' +
  721.                     '<td class="descripcion">' + equipo.descripcion + '</td>' +
  722.                     '<td class="marca">' + equipo.marca + '</td>' +
  723.                     '<td class="modelo">' + equipo.modelo + '</td>' +
  724.                     '<td class="uso">' + equipo.uso + '</td>' +
  725.                     '<td class="estatus">' + equipo.estatus + '</td>' +
  726.                     '<td class="emhv">' + equipo.emhv + '</td>' +
  727.                     '<td class="unidad">' + equipo.unidad + '</td>' +
  728.                     '<td class="usuario">' + equipo.usuario + '</td>' +
  729.                     '<td class="ubicacion">' + equipo.ubicacion + '</td>' +
  730.                     '<td class="text-right">' +
  731.                     '<a href="#" onclick="postPdfRequest(' + equipo.idEqu + '); return false;" title="Generar resguardatario">' +
  732.                     '<i class="fas fa-file-pdf mr-2"></i>' +
  733.                     '</a>' +
  734.                     '<a href="javascript: void(0)" data-id="' + equipo.idEqu + '" class="btn-redirect" title="Ver equipo"><i class="fas fa-eye"></i></a>' +
  735.                     edit +
  736.                     '</td>' +
  737.                     '</tr>';
  738.                 //cambiarEstatus('estatus/' + equipo.idEqu, 'estatus');
  739.             });
  740.             $("#table-equipo").find($("tbody")).html(html);
  741.             $('#table-equipo').DataTable({
  742.                 "aaSorting": [],
  743.                 orderCellsTop: true,
  744.                 {# Define un valor predeterminado para LengthChange #}
  745.                 "pageLength": 50,
  746.                 "scrollX": true,
  747.                 {# sDom: 'lrtip', #}
  748.                 "bLengthChange" : true,
  749.                 language: {
  750.                     url: 'https://cdn.datatables.net/plug-ins/1.10.22/i18n/Spanish.json'
  751.                 },
  752.             });
  753.         }
  754.         <!-- Actualizar tabla de bitácora -->
  755.         function actualizarEquipoRefaccion(data) {
  756.             $("#table-equipo").dataTable().fnClearTable();
  757.             $("#table-equipo").dataTable().fnDestroy();
  758.             var edit = "";
  759.             var html = "";
  760.             $.each(data, function (key, equipo) {
  761.                 {# Para edición del equipo #}
  762.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'true' : 'false' }}) {
  763.                     edit = '&nbsp;&nbsp;<a href="#editar-equipo" onclick="editarInfoEquipo(\'' + equipo.editar + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  764.                 }
  765.                 {# Solo para edición de estatus y reguardatario #}
  766.                 if (('{{ nivel }}' === '1' || '{{ nivel }}' === '2') && {{ unidadActiva ? 'false' : 'true' }}) {
  767.                     edit = '&nbsp;&nbsp;<a href="#editar-equiporesguardo" onclick="editarInfoEquipoResguardo(\'' + equipo.editar_resguardo + '\')" data-toggle="modal" title="Modificar equipo"><i class="fas fa-pen"></i></a>';
  768.                 }
  769.                 html +=
  770.                     '<tr id="idEqu' + equipo.idEqu + '">' +
  771.                     '<td class="marbete">' + equipo.marbete + '</td>' +
  772.                     '<td class="descripcion">' + equipo.descripcion + '</td>' +
  773.                     '<td class="marca">' + equipo.marca + '</td>' +
  774.                     '<td class="modelo">' + equipo.modelo + '</td>' +
  775.                     '<td class="uso">' + equipo.uso + '</td>' +
  776.                     '<td class="estatus">' + equipo.estatus + '</td>' +
  777.                     '<td class="emhv">' + equipo.emhv + '</td>' +
  778.                     '<td class="unidad">' + equipo.unidad + '</td>' +
  779.                     '<td class="usuario">' + equipo.usuario + '</td>' +
  780.                     '<td class="ubicacion">' + equipo.ubicacion + '</td>' +
  781.                     '<td class="text-right">' +
  782.                     '<a href="#" onclick="postPdfRequest(' + equipo.idEqu + '); return false;" title="Generar resguardatario">' +
  783.                     '<i class="fas fa-file-pdf mr-2"></i>' +
  784.                     '</a>' +
  785.                     '<a href="javascript: void(0)" data-id="' + equipo.idEqu + '" class="btn-redirect" title="Ver equipo"><i class="fas fa-eye"></i></a>' +
  786.                     edit +
  787.                     '</td>' +
  788.                     '</tr>';
  789.                 //cambiarEstatus('estatus/' + equipo.idEqu, 'estatus');
  790.             });
  791.             $("#table-equipo").find($("tbody")).html(html);
  792.             $('#table-equipo').DataTable({
  793.                 "aaSorting": [],
  794.                 orderCellsTop: true,
  795.                 {# Define un valor predeterminado para LengthChange #}
  796.                 "pageLength": 50,
  797.                 "scrollX": true,
  798.                 {# sDom: 'lrtip', #}
  799.                 "bLengthChange" : true,
  800.                 language: {
  801.                     url: 'https://cdn.datatables.net/plug-ins/1.10.22/i18n/Spanish.json'
  802.                 },
  803.             });
  804.         }
  805.         function cambiarEstatus(url, accion) {
  806.             $.ajax({
  807.                 url: url,
  808.                 dataType: "json",
  809.                 cache: false,
  810.                 contentType: false,
  811.                 processData: false,
  812.                 success: function (data) {
  813.                     let datos = data;
  814.                     let row = $('#idEqu'+ datos.idEqu);
  815.                     if (datos.estatus === "En operacion") {
  816.                         row.find('.estatus').html('<div class="badge bg-gradient-green d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  817.                     }
  818.                     if(datos.estatus === "Descompuesto") {
  819.                         row.find('.estatus').html('<div class="badge bg-gradient-orange d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  820.                     }
  821.                     if (datos.estatus === "Sin instalar") {
  822.                         row.find('.estatus').html('<div class="badge bg-gradient-primary d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  823.                     }
  824.                     if(datos.estatus === "En proceso de baja") {
  825.                         row.find('.estatus').html('<div class="badge bg-gradient-yellow d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  826.                     }
  827.                     if(datos.estatus === "Baja") {
  828.                         row.find('.estatus').html('<div class="badge bg-gradient-danger d-block" style="width: 8rem;">' + datos.estatus + '</div>');
  829.                     }
  830.                     //alertMessage(0, datos.mensaje);
  831.                 },
  832.                 error: function (data, text, error) {
  833.                     alertMessage(1, error);
  834.                 },
  835.                 complete: function (data) {
  836.                     // Se ejecuta al termino de la petición
  837.                 }
  838.             });
  839.         }
  840.     </script>
  841.     <script>
  842.         $(function () {
  843.             $(document).on('click', '.btn-redirect', function(){
  844.                 let data = $(this).attr('data-id');
  845.                 $.redirect("{{ path('app_equipo_show') }}", {idEqu: data}, "POST", "_self");
  846.             });
  847.         });
  848.     </script>
  849.     <script>
  850.         function confirmDelete(actionUrl, csrfToken) {
  851.             // Configura la acción del formulario en el modal
  852.             const deleteForm = document.getElementById('deleteForm');
  853.             deleteForm.action = actionUrl;
  854.             // Configura el token CSRF
  855.             document.getElementById('csrfToken').value = csrfToken;
  856.             // Muestra el modal
  857.             $('#confirmDeleteModal').modal('show');
  858.         }
  859.     </script>
  860. {% endblock %}