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

<head>
  <%- include('../../../tools/head'); %>
  <link rel="stylesheet" href="/css/dropzone.css">
</head>

<body id="page-top">
  <!-- Page Wrapper -->
  <div id="wrapper">
    <!-- Sidebar -->
    <%- include('../../../tools/sidebarTec'); %>
    <!-- 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">VEHICULOS</h1>
                  </div>
                  <form onsubmit="vehiculosForm(event)" action="/tecnico/Consolidaciones/Enviar/Vehiculos/<%= user.user %>" method="POST" autocomplete="off" enctype="multipart/form-data">
                    <input type="text" value="on" id="vehiculosON" name="vehiculosON" style="display: none;" readonly>
                    <input type="text" id="idHV" name="idHV" style="display: none;" readonly>

                    <div class="form-row align-items-center mb-sm-2">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="provinciaID">Provincia</label>
                        <input type="text" class="form-control form-control-user" id="provinciaID" name="provincia" value="<%= user.provincia %>" readonly />
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="muniSelect">Municipio</label>
                        <select id="muniSelect" name="municipio" class="custom-select mr-sm-2">
                          <option selected disabled>
                            Seleccione el Municipio
                          </option>
                          <option value="<%= user.municipio %>">
                            <%= user.municipio %>
                          </option>
                          <% if(user.municipioExtra1 !="" ){ %>
                          <option value="<%= user.municipioExtra1 %>">
                            <%= user.municipioExtra1 %>
                          </option>
                          <% } %> <% if(user.municipioExtra2 !="" ){ %>
                          <option value="<%= user.municipioExtra2 %>">
                            <%= user.municipioExtra2 %>
                          </option>
                          <% } %> <% if(user.municipioExtra3 !="" ){ %>
                          <option value="<%= user.municipioExtra3 %>">
                            <%= user.municipioExtra3 %>
                          </option>
                          <% } %>
                        </select>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-8 mb-3 mb-sm-0">
                        <label class="mr-sm-2" for="grupEsta">Grupo Del Establecimiento</label>
                        <select id="grupEsta" name="grupEsta" class="custom-select mr-sm-2">
                          <option selected disabled>
                            Seleccione el Grupo
                          </option>
                          <option value="VEHÍCULOS TRANSPORTADORES DE ALIMENTOS Y BEBIDAS">
                            VEHÍCULOS TRANSPORTADORES DE ALIMENTOS Y BEBIDAS
                          </option>
                          <option value="LOS DEMAS QUE NO SE ENCUENTRAN">
                            LOS DEMAS QUE NO SE ENCUENTRAN
                          </option>
                        </select>
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="codEsta">Codigo</label>
                        <input type="text" class="form-control form-control-user" id="codEsta" name="codEsta" readonly />
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="Nriesgo">Nivel de Riesgo</label>
                        <input type="text" class="form-control form-control-user" id="Nriesgo" name="Nriesgo" readonly />
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="tipoEsta">Tipo Del Establecimiento</label>
                        <select id="tipoEsta" name="tipoEsta" class="custom-select mr-sm-2">
                          <option selected>Seleccione el Tipo</option>
                        </select>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-5">
                        <label class="mr-sm-2" for="rSocial">Razón Social</label>
                        <select id="rSocial" name="rSocial" data-live-search="true" data-show-subtext="true" class="custom-select mr-sm-2 selectpicker">
                          <option selected disabled>
                            Seleccione El Establecimiento
                          </option>
                        </select>
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-3" for="tIden">Tipo </label>
                        <input type="text" id="tIden" name="tIden" class="form-control form-control-user" readonly />
                      </div>
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="inputIden">Identificación</label>
                        <input type="number" id="inputIden" name="inputIden" class="form-control form-control-user" readonly />
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="phone">Telefono</label>
                        <input type="number" id="phone" name="phone" class="form-control form-control-user" readonly />
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="rLegal">Representante Legal</label>
                        <input type="text" class="form-control form-control-user" id="rLegal" name="rLegal" readonly />
                      </div>
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="direccion">Dirección</label>
                        <input type="text" class="form-control form-control-user" id="direccion" name="direccion" readonly />
                      </div>
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="estado">Estado</label>
                        <input type="text" class="form-control form-control-user" id="estado" name="estado" readonly />
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="classVehi">Clase de Vehiculo</label>
                        <select id="classVehi" name="classVehi" class="custom-select mr-sm-2">
                          <option selected disabled>Seleccione</option>
                          <option value="MOTO">MOTO</option>
                          <option value="CAMIONETA">CAMIONETA</option>
                          <option value="CAMIÓN">CAMIÓN</option>
                          <option value="FURGON">FURGON</option>
                          <option value="FURGON">REMOLQUE</option>
                          <option value="SEMIREMOLQUE">SEMIREMOLQUE</option>
                          <option value="FURGON">FURGON</option>
                          <option value="OTRO">OTRO, ¿CUÁL?</option>
                        </select>
                      </div>
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="otroV">Otro Vehiculo</label>
                        <input type="text" class="form-control form-control-user" id="otroV" name="otroV" placeholder="¿CUÁL?" onkeyup="mayus(this);" readonly />
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="placa">Placa</label>
                        <input type="text" class="form-control form-control-user" id="placa" name="placa" onkeyup="mayus(this);" readonly />
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="refriV">Refrigeración</label>
                        <select id="refriV" name="refriV" class="custom-select mr-sm-2">
                          <option selected disabled>Seleccione</option>
                          <option value="SI">SI</option>
                          <option value="NO">NO</option>
                        </select>
                      </div>
                      <div class="col-sm-2">
                        <label class="mr-sm-2" for="nInscrip">N° de Inscripción</label>
                        <input type="text" class="form-control form-control-user" id="nInscrip" name="nInscrip" onkeyup="mayus(this);" list="defaultNInscrip" />
                      </div>
                    </div>

                    <datalist id="defaultNInscrip">
                      <option value="NO REPORTA"></option>
                    </datalist>

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="produTrans">Productos Y/O Mercancia Que Transporta
                        </label>
                        <input type="text" class="form-control form-control-user" id="produTrans" name="produTrans" onkeyup="mayus(this);" list="defaultProdu" />
                      </div>
                    </div>

                    <datalist id="defaultProdu">
                      <option value="NO PRESENTA"></option>
                    </datalist>

                    <div class="form-group row">
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="fVisit">Fecha_Visita</label>
                        <input type="date" placeholder="Ninguna" class="form-control form-control-user" id="fVisit" name="fVisit" />
                      </div>
                      <div class="col-sm-3">
                        <label class="mr-sm-2" for="score">Puntaje</label>
                        <input type="number" placeholder="1.0" min="0" max="100" class="form-control form-control-user" step="0.1" id="score" name="score" onkeyup="AlimentosConcepto(this);" />
                      </div>
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="concepto">Concepto</label>
                        <input type="text" class="form-control form-control-user" id="concepto" name="concepto" readonly value="NO APLICA" />
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="observacion">Observaciones (Opcional)</label>
                        <textarea name="observacion" id="observacion" onkeyup="mayus(this);" maxlength="270" rows="2" class="form-control form-control-user" placeholder="Escribe las Observaciones Que Creas Necesarias"></textarea>
                      </div>
                    </div>

                    <!-- Divider -->
                    <hr class="sidebar-divider" style="border-top: 1px solid rgb(0 0 0)" />

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="fields">Adjuntar
                          Archivo(s)</label>
                        <div class="drop-zone">
                          <span class="drop-zone__prompt">Arrastra el archivo o da click para buscar</span>
                          <input type="file" name="myFile" id="myFile" class="drop-zone__input" />
                        </div>
                      </div>
                    </div>

                    <button class="btn btn-primary btn-user btn-block" type="submit">
                      Registrar Consolidación
                    </button>
                    <a href="/tecnico/Consolidaciones/Enviar" class="btn btn-secondary btn-user btn-block">
                      Cancelar
                    </a>
                  </form>
                </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="/tecnico/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>

  <!-- Validations -->
  <script type="text/JavaScript" src="/js/Tecnico/formularios.js"></script>
  <script type="text/JavaScript" src="/js/tools/codigoEsta.js"></script>
  <script type="text/JavaScript" src="/js/tools/consolidaciones.js"></script>
  <script type="text/JavaScript" src="/js/tools/dropzone.js"></script>

  <!-- Alert -->
  <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

  <% if(typeof alert !="undefined" ) { %>
  <script type="text/JavaScript">
    Swal.fire({
        title: '<%= alert[0].alertTitle %>',
        text:'<%= alert[0].alertMessage %>',
        icon:'<%= alert[0].alertIcon %>',
        showConfirmButton: <%= alert[0].showConfirmButton %>,
        timer: <%= alert[0].timer %>
      }).then(()=>{
        window.location = '<%= alert[0].ruta %>'
      })
    </script>
  <% } %>

  <script type="text/JavaScript">
    <% if(codigos){ %>
          var arrayCod = []
          <% codigos.forEach((codigos)=> { %>
              arrayCod.push(["<%= codigos.grupo %>"], ["<%= codigos.codigo %>"], ["<%= codigos.tipo %>"], ["<%= codigos.nivelRiesgo %>"])
          <% }) %>
      <% } %>

      <% if(hojavida){ %>
          var arrayEsta = []
          <% hojavida.forEach((hojavida)=> { %>
              arrayEsta.push(["<%= hojavida.provincia %>"], ["<%= hojavida.municipio %>"], ["<%= hojavida.tipo %>"], ["<%= hojavida.razonSocial %>"], ["<%= hojavida.tipoIdentificacion %>"], ["<%= hojavida.identificacion %>"], ["<%= hojavida.direccion %>"], ["<%= hojavida.repreLegal %>"], ["<%= hojavida.estado %>"], ["<%= hojavida.telefono %>"], ["<%= hojavida._id %>"], ["<%= hojavida.placa %>"])
          <% }) %>
      <% } %>

      $("#classVehi").change(function () {
          if (document.getElementById("classVehi").value == "OTRO") {
              $("#otroV").attr("readonly", false);
          } else {
            document.getElementById("otroV").value = ""
              $("#otroV").attr("readonly", true);
          }
      });
    </script>

  <script>
    $(window).bind("load", function() {
      var nav = document.getElementById("nav2");
      $("#navlink1").removeClass("collapsed");
      var nav3 = document.getElementById("collapseOne");
      var nav4 = document.getElementById("show2");
      nav.className += "  active";
      nav3.className += "  show";
      nav4.className += "  active";
    });

    $("#grupEsta").change(function() {
      if (document.getElementById("grupEsta").value == "VEHÍCULOS TRANSPORTADORES DE ALIMENTOS Y BEBIDAS") {
        $("#placa").attr("readonly", true);
      } else {
        $("#placa").attr("readonly", false);
      }
    });
  </script>
</body>

</html>