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

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

  <script type="Text/JavaScript">
    <% if(settings){ %>
    var infMensStart = <%= settings[0].infMensStart %>
    var infMensEnd = <%= settings[0].infMensEnd %>
    <% } %>
  </script>
</head>

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

    <!-- Sidebar -->
    <%- include('../../../tools/sidebarProf'); %>
    <!-- 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">
          <!-- Page Heading -->
          <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">Inscribir Informe Mensual</h1>
                  </div>
                  <form onsubmit="novAdminis(event)" action="/profesional/Consolidaciones/Enviar/NoveAdministrativa/<%= user.user %>" method="POST" autocomplete="off" enctype="multipart/form-data">
                    <input type="text" value="on" id="noveadministrativa" name="noveadministrativa" 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="mesNA">Mes</label>
                        <input type="text" class="form-control form-control-user" id="mesNA" name="mesNA" onkeyup="mayus(this);" readonly>
                      </div>
                      <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>
                          <% if(fields){ %>
                          <% fields.forEach((fields)=> { %>
                          <option value="<%= fields.municipio %>">
                            <%= fields.municipio %>
                          </option>
                          <% }); %>
                          <% } %>
                        </select>
                      </div>
                    </div>

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

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="entreInfor">Si/No</label>
                        <select id="entreInfor" name="entreInfor" class="custom-select mr-sm-2">
                          <option selected disabled>Seleccione</option>
                          <option value="SI">Si</option>
                          <option value="NO">No</option>
                        </select>
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">ENTREGA DE CRONOGRAMA DE ACTIVIDADES</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="entreCrono">Si/No</label>
                        <select id="entreCrono" name="entreCrono" 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-6">
                        <label class="mr-sm-2" for="fechCrono">Fecha de Entrega</label>
                        <input type="date" class="form-control form-control-user" id="fechCrono" name="fechCrono" readonly />
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">CONTROL DE ASISTENCIA AL MUNICIPIO</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="entreAsis">Si/No</label>
                        <select id="entreAsis" name="entreAsis" 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-6">
                        <label class="mr-sm-2" for="fechAsis">Fecha de Entrega</label>
                        <input type="date" class="form-control form-control-user" id="fechAsis" name="fechAsis" readonly />
                      </div>
                    </div>

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

                    <div class="form-group row">
                      <div class="col-sm-6">
                        <label class="mr-sm-2" for="entreCircu">Si/No</label>
                        <select id="entreCircu" name="entreCircu" 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-6">
                        <label class="mr-sm-2" for="NumCir">N° de Circular</label>
                        <input type="text" class="form-control form-control-user" id="NumCir" name="NumCir" readonly />
                      </div>
                    </div>

                    <div class="row" style="text-align: center !important;">
                      <div class="col-sm-12">
                        <label class="mr-sm-12">DEVOLUCIÓN DE ACTAS</label>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-2">
                        <label class="mr-sm-6" for="numActas">N° de Actas</label>
                        <input type="number" class="form-control form-control-user" min="0" id="numActas" name="numActas" value="0" readonly />
                      </div>
                      <div class="col-sm-4">
                        <label class="mr-sm-4" for="nomActas">Nombre del Acta</label>
                        <textarea type="text" class="form-control form-control-user" onkeyup="mayus(this);" id="nomActas" name="nomActas" placeholder="Escriba los nombres segun la cantidad de actas" readonly></textarea>
                      </div>
                      <div class="col-sm-6">
                        <label class="mr-sm-4" for="motDevol">Motivo de Devolucion</label>
                        <textarea type="text" class="form-control form-control-user" onkeyup="mayus(this);" id="motDevol" name="motDevol" placeholder="Escriba el motivo de haber devuelto el acta" readonly></textarea>
                      </div>
                    </div>

                    <div class="form-group row">
                      <div class="col-sm-12">
                        <label class="mr-sm-2" for="observacion">Observaciones Y Comentarios
                          (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 Novedad
                    </button>

                  </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="/profesional/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/Profesional/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(actaAnul){ %>
      var arrayActa = []
      <% actaAnul.forEach((actaAnul)=> { %>
        arrayActa.push(["<%= actaAnul._id.municipio %>"], [<%= actaAnul.count %>])
      <% }) %>
    <% } %>
  </script>

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

    $("#entreCrono").change(function() {
      if (document.getElementById("entreCrono").value == "SI") {
        $("#fechCrono").attr("readonly", false);
        document.getElementById("fechCrono").setAttribute("max", new Date().toJSON().substring(0, 10));
      } else {
        $("#fechCrono").attr("readonly", true);
      }
    });
    $("#entreAsis").change(function() {
      if (document.getElementById("entreAsis").value == "SI") {
        $("#fechAsis").attr("readonly", false);
        document.getElementById("fechAsis").setAttribute("max", new Date().toJSON().substring(0, 10));
      } else {
        $("#fechAsis").attr("readonly", true);
      }
    });
    $("#entreCircu").change(function() {
      if (document.getElementById("entreCircu").value == "SI") {
        $("#NumCir").attr("readonly", false);
      } else {
        $("#NumCir").attr("readonly", true);
      }
    });

    var muni = document.getElementById("muniSelect")
    muni.addEventListener("change", function () {
      for (var i = 0; i < arrayActa.length; i++) {
        if (arrayActa[i] == muni.value) {
          $("#nomActas").attr("readonly", false);
          $("#motDevol").attr("readonly", false);
          document.getElementById("numActas").value = arrayActa[i + 1]
          return;
        }
        if(!arrayActa[i].includes(muni.value)){
            $("#nomActas").attr("readonly", true);
            $("#motDevol").attr("readonly", true);
            document.getElementById("numActas").value = 0
        }
      }
    });
  </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>
  <% } %>

</body>

</html>