<!DOCTYPE html>
<html lang="es">

<head>
  <%- include('../../tools/head'); %>
  <!-- Custom styles for this page -->
  <link href="/vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.1.2/css/dataTables.dateTime.min.css">
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/amcharts/3.21.15/plugins/export/libs/FileSaver.js/FileSaver.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.15.6/xlsx.full.min.js"></script>
  <link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.dataTables.min.css">
</head>

<body id="page-top">
  <!-- Page Wrapper -->
  <div id="wrapper">

    <!-- Sidebar -->
    <%- include('../../tools/sidebarAdmin'); %>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">
      <!-- Main Content -->
      <div id="content">

        <!-- Topbar -->
        <%- include('../../tools/topbar'); %>
        <!-- End of Topbar -->

        <!-- Begin Page Content -->
        <div class="container-fluid">

          <div class="container">
            <div class="card o-hidden border-0 shadow-lg my-5">
              <div class="card-body p-0">
                <!-- Nested Row within Card Body -->
                <div class="p-5">
                  <div class="text-center">
                    <h1 class="h4 text-gray-900 mb-4">HOJAS DE VIDA</h1>
                  </div>

                  <div class="card-body">
                    <div class="table-responsive">
                      <table class="table table-bordered table-hover display nowrap" id="dataTable" width="100%" cellspacing="0" style="font-size: 13px;  text-align: center !important;">
                        <thead>
                          <tr>
                            <th>Acción</th>
                            <th>Provincia</th>
                            <th>Municipio</th>
                            <th>Codigo</th>
                            <th>Tipo</th>
                            <th>Identificiación</th>
                            <th>Razón Social</th>
                            <th>Codigo Inscripción</th>
                            <th>Dirección</th>
                            <th>Representante Legal</th>
                            <th>Placa</th>
                            <th>Nivel de Riesgo</th>
                            <th>Estado</th>
                            <th>Identificación Dueño</th>
                            <th>Nombre Dueño</th>
                          </tr>
                        </thead>
                        <tfoot>
                          <tr>
                            <th>Acción</th>
                            <th><input type="text" placeholder="Busca por Provincia" /></th>
                            <th><input type="text" placeholder="Busca por Municipio" /></th>
                            <th><input type="text" placeholder="Busca por Codigo" /></th>
                            <th><input type="text" placeholder="Busca por Tipo" /></th>
                            <th><input type="text" placeholder="Busca por Identificación" /></th>
                            <th><input type="text" placeholder="Busca por Razón Social" /></th>
                            <th><input type="text" placeholder="Busca por Codigo Inscripción" /></th>
                            <th><input type="text" placeholder="Busca por Dirección" /></th>
                            <th><input type="text" placeholder="Busca por Representante Legal" /></th>
                            <th><input type="text" placeholder="Busca por Placa" /></th>
                            <th><input type="text" placeholder="Busca por Nivel de Riesgo" /></th>
                            <th><input type="text" placeholder="Busca por Estado" /></th>
                            <th><input type="text" placeholder="Busca por Identificación Dueño" /></th>
                            <th><input type="text" placeholder="Busca por Nombre Dueño" /></th>
                          </tr>
                        </tfoot>
                        <tbody>
                          <% if (hv){ %>
                          <% hv.forEach((hv)=> { %>
                          <tr>
                            <td>
                              <a href="/coordinacion/HojaVida/ConsultarHV/Edit/<%= hv._id%>" type="button" class="btn btn-warning btn-circle btn-sm">
                                <i class="fas fa-pen-to-square"></i>
                              </a>
                              <a href="/coordinacion/HojaVida/ConsultarHV/View/<%= hv._id%>" type="button" class="btn btn-info btn-circle btn-sm">
                                <i class="fas fa-magnifying-glass"></i>
                              </a>
                            </td>
                            <td>
                              <%= hv.provincia %>
                            </td>
                            <td>
                              <%= hv.municipio %>
                            </td>
                            <td>
                              <%= hv.codigo %>
                            </td>
                            <td>
                              <%= hv.tipo %>
                            </td>
                            <td>
                              <%= hv.tipoIdentificacion %> - <%= hv.identificacion %>
                            </td>
                            <td>
                              <%= hv.razonSocial %>
                            </td>
                            <td>
                              <%= hv.idenSocial %>
                            </td>
                            <td>
                              <%= hv.direccion %>
                            </td>
                            <td>
                              <%= hv.repreLegal %>
                            </td>
                            <td><%= hv.placa %></td>
                            <td>
                              <%= hv.nivelRiesgo %>
                            </td>
                            <td>
                              <%= hv.estado %>
                            </td>
                            <td>
                              <%= hv.nDueno %>
                            </td>
                            <td>
                              <%= hv.iDueno %>
                            </td>
                          </tr>
                          <% }); %>
                          <% } %>
                        </tbody>
                      </table>
                    </div>
                  </div>

                </div>
              </div>
            </div>
          </div>

        </div>
        <!-- /.container-fluid -->

      </div>
      <!-- End of Main Content -->

      <!-- Footer -->
      <%- include('../../tools/footer'); %>
      <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

  </div>
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Salida</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">Seleccione "Cerrar
          sesión" a continuación si está listo para
          finalizar su sesión actual.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancelar</button>
          <a class="btn btn-primary" href="/coordinacion/logout">Cerrar Sesión</a>
        </div>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="/vendor/jquery/jquery.min.js"></script>
  <script src="/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="/vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="/js/sb-admin-2.min.js"></script>

  <!-- Page level plugins -->
  <script src="/vendor/datatables/jquery.dataTables.min.js"></script>
  <script src="/vendor/datatables/dataTables.bootstrap4.min.js"></script>

  <!-- Page level custom scripts -->
  <script src="/js/demo/datatables-demo.js"></script>

  <!-- Excel -->
  <script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>

  <!-- Search Advanced -->
  <script src="https://cdn.datatables.net/fixedcolumns/4.1.0/js/dataTables.fixedColumns.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.2/moment.min.js"></script>
  <script src="https://cdn.datatables.net/datetime/1.1.2/js/dataTables.dateTime.min.js"></script>

  <script>
    $(window).bind('load', function() {
      var nav = document.getElementById('nav3');
      $('#navlink2').removeClass('collapsed');
      var nav3 = document.getElementById('collapseThree');
      var nav4 = document.getElementById('show3');
      nav.className += "  active";
      nav3.className += "  show";
      nav4.className += "  active";
    });
    $("#grupEsta").change(function() {
      if (document.getElementById("grupEsta").value == "VEHÍCULOS TRANSPORTADORES DE ALIMENTOS Y BEBIDAS") {
        document.getElementById("placaDiv").removeAttribute("style")
      } else {
        document.getElementById("placaDiv").style.display = "none"
      }
    });

    var table = $("#dataTable").DataTable({
      order: [
        [1, 'desc']
      ],
      scrollY: true,
      scrollX: true,
      scrollCollapse: true,
      language: {
        search: "Buscar:",
        info: "Mostrando _START_ elementos a _END_ de _TOTAL_ entradas",
        zeroRecords: "Sin Datos en esta Tabla",
        infoFiltered: " - filtrado desde _MAX_ entradas",
        lengthMenu: "Mostrando _MENU_ entradas",
        paginate: {
          previous: "Anterior",
          next: "Siguiente",
        },
      },
      dom: 'Bfrtlip',
      buttons: [{
        extend: 'excel',
        filename: 'HOJAVIDA_' + new Date().toJSON().substring(0, 10),
        autoFilter: true,
        sheetName: "HOJAS DE VIDA",
      }],
    });

    table.columns().every(function() {
      var that = this;
      $('input', this.footer()).on('keyup change', function() {
        that
          .search(this.value)
          .draw();
      });
    });
  </script>

</body>

</html>