<!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">VIVIENDA SALUDABLE</h1>
                  </div>

                  <form onsubmit="VivSaludableForm(event)" action="/tecnico/Consolidaciones/Enviar/ViviendaSaludable/<%= user.user %>" method="POST" enctype="multipart/form-data">
                    <input type="text" value="on" id="viviSaluON" name="viviSaluON" 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 class="col my-1">
                        <label class="mr-sm-2" for="vereda">Vereda/Localidad</label>
                        <input type="text" class="form-control form-control-user" id="vereda" name="vereda" onkeyup="mayus(this);" readonly>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="direccion">Dirección</label>
                        <input type="text" class="form-control form-control-user" id="direccion" name="direccion" onkeyup="mayus(this);" readonly />
                      </div>
                      <div class="col my-1">
                        <label class=" mr-sm-2" for="vivienda">Vivienda</label>
                        <select id="vivienda" name="vivienda" class="custom-select mr-sm-2">
                          <option selected disabled>Seleccione
                          </option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class=" mr-sm-2">Vivienda Nueva</label>
                        <a href="/tecnico/Consolidaciones/InsVivi" class="btn btn-primary btn-user btn-block">
                          INSCRIBIR
                        </a>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="NVisit">Nº de Visita</label>
                        <input type="number" min="1" max="6" value="1" class="form-control form-control-user" id="NVisit" name="NVisit" />
                      </div>
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="fVisit">Fecha Visita</label>
                        <input type="date" class="form-control form-control-user" id="fVisit" name="fVisit" />
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">VIVIENDA COMO ESPACIO VITAL</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F101">101</label>
                        <select id="F101" name="F101" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F102">102</label>
                        <select id="F102" name="F102" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F103">103</label>
                        <select id="F103" name="F103" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F104">104</label>
                        <select id="F104" name="F104" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F105">105</label>
                        <select id="F105" name="F105" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final1">Final</label>
                        <select id="Final1" name="Final1" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">SORBOS DE VIDA - AGUA PARA CONSUMIR EN LA VIVIENDA</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F201">201</label>
                        <select id="F201" name="F201" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F202">202</label>
                        <select id="F202" name="F202" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F203">203</label>
                        <select id="F203" name="F203" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F204">204</label>
                        <select id="F204" name="F204" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final2">Final</label>
                        <select id="Final2" name="Final2" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">LAS EXCRETAS Y LAS AGUAS SUCIAS ANDAN POR AHÍ</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F301">301</label>
                        <select id="F301" name="F301" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F302">302</label>
                        <select id="F302" name="F302" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F303">303</label>
                        <select id="F303" name="F303" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F304">304</label>
                        <select id="F304" name="F304" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F305">305</label>
                        <select id="F305" name="F305" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final3">Final</label>
                        <select id="Final3" name="Final3" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">LOS RESIDUOS SOLIDOS (BASURA EN LA VIVIENDA)</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F401">401</label>
                        <select id="F401" name="F401" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F402">402</label>
                        <select id="F402" name="F402" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F403">403</label>
                        <select id="F403" name="F403" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F404">404</label>
                        <select id="F404" name="F404" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final4">Final</label>
                        <select id="Final4" name="Final4" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">OJO CON LAS PLAGAS</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F501">501</label>
                        <select id="F501" name="F501" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F502">502</label>
                        <select id="F502" name="F502" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F503">503</label>
                        <select id="F503" name="F503" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F504">504</label>
                        <select id="F504" name="F504" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final5">Final</label>
                        <select id="Final5" name="Final5" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">ALIMENTOS Y VIVIENDA CON HIGIENE Y SALUD</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F601">601</label>
                        <select id="F601" name="F601" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F602">602</label>
                        <select id="F602" name="F602" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F603">603</label>
                        <select id="F603" name="F603" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="caninosUrbano">Final</label>
                        <select id="Final6" name="Final6" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">DINAMICA FAMILIAR</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F701">701</label>
                        <select id="F701" name="F701" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F702">702</label>
                        <select id="F702" name="F702" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="F703">703</label>
                        <select id="F703" name="F703" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </div>
                      <div class="col my-1">
                        <label class="mr-sm-2" for="Final7">Final</label>
                        <select id="Final7" name="Final7" class="custom-select mr-sm-2">
                          <option>Blanco</option>
                          <option>Rojo</option>
                          <option>Verde</option>
                          <option>Amarillo</option>
                        </select>
                      </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/dropzone.js"></script>

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

  <script type="text/JavaScript">
    <% if(ListVivi){ %>
          var arrayLisVivi = []
          <% ListVivi.forEach((ListVivi)=> { %>
            arrayLisVivi.push("<%= ListVivi.municipio %>", "<%= ListVivi.ForVivienda.viviendaViv %>", "<%= ListVivi.ForVivienda.direccionViv %>", "<%= ListVivi.ForVivienda.veredaViv %>")
          <% }) %>
      <% } %>
  </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>
    $(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";
    });

    const muniSelect = document.getElementById("muniSelect")
    const vivienda = document.getElementById("vivienda")
    const direccion = document.getElementById("direccion")
    const vereda = document.getElementById("vereda")

    muniSelect.addEventListener("change", function() {
      direccion.value = "";
      vereda.value = "";

      for (let i = vivienda.options.length; i >= 1; i--) {
        vivienda.remove(i);
        vivienda.selectedIndex = "Seleccione";
      }

      for (var i = 0; i < arrayLisVivi.length; i++) {
        if (arrayLisVivi[i] == muniSelect.value) {
          const option = document.createElement("option");
          const valor = arrayLisVivi[i + 1];
          option.value = valor;
          option.text = valor;
          vivienda.add(option);
        }
      }
    });

    vivienda.addEventListener("change", function() {
      for (var i = 0; i < arrayLisVivi.length; i++) {
        if (arrayLisVivi[i] == vivienda.value) {
          direccion.value = arrayLisVivi[i + 1];
          vereda.value = arrayLisVivi[i + 2];
        }
      }
    });
  </script>
</body>

</html>