/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.siso.horario.Servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import pe.siso.horario.Beans.Area;
import pe.siso.horario.Beans.AreaDocente;
import pe.siso.horario.Beans.DisponibilidadDocente;
import pe.siso.horario.Beans.Docente;
import pe.siso.horario.Beans.Merito;
import pe.siso.horario.Beans.PeriodoAcademico;
import pe.siso.horario.Beans.Plana;
import pe.siso.horario.Beans.PlanaDocente;
import pe.siso.horario.Beans.UbigeoDocente;
import pe.siso.horario.Beans.Usuario;
import pe.siso.horario.Services.AreaDocenteServices;
import pe.siso.horario.Services.AreaServices;
import pe.siso.horario.Services.DisponibilidadServices;
import pe.siso.horario.Services.DocenteServices;
import pe.siso.horario.Services.HorarioServices;
import pe.siso.horario.Services.MeritoServices;
import pe.siso.horario.Services.PeriodoAcademicoServices;
import pe.siso.horario.Services.PlanaDocenteServices;
import pe.siso.horario.Services.PlanaServices;
import pe.siso.horario.Services.UbigeoDocenteServices;
import pe.siso.horario.Services.ZonaServices;

/**
 *
 * @author sistem16user
 */
public class ServletDocente extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String param = request.getParameter("Accion");
        if ("listaDocente".equals(param)) {
            listaDocente(request, response);
        } else if ("listaBusqueda".equals(param)) {
            listaBusqueda(request, response);
        } else if ("registrarAreaDocente".equals(param)) {
            registrarAreaDocente(request, response);
        } else if ("listadoDocentesSecundaria".equals(param)) {
            listadoDocentesSecundaria(request, response);
        } else if ("armarEdicion".equals(param)) {
            armarEdicion(request, response);
        } else if ("cargarDocentesDisponibles".equals(param)) {
            cargarDocentesDisponibles(request, response);
        } else if ("RegistrarDisp".equals(param)) {
            RegistrarDisp(request, response);
        } else if ("buscarDocenteSecundaria".equals(param)) {
            buscarDocenteSecundaria(request, response);
        } else if ("quitarAreaDocente".equals(param)) {
            quitarAreaDocente(request, response);
        } else if ("buscarUsuarioDocente".equals(param)) {
            buscarUsuarioDocente(request, response);
        } else if ("listarTodoUsuDocente".equals(param)) {
            listarTodoUsuDocente(request, response);
        } else if ("cargarDocentesDisponiblesEdit".equals(param)) {
            cargarDocentesDisponiblesEdit(request, response);
        } else if ("buscarUsuarioDocenteDatos".equals(param)) {
            buscarUsuarioDocenteDatos(request, response);
        } else if ("armarRegistroDatosDocente".equals(param)) {
            armarRegistroDatosDocente(request, response);
        } else if ("registraDatosDocente".equals(param)) {
            registraDatosDocente(request, response);
        } else if ("listarDatosDocente".equals(param)) {
            listarDatosDocente(request, response);
        } else if ("armarEditarDatos".equals(param)) {
            armarEditarDatos(request, response);
        } else if ("actualizarDatos".equals(param)) {
            actualizarDatos(request, response);
        } else if ("registraDatosDocenteEdit".equals(param)) {
            registraDatosDocenteEdit(request, response);
        } else if ("darDeBaja".equals(param)) {
            darDeBaja(request, response);
        } else if ("buscarDocenteHorario".equals(param)) {
            buscarDocenteHorario(request, response);
        } else if ("armarDocenteHorario".equals(param)) {
            armarDocenteHorario(request, response);
        } else if ("verificarCruces".equals(param)) {
            verificarCruces(request, response);
        } else if ("armarRegistroDatosDocenteEdit".equals(param)) {
            armarRegistroDatosDocenteEdit(request, response);
        } else if ("armarEdicionEspecial".equals(param)) {
            armarEdicionEspecial(request, response);
        } else if ("cargarDocentesDisponiblesGeneral".equals(param)) {
            cargarDocentesDisponiblesGeneral(request, response);
        } else if ("cargarDocentesDisponiblesGeneral2".equals(param)) {
            cargarDocentesDisponiblesGeneral2(request, response);
        } else if ("cargarDocentesDisponiblesGeneral3".equals(param)) {
            cargarDocentesDisponiblesGeneral3(request, response);
        } else if ("tablaDocentesDisponiblesGeneral3".equals(param)) {
            tablaDocentesDisponiblesGeneral3(request, response);
        } else if ("listarDocenteSede".equals(param)) {
            listarDocenteSede(request, response);
        } else if ("listarBandeja".equals(param)) {
            listarBandeja(request, response);
        } else if ("armarPopUpInforme".equals(param)) {
            armarPopUpInforme(request, response);
        } else if ("respuesta".equals(param)) {
            respuesta(request, response);
        } else if ("cargarEncuestas".equals(param)) {
            cargarEncuestas(request, response);
        } else if ("migrar".equals(param)) {
            migrar(request, response);
        } else if ("insercion".equals(param)) {
            insercion(request, response);
        } else if ("VerDatosMigrados".equals(param)) {
            VerDatosMigrados(request, response);
        } else if ("listarDocentesTotales".equals(param)) {
            listarDocentesTotales(request, response);
        } else if ("validarEstadoDoc".equals(param)) {
            validarEstadoDoc(request, response);
        } else if ("registrarFichaEvaluacion".equals(param)) {
            registrarFichaEvaluacion(request, response);
        } else if ("editarFichaEvaluacion".equals(param)) {
            editarFichaEvaluacion(request, response);
        } else if ("reportePromedioAnualMeritoDocente".equals(param)) {
            reportePromedioAnualMeritoDocente(request, response);
        } else if ("tablaDocentesDisponiblesGeneral4".equals(param)) {
            tablaDocentesDisponiblesGeneral4(request, response);
        } else if ("armarEdicionDoc".equals(param)) {
            armarEdicionDoc(request, response);
        } else if ("verificarExisteRegistroDatosDocente".equals(param)) {
            verificarExisteRegistroDatosDocente(request, response);
        } else if ("listarDocentePorArea".equals(param)) {
            listarDocentePorArea(request, response);
        } else if ("registrarPlanaDocente".equals(param)) {
            registrarPlanaDocente(request, response);
        } else if ("quitarPlanaDocente".equals(param)) {
            quitarPlanaDocente(request, response);
        } else if ("verificarCrucesPorPeriodo".equals(param)) {
            verificarCrucesPorPeriodo(request, response);
        } else if ("tablaDocentesDisponiblesGeneral5".equals(param)) {
            tablaDocentesDisponiblesGeneral5(request, response);
        }

    }

    private void listaDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        DisponibilidadServices servicios2 = new DisponibilidadServices();
        ArrayList<Docente> lista = null;
        ArrayList<DisponibilidadDocente> lista2 = null;
        lista2 = servicios2.docentesAsignados();
        // String codDoc = request.getParameter("codDoc");
        int dato = 0;
        //int cDocDis = 0;
        String cDocDis = "";
        lista = servicios.listaDocentes();

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">"
          + "	    <tr>"
          + "               <td height=\"10\"></td>"
          + "           </tr>"
          + "           <tr><td width=\"550\">"
          + "                   <div class=\"datagrid\">"
          + "                           <table >"
          + "                                   <thead>"
          + "                                       <tr >"
          + "                                           <th>N°</th>"
          + "                                           <th>DNI</th>"
          + "                                           <th>APELLIDOS</th>"
          + "                                           <th>NOMBRE</th>"
          + "                                           <th>DISPONIBILIDAD</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");
        int cont = 1;
        for (int i = 0; i < lista.size(); i++) {
            String cDoc = lista.get(i).getCod_pro();

            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center'>" + cont + "</td>"
              + "    <td>" + lista.get(i).getDni() + "</td>"
              + "    <td>" + lista.get(i).getApe_pro() + "</td>"
              + "    <td>" + lista.get(i).getNom_pro() + "</td>");

            for (int j = 0; j < lista2.size(); j++) {
                //cDocDis = Integer.parseInt(lista2.get(j).getCodDoc());
                cDocDis = lista2.get(j).getCodDoc();
                if (cDocDis.equals(cDoc)) {
                    dato = dato + 1;
                } else {
                    dato = dato + 0;
                }
            }

            if (dato == 0) {
                pw.println(
                  "    <td  align='center'><a href=\"javascript:editar(" + lista.get(i).getCod_pro() + ");\" class=\"regular\" >"
                  + "            <img src=\"imagenes/icons/table_add.png\" />"
                  + "        </a>"
                  + "    </td>");
            } else {
                pw.println(
                  "    <td  align='center'><a href=\"javascript:editar(" + lista.get(i).getCod_pro() + ");\" class=\"regular\" >"
                  + "            <img src=\"imagenes/icons/page_edit.png\" />"
                  + "        </a>"
                  + "    </td>");//editar
            }

            dato = 0;

            pw.println(" </tr>");
            cont++;

        }
        if (cont == 1) {
            pw.println("<tr><td colspan='7' align='center'>No hay Docentes registrados</td></tr>");
        }

        pw.println("</tbody>"
          + "			</table>"
          + "			</div>"
          + "			</td></tr></table>");
    }

    private void listaBusqueda(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;

        int cantRegistro = 0;
        DisponibilidadServices servicios2 = new DisponibilidadServices();
        String periodo = request.getParameter("periodo");
        String apellido = request.getParameter("apellido");
        int pagina = Integer.parseInt(request.getParameter("pagina"));
        int cantidad = Integer.parseInt(request.getParameter("cantidad"));

        int inicio = (pagina - 1) * cantidad;

        lista = servicios.listaDocentes(apellido, inicio, cantidad);
        cantRegistro = servicios.cantListaDocente(apellido);

        //--------------CALCULO DE PAGINADO---------
        int numero = cantRegistro / cantidad;
        int resto = cantRegistro % cantidad;
        if (resto > 0) {
            numero = numero + 1;
        }
        //----------------------------------------------

        ArrayList<DisponibilidadDocente> lista2 = null;
        lista2 = servicios2.docentesAsignados(periodo);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarDisponibilidad();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar todo"
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DNI</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRE</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DISPONIBILIDAD</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">EXPORTAR DISPONIBILIDAD</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int cont_ini = 0;
        int cont_fin = 0;
        int cont = inicio + 1;
        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            //int cDoc = lista.get(i).getCod_pro();
            String cDoc = lista.get(i).getCod_pro();
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center' width='30'>" + cont + "</td>"
              + "    <td align='center' width='150'>" + lista.get(i).getDni() + "</td>"
              + "    <td width='180'>" + lista.get(i).getApe_pro() + "</td>"
              + "    <td width='180'>" + lista.get(i).getNom_pro() + "</td>"
            );

            for (int j = 0; j < lista2.size(); j++) {
                String cDocDis = lista2.get(j).getCodDoc();
                if (cDocDis.equals(cDoc)) {
                    dato = dato + 1;
                }
            }
            if (dato == 0) {
                pw.println("    <td  align='center'><a href=\"javascript:armarEdicion(" + lista.get(i).getCod_pro() + "," + pagina + ");\" class=\"regular\" title=\"[Click para Registrar]\">"
                  + "            <img src=\"imagenes/icons/table_add.png\" />"
                  + "        </a>"
                  + "    </td>");//agregar

                pw.println("  <td  align='center'> --"
                  + "    </td>"
                  + "</tr>");

            } else {
                pw.println("    <td  align='center'><a href=\"javascript:armarEdicion(" + lista.get(i).getCod_pro() + "," + pagina + ");\" class=\"regular\" title=\"[Click para Modificar]\">"
                  + "            <img src=\"imagenes/icons/page_edit.png\" />"
                  + "        </a>"
                  + "    </td>");//editar

                pw.println("  <td  align='center'><a href=\"javascript:exportar(" + lista.get(i).getCod_pro() + ");\" class=\"regular\" >"
                  + "            <img src=\"imagenes/icons/export_excel.png\" />"
                  + "        </a>"
                  + "    </td>"
                  + "</tr>");//exportar los que tengan

            }

            dato = 0;

            /*
             pw.println( "  <td  align='center'><a href=\"javascript:exportar("+lista.get(i).getCod_pro()+");\" class=\"regular\" >"
             + "            <img src=\"imagenes/icons/export_excel.png\" />"
             + "        </a>"
             + "    </td>"
             + "</tr>"); */
            cont++;
        }

        cont_fin = cont - 1;

        if (cont == 1) {
            pw.println("<tr><td colspan='7' align='center'>No hay coincidencias en la búsqueda de docentes</td></tr>");
        }

        pw.println("       </tbody>"
          + "			</table>");

        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

    }

    private void listadoDocentesSecundaria(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        AreaServices serviciosA = new AreaServices();
        AreaDocenteServices serviciosAD = new AreaDocenteServices();
        ArrayList<Docente> lista = null;
        ArrayList<Area> listaA = null;
        ArrayList<AreaDocente> listaAD = null;
        int cantidadAsignada = 0;
        listaA = serviciosA.cargarArea();
        lista = servicios.listarDocenteScundaria();
        String codigosArea = "";
        String codArea = "";
        String codDocente = "";
        int asignado = 0;
        String cadenaCodigoDocente = "";

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">"
          + "	    <tr>"
          + "               <td height=\"10\"></td>"
          + "           </tr>"
          + "           <tr><td >"
          + "                   <div class=\"datagrid\">"
          + "                           <table border='1'>"
          + "                                   <thead>"
          + "                                       <tr >"
          + "                                           <th>N°</th>"
          + "                                           <th>APELLIDOS</th>"
          + "                                           <th>NOMBRES</th>");
        for (int i = 0; i < listaA.size(); i++) {
            pw.println("<th>" + listaA.get(i).getNombreArea() + "</th>");
            if (codigosArea == "") {
                codigosArea += listaA.get(i).getCodigoArea();
            } else {
                codigosArea += "#" + listaA.get(i).getCodigoArea();
            }

        }
        pw.println("</tr>"
          + "                                   </thead>"
          + "                                   <tbody>");
        int cont = 1;

        //CODIGOS DE DOCENTES
        for (int i = 0; i < lista.size(); i++) {
            if (cadenaCodigoDocente.equals("")) {
                cadenaCodigoDocente += lista.get(i).getCod_pro();
            } else {
                cadenaCodigoDocente += "," + lista.get(i).getCod_pro();
            }
        }

        listaAD = serviciosAD.consultarAsignados(cadenaCodigoDocente);

        for (int i = 0; i < lista.size(); i++) {

            /*
             cantidadAsignada= serviciosAD.cantidadAsignado(lista.get(i).getCodigoDocente());

             if(cantidadAsignada>0){
             pw.println("<tr class=\"alt\" >");
             }else{
             pw.println("<tr>");
             }*/
            pw.println("<tr>");
            pw.println("   <td align='center'>" + cont + "</td>"
              + "   <td>" + lista.get(i).getApe_pro() + "</td>"
              + "   <td>" + lista.get(i).getNom_pro() + "</td>");

            for (int j = 0; j < listaA.size(); j++) {
                int dato = j + 1;
                //consultar area y docente
                codArea = "" + listaA.get(j).getCodigoArea();
                codDocente = "" + lista.get(i).getCod_pro();
                int valor = 0;
                for (int x = 0; x < listaAD.size(); x++) {

                    if (listaAD.get(x).getCodigoArea() == listaA.get(j).getCodigoArea()) {
                        if (listaAD.get(x).getCodigoDocente().equals(lista.get(i).getCod_pro())) {
                            valor = 1;
                        }
                    }
                }

                if (valor == 1) {
                    pw.println("<td align='center' valign='middle'><a href=\"javascript:popup_QuitarSeleccion(" + codArea + "," + codDocente + ");\" class=\"regular\" ><img src=\"imagenes/icons/check_box.png\" /></a></td>");
                } else {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' name='" + dato + "_docente_" + cont + "' value='" + codArea + "_" + codDocente + "'  /></td>");
                }
                valor = 0;

                /*
                 codArea = ""+listaA.get(j).getCodigoArea();
                 codDocente = ""+lista.get(i).getCodigoDocente();
                 asignado = serviciosAD.consultarAsignado(codDocente, codArea);
                 if(asignado==0){
                 pw.println("    <td align='center' valign='middle'><input type='checkbox' name='"+dato+"_docente_"+cont+"' value='"+codArea+"_"+codDocente+"'  /></td>");
                 }else{
                 pw.println("    <td align='center' valign='middle'><a href=\"javascript:quitarAreaSelecciona("+codArea+","+codDocente+");\" class=\"regular\" ><img src=\"imagenes/icons/check_box.png\" /></a></td>");
                 }
                 */
            }

            pw.println(" </tr>");
            cont++;
        }

        if (cont == 1) {
            pw.println("<tr><td colspan='7' align='center'>No hay Docentes</td></tr>");
        }
        int cantidad = cont - 1;
        pw.println("</tbody>"
          + "			</table>"
          + "			</div>"
          + "			</td></tr></table>"
          + "<input type='hidden' id='codAreas' value='" + codigosArea + "' />"
          + "<input type='hidden' id='cantidad' value='" + cantidad + "' />");
    }

    private void registrarAreaDocente(HttpServletRequest request, HttpServletResponse response) {
        AreaDocenteServices servicios = new AreaDocenteServices();
        String dato = request.getParameter("res");

        String[] ArrayGrande = dato.split("#");
        for (int i = 0; i < ArrayGrande.length; i++) {
            String[] ArrayChico = ArrayGrande[i].split("_");
            servicios.registrarAreaDocente(ArrayChico[1], ArrayChico[0]);
        }

    }

    private void armarEdicion(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        DisponibilidadServices serviciosDD = new DisponibilidadServices();
        Docente docente = new Docente();
        String codDoc = request.getParameter("codDoc");
        String periodo = request.getParameter("periodo");

        docente = servicios.NombreDocente(codDoc);
        String cadenaDia = serviciosDD.ConsultaDisponibilidad(codDoc, periodo);

        String cadena = "";
        //String dato = request.getParameter("dato");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        String TM = "";
        String TT = "";
        String TN = "";

        String[] arrayGrupo = cadenaDia.split("-");
        for (int i = 0; i < arrayGrupo.length; i++) {
            String[] arrayTD = arrayGrupo[i].split("#");
            if (arrayTD[0].equals("1")) {
                if (TM.equals("")) {
                    TM += "0-" + arrayTD[1];
                } else {
                    TM += "-" + arrayTD[1];
                }

            } else if (arrayTD[0].equals("2")) {
                if (TT.equals("")) {
                    TT += "0-" + arrayTD[1];
                } else {
                    TT += "-" + arrayTD[1];
                }
            } else if (arrayTD[0].equals("3")) {
                if (TN.equals("")) {
                    TN += "0-" + arrayTD[1];
                } else {
                    TN += "-" + arrayTD[1];
                }
            }
        }

        String[] arrayDisponibilidad = {TM, TT, TN};

        String[] arrayHora = {"07:50 a 14:30", "15:00 a 19:00 ", "19:00 a 22:00"};
        String[] arrayTurno = {"MAÑANA", "TARDE", "NOCHE"};

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" >"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>DOCENTE: " + docente.getApe_pro() + ", " + docente.getNom_pro() + "</td>"
          + "                     <td align=\"right\">"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORAS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TODOS</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int dato = 0;
        int turno = 0;
        int posicion = 1;
        int dia = 0;
        for (int i = 0; i < 3; i++) {
            turno = i + 1;

            pw.println("<tr >"
              + "<td align='center'>" + arrayHora[i] + "</td>"
              + "<td>" + arrayTurno[i] + "</td>");
            for (int j = 1; j <= 6; j++) {
                //int cantidad=0;
                if (arrayDisponibilidad[i] == "") {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                } else {
                    String[] arrayDias = arrayDisponibilidad[i].split("-");
                    for (int d = 0; d < arrayDias.length; d++) {
                        dia = Integer.parseInt(arrayDias[d]);
                        if (j == dia) {
                            dato = dato + 1;
                        } else {
                            dato = dato + 0;
                        }

                    }
                    int cantidad = serviciosDD.asignadoDisponibilidad(codDoc, j, turno, periodo);
//                    int cantidad = serviciosDD.asignadoDisponibilidad(codDoc, j, turno);
                    if (cantidad > 0) {
                        if (dato == 1) {
                            if (cadena.equals("")) {
                                cadena = turno + "#" + j;
                            } else {
                                cadena += "-" + turno + "#" + j;
                            }
                            //if(cantidad>0){
                            pw.println("<td align='center' valign='middle' style='background-color:#9FCEF8'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked disabled /></td>");
                            // }
                        } else {
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                        }
                    } else {
                        if (dato == 1) {
                            //if(cantidad>0){
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked /></td>");
                            // }
                        } else {
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                        }
                    }
                    dato = 0;
                }
                posicion++;

            }

            pw.println("    <td align='center'><a href='javascript:seleccionar_todo(" + turno + ");'> <img src='imagenes/icons/check_box.png'></a>"
              + " </td>"
              + "</tr> ");

        }
        // PG000019
        pw.println("<!--<td align='center' valign='middle'><a href='javascript:seleccionar_todo();'> <img src='imagenes/icons/check_box.png'></a></td> </tr>-->"
          + "               </tbody>"
          + "           </table> <input type=hidden id='dato' value='1'> <input type='hidden' id='selec' value='" + cadena + "' >"
          + "       </div>"
          + "   </div>"
          + "   <center>"
          + "       <table border='0'>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td style='background-color:#9FCEF8;  border: 1px solid black;'  width='20'> </td>"
          + "               <td width='10'> </td>"
          + "               <td >Este color muestra que ya tiene asignado un  curso en ese día.</td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "       </table>"
          + "   </center>"
          + "</div>");

        /*+"<tr><td height='20' > </td> </tr>"
         +"<table border='0' cellpadding='0' cellspacing='0'>"
         +"   <tr>"
         +"       <td style='background-color:#9FCEF8;  border: 1px solid black;'  width='20'> </td> "
         +"       <td width='10'> </td>"
         +"       <td > Este color muestra que ya tiene asignado un  curso en ese día. </td>"
         +"  </tr>"
         +"</table>"
         +"</div>"
         +"</td>"
         +"</tr>"
         +"</table> ");*/
    }

    private void cargarDocentesDisponibles(HttpServletRequest request, HttpServletResponse response) throws IOException {
        AreaDocenteServices servicios = new AreaDocenteServices();
        ArrayList<AreaDocente> lista = null;
        String nombre = request.getParameter("nombre");
        String accion = request.getParameter("accion");
        String codTurno = request.getParameter("codTurno");
        String codcurso = request.getParameter("codCurso");
        String dia = request.getParameter("dia");

        lista = servicios.cargarDocentesDisponibles(codTurno, dia, codcurso);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='" + nombre + "' class='form-control validate[required]' onChange='" + accion + "'>");
        pw.println("<option value=''>[Seleccione]</option>");
        for (int i = 0; i < lista.size(); i++) {
            pw.println("<option value='" + lista.get(i).getCodigoDocente() + "'>" + lista.get(i).getApellidoDocente() + ", " + lista.get(i).getNombreDocente() + "</option>");
        }

        pw.println("</select>");
    }

    private void RegistrarDisp(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DisponibilidadServices servicios = new DisponibilidadServices();
        String codDoc = request.getParameter("codDoc");
        String DiaDis = request.getParameter("DiaDis");
        String periodo = request.getParameter("periodo");

        int dato = servicios.registrarDisponibilidad(codDoc, DiaDis, periodo);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        if (dato == 1) {
            pw.println("1");//registrable
        } else if (dato == 2) {
            pw.println("2");//Actualizar
        } else {
            pw.println("0");// Error
        }
    }

    private void buscarDocenteSecundaria(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        AreaServices serviciosA = new AreaServices();
        AreaDocenteServices serviciosAD = new AreaDocenteServices();
        ArrayList<Docente> lista = null;
        ArrayList<Area> listaA = null;
        ArrayList<AreaDocente> listaAD = null;
        String apellidoDocente = request.getParameter("apellidoDocente");
        int cantRegistro = 0;
        int cantidadAsignada = 0;
        listaA = serviciosA.cargarArea();
        // lista=servicios.listarDocenteScundaria(apellidoDocente);
        String codigosArea = "";
        String codArea = "";
        String codDocente = "";
        int asignado = 0;
        String cadenaCodigoDocente = "";
        int verificarCruce = 0;

        //---------------datos de la pginacion----------------------
        int cant = Integer.parseInt(request.getParameter("cantidad"));
        int pagina = Integer.parseInt(request.getParameter("pagina"));
        int inicio = (pagina - 1) * cant;

        lista = servicios.listaDocentes(apellidoDocente, inicio, cant);
        cantRegistro = servicios.cantListaDocente(apellidoDocente);

        //--------------CALCULO DE PAGINADO---------
        int numero = cantRegistro / cant;
        int resto = cantRegistro % cant;
        if (resto > 0) {
            numero = numero + 1;
        }

        //----------------------------------------------
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"validar_asignar();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-check icon-on-right bigger-110\"></i>"
          + "                                               Asignar Área"
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline n o-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRES</th>");
        int canti = 0;
        for (int i = 0; i < listaA.size(); i++) {
            canti++;
            pw.println("<th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">" + listaA.get(i).getNombreArea() + "</th>");
            if (codigosArea == "") {
                codigosArea += listaA.get(i).getCodigoArea();
            } else {
                codigosArea += "#" + listaA.get(i).getCodigoArea();
            }

        }
        String[] ArrayCodArea = codigosArea.split("#");
        pw.println("</tr>"
          + "                                   </thead>"
          + "<tbody>");
        int cont_ini = 0;
        int cont_fin = 0;
        int cont = inicio + 1;

        //CODIGOS DE DOCENTES
        for (int i = 0; i < lista.size(); i++) {
            if (cadenaCodigoDocente.equals("")) {
                cadenaCodigoDocente += lista.get(i).getCod_pro();
            } else {
                cadenaCodigoDocente += "," + lista.get(i).getCod_pro();
            }
        }

        listaAD = serviciosAD.consultarAsignados(cadenaCodigoDocente);

        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            pw.println("<tr>");
            pw.println("   <td align='center'>" + cont + "</td>"
              + "   <td>" + lista.get(i).getApe_pro() + "</td>"
              + "   <td>" + lista.get(i).getNom_pro() + "</td>");

            for (int j = 0; j < listaA.size(); j++) {
                int dato = j + 1;
                //consultar area y docente
                codArea = "" + listaA.get(j).getCodigoArea();
                codDocente = "" + lista.get(i).getCod_pro();
                int valor = 0;
                for (int x = 0; x < listaAD.size(); x++) {

                    if (listaAD.get(x).getCodigoArea() == listaA.get(j).getCodigoArea()) {
                        if (listaAD.get(x).getCodigoDocente().equals(lista.get(i).getCod_pro())) {
                            valor = 1;
                        }
                    }
                }

                if (valor == 1) {
                    verificarCruce = servicios.verificarCruces(codDocente, codArea);
                    if (verificarCruce == 0) {
                        pw.println("<td align='center' valign='middle' >"
                          + "     <div id='div_" + codArea + "_" + codDocente + "'>"
                          + "         <a href=\"javascript:verificarCruces(" + codArea + "," + codDocente + "," + codArea + "," + cont + ");\" class=\"regular\" >"
                          + "             <img src=\"imagenes/icons/check_box.png\" />"
                          + "         </a>"
                          + "     </div>"
                          + "</td>");
                    } else {
                        pw.println("<td align='center' valign='middle'  style='background-color:#D0EAFF'>"
                          + "     <div id='div_" + codArea + "_" + codDocente + "'>"
                          + "         <a href=\"javascript:verificarCruces(" + codArea + "," + codDocente + "," + codArea + "," + cont + ");\" class=\"regular\" >"
                          + "             <img src=\"imagenes/icons/check_box.png\" />"
                          + "         </a>"
                          + "     </div>"
                          + "</td>");

                    }

                } else {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' name='" + codArea + "_docente_" + cont + "' value='" + codArea + "_" + codDocente + "'  /></td>");
                }
                valor = 0;
            }

            pw.println(" </tr>");
            cont++;
        }

        cont_fin = cont - 1;
        canti = canti + 3;
        if (cont == 1) {
            pw.println("<tr><td colspan='" + canti + "' align='center'>No hay docente para asignar</td></tr>");
        }
        int cantidad = cont - 1;
        pw.println("</tbody>"
          + "			</table>"
          + "                       <input type='hidden' id='codAreas' value='" + codigosArea + "' />"
          + "                       <input type='hidden' id='cantidad' value='" + cantidad + "' />"
          + "			</table>");

        //::::::::::::::: PIE ::::::::::::::::
        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:buscarDocente(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:buscarDocente(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:buscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:buscarDocente(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:buscarDocente(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

        /*
         "			</div>" +
         "			</td></tr></table>" +
         "			<table >" +
         "                       <tr>        "+
         "			<td colspan='8' align='center'></td>" +
         "                       </tr>        "+
         "                       <tr>        "+
         "			<td  width='15'  style='background-color:#D0EAFF;  border: 1px solid; border-color: #000000;' >  " +
         "			</td> " +
         "			<td>  " +
         "			: Este color indica que no se puede quitar la selección debido a que tiene un horario asignado." +
         "			</td>      " +
         "                       </tr>        "+
         "			</table>"
         + "<input type='hidden' id='codAreas' value='"+codigosArea+"' />"
         + "<input type='hidden' id='cantidad' value='"+cantidad+"' />"); */
    }

    private void quitarAreaDocente(HttpServletRequest request, HttpServletResponse response) {
        AreaDocenteServices servicios = new AreaDocenteServices();
        String codigoDocente = request.getParameter("codigoDocente");
        String codigoArea = request.getParameter("codigoArea");
        servicios.quitarAreaDocente(codigoDocente, codigoArea);
    }

    private void buscarUsuarioDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;
        String apellido = request.getParameter("apellido");
        int cantidad = Integer.parseInt(request.getParameter("cantidad"));
        int pagina = Integer.parseInt(request.getParameter("pagina"));

        int cantRegistro = 0;
        int inicio = (pagina - 1) * cantidad;
        int cantidadAsignada = 0;
        //listaA=serviciosA.cargarArea();
        // lista=servicios.listarDocenteScundaria(apellidoDocente);

        int asignado = 0;
        String cadenaCodigoDocente = "";
        cantRegistro = servicios.cantListaDocente(apellido);
        //--------------CALCULO DE PAGINADO---------
        int numero = cantRegistro / cantidad;
        int resto = cantRegistro % cantidad;
        if (resto > 0) {
            numero = numero + 1;
        }
        lista = servicios.buscarUsuarioDocente(apellido, inicio, cantidad);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Usuarios Docente</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarUsuario();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar lista de usuarios"
          + "                                           </button>"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodoUsuario();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar todos"
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CODIGO USUARIO</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int cont_ini = 0;
        int cont_fin = 0;
        int cont = inicio + 1;
        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center'>" + cont + "</td>"
              + "    <td >" + lista.get(i).getApe_pro() + "</td>"
              + "    <td >" + lista.get(i).getNom_pro() + "</td>"
              + "    <td align='center'>" + lista.get(i).getCodDocenteId() + "</td>"
            );

            pw.println("</tr>");
            cont++;
        }

        cont_fin = cont - 1;

        if (cont == 1) {
            pw.println("<tr><td colspan='4' align='center'>No hay Docentes registrados</td></tr>");
        }

        pw.println("       </tbody>"
          + "			</table>");

        //::::::::::::::: PIE ::::::::::::::::
        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

    }

    private void listarTodoUsuDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;

        String apellido = request.getParameter("apellido");

        lista = servicios.listarTodoUsuDocente();

        // ArrayList<DisponibilidadDocente> lista2=null;
        //lista2=servicios2.docentesAsignados();
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;
        pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">"
          + "	    <tr>"
          + "               <td height=\"10\"></td>"
          + "           </tr>"
          + "           <tr><td width=\"550\">"
          + "                   <div class=\"datagrid\">"
          + "                           <table >"
          + "                                   <thead>"
          + "                                       <tr >"
          + "                                           <th>N°</th>"
          + "                                           <th>APELLIDOS</th>"
          + "                                           <th>NOMBRES</th>"
          + "                                           <th>CODIGO USUARIO</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");
        int cont = 1;
        for (int i = 0; i < lista.size(); i++) {
            //int cDoc = lista.get(i).getCod_pro();
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center'>" + cont + "</td>"
              + "    <td >" + lista.get(i).getApe_pro() + "</td>"
              + "    <td >" + lista.get(i).getNom_pro() + "</td>"
              + "    <td align='center'>" + lista.get(i).getCodDocenteId() + "</td>"
            );

            pw.println("</tr>");
            cont++;
        }

        if (cont == 1) {
            pw.println("<tr><td colspan='7' align='center'>No hay Docentes registrados</td></tr>");
        }

        pw.println("</tbody>"
          + "			</table>"
          + "			</div>"
          + "			</td></tr></table>");
    }

    private void cargarDocentesDisponiblesEdit(HttpServletRequest request, HttpServletResponse response) throws IOException {
        AreaDocenteServices servicios = new AreaDocenteServices();
        ArrayList<AreaDocente> lista = null;
        String nombre = request.getParameter("nombre");
        String accion = request.getParameter("accion");
        String codTurno = request.getParameter("codTurno");
        String codcurso = request.getParameter("codCurso");
        String codDocente = request.getParameter("codDoc");
        String dia = request.getParameter("dia");

        System.out.println(codDocente);

        lista = servicios.cargarDocentesDisponibles(codTurno, dia, codcurso);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='" + nombre + "' class='form-control validate[required]' onChange='" + accion + "'>");
        pw.println("<option value=''>[Seleccione]</option>");
        for (int i = 0; i < lista.size(); i++) {
            if (codDocente.equals(lista.get(i).getCodigoDocente())) {
                pw.println("<option value='" + lista.get(i).getCodigoDocente() + "' selected>" + lista.get(i).getApellidoDocente() + ", " + lista.get(i).getNombreDocente() + "</option>");
            } else {
                pw.println("<option value='" + lista.get(i).getCodigoDocente() + "'>" + lista.get(i).getApellidoDocente() + ", " + lista.get(i).getNombreDocente() + "</option>");
            }
        }

        pw.println("</select>");
    }

    private void buscarUsuarioDocenteDatos(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;
        String apellido = request.getParameter("apellido");
        int pagina = Integer.parseInt(request.getParameter("pagina"));
        int cantidad = Integer.parseInt(request.getParameter("cantidad"));
        int cantRegistro = 0;

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        int inicio = (pagina - 1) * cantidad;
        lista = servicios.buscarUsuarioDocente(apellido, inicio, cantidad);

        cantRegistro = servicios.cantListaDocente(apellido);

        //--------------CALCULO DE PAGINADO---------
        int numero = cantRegistro / cantidad;
        int resto = cantRegistro % cantidad;
        if (resto > 0) {
            numero = numero + 1;
        }

        int dato = 0;

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" >"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DATOS PERSONALES</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int cont = inicio + 1;
        int cont_ini = 0;
        int cont_fin = 0;
        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            String codDoc = "" + lista.get(i).getCod_pro();
            int cant = servicios.cantidadDocenteDatos(codDoc);
            //int cDoc = lista.get(i).getCod_pro();
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center' width='25' >" + cont + "</td>"
              + "    <td width='170'>" + lista.get(i).getApe_pro() + "</td>"
              + "    <td width='170'>" + lista.get(i).getNom_pro() + "</td>");

            if (cant > 0) {
                pw.println("    <td align='center' width='25'><a href=\"javascript:armarRegistroEdit(" + lista.get(i).getCod_pro() + ",'" + lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro() + "');\" class=\"regular\" ><img src=\"imagenes/icons/page_edit.png\" / title=\"Click para [Modificar]\"> </a></td>");
            } else {
                pw.println("    <td align='center' width='25'><a href=\"javascript:armarRegistro(" + lista.get(i).getCod_pro() + ",'" + lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro() + "');\" class=\"regular\" ><img src=\"imagenes/icons/page_add.png\" / title=\"Click para [Registrar]\"></a></td>");
            }

            pw.println("</tr>");
            cont++;
        }

        cont_fin = cont - 1;

        if (cont == 1) {
            pw.println("<tr><td colspan='4' align='center'>No hay Docentes registrados</td></tr>");
        }

        pw.println("       </tbody>"
          + "			</table>");

        //::::::::::::::: PIE ::::::::::::::::
        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

    }

    private void armarRegistroDatosDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicio = new DocenteServices();
        //cargar departamento
        UbigeoDocenteServices servicios = new UbigeoDocenteServices();
        ArrayList<UbigeoDocente> lista = null;
        String accion = request.getParameter("accion");
        String nombre = request.getParameter("nombre");
        lista = servicios.cargarDepartamento();

        //------------------------------------------
        Docente docente = new Docente();
        String codDocente = request.getParameter("codDocente");
        String nomDocente = request.getParameter("nomDocente");
        docente = servicio.datosDocente(codDocente);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        String telefono = "", correo = "", direccion = "", celular = "";
        int codDepartamento = 0;
        int codProvincia = 0;
        int codDistrito = 0;

        if (docente.getTelefono() == null) {
            telefono = "";
        } else {
            telefono = docente.getTelefono();
        }

        if (docente.getCorreo() == null) {
            correo = "";
        } else {
            correo = docente.getCorreo();
        }

        if (docente.getCodigoDep() == 0) {
            codDepartamento = 0;
        } else {
            codDepartamento = docente.getCodigoDep();
        }

        if (docente.getCell() == null) {
            celular = "";
        } else {
            celular = docente.getCell();
        }

        if (docente.getDireccion() == null) {
            direccion = "";
        } else {
            direccion = docente.getDireccion();
        }

        pw.println("<center>"
          + " <table width='400' border='0'>"
          + "     <tr>"
          + "         <td height='15' colspan='3'> </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' align='center'>  <b>DOCENTE: </b>  " + nomDocente + " </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='20' colspan='3'> </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Teléfono <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required ,custom[phone]]' id='txt_new_tel' value='" + telefono + "'/></td><!--- maxSize[15], minSize[7]-->"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='15' colspan='3'> </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Celular <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required ,custom[onlyCelular]]' id='txt_new_celular' value='" + celular + "'/></td><!--- maxSize[15], minSize[7]-->"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Correo <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required,custom[email]]' id='txt_new_mail' value='" + correo + "' /></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Departamento <font color='red'>*</font></td>"
          + "         <td width='5'></td>");
        //combo departamento--------------
        pw.println("<td>"
          + "     <span id='divDepartamento'>"
          + "      <select class='form-control validate[required]' id='cmbDep' onChange='" + accion + "'>"
          + "         <option value=''>[Seleccione]</option>");
        pw.println("       </select>"
          + "     </span>"
          + " </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'></td>"
          + "     </tr>"
          + "     <tr>"
          // combo provincia

          + "         <td>Provincia <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td>"
          + "     <span id='divProvincia'>"
          + "      <select class='form-control validate[required]' id='cmbProv' >"
          + "         <option value=''>[Seleccione]</option>"
          + "     </select>"
          + "</span>"
          + " </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'></td>"
          + "     </tr>"
          + "     <tr>"
          //combo Distrito
          + "         <td>Distrito <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td>"
          + "     <span id='divDistrito'>"
          + "      <select class='form-control validate[required]' id='cmbDis' >"
          + "         <option value=''>[Seleccionar]</option>"
          + "     </select>"
          + "</span>"
          + " </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='15' colspan='3'> </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Dirección <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required]' id='txt_new_dir' value='" + direccion + "'/></td><!--- maxSize[15], minSize[7]-->"
          + "     </tr>"
          + "</table>"
          + "</center>");

    }

    private void registraDatosDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ZonaServices servicios2 = new ZonaServices();
        int dato = 0;
        int dato2 = 0;

        String telefono = request.getParameter("telefono");
        String mail = request.getParameter("mail");
        String zona = request.getParameter("zona");
        String codDocente = request.getParameter("codDocente");
        String direccion = request.getParameter("direccion");
        String cel = request.getParameter("cel");
        int codDepartamento = Integer.parseInt(request.getParameter("codDepartamento"));
        int codProvincia = Integer.parseInt(request.getParameter("codProvincia"));
        int codDistrito = Integer.parseInt(request.getParameter("codDistrito"));

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        dato = servicios.registroDatos(codDocente, telefono, mail, codDepartamento, codProvincia, codDistrito, cel, direccion);

        dato2 = servicios2.registrarZonaDocente(codDocente, codDepartamento, codProvincia, codDistrito);
        if (dato == 0) {
            pw.println("1");
        } else if (dato > 0) {
            pw.println("0");

        } else {
            pw.println("2");
        }
    }

    private void listarDatosDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;
        DisponibilidadServices servicios2 = new DisponibilidadServices();
        String codDocente = request.getParameter("codDocente");
        String dni = request.getParameter("dni");
        String nombres = request.getParameter("nombres");
        lista = servicios.consultarDatos(codDocente);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" >"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>DATOS DEL DOCENTE</td>"
          + "                     <td align=\"right\">"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DNI</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS Y NOMBRES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TEL. FIJO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TEL. CELULAR</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CORREO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DEPARTAMENTO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">PROVINCIA</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DISTRITO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ACCIÓN</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int cont = 1;
        for (int i = 0; i < lista.size(); i++) {
            String cDoc = lista.get(i).getCod_pro();
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center'>" + cont + "</td>"
              + "    <td align='center'>" + dni + "</td>"
              + "    <td align='center'>" + nombres + "</td>"
              + "    <td align='center'>" + lista.get(i).getTelefono() + "</td>"
              + "    <td align='center'>" + lista.get(i).getCell() + "</td>"
              + "    <td align='center'>" + lista.get(i).getCorreo() + "<input type='hidden' value='" + lista.get(i).getCorreo() + "' id='correo' ></td>"
              + "    <td align='center'>" + lista.get(i).getNombreDep() + "</td>"
              + "    <td align='center'>" + lista.get(i).getNombrePro() + "</td>"
              + "    <td align='center'>" + lista.get(i).getNombreDDis() + "</td>"
            );

            pw.println("  <td  align='center'><a href=\"javascript:armarEditarDatos(" + lista.get(i).getCodDocenteId() + ");\" class=\"regular\" >"
              + "            <img src=\"imagenes/icons/page_edit.png\" />"
              + "        </a>"
              + "    </td>"
              + "</tr>");
            cont++;
        }

        if (cont == 1) {
            pw.println("<tr><td colspan='5' align='center'>No hay datos registrados</td></tr>");
        }

        pw.println("</tbody>"
          + "			</table>"
          + "			</div>"
          + "			</td> <input type='hidden' id='cantidadRegistrado' value='" + cont + "'></tr></table>");
    }

    private void armarEditarDatos(HttpServletRequest request, HttpServletResponse response) throws IOException {
        /*DocenteServices servicios = new DocenteServices();
         Docente docente = new Docente();
         String codDocente = request.getParameter("codDocente");
         docente = servicios.datosDocente(codDocente);

         //String dato = request.getParameter("dato");
         response.setContentType("text/html");
         PrintWriter pw = response.getWriter();

         pw.println("<table  width='100%'>"
         + "<tr>"
         + "  <td height='15'></td>"
         + "</tr>"
         + "<tr>"
         + "<td align='center'> "
         + "<table>"
         + "      <tr>"
         + "          <td><b>Télefono:</b></td>"
         + "          <td width='10'></td>"
         + "          <td><input id='txt_tel' type='text' class='validate[required,custom[phone], maxSize[11], minSize[7]]' value='"+docente.getTelefono()+"' ></td>"
         + "      </tr>"
         + "      <tr>"
         + "          <td><b>Correo:</b></td>"
         + "          <td width='10'></td>"
         + "          <td><input id='txt_correo' type='text' class='validate[required,custom[email]]' value='"+docente.getCorreo()+"'  ></td>"
         + "      </tr>"
         + "      <tr>"
         + "          <td><b>Distrito:</b></td>"
         + "          <td width='10'></td>"
         + "          <td><input id='txt_zona' type='text' class='validate[required,custom[onlyLetterSp]]' value='"+docente.getZona()+"' onChange='conMayusculas(this);' ></td>"
         + "      </tr>"
         + "  </table>"
         + "</td>"
         + "</tr>"
         + "</table>");*/
        DocenteServices servicio = new DocenteServices();
        //cargar departamento
        UbigeoDocenteServices servicios = new UbigeoDocenteServices();
        ArrayList<UbigeoDocente> lista = null;
        String accion = request.getParameter("accion");
        String nombre = request.getParameter("nombre");
        lista = servicios.cargarDepartamento();

        //------------------------------------------
        Docente docente = new Docente();
        String codDocente = request.getParameter("codDocente");
        String nomDocente = request.getParameter("nomDocente");
        docente = servicio.datosDocente(codDocente);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        String telefono = "", correo = "", direccion = "", celular = "";
        int codDepartamento = 0;
        int codProvincia = 0;
        int codDistrito = 0;

        if (docente.getTelefono() == null) {
            telefono = "";
        } else {
            telefono = docente.getTelefono();
        }

        if (docente.getCorreo() == null) {
            correo = "";
        } else {
            correo = docente.getCorreo();
        }

        if (docente.getCodigoDep() == 0) {
            codDepartamento = 0;
        } else {
            codDepartamento = docente.getCodigoDep();
        }
        if (docente.getDireccion() == null) {
            direccion = "";
        } else {
            direccion = docente.getDireccion();
        }
        if (docente.getCell() == null) {
            celular = "";
        } else {
            celular = docente.getCell();
        }

        pw.println("<center><br><br>"
          + "         <table width='380' border='0'>"
          + "             <tr>"
          + "                 <td><b>Teléfono Fijo</b><span style=\"font-style: italic \">(Opcional)</span></td>"
          + "                 <td width='5'></td>"
          + "                 <td><input type='text' class='form-control validate[custom[phone]]]' maxlength=\"7\" id='txt_new_tel' value='" + telefono + "'/> </td>"
          + "             </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          //-----------------------------------------
          + "             <tr>"
          + "                 <td><b>Teláfono Celular </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>"
          + "                 <td><input type='text' class='form-control validate[required,custom[phone]]' maxlength=\"9\" id='txt_new_celular' value='" + celular + "' /> </td>"
          + "             </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          //------------------------------------------
          + "             <tr>"
          + "                 <td><b>Correo </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>"
          + "                 <td><input type='text' class='form-control validate[required,custom[email]]' id='txt_new_mail' value='" + correo + "' /> </td>"
          + "             </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          + "             <tr>"
          + "                 <td><b>Departamento </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>");
        //combo departamento--------------
        pw.println("                <td><div id='divDepartamentoEdit'>"
          + "                         <select class='form-control'  id='cmbDep' onChange='" + accion + "'>"
          + "                             <option value=''>[Seleccione]</option>");
        pw.println("                        </select>"
          + "                 </div> </td>");

        pw.println("            </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          + "             <tr>"
          // combo provincia

          + "                 <td><b>Provincia </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>");
        pw.println("                <td><div id='divProvinciaEdit'>"
          + "                         <select  id='cmbProv' >"
          + "                             <option value=''>[Seleccione]</option>"
          + "                         </select>"
          + "                     </div> </td>");
        pw.println("            </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          + "             <tr>"
          //combo Distrito
          + "                 <td><b>Distrito </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>");
        pw.println("                <td><div id='divDistritoEdit'>"
          + "                         <select class='form-control' id='cmbDis' >"
          + "                             <option value=''>[Seleccione]</option>"
          + "                         </select>"
          + "                     </div> </td>");

        pw.println("            </tr>"
          + "             <tr>"
          + "                 <td colspan='3' height='15'></td>"
          + "             </tr>"
          + "             <tr>"
          + "                 <td><b>Dirección </b><font color='red'>*</font></td>"
          + "                 <td width='5'></td>"
          + "                 <td><input type='text' class='form-control validate[required]' id='txt_new_dir' value='" + direccion + "' /> </td>"
          + "             </tr>"
          + "         </table>"
          + "</center>");

        /*pw.println("<table width='100%' border='0'>"

         + "<tr>"

         + "<td height='10'> </td>"

         + "  </tr>"

         + "  <tr>"
         // + "     <td align='center'>"
         // + "         <table>"
         + "             <tr>"
         + "                 <td><b>Teléfono:</b></td>"
         + "                 <td width='5'></td>"
         + "                 <td><input type='text' class='validate[required ,custom[onlyCelular], maxSize[15], minSize[7]]' id='txt_new_tel' value='"+telefono+"'/> <font color='red'>*</font></td>"
         + "             </tr>"
         + "             <tr>"
         + "                 <td><b>Correo:</b></td>"
         + "                 <td width='5'></td>"
         + "                 <td><input type='text' class='validate[required,custom[email]]' id='txt_new_mail' value='"+correo+"' /> <font color='red'>*</font></td>"
         + "             </tr>"
         + "             <tr>"
         + "                 <td><b>Departamento:</b></td>"
         + "                 <td width='5'></td>");
         //combo departamento--------------
         pw.println("<td><span id='divDepartamentoEdit'>"
         +"<select  id='cmbDep' onChange='"+accion+"'>"
         + " <option value=''>[Seleccionar]</option>");

         pw.println( "</select>"
         + "</span> <font color='red'>*</font></td>");

         pw.println("     </tr>  <tr>"

         // combo provincia

         + "                 <td><b>Provincia:</b></td>"
         + "                 <td width='5'></td>");
         pw.println("<td><span id='divProvinciaEdit'>"
         +"<select  id='cmbProv' >"
         + " <option value=''>[Seleccionar]</option>"
         + "</select>"
         + "</span> <font color='red'>*</font></td>");
         pw.println("     </tr>  <tr>"
         //combo Distrito
         + "                 <td><b>Distrito:</b></td>"
         + "                 <td width='5'></td>");
         pw.println("<td><span id='divDistritoEdit'>"
         +"<select  id='cmbDis' >"
         + " <option value=''>[Seleccionar]</option>"
         + "</select>"
         + "</span> <font color='red'>*</font></td>");

         // + "         </table>"
         // + "     </td>"
         pw.println( "  </tr>"
         + "</table>");*/
    }

    private void actualizarDatos(HttpServletRequest request, HttpServletResponse response) {
        DocenteServices servicios = new DocenteServices();
        String codDocente = request.getParameter("codDocente");
        String telefono = request.getParameter("telefono");
        String zona = request.getParameter("zona");
        String correo = request.getParameter("correo");
        servicios.actualizarDatos(codDocente, telefono, zona, correo);
    }

    private void registraDatosDocenteEdit(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        int dato = 0;
        String telefono = request.getParameter("telefono");
        String mail = request.getParameter("mail");

        String codDocente = request.getParameter("codDocente");
        String dir = request.getParameter("dir");
        String cel = request.getParameter("cel");

        int codDepartamento = Integer.parseInt(request.getParameter("codDepartamento"));
        int codProvincia = Integer.parseInt(request.getParameter("codProvincia"));
        int codDistrito = Integer.parseInt(request.getParameter("codDistrito"));
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        dato = servicios.registrarDatosEdit(codDocente, telefono, mail, codDepartamento, codProvincia, codDistrito, cel, dir);
        pw.println(dato);
    }

    private void buscarDocenteHorario(HttpServletRequest request, HttpServletResponse response) throws IOException { //checkpoint
        DocenteServices servicios = new DocenteServices();
        HorarioServices servicios2 = new HorarioServices();

        int cant = 0;
        ArrayList<Docente> lista = null;
        String apellido = request.getParameter("apellido");
        String periodo = request.getParameter("periodo");

        //-------------------datos de la paginacion----------------
        int pagina = Integer.parseInt(request.getParameter("pagina"));
        int cantidad = Integer.parseInt(request.getParameter("cantidad"));
        int inicio = (pagina - 1) * cantidad;
        int cantRegistro = 0;
        lista = servicios.buscarUsuarioDocente(apellido, inicio, cantidad);
        String cargos = "41,57,102,95,11,51,30,33,19";
        ArrayList<Docente> lista2 = servicios.cargarDocentePrimaria2(cargos, apellido, inicio, cantidad - lista.size());

        for (Docente docente : lista2) {
            Docente docente1 = lista.stream()
              .filter(docente2 -> docente2.getDni().equals(docente.getDni()))
              .findAny()
              .orElse(null);
            if (docente1 == null) {
                lista.add(docente);
            }
        }
        cantRegistro = servicios.cantListaDocente(apellido);

        //=============CALCULO DE PAGINADO=============
        int numero = cantRegistro / cantidad;
        int resto = cantRegistro % cantidad;
        if (resto > 0) {
            numero = numero + 1;
        }

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodoCompleto();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar detallado"
          + "                                           </button>"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodoCompletoReducido();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar corto"
          + "                                           </button>"
          + "                         <!--<button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodo();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar todo"
          + "                                           </button>-->"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">NOMBRES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">VER HORARIO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">EXPORTAR</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">BAJA</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int cont_ini = 0;
        int cont_fin = 0;
        int cont = inicio + 1;
        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            //int cDoc = lista.get(i).getCod_pro();
            String codDocente = lista.get(i).getCod_pro() == null ? lista.get(i).getCodDocenteId() : lista.get(i).getCod_pro();
            cant = servicios2.cantidadAsignadoCursosDoc(codDocente, periodo);
            String nombre = lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro();
            if (cont % 2 == 0) {
                pw.println("<tr class=\"alt\" >");
            } else {
                pw.println("<tr >");
            }

            pw.println("    <td align='center'>" + cont + "</td>"
              + "    <td >" + lista.get(i).getApe_pro() + "</td>"
              + "    <td >" + lista.get(i).getNom_pro() + "</td>"
            );
            if (cant > 0) {
                pw.println(" "
                  + " <td  align='center'>"
                  + "               <a title='Horario detallado' href=\"javascript:armarHorarioDocente2('" + codDocente + "','" + nombre + "');\" class=\"regular\" >"
                  + "             <img src=\"imagenes/icons/zoom.png\" />"
                  + "         </a>"
                  + "    |    <a title='Horario corto' href=\"javascript:armarHorarioDocente('" + codDocente + "','" + nombre + "');\" class=\"regular\" >"
                  + "            <img src=\"imagenes/icons/zoom.png\" />"
                  + "        </a>"
                  + "    </td>"
                );//tiene cursos asignados
                
                pw.println("<!--<td  align='center'>"
                  + " <a href=\"javascript:exportar('" + codDocente + "');\" class=\"regular\" >"
                  + "     <img src=\"imagenes/icons/export_excel.png\" />"
                  + " </a>"
                  + "</td>-->"
                  + "<td align='center'>"
                  + " <a title='Horario corto' href=\"javascript:exportarCompletoReducido('" + codDocente + "');\" class=\"regular\" >"
                  + "     <img src=\"imagenes/icons/export_excel.png\" />"
                  + " </a>"
                  + " | "
                  + " <a title='Horario detallado' href=\"javascript:exportarCompleto('" + codDocente + "');\" class=\"regular\" >"
                  + "     <img src=\"imagenes/icons/export_excel.png\" />"
                  + " </a>"
                  + "</td>"
                );
                pw.println("<td align='center'>"
                  + " <a title='Dar de baja' href=\"javascript:darDeBaja('" + codDocente + "');\" class=\"regular\" >"
                  + "     <i class='ace-icon fa fa-user-times red'></i>"
                  + " </a>"
                  + "</td>"
                );
            } else {
                pw.println("  <td align='center'><font color='red'><b>No tiene cursos</b></font></td>"
                );//no tiene cursos
                pw.println("    <!--<td  align='center'> --"
                  + " </td>-->"
                  + " <td align='center'> <font color='red'><b>No tiene cursos</b></font>"
                  + " </td>"
                  + "<td></td>"
                );
            }
            

            pw.println("</tr>");
            cont++;
        }

        cont_fin = cont - 1;

        if (cont == 1) {
            pw.println("<tr><td colspan='6' align='center'>No hay resultados de búsqueda</td></tr>");
        }

        pw.println("       </tbody>"
          + "                       </table>");

        //::::::::::::::: PIE ::::::::::::::::
        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:BuscarDocente(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:BuscarDocente(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:BuscarDocente(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

    }

    private void armarDocenteHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        DisponibilidadServices serviciosDD = new DisponibilidadServices();
        Docente docente = new Docente();
        String codDocente = request.getParameter("codDocente");

        docente = servicios.NombreDocente(codDocente);
        String cadenaDia = serviciosDD.ConsultaDisponibilidad(codDocente);

        //String dato = request.getParameter("dato");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        String TM = "";
        String TT = "";
        String TN = "";

        String[] arrayGrupo = cadenaDia.split("-");
        for (int i = 0; i < arrayGrupo.length; i++) {
            String[] arrayTD = arrayGrupo[i].split("#");
            if (arrayTD[0].equals("1")) {
                if (TM.equals("")) {
                    TM += "0-" + arrayTD[1];
                } else {
                    TM += "-" + arrayTD[1];
                }

            } else if (arrayTD[0].equals("2")) {
                if (TT.equals("")) {
                    TT += "0-" + arrayTD[1];
                } else {
                    TT += "-" + arrayTD[1];
                }
            } else if (arrayTD[0].equals("3")) {
                if (TN.equals("")) {
                    TN += "0-" + arrayTD[1];
                } else {
                    TN += "-" + arrayTD[1];
                }
            }
        }

        String[] arrayDisponibilidad = {TM, TT, TN};

        String[] arrayHora = {"07:50 am. a 02:30 pm.", "03:00 pm. a 07:00 pm.", "07:00 pm. a 10:00 pm."};
        String[] arrayTurno = {"MAÑANA", "TARDE", "NOCHE"};

        pw.println("<table  width='110%'>"
          + "<tr>"
          + "<td align='center'> "
          + "<table>"
          + "      <tr>"
          + "          <td><b>DOCENTE:</b></td>"
          + "          <td width='10'></td>"
          + "          <td><label > " + docente.getNom_pro() + ' ' + docente.getApe_pro() + "</label ></td>"
          + "      </tr>"
          + "  </table>"
          + "<table cellpadding='0' cellspacing='0'>"
          + "<tr>"
          + "<td height=10>"
          + "</tr>"
          + "<tr><td >"
          + "<div class=datagrid>"
          + "<table border='1'>"
          + "<thead>"
          + "<tr >"
          + "<th>HORAS</th>"
          + "<th>TURNO</th>"
          + "<th>Lunes</th>"
          + "<th>Martes</th>"
          + "<th>Miercoles</th>"
          + "<th>Jueves</th>"
          + "<th>Viernes</th>"
          + "<th>Sábado</th>"
          + "<th>Todos</th>"
          + "</tr> </thead> "
          + "<tbody>");
        int dato = 0;
        int turno = 0;
        int posicion = 1;
        int dia = 0;
        for (int i = 0; i < 3; i++) {
            turno = i + 1;

            pw.println("<tr >"
              + "<td>" + arrayHora[i] + "</td>"
              + "<td>" + arrayTurno[i] + "</td>");
            for (int j = 1; j <= 6; j++) {
                if (arrayDisponibilidad[i] == "") {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                } else {
                    String[] arrayDias = arrayDisponibilidad[i].split("-");
                    for (int d = 0; d < arrayDias.length; d++) {
                        dia = Integer.parseInt(arrayDias[d]);
                        if (j == dia) {
                            dato = dato + 1;
                        } else {
                            dato = dato + 0;
                        }
                    }

                    if (dato == 1) {
                        pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked /></td>");
                    } else {
                        pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                    }
                    dato = 0;
                }

                posicion++;
            }

            pw.println("<td><a href='javascript:seleccionar_todo(" + turno + ");'> <img src='imagenes/icons/check_box.png'></a></td>"
              + "</tr> ");
        }
        // PG000019

        pw.println("<!--<td align='center' valign='middle'><a href='javascript:seleccionar_todo();'> <img src='imagenes/icons/check_box.png'></a></td> </tr>-->"
          + "</tbody>"
          + "</table>"
          + "</div>"
          + "</td>"
          + "</tr>"
          + "</table> <input type=hidden id='dato' value='1'>");
    }

    private void verificarCruces(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        String codigoArea = request.getParameter("codigoArea");
        String codigoDocente = request.getParameter("codigoDocente");
        HttpSession session_actual = request.getSession(true);
        PeriodoAcademico periodo = (PeriodoAcademico) session_actual.getAttribute("periodo");
        String codigoPeriodo = String.valueOf(periodo.getCodigoPeriodo());
//        int dato = servicios.verificarCruces(codigoDocente, codigoArea);
        int dato = servicios.verificarCrucesPorPeriodo(codigoDocente, codigoArea, codigoPeriodo);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.println(dato);

    }

    private void armarRegistroDatosDocenteEdit(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicio = new DocenteServices();
        //cargar departamento
        UbigeoDocenteServices servicios = new UbigeoDocenteServices();
        ArrayList<UbigeoDocente> lista = null;
        String accion = request.getParameter("accion");
        String nombre = request.getParameter("nombre");
        lista = servicios.cargarDepartamento();

        //------------------------------------------
        Docente docente = new Docente();
        String codDocente = request.getParameter("codDocente");
        String nomDocente = request.getParameter("nomDocente");
        docente = servicio.datosDocente(codDocente);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        String telefono = "", correo = "", direccion = "", celular = "";
        int codDepartamento = 0;
        int codProvincia = 0;
        int codDistrito = 0;

        if (docente.getTelefono() == null) {
            telefono = "";
        } else {
            telefono = docente.getTelefono();
        }

        if (docente.getCorreo() == null) {
            correo = "";
        } else {
            correo = docente.getCorreo();
        }

        if (docente.getCodigoDep() == 0) {
            codDepartamento = 0;
        } else {
            codDepartamento = docente.getCodigoDep();
        }
        if (docente.getCell() == null) {
            celular = "";
        } else {
            celular = docente.getCell();
        }
        if (docente.getDireccion() == null) {
        } else {
            direccion = docente.getDireccion();
        }

        pw.println("<center>"
          + "<table width='400' border='0'>"
          + "     <tr>"
          + "         <td height='15' colspan='3' ></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td  colspan='3' align='center'><b>DOCENTE:</b> " + nomDocente + " </td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='20' colspan='3' ></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Teléfono <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required ,custom[phone], maxSize[15], minSize[7]]' id='txt_new_tel' value='" + telefono + "'/></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='15' colspan='3' ></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Celular <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required ,custom[onlyCelular], maxSize[15], minSize[7]]' id='txt_new_celEdit' value='" + celular + "'/></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Correo <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required,custom[email]]' id='txt_new_mail' value='" + correo + "' /></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Departamento <font color='red'>*</font></td>"
          + "         <td width='5'></td>");
        //combo departamento--------------
        pw.println("<td>"
          + "     <span id='divDepartamentoEdit'>"
          + "      <select class='form-control' id='cmbDep' onChange='" + accion + "'>"
          + "         <option value=''>[Seleccionar]</option>");

        pw.println("       </select>"
          + " </span>"
          + "</td>"
          + "     </tr> "
          + "     <tr>"
          + "         <td colspan='3' height='15'>"
          + "     </tr>"
          + "     <tr>"
          // combo provincia

          + "         <td>Provincia <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td>"
          + "     <span id='divProvinciaEdit'>"
          + "      <select class='form-control' id='cmbProv' >"
          + "         <option value=''>[Seleccionar]</option>"
          + "     </select>"
          + "</span> "
          + "</td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td colspan='3' height='15'>"
          + "     </tr>"
          + "     <tr>"
          //combo Distrito
          + "         <td>Distrito <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td>"
          + "     <span id='divDistritoEdit'>"
          + "      <select class='form-control' id='cmbDis' >"
          + "         <option value=''>[Seleccionar]</option>"
          + "     </select>"
          + " </span>"
          + "</td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td height='20' colspan='3' ></td>"
          + "     </tr>"
          + "     <tr>"
          + "         <td>Dirección <font color='red'>*</font></td>"
          + "         <td width='5'></td>"
          + "         <td><input type='text' class='form-control validate[required]' id='txt_new_dirEdit' value='" + direccion + "'/></td>"
          + "     </tr>"
          + "</table>"
          + "</center>");

    }

    private void armarEdicionEspecial(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        DisponibilidadServices serviciosDD = new DisponibilidadServices();
        Docente docente = new Docente();
        String codDoc = request.getParameter("codDoc");

        docente = servicios.NombreDocente(codDoc);
        String cadenaDia = serviciosDD.ConsultaDisponibilidad(codDoc);
        String cadena = "";
        //String dato = request.getParameter("dato");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        String TM = "";
        String TT = "";
        String TN = "";

        String[] arrayGrupo = cadenaDia.split("-");
        for (int i = 0; i < arrayGrupo.length; i++) {
            String[] arrayTD = arrayGrupo[i].split("#");
            if (arrayTD[0].equals("1")) {
                if (TM.equals("")) {
                    TM += "0-" + arrayTD[1];
                } else {
                    TM += "-" + arrayTD[1];
                }

            } else if (arrayTD[0].equals("2")) {
                if (TT.equals("")) {
                    TT += "0-" + arrayTD[1];
                } else {
                    TT += "-" + arrayTD[1];
                }
            } else if (arrayTD[0].equals("3")) {
                if (TN.equals("")) {
                    TN += "0-" + arrayTD[1];
                } else {
                    TN += "-" + arrayTD[1];
                }
            }
        }

        String[] arrayDisponibilidad = {TM, TT, TN};

        String[] arrayHora = {"07:50 a 14:30", "15:00 a 19:00 ", "19:00 a 22:00", "15:00 a 22:00"};
        String[] arrayTurno = {"MAÑANA", "TARDE", "NOCHE", "TARDE-NOCHE"};

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" >"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>DOCENTE: " + docente.getApe_pro() + ", " + docente.getNom_pro() + "</td>"
          + "                     <td align=\"right\">"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORAS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TODOS</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int dato = 0;
        int turno = 0;
        int posicion = 1;
        int dia = 0;
        for (int i = 0; i < 3; i++) {
            turno = i + 1;

            pw.println("<tr >"
              + "<td align='center'>" + arrayHora[i] + "</td>"
              + "<td>" + arrayTurno[i] + "</td>");
            for (int j = 1; j <= 6; j++) {
                //int cantidad=0;
                if (arrayDisponibilidad[i] == "") {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                } else {
                    String[] arrayDias = arrayDisponibilidad[i].split("-");
                    for (int d = 0; d < arrayDias.length; d++) {
                        dia = Integer.parseInt(arrayDias[d]);
                        if (j == dia) {
                            dato = dato + 1;
                        } else {
                            dato = dato + 0;
                        }

                    }
                    int cantidad = serviciosDD.asignadoDisponibilidad(codDoc, j, turno);
                    if (cantidad > 0) {
                        if (dato == 1) {
                            if (cadena.equals("")) {
                                cadena = turno + "#" + j;
                            } else {
                                cadena += "-" + turno + "#" + j;
                            }
                            //if(cantidad>0){
                            pw.println("<td align='center' valign='middle' style='background-color:#9FCEF8'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked disabled /></td>");
                            // }
                        } else {
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                        }
                    } else {
                        if (dato == 1) {
                            //if(cantidad>0){
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked /></td>");
                            // }
                        } else {
                            pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                        }
                    }
                    dato = 0;
                }
                posicion++;

            }

            pw.println("    <td align='center'><a href='javascript:seleccionar_todo(" + turno + ");'> <img src='imagenes/icons/check_box.png'></a>"
              + " </td>"
              + "</tr> ");

        }
        // PG000019
        pw.println("<!--<td align='center' valign='middle'><a href='javascript:seleccionar_todo();'> <img src='imagenes/icons/check_box.png'></a></td> </tr>-->"
          + "               </tbody>"
          + "           </table> <input type=hidden id='dato' value='1'> <input type='hidden' id='selec' value='" + cadena + "' >"
          + "       </div>"
          + "   </div>"
          + "   <center>"
          + "       <table border='0'>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td style='background-color:#9FCEF8;  border: 1px solid black;'  width='20'> </td>"
          + "               <td width='10'> </td>"
          + "               <td >Este color muestra que ya tiene asignado un  curso en ese día.</td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "       </table>"
          + "   </center>"
          + "</div>");

        /*+"<tr><td height='20' > </td> </tr>"
         +"<table border='0' cellpadding='0' cellspacing='0'>"
         +"   <tr>"
         +"       <td style='background-color:#9FCEF8;  border: 1px solid black;'  width='20'> </td> "
         +"       <td width='10'> </td>"
         +"       <td > Este color muestra que ya tiene asignado un  curso en ese día. </td>"
         +"  </tr>"
         +"</table>"
         +"</div>"
         +"</td>"
         +"</tr>"
         +"</table> ");*/
    }

    private void cargarDocentesDisponiblesGeneral(HttpServletRequest request, HttpServletResponse response) throws IOException {
        AreaDocenteServices servicios = new AreaDocenteServices();
        ArrayList<AreaDocente> lista = null;
        String nombre = request.getParameter("nombre");
        String accion = request.getParameter("accion");
        String codTurno = request.getParameter("codTurno");
        String codcurso = request.getParameter("codCurso");
        String dia = request.getParameter("dia");
        String opcion = request.getParameter("opcion");
        String periodo = request.getParameter("periodo");

        lista = servicios.cargarDocentesDisponibles(codTurno, dia, codcurso, periodo);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='" + nombre + "' class='form-control validate[required]' onChange='" + accion + "'>");
        pw.println("<option value=''>[Seleccione]</option>");
        for (int i = 0; i < lista.size(); i++) {
            pw.println("<option value='" + lista.get(i).getCodigoDocente() + "'>" + lista.get(i).getApellidoDocente() + ", " + lista.get(i).getNombreDocente() + "</option>");
        }

        pw.println("</select>");
    }

    private void cargarDocentesDisponiblesGeneral2(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices serviciosDocente = new DocenteServices();
        AreaDocenteServices servicios = new AreaDocenteServices();
        ArrayList<AreaDocente> lista = null;
        String nombre = request.getParameter("nombre");
        String accion = request.getParameter("accion");
        String codTurno = request.getParameter("codTurno");
        String codcurso = request.getParameter("codCurso");
        String dia = request.getParameter("dia");
        String opcion = request.getParameter("opcion");
        String periodo = request.getParameter("periodo");

        lista = servicios.cargarDocentesDisponibles2(codTurno, dia, codcurso, periodo);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='" + nombre + "' class='form-control validate[required]' onChange='" + accion + "'>");
        pw.println("<option value=''>[Seleccione]</option>");
        for (int i = 0; i < lista.size(); i++) {
            pw.println("<option value='" + lista.get(i).getCodigoDocente() + "'>" + lista.get(i).getApellidoDocente() + ", " + lista.get(i).getNombreDocente() + "</option>");
        }

        String codigoCurso = "";
        if (codcurso.equals("13") || codcurso.equals("34")) {
            pw.println("<option value=''>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </option>");
            ArrayList<Docente> listaDocentePrimaria = null;
            if (codcurso.equals("13")) {
                codigoCurso = "19";
            } else {
                codigoCurso = "41,57,102";
            }

            listaDocentePrimaria = serviciosDocente.cargarDocentePrimaria(codigoCurso);
            for (int i = 0; i < listaDocentePrimaria.size(); i++) {
                pw.println("<option value='P" + listaDocentePrimaria.get(i).getCodigoDocentePrimaria() + "'>" + listaDocentePrimaria.get(i).getApellidosDocentePrimaria() + ", " + listaDocentePrimaria.get(i).getNombreDocentePrimaria() + "</option>");
            }

        }

        pw.println("</select>");
    }

    private void cargarDocentesDisponiblesGeneral3(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices serviciosDocente = new DocenteServices();
        AreaDocenteServices servicios = new AreaDocenteServices();
        ArrayList<AreaDocente> lista = null;
        String codTurno = request.getParameter("codTurno");
        String codcurso = request.getParameter("codCurso");
        String dia = request.getParameter("dia");
        String periodo = request.getParameter("periodo");
        int dato = 0;

        lista = servicios.cargarDocentesDisponibles2(codTurno, dia, codcurso, periodo);

        int cont = 1;
        String cadena = "";
        for (int i = 0; i < lista.size(); i++) {
            String codigoDoceSec = lista.get(i).getCodigoDocente();
            String apellidoDoc = lista.get(i).getApellidoDocente();
            String nombreDoc = lista.get(i).getNombreDocente();
            cont++;
            if (cadena.equals("")) {
                cadena = "INSERT INTO docente_temporal (cod_doc,apellido_doc,nombre_doc) VALUES ('" + codigoDoceSec + "','" + apellidoDoc + "','" + nombreDoc + "')";

            } else {
                cadena += ";" + "INSERT INTO docente_temporal (cod_doc,apellido_doc,nombre_doc) VALUES ('" + codigoDoceSec + "','" + apellidoDoc + "','" + nombreDoc + "')";
            }
        }

        String codigoCurso = "";
        if (codcurso.equals("13") || codcurso.equals("34") || codcurso.equals("39") || codcurso.equals("38") || codcurso.equals("42") || codcurso.equals("7") || codcurso.equals("8") || codcurso.equals("26") || codcurso.equals("27") || codcurso.equals("37") || codcurso.equals("54")) {
            ArrayList<Docente> listaDocentePrimaria = null;
            if (codcurso.equals("13")) {
                codigoCurso = "19";
            } else if (codcurso.equals("38")) {
                codigoCurso = "33";
            } else if (codcurso.equals("42") || codcurso.equals("7") || codcurso.equals("48")) { //directores
                codigoCurso = "30";
            } else if (codcurso.equals("26") || codcurso.equals("27")) { //personal social
                codigoCurso = "51";
            } else if (codcurso.equals("37") || codcurso.equals("54")) { //CyA
                codigoCurso = "11";
            } else {
                codigoCurso = "41,57,102,95";
            }

            listaDocentePrimaria = serviciosDocente.cargarDocentePrimaria(codigoCurso);
            String DocPrim = "";
            for (int p = 0; p < listaDocentePrimaria.size(); p++) {
                String codigoDocentePrimaria = "P" + listaDocentePrimaria.get(p).getCodigoDocentePrimaria();
                String apellidoPrimaria = listaDocentePrimaria.get(p).getApellidosDocentePrimaria();
                String nombrePrimaria = listaDocentePrimaria.get(p).getNombreDocentePrimaria();
                cont++;
                if (cadena.equals("")) {
                    cadena = "INSERT INTO docente_temporal (cod_doc,apellido_doc,nombre_doc) VALUES ('" + codigoDocentePrimaria + "','" + apellidoPrimaria + "','" + nombrePrimaria + "')";
                } else {
                    cadena += ";" + "INSERT INTO docente_temporal (cod_doc,apellido_doc,nombre_doc) VALUES ('" + codigoDocentePrimaria + "','" + apellidoPrimaria + "','" + nombrePrimaria + "')";
                }
            }
        }

        dato = serviciosDocente.insertarTemporal(cadena);

    }

    private void tablaDocentesDisponiblesGeneral3(HttpServletRequest request, HttpServletResponse response) throws IOException {

        String periodo = request.getParameter("periodo");
        ArrayList<Docente> lista = null;
        DocenteServices servicio = new DocenteServices();
        lista = servicio.filtroDocentesPrimSec(periodo);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<div style='border: 1px solid #CCCCCC;' >");
        pw.println("<div class='table-header'>");
        pw.println("<table width='100%' height='30'>");
        pw.println("<tbody>");
        pw.println("<tr>");
        pw.println("<td>Lista de docentes</td>");
        pw.println("<td align='right'>");
        pw.println("</td>");
        pw.println("<td width='10'></td>");
        pw.println("</tr>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
//            pw.println("<div style='height:300px;'>");
        pw.println("<div style='height: 500px;overflow: auto; position: relative;'>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer'>");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='datos' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role='row'>");
        pw.println("<th width='35' class='center' rowspan='1' colspan='1' >N°</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>ZONA</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>INFORME</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>SELECCIÓN</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");
        int cont = 1;
        String color = "";
        for (int i = 0; i < lista.size(); i++) {
            int codigoTipoDocente = lista.get(i).getCod_tip();

            if (codigoTipoDocente == 1) {
                color = "style=''";
            } else { //profesores nuevos
                if (cont % 2 == 0) {
                    color = "style='background-color:#FFF9C0;'";
                } else {
                    color = "style='background-color:#FFFCE0;'";
                }
            }
            pw.println("<tr " + color + ">");
            String codigoDocente = lista.get(i).getCodigoDocente();
            String apeDocente = lista.get(i).getApe_pro();
            String nomDocente = lista.get(i).getNom_pro();
            String nombreCompleto = apeDocente.replace("Ã‘", "Ñ") + ", " + nomDocente.replace("Ã‘", "Ñ");
            String zona = lista.get(i).getZona();
            String informe = lista.get(i).getRespuestaInforme();
            String promedio = lista.get(i).getPuntaje();
            pw.println("<td align='center' style='vertical-align:middle; width:50px;'>" + cont + "</td>");
            pw.println("<td style='vertical-align:middle'>" + nombreCompleto + "</td>");
            pw.println("<td style='vertical-align:middle'>" + zona + "</td>");
            if (informe == null) {
                informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
            } else {
                if (informe.equals("0")) {
                    informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
                } else {
                    informe = "<span class=\"label label-danger arrowed\">Restringido</span>";
                }
            }
            pw.println("<td align='center'  style='vertical-align:middle'>" + informe + "</td>");
            String icono = "";
            if (!promedio.equals("-")) {
                double prom = Double.parseDouble(promedio);

                if (prom > 8.49 && prom <= 10) {
                    icono = "fa fa-arrow-up green";
                } else if (prom < 8.5) {
                    icono = "fa fa-arrow-down red";
                }
            }
            pw.println("<td align='center' style='vertical-align:middle'><i class=\"" + icono + "\"></i>&nbsp;" + promedio + "</td>");
            pw.println("<td align='center' style='vertical-align:middle'>");
            pw.println("<label>");
            pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
            pw.println("<span  class='lbl'></span>");
            pw.println("</label>");
            pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codigoDocente + "'>");
            pw.println("<input type='hidden' id='datos2_" + cont + "' value='" + cont + "#" + nombreCompleto + "'>");
            pw.println("</td>");
            pw.println("</tr>");
            cont++;
        }
//        pw.println("<input type='hidden' id='cantidad' value='"+lista.size()+"'>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div><input type='hidden' id='cantidad' value='" + lista.size() + "'>");
        pw.println("<div style='width:707px;'>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer' >");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='datos' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role='row'>");
        pw.println("<th width='80' class='center' rowspan='1' colspan='1' >N°</th>");
        pw.println("<th width='700' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
        pw.println("<th width='623' class='center' rowspan='1' colspan='1'>ZONA</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>INFORME</th>");
        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>SELECCIÓN</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");

    }

    private void listarDocenteSede(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;
        Docente docente = new Docente();
        String nombre = request.getParameter("nombre");
        String local = request.getParameter("local");
        docente = servicios.listarDocenteSede(local);
        String codPri = docente.getCadenaCodigoDocentePri();
        String codSec = docente.getCadenaCodigoDocenteSec();
        lista = servicios.listarDocSecPri(codPri, codSec);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='" + nombre + "' class=' chosen-select form-control validate[required]' onChange='' style='width:100%'>");
        pw.println("<option value='' ></option>");
        for (int i = 0; i < lista.size(); i++) {
            String codDocente = lista.get(i).getCod_pro();
            String estado = "";
            estado = servicios.verEstado(codDocente, local);
            String EstadoDoc = "";
            String estilo = " ";
            if (estado.equals("")) {
                EstadoDoc = "";
                estilo = " ";
            } else if (estado.equals("0")) {
                EstadoDoc = " <b> - (SIN ACCIÓN) </b>";
                estilo = " style='color: #F3A100' ";
            } else if (estado.equals("1")) {
                EstadoDoc = " <b> - (RESTRINGIDO) </b>";
                estilo = " style='color: #FF4B4B ' ";
            }
            pw.println("<option " + estilo + " value='" + lista.get(i).getCod_pro() + "'>" + lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro() + " " + EstadoDoc + "</option>"
              + "");
        }
        pw.println("</select>");

    }

    private void listarBandeja(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        ArrayList<Docente> lista = new ArrayList<Docente>();
        lista = servicios.listarBandeja();

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">BANDEJA DE INFORMES DE DIRECTORES"
          + "                           <!--<table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>BANDEJA DE INFORMES DE DIRECTORES</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportar();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar "
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>-->"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\" >N°</th>"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>"
          + "                                           <th class=\"center\" rowspan=\"2\" colspan=\"1\">FECHA</th>"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\">DOCENTE</th>"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\">MOTIVO</th>"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\">ARGUMENTO</th>"
          + "                                           <th  class=\"center\" rowspan=\"2\" colspan=\"1\">ESTADO</th>"
          + "                                           <th class=\"center\" rowspan=\"2\" colspan=\"1\">ACCIÓN</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");
        int cont = 1;
        for (int i = 0; i < lista.size(); i++) {
            String estado = "<span class='label arrowed'><s>SIN ACCIÓN</s></span> ";
            if (lista.get(i).getRespuestaInforme().equals("1")) {
                estado = "<span class='label label-danger arrowed'>RESTRINGIDO</span> ";
            }
            String codDocente = lista.get(i).getCodigoDocente();
            String codSede = lista.get(i).getCodigoSede();
            String cortado = lista.get(i).getArgumento().substring(0, 10);
            String fechaInforme = lista.get(i).getFechaInforme().substring(0, 10);
            String[] array = fechaInforme.split("-");
            String anio = array[0];
            String mes = array[1];
            String dia = array[2];
            String fecInfo = dia + "-" + mes + "-" + anio;
            pw.println("<tr>"
              + "     <td align='center' style='vertical-align: middle;' width='50' >" + cont + "</td>"
              + "     <td style='vertical-align: middle;' width='140' >" + lista.get(i).getNombreSede().toUpperCase() + "</td>"
              + "     <td style='vertical-align: middle;' width='100' >" + fecInfo + "</td>"
              + "     <td style='vertical-align: middle;' width='250'>" + lista.get(i).getNombreDocente().toUpperCase() + "</td>"
              + "     <td style='vertical-align: middle;' width='200'>" + lista.get(i).getMotivo().toUpperCase() + "</td>"
              + "     <td style='vertical-align: middle;' width='250'><span class='' data-rel='tooltip' data-placement='left' title='' style='cursor: pointer;' data-original-title='" + lista.get(i).getArgumento().toUpperCase() + "'>" + cortado.toUpperCase() + "...<a href=\"javascript:armarPopUpInforme('" + codDocente + "');\"><span style='color:orange;'><b>ver más</b></span></a></span></td>"
              + "                       <td style='vertical-align: middle;'>" + estado + "</td>"
              + "                       <td style='vertical-align: middle;' width='50'>"
              + "         <div class=\"inline pull-center position-relative dropdown-hover\">"
              + "                               <p class=\"btn btn-minier bigger btn-primary \">"
              + "                                   <i class=\"ace-icon fa fa-cog icon-only bigger-120\"></i>"
              + "                                   <b>Acción</b>"
              + "                               </p>"
              + "                               <ul class=\"dropdown-menu dropdown-only-icon dropdown-yellow dropdown-caret dropdown-close dropdown-menu-right\">"
              + "                                   <li>"
              + "                                       <a href=\"javascript:respuesta('" + lista.get(i).getCodigoInforme() + "','0');\" >"
              + "                                           <span >"
              + "                                               <i class=\"ace-icon fa fa-eye-slash bigger-110\"></i>"
              + "                                               SIN ACCIÓN"
              + "                                           </span>"
              + "                                       </a>"
              + "                                   </li>"
              + "                                   <li>"
              + "                                       <a  href=\"javascript:respuesta('" + lista.get(i).getCodigoInforme() + "','1');\" >"
              + "                                           <span class=\"red\">"
              + "                                               <i class=\"ace-icon fa fa-ban  bigger-110\"></i>"
              + "                                               RESTRINGIR"
              + "                                           </span>"
              + "                                       </a>"
              + "                                   </li>"
              + "                               </ul>"
              + "                           </div>"
              + "                       </td>"
              + "                   </tr>");
            cont++;
        }

        if (lista.size() == 0) {
            pw.println("<tr><td colspan='8' align='center'><b style='color:red;'>NO HAY INFORMES</b></td></tr>");
        }

        pw.println("</tbody>"
          + "</table>"
          + "</div>"
          + "</div>"
          + "</div>");

    }

    private void armarPopUpInforme(HttpServletRequest request, HttpServletResponse response) throws IOException {

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        String codigoDocente = request.getParameter("codigoDocente");
        DocenteServices servicios = new DocenteServices();
        Docente docente = new Docente();
        docente = servicios.consultarInforme(codigoDocente);
        String respuestaInforme = docente.getRespuestaInforme();

        String fechaInforme = docente.getFechaInforme();
        String[] array = fechaInforme.split("-");
        String anio = array[0];
        String mes = array[1];
        String dia = array[2];
        String fecInfo = dia + "-" + mes + "-" + anio;

        pw.println("<div class='col-sm-2'></div>");
        pw.println("<div class=\"col-sm-4 infobox-container\">");
        String colorDiv = "";
        String rspInfo = "";

        if (respuestaInforme.equals("1")) {
            colorDiv = "red";
            rspInfo = "Restringido";
        } else {
            colorDiv = "green";
            rspInfo = "Habilitado";
        }
        pw.println("<div class=\"infobox infobox-" + colorDiv + "\">");
        pw.println("<div class=\"infobox-icon\">");
        pw.println("<i class=\"ace-icon fa fa-comment-o\"></i>");
        pw.println("</div>");
        pw.println("<div class=\"infobox-data\">");
        pw.println("<span class=\"infobox-data-number\">Estado</span>");
        pw.println("<div class=\"infobox-content\">" + rspInfo + "</div>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("<div class=\"col-sm-4 infobox-container\">");
        pw.println("<div class=\"infobox infobox-blue\">");
        pw.println("<div class=\"infobox-icon\">");
        pw.println("<i class=\"ace-icon fa fa-calendar\"></i>");
        pw.println("</div>");
        pw.println("<div class=\"infobox-data\">");
        pw.println("<span class=\"infobox-data-number\">Fecha</span>");
        pw.println("<div class=\"infobox-content\">" + fecInfo + "</div>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("<div class='col-sm-2'></div>");
        pw.println("<div class='col-sm-12' style='width:100%;height:40px;'><hr></div>");
        pw.println("<div class='col-sm-12'>");
        pw.println("<div class=\"profile-user-info profile-user-info-striped\">");
        pw.println("<div class=\"profile-info-row\">");
        pw.println("<div class=\"profile-info-name\"> Sede </div>");
        pw.println("<div class=\"profile-info-value\">");
        pw.println("<span>" + docente.getNombreSede() + "</span>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("<div class=\"profile-info-row\">");
        pw.println("<div class=\"profile-info-name\"> Docente </div>");
        pw.println("<div class=\"profile-info-value\">");
        pw.println("<span>" + docente.getNombreDocente() + "</span>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("<div class=\"profile-info-row\">");
        pw.println("<div class=\"profile-info-name\"> Motivo </div>");
        pw.println("<div class=\"profile-info-value\">");
        pw.println("<span>" + docente.getMotivo() + "</span>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("<div class=\"profile-info-row\">");
        pw.println("<div class=\"profile-info-name\"> Argumento </div>");
        pw.println("<div class=\"profile-info-value\">");
        pw.println("<span>" + docente.getArgumento() + "</span>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div> ");
        pw.println("</div> ");

    }

    private void respuesta(HttpServletRequest request, HttpServletResponse response) {
        DocenteServices servicios = new DocenteServices();
        String codInforme = request.getParameter("codInforme");
        String accion = request.getParameter("accion");
        int dato = servicios.registrarRespuesta(codInforme, accion);
    }

    private void cargarEncuestas(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //String nombre = request.getParameter("nombre");
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = null;
        lista = servicios.listarEncuestas();

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<select id='codEnc' class='form-control validate[required]' onChange=''>");
        pw.println("<option value='' >[Selecione]</option>");
        for (int i = 0; i < lista.size(); i++) {
            pw.println("<option value='" + lista.get(i).getCodigoEncuesta() + "'>" + lista.get(i).getNombreEncuesta() + "</option>");
        }
        pw.println("</select>");
    }

    private void migrar(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        String codEnc = request.getParameter("codEnc");
        ArrayList<Docente> lista = null;
        lista = servicios.migrarPuntaje(codEnc);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        String cadena = "";
        for (int i = 0; i < lista.size(); i++) {
            String codDoc = lista.get(i).getCodigoDocente();
            String codNom = lista.get(i).getNombreDocente();
            String pun = lista.get(i).getPuntaje();
            String cadCur = lista.get(i).getNombreCurso();
            if (cadena.equals("")) {
                cadena += codDoc + "#" + codNom + "#" + pun + "#" + cadCur;
            } else {
                cadena += "-" + codDoc + "#" + codNom + "#" + pun + "#" + cadCur;
            }
        }
        System.out.println("CADENA" + cadena + "s");
        pw.println(cadena);

    }

    private void insercion(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        String codEnc = request.getParameter("codEnc");
        String codDoc = request.getParameter("codDoc");
        String nomDoc = request.getParameter("nomDoc");
        String puntaje = request.getParameter("puntaje");
        String cadenaCurso = request.getParameter("cadenaCurso");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = servicios.insertar(codEnc, codDoc, nomDoc, puntaje, cadenaCurso);
        pw.println("1");
    }

    private void VerDatosMigrados(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicicos = new DocenteServices();
        ArrayList<Docente> lista = new ArrayList<Docente>();
        lista = servicicos.listarDatosMigrados();
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\"> Puntajes migrados"
          + "                           <!--<table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarDisponibilidad();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>"
          + "                                               Exportar todo"
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>-->"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th width='50' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DOCENTE</th>"
          + "                                           <th width='250' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">PUNTAJE</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");
        int cont = 1;
        for (int i = 0; i < lista.size(); i++) {
            String puntajeReal = lista.get(i).getPuntaje();
            double puntaje = Double.parseDouble(lista.get(i).getPuntaje());
            double progreso = puntaje * 10;
            double progresoDec = round(progreso, 2);
            String progressColor = "progress-bar-success";
            if (puntaje >= 9) {
                progressColor = "progress-bar-success";
            } else if (puntaje > 8.49 && puntaje < 9) {
                progressColor = "progress-bar-warning";
            } else if (puntaje < 8.5) {
                progressColor = "progress-bar-danger";
            }

            pw.println("<tr>");
            pw.println("    <td align='center' style='vertical-align: middle;'>" + cont + "</td>");
            pw.println("    <td style='vertical-align: middle;'>" + lista.get(i).getNombreDocente() + "</td>");
            pw.println("    <td><div class='progress pos-rel' data-percent='Puntaje: " + puntajeReal + "' style='color:#F0F0F0 !important;'> ");
            pw.println("            <div class='progress-bar " + progressColor + "  progress-bar-striped active' style='width:" + progresoDec + "%;'></div>");
            pw.println("    </td>");
            pw.println("</tr>");
            cont++;
        }

        if (lista.size() == 0) {
            pw.println("<tr>");
            pw.println("<td colspan='3' align='center'>No cuenta con datos migrados.</td>");
            pw.println("</tr>");
        }

        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div>");

    }

    public static double round(double value, int places) {
        if (places < 0) {
            throw new IllegalArgumentException();
        }

        long factor = (long) Math.pow(10, places);
        value = value * factor;
        long tmp = Math.round(value);
        return (double) tmp / factor;
    }

    private void listarDocentesTotales(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        ArrayList<Docente> lista = new ArrayList<Docente>();
        Merito merito = new Merito();
        MeritoServices servicios3 = new MeritoServices();

        String cod_per = request.getParameter("cod_per");
        lista = servicios.listaDocentesSec(cod_per);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        String codigoEncuesta = "";
        codigoEncuesta = servicios.consultarCodigoEncuesta();
        PeriodoAcademico periodo = null;
        PeriodoAcademicoServices servicio2 = new PeriodoAcademicoServices();
        periodo = servicio2.mostrarPeriodo(codigoEncuesta);

        String anio = periodo.getAnio();
        String nombrePeriodo = periodo.getNombrePeriodo();
        int cantDatos = servicios3.cantidad(codigoEncuesta, cod_per);
        pw.println("<div style=\"border: 1px solid #CCCCCC;\">");
        pw.println("<div class=\"table-header\">");
        pw.println("<table width=\"100%\" height=\"50\">");
        pw.println("<tbody>");
        pw.println("<tr>");
        pw.println("<td>Listado de Docentes " + nombrePeriodo + "</td>");
        pw.println("<td align=\"right\"><div id='boton' class='hide'>");
        String onclick = "";
        if (cantDatos == 0) {
            onclick = "validar();";
        } else {
            onclick = "validarEdicion();";
        }
        pw.println("<button class=\"btn btn-sm btn-success\" onclick=\"" + onclick + "\" type=\"button\">");
        pw.println("<i class=\"ace-icon fa fa-save icon-on-right bigger-110\"></i>");
        pw.println("Registrar");
        pw.println("</button></div>");
        pw.println("</td>");
        pw.println("<td width=\"10\"></td>");
        pw.println("</tr>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("<div>");
        pw.println("<div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">");
        pw.println("<table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"datos\" role=\"grid\" aria-describedby=\"sample-table-2_info\" style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role=\"row\">");
        pw.println("<th width='50' class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>");
        pw.println("<th width='400' class=\"center\" rowspan=\"1\" colspan=\"1\">DOCENTE</th>");
        pw.println("<th width='150' class=\"center\" rowspan=\"1\" colspan=\"1\">ENCUESTA </th>");
        pw.println("<th width='250' class=\"center\" rowspan=\"1\" colspan=\"1\">ASISTENCIA <br>");

        String change = "";
        String change2 = "";
        String change3 = "";
        String cerrar = "";
        String cerrar2 = "";
        String cerrar3 = "";

        if (cantDatos == 0) {
            change = "javascript:change(1);";
            change2 = "javascript:change(2);";
            change3 = "javascript:change(3);";
        } else {
            change = "javascript:changeLleno(1);";
            change2 = "javascript:changeLleno(2);";
            change3 = "javascript:changeLleno(3);";
        }

        if (cantDatos == 0) {
            cerrar = "javascript:retornar(1);";
            cerrar2 = "javascript:retornar(2);";
            cerrar3 = "javascript:retornar(3);";
        } else {
            cerrar = "javascript:retornarLleno(1);";
            cerrar2 = "javascript:retornarLleno(2);";
            cerrar3 = "javascript:retornarLleno(3);";
        }

        pw.println("<div id='edit_1'><a href=\"" + change + "\"><img src=\"imagenes/icons/pencil.png\" alt=\"\"/></a></div>");
        pw.println("<div id='cerrar_1' class='hide'><a href=\"" + cerrar + "\"><img src=\"imagenes/icons/arrow_rotate_clockwise.png\" alt=\"\"/></a></div>");
        pw.println("</th>");
        pw.println("<th width='250' class=\"center\" rowspan=\"1\" colspan=\"1\">EXAMEN <br>");
        pw.println("<div id='edit_2'><a href=\"" + change2 + "\"><img src=\"imagenes/icons/pencil.png\" alt=\"\"/></a></div>");
        pw.println("<div id='cerrar_2' class='hide'><a href=\"" + cerrar2 + "\"><img src=\"imagenes/icons/arrow_rotate_clockwise.png\" alt=\"\"/></a></div>");
        pw.println("</th>");
        pw.println("<th width='250' class=\"center\" rowspan=\"1\" colspan=\"1\">MATERIALES <br>");
        pw.println("<div id='edit_3'><a href=\"" + change3 + "\"><img src=\"imagenes/icons/pencil.png\" alt=\"\"/></a></div>");
        pw.println("<div id='cerrar_3' class='hide'><a href=\"" + cerrar3 + "\"><img src=\"imagenes/icons/arrow_rotate_clockwise.png\" alt=\"\"/></a></div>");
        pw.println("</th>");
        pw.println("<th width='250' class=\"center\" rowspan=\"1\" colspan=\"1\">PROMEDIO</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");
        int cont = 1;
        String etiqueta = "";

        String span = "";
        for (int i = 0; i < lista.size(); i++) {
            String codDoc = lista.get(i).getCodigoDocente();
            String puntajeReal = servicios.puntajeDocente(codDoc);
            String nombreDocente = lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro();

            merito = servicios3.consultarFichaEvaluacion(codDoc, codigoEncuesta, cod_per);
            String puntajeAsistencia = merito.getPuntajeAsistencia();
            String puntajeExamen = merito.getPuntajeExamen();
            String puntajeMateriales = merito.getPuntajeMateriales();
            String promedio = merito.getPromedio();
            String colorTd = "";
            if (puntajeAsistencia == null) {
                colorTd = "color:red;";
            } else {
                colorTd = "";
            }

            pw.println("<tr>");
            pw.println("<td align='center' style='vertical-align: middle;" + colorTd + "'>" + cont + "</td>");
            pw.println("<td style='vertical-align: middle;" + colorTd + "'>" + lista.get(i).getApe_pro() + ", " + lista.get(i).getNom_pro() + "</td>");

            if (puntajeReal.equals("")) {
                etiqueta = "inverse";
                puntajeReal = "Sin puntaje";
                pw.println("<td align='center' style='vertical-align: middle;'><span class='label label-" + etiqueta + " arrowed'>" + puntajeReal + "</span><input id='encuesta_" + cont + "' type='hidden' value='" + puntajeReal + "'></td>");
            } else {
                puntajeReal = servicios.puntajeDocente(codDoc);
                double puntaje = Double.parseDouble(puntajeReal);
                if (puntaje > 8.49 && puntaje <= 10) {
                    etiqueta = "label label-success  arrowed-in arrowed-right";
                } else if (puntaje < 8.5) {
                    etiqueta = "label label-danger arrowed arrowed-in-right";
                }
                pw.println("<td align='center' style='vertical-align: middle;'><span class='" + etiqueta + "'>&nbsp;" + puntajeReal + "&nbsp;</span><input id='encuesta_" + cont + "' type='hidden' value='" + puntajeReal + "'></td>");

            }

            pw.println("<td align='center' style='vertical-align: middle;'>");

            if (puntajeAsistencia == null) {
                span = "";
                puntajeAsistencia = "";
            } else if (puntajeAsistencia.equals("vacio")) {
                span = "";
                puntajeAsistencia = "-";
            } else if (puntajeAsistencia.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeAsistencia.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeAsist = Double.parseDouble(puntajeAsistencia);
                if (puntajeAsist > 8.49 && puntajeAsist <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeAsist < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }

            pw.println("<span id='asistencia1_" + cont + "' class='" + span + "'>" + puntajeAsistencia + "</span><input id='demo1_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton1" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg1_" + cont + "' href=\"javascript:cambiarBoton('1','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span1_" + cont + "'></div>");

            pw.println("<input type='text' id='input1_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeAsistencia + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);' >");

            // --- botones --- //
            pw.println("<div id='divBotones1" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero1_" + cont + "' href=\"javascript:boton('1','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor1_" + cont + "' href=\"javascript:boton('1','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor1_" + cont + "' href=\"javascript:boton('1','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr1_" + cont + "' href=\"javascript:boton('1','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");

            pw.println("<a id='return1_" + cont + "' href=\"javascript:regresar('1','" + cont + "','" + puntajeAsistencia + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");

            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('1','" + cont + "','0')\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('1','" + cont + "','1')\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a  href=\"javascript:boton('1','" + cont + "','2')\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a  href=\"javascript:boton('1','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"dark\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret1_" + cont + "'  href=\"javascript:regresar('1','" + cont + "','" + puntajeAsistencia + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (puntajeExamen == null) {
                puntajeExamen = "";
                span = "";
            } else if (puntajeExamen.equals("vacio")) {
                puntajeExamen = "-";
                span = "";
            } else if (puntajeExamen.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeExamen.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeEx = Double.parseDouble(puntajeExamen);
                if (puntajeEx > 8.49 && puntajeEx <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeEx < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }

            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='examen1_" + cont + "' class='" + span + "'>" + puntajeExamen + "</span><input id='demo2_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton2" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg2_" + cont + "' href=\"javascript:cambiarBoton('2','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span2_" + cont + "'></div>");
            pw.println("<input type='text' id='input2_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeExamen + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);'  >");
            // --- botones --- //
            pw.println("<div id='divBotones2" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero2_" + cont + "' href=\"javascript:boton('2','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr2_" + cont + "' href=\"javascript:boton('2','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");
            //regresar
            pw.println("<a id='return2_" + cont + "' href=\"javascript:regresar('2','" + cont + "','" + puntajeExamen + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");
            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('2','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='asesor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='coor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='regr2_" + cont + "' href=\"javascript:boton('2','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"dark\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret2_" + cont + "'  href=\"javascript:regresar('2','" + cont + "','" + puntajeExamen + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (puntajeMateriales == null) {
                span = "";
                puntajeMateriales = "";
            } else if (puntajeMateriales.equals("vacio")) {
                span = "";
                puntajeMateriales = "-";
            } else if (puntajeMateriales.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeMateriales.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeMat = Double.parseDouble(puntajeMateriales);
                if (puntajeMat > 8.49 && puntajeMat <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeMat < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }
            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='materiales1_" + cont + "' class='" + span + "'>" + puntajeMateriales + "</span><input id='demo3_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton3" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg3_" + cont + "' href=\"javascript:cambiarBoton('3','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span3_" + cont + "'></div>");
            pw.println("<input type='text' id='input3_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeMateriales + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);' >");
            // --- botones --- //
            pw.println("<div id='divBotones3" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero3_" + cont + "' href=\"javascript:boton('3','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr3_" + cont + "' href=\"javascript:boton('3','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");
            //regresar
            pw.println("<a id='return3_" + cont + "' href=\"javascript:regresar('3','" + cont + "','" + puntajeMateriales + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");
            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='asesor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='coor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='regr3_" + cont + "' href=\"javascript:boton('3','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130 dark\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret3_" + cont + "'  href=\"javascript:regresar('3','" + cont + "','" + puntajeMateriales + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (promedio == null) {
                promedio = puntajeReal;
                if (promedio.equals("Sin puntaje")) {
                    span = "";
                    promedio = "-";
                } else {
                    double prom = Double.parseDouble(promedio);
                    if (prom > 8.49 && prom <= 10) {
                        span = "";
                    } else if (prom < 8.5) {
                        span = "red";
                    }
                }
            } else if (promedio.equals("vacio")) {
                promedio = "-";
            } else {
                double prom = Double.parseDouble(promedio);
                if (prom > 8.49 && prom <= 10) {
                    //span = "label label-success  arrowed-in arrowed-right";
                    span = "";
                } else if (prom < 8.5) {
                    span = "red";
                }
            }
            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='prom_" + cont + "' class='" + span + "'><b>" + promedio + "</b></span><input type='hidden' value='' id='promedio_" + cont + "'><input type='hidden' value='0' id='datoSelec_" + cont + "'>");
            pw.println("</td>");
            pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codDoc + "#" + nombreDocente + "#" + cod_per + "#" + anio + "#" + codigoEncuesta + "#" + puntajeReal + "'>");
            pw.println("</tr>");
            cont++;
        }
        ArrayList<Docente> lista2 = null;
        String codigoCurso = "19,41,57,102";
        lista2 = servicios.cargarDocentePrimaria(codigoCurso);

        for (int z = 0; z < lista2.size(); z++) {
            String codigoDoc = "P" + lista2.get(z).getCodigoDocentePrimaria();
            String apDocPri = lista2.get(z).getApellidosDocentePrimaria();
            String apellidosDocentePrimaria = apDocPri.replace("Ã‘", "Ñ");
            String nomDocPri = lista2.get(z).getNombreDocentePrimaria();
            String nombresDocentePrimaria = nomDocPri.replace("Ã‘", "Ñ");
            String puntajeReal = servicios.puntajeDocente(codigoDoc);
            String nombreCompletoDocPri = apellidosDocentePrimaria + ", " + nombresDocentePrimaria;

            String color = "";
            String colorTd = "";
//            String span = "";
            merito = servicios3.consultarFichaEvaluacion(codigoDoc, codigoEncuesta, cod_per);
            String puntajeAsistencia = merito.getPuntajeAsistencia();
            String puntajeExamen = merito.getPuntajeExamen();
            String puntajeMateriales = merito.getPuntajeMateriales();
            String promedio = merito.getPromedio();

            if (cont % 2 == 0) {
                color = "style='background-color:#FFF7E8;'";
            } else {
                color = "style='background-color:#FFFEFB;'";
            }

            String icono = "";
            String codigoCargo = lista2.get(z).getCodigoCargo();

            pw.println("<tr " + color + ">");
            if (codigoCargo.equals("19")) {
//                color = "style='background-color:#7DE2EF;'";
                icono = "<a href=\"#\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Computación\"><i class='fa fa-laptop bigger-130 blue'></i></a>";

            } else if (codigoCargo.equals("41") || codigoCargo.equals("57")) {
                icono = "<a href=\"#\" class=\"tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Psicólogo(a)\"><i class='fa fa-balance-scale bigger-130 orange'></i></a>";
            }

            if (puntajeAsistencia == null) {
                colorTd = "color:red;";
            } else {

            }

            pw.println("<td align='center' style='vertical-align: middle;" + colorTd + "'>" + cont + "</td>");

            pw.println("<td style='vertical-align: middle;" + colorTd + "'>" + nombreCompletoDocPri + " " + icono + "</td>");
            if (puntajeReal.equals("")) {
                etiqueta = "inverse";
                puntajeReal = "Sin puntaje";
                pw.println("<td align='center' style='vertical-align: middle;'><span class='label label-" + etiqueta + " arrowed'>" + puntajeReal + "</span><input id='encuesta_" + cont + "' type='hidden' value='" + puntajeReal + "'></td>");
            } else {
                puntajeReal = servicios.puntajeDocente(codigoDoc);
                double puntaje = Double.parseDouble(puntajeReal);
                if (puntaje > 8.49 && puntaje <= 10) {
                    etiqueta = "label label-success  arrowed-in arrowed-right";
                } else if (puntaje < 8.5) {
                    etiqueta = "label label-danger arrowed arrowed-in-right";
                }
                pw.println("<td align='center' style='vertical-align: middle;'><span class='" + etiqueta + "'>&nbsp;" + puntajeReal + "&nbsp;</span><input id='encuesta_" + cont + "' type='hidden' value='" + puntajeReal + "'></td>");

            }
            pw.println("</td>");
            pw.println("<td align='center' style='vertical-align: middle;'>");

            if (puntajeAsistencia == null) {
                span = "";
                puntajeAsistencia = "";
            } else if (puntajeAsistencia.equals("vacio")) {
                span = "";
                puntajeAsistencia = "-";
            } else if (puntajeAsistencia.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeAsistencia.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeAsist = Double.parseDouble(puntajeAsistencia);
                if (puntajeAsist > 8.49 && puntajeAsist <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeAsist < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }

            pw.println("<span id='asistencia1_" + cont + "' class='" + span + "'>" + puntajeAsistencia + "</span><input id='demo1_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton1" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg1_" + cont + "' href=\"javascript:cambiarBoton('1','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span1_" + cont + "'></div>");

            pw.println("<input type='text' id='input1_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeAsistencia + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);' >");

            // --- botones --- //
            pw.println("<div id='divBotones1" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero1_" + cont + "' href=\"javascript:boton('1','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor1_" + cont + "' href=\"javascript:boton('1','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor1_" + cont + "' href=\"javascript:boton('1','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr1_" + cont + "' href=\"javascript:boton('1','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");

            pw.println("<a id='return1_" + cont + "' href=\"javascript:regresar('1','" + cont + "','" + puntajeAsistencia + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");

            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('1','" + cont + "','0')\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('1','" + cont + "','1')\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a  href=\"javascript:boton('1','" + cont + "','2')\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a  href=\"javascript:boton('1','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"dark\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret1_" + cont + "'  href=\"javascript:regresar('1','" + cont + "','" + puntajeAsistencia + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (puntajeExamen == null) {
                span = "";
                puntajeExamen = "";
            } else if (puntajeExamen.equals("vacio")) {
                span = "";
                puntajeExamen = "-";
            } else if (puntajeExamen.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeExamen.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeEx = Double.parseDouble(puntajeExamen);
                if (puntajeEx > 8.49 && puntajeEx <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeEx < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }

            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='examen1_" + cont + "' class='" + span + "'>" + puntajeExamen + "</span><input id='demo2_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton2" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg2_" + cont + "' href=\"javascript:cambiarBoton('2','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span2_" + cont + "'></div>");
            pw.println("<input type='text' id='input2_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeExamen + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);'  >");
            // --- botones --- //
            pw.println("<div id='divBotones2" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero2_" + cont + "' href=\"javascript:boton('2','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr2_" + cont + "' href=\"javascript:boton('2','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");
            //regresar
            pw.println("<a id='return2_" + cont + "' href=\"javascript:regresar('2','" + cont + "','" + puntajeExamen + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");
            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('2','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='asesor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='coor2_" + cont + "' href=\"javascript:boton('2','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='regr2_" + cont + "' href=\"javascript:boton('2','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"dark\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret2_" + cont + "'  href=\"javascript:regresar('2','" + cont + "','" + puntajeExamen + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (puntajeMateriales == null) {
                span = "";
                puntajeMateriales = "";
            } else if (puntajeMateriales.equals("vacio")) {
                span = "";
                puntajeMateriales = "-";
            } else if (puntajeMateriales.equals("ASESOR(A)")) {
                span = "blue";
            } else if (puntajeMateriales.equals("COORDINADOR(A)")) {
                span = "green";
            } else {
                double puntajeMat = Double.parseDouble(puntajeMateriales);
                if (puntajeMat > 8.49 && puntajeMat <= 10) {
                    span = "label label-success  arrowed-in arrowed-right";
                } else if (puntajeMat < 8.5) {
                    span = "label label-danger arrowed arrowed-in-right";
                }
            }
            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='materiales1_" + cont + "' class='" + span + "'>" + puntajeMateriales + "</span><input id='demo3_" + cont + "' type='hidden' value=''>"
              + "<span id='spanBoton3" + cont + "' class='hide'>&nbsp;&nbsp;&nbsp;&nbsp;"
              + "<a id='reg3_" + cont + "' href=\"javascript:cambiarBoton('3','" + cont + "');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Resetear\">"
              + "<i class=\"ace-icon fa fa-refresh bigger-130 \"></i>"
              + "</a>"
              + "</span>"
              + "<div id='span3_" + cont + "'></div>");
            pw.println("<input type='text' id='input3_" + cont + "' class='hide validate[required,max[10.00]]' value='" + puntajeMateriales + "'  style=\"height: 25px\" onpaste='return false' onkeyPress='return validarIngreso(event, this);' >");
            // --- botones --- //
            pw.println("<div id='divBotones3" + cont + "' class='hide'>");
            pw.println("<div class=\"hidden-sm hidden-xs action-buttons\">");
            //numero
            pw.println("<a id='numero3_" + cont + "' href=\"javascript:boton('3','" + cont + "','0');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">");
            pw.println("<i class=\"ace-icon fa fa-hashtag bigger-130 blue\"></i>");
            pw.println("</a>");
            //asesor
            pw.println("<a id='asesor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 green\"><b>A</b></i>");
            pw.println("</a>");
            //coordinador
            pw.println("<a id='coor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">");
            pw.println("<i class=\"ace-icon bigger-130 red\"><b>C</b></i>");
            pw.println("</a>");
            //en blanco
            pw.println("<a id='regr3_" + cont + "' href=\"javascript:boton('3','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">");
            pw.println("<i class=\"ace-icon fa fa-times bigger-130 dark\"></i>");
            pw.println("</a>");
            //regresar
            pw.println("<a id='return3_" + cont + "' href=\"javascript:regresar('3','" + cont + "','" + puntajeMateriales + "');\" class=\"hide tooltip-warning\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">");
            pw.println("<i class=\"ace-icon fa fa-undo bigger-130 orange\"></i>");
            pw.println("</a>");
            pw.println("</div>"
              + "            <div class=\"hidden-md hidden-lg\">"
              + "                <div class=\"inline position-relative\">"
              + "                    <button class=\"btn btn-minier btn-inverse dropdown-toggle\" data-toggle=\"dropdown\" data-position=\"auto\">"
              + "                        <i class=\"ace-icon fa fa-chevron-down icon-only bigger-100\"></i>"
              + "                    </button>"
              + "                    <ul class=\"dropdown-menu dropdown-only-icon dropdown-light dropdown-menu-right dropdown-caret dropdown-close\">"
              + "                        <li>"
              + "                            <a href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-info\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Número\">"
              + "                                <span class=\"blue\">"
              + "                                    <i class=\"ace-icon fa fa fa-hashtag bigger-120\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='asesor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','1');\" class=\"tooltip-success\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Asesor(a)\">"
              + "                                <span class=\"green\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>A</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='coor3_" + cont + "' href=\"javascript:boton('3','" + cont + "','2');\" class=\"tooltip-error\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Coordinador(a)\">"
              + "                                <span class=\"red\">"
              + "                                    <i class=\"ace-icon bigger-130\"><b>C</b></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='regr3_" + cont + "' href=\"javascript:boton('3','" + cont + "','3');\" class=\"tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"En blanco\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-times bigger-130 dark\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                        <li>"
              + "                            <a id='ret3_" + cont + "'  href=\"javascript:regresar('3','" + cont + "','" + puntajeMateriales + "');\" class=\"hide tooltip-default\" data-rel=\"tooltip\" title=\"\" data-original-title=\"Regresar\">"
              + "                                <span class=\"orange\">"
              + "                                    <i class=\"ace-icon fa fa-undo bigger-130\"></i>"
              + "                                </span>"
              + "                            </a>"
              + "                        </li>"
              + "                    </ul>"
              + "                </div>"
              + "            </div>"
              + "    </div>");
            // --- // fin botones // --- //
            pw.println("</td>");

            if (promedio == null) {
                promedio = puntajeReal;
                if (promedio.equals("Sin puntaje")) {
                    span = "";
                    promedio = "-";
                } else {
                    double prom = Double.parseDouble(promedio);
                    if (prom > 8.49 && prom <= 10) {
                        span = "";
                    } else if (prom < 8.5) {
                        span = "red";
                    }
                }
            } else if (promedio.equals("vacio")) {
                span = "";
                promedio = "-";
            } else {
                double prom = Double.parseDouble(promedio);
                if (prom > 8.49 && prom <= 10) {
                    //span = "label label-success  arrowed-in arrowed-right";
                    span = "";
                } else if (prom < 8.5) {
                    span = "red";
                }
            }
            pw.println("<td align='center' style='vertical-align: middle;'>");
            pw.println("<span id='prom_" + cont + "' class='" + span + "'><b>" + promedio + "</b><input type='hidden' value='' id='promedio_" + cont + "'><input type='hidden' value='0' id='datoSelec_" + cont + "'></span>");
            pw.println("</td>");
            pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codigoDoc + "#" + nombreCompletoDocPri + "#" + cod_per + "#" + anio + "#" + codigoEncuesta + "#" + puntajeReal + "'>");

            cont++;
        }
        int cantidad = lista.size() + lista2.size();

//        for(int x=0; x< 10 ; x++){
//
//        }
//
        pw.println("</tbody>");
        pw.println("</table><input id='cantidad' type='hidden' value='" + cantidad + "'></input>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div>");

    }

    private void validarEstadoDoc(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String estado = "";
        String codDocente = request.getParameter("cod_doc");
        String local = request.getParameter("local");
        DocenteServices servicios = new DocenteServices();
        estado = servicios.verEstado(codDocente, local);
//         System.out.println("estado "+estado);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        if (estado.equals("")) {
            estado = "2";
            pw.println(estado);
        } else {
            pw.println(estado);
        }

    }

    private void registrarFichaEvaluacion(HttpServletRequest request, HttpServletResponse response) {
        int dato = 0;
        String cadena = request.getParameter("cadena");
        DocenteServices servicios = new DocenteServices();
        String[] array1 = cadena.split("!");
        int cont = 0;

        for (int i = 0; i < array1.length; i++) {
            float suma = 0;
            float promedio = 0;
            String[] array2 = array1[i].split("#");
            String codigoDocente = array2[0];
            String nombreDocente = array2[1];
            String codigoPeriodoAcademico = array2[2];
            String anio = array2[3];
            String codigoPeriodo = array2[4];
            String puntajeEncuesta = array2[5];
            String puntajeAsistencia = array2[6];
            String puntajeExamen = array2[7];
            String puntajeMateriales = array2[8];
            String promedioString = "";
            int contador = 0;

            if (puntajeEncuesta.equals("Sin puntaje")) {

            } else {
                suma = Float.parseFloat(puntajeEncuesta);
                contador++;
            }

            if (puntajeAsistencia.equals("vacio") || puntajeAsistencia.equals("ASESOR(A)") || puntajeAsistencia.equals("COORDINADOR(A)")) {

            } else {
                suma += Float.parseFloat(puntajeAsistencia);
                contador++;
            }

            if (puntajeExamen.equals("vacio") || puntajeExamen.equals("ASESOR(A)") || puntajeExamen.equals("COORDINADOR(A)")) {

            } else {
                suma += Float.parseFloat(puntajeExamen);
                contador++;
            }

            if (puntajeMateriales.equals("vacio") || puntajeMateriales.equals("ASESOR(A)") || puntajeMateriales.equals("COORDINADOR(A)")) {

            } else {
                suma += Float.parseFloat(puntajeMateriales);
                contador++;
            }

            if (contador == 0) {
                promedioString = "vacio";
//                System.out.println("contador "+contador);
//                System.out.println("promedio2 "+promedioString);
            } else {
                promedio = suma / contador;
                double prom = promedio;
                prom = Math.round(prom * Math.pow(10, 2)) / Math.pow(10, 2);
                //            DecimalFormat formatter = new DecimalFormat("#0.00");//imprime decimal con comas
                DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
                simbolos.setDecimalSeparator('.');
                DecimalFormat formateador = new DecimalFormat("#0.00", simbolos); // imprime decimal con puntos
//                System.out.println("contador "+contador);
                promedioString = formateador.format(prom);
            }

            System.out.println("codigoDocente " + codigoDocente + " nombreDocente " + nombreDocente + " codigoPeriodoAcademico " + codigoPeriodoAcademico + " anio " + anio + " codigoPeriodo " + codigoPeriodo + " puntajeEncuesta " + puntajeEncuesta + " puntajeAsistencia " + puntajeAsistencia + " puntajeExamen " + puntajeExamen + " puntajeMateriales " + puntajeMateriales + " promedio " + promedioString);

            dato = servicios.registrarFichaEvaluacion(codigoDocente, nombreDocente, codigoPeriodoAcademico, anio, codigoPeriodo, puntajeEncuesta, puntajeAsistencia, puntajeExamen, puntajeMateriales, promedioString);

        }
    }

    private void editarFichaEvaluacion(HttpServletRequest request, HttpServletResponse response) {
        int dato = 0;
        String cadena = request.getParameter("cadena");
        DocenteServices servicios = new DocenteServices();
        String[] array1 = cadena.split("!");
        int cont = 0;

        for (int i = 0; i < array1.length; i++) {
            float suma = 0;
            float promedio = 0;
            String[] array2 = array1[i].split("#");
            String codigoDocente = array2[0];
            String nombreDocente = array2[1];
            String codigoPeriodoAcademico = array2[2];
            String anio = array2[3];
            String codigoPeriodo = array2[4];
            String puntajeEncuesta = array2[5];
            String puntajeAsistencia = array2[6];
            String puntajeExamen = array2[7];
            String puntajeMateriales = array2[8];
            String promedioString = "";
            int contador = 0;

            if (puntajeEncuesta.equals("Sin puntaje")) {

            } else {
                suma = Float.parseFloat(puntajeEncuesta);
                contador++;
            }

            if (puntajeAsistencia.equals("vacio") || puntajeAsistencia.equals("ASESOR(A)") || puntajeAsistencia.equals("COORDINADOR(A)") || puntajeAsistencia.equals("-")) {
                if (puntajeAsistencia.equals("-")) {
                    puntajeAsistencia = "vacio";
                } else {

                }
            } else {
                suma += Float.parseFloat(puntajeAsistencia);
                contador++;
            }

            if (puntajeExamen.equals("vacio") || puntajeExamen.equals("ASESOR(A)") || puntajeExamen.equals("COORDINADOR(A)") || puntajeExamen.equals("-")) {
                if (puntajeExamen.equals("-")) {
                    puntajeExamen = "vacio";
                } else {

                }
            } else {
                suma += Float.parseFloat(puntajeExamen);
                contador++;
            }

            if (puntajeMateriales.equals("vacio") || puntajeMateriales.equals("ASESOR(A)") || puntajeMateriales.equals("COORDINADOR(A)") || puntajeMateriales.equals("-")) {
                if (puntajeMateriales.equals("-")) {
                    puntajeMateriales = "vacio";
                } else {

                }
            } else {
                suma += Float.parseFloat(puntajeMateriales);
                contador++;
            }

            if (contador == 0) {
                promedioString = "vacio";
//                System.out.println("contador "+contador);
//                System.out.println("promedio2 "+promedioString);
            } else {
                promedio = suma / contador;
                double prom = promedio;
                prom = Math.round(prom * Math.pow(10, 2)) / Math.pow(10, 2);
                //            DecimalFormat formatter = new DecimalFormat("#0.00");//imprime decimal con comas
                DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
                simbolos.setDecimalSeparator('.');
                DecimalFormat formateador = new DecimalFormat("#0.00", simbolos); // imprime decimal con puntos
//                System.out.println("contador "+contador);
                promedioString = formateador.format(prom);
            }

            System.out.println("codigoDocente =" + codigoDocente + " - nombreDocente =" + nombreDocente + " - codigoPeriodoAcademico =" + codigoPeriodoAcademico + " - anio =" + anio + " - codigoPeriodo =" + codigoPeriodo + " - puntajeEncuesta =" + puntajeEncuesta + " - puntajeAsistencia =" + puntajeAsistencia + " - puntajeExamen =" + puntajeExamen + " - puntajeMateriales =" + puntajeMateriales + " - promedio =" + promedioString);

            dato = servicios.actualizarFichaEvaluacion(codigoDocente, nombreDocente, codigoPeriodoAcademico, anio, codigoPeriodo, puntajeEncuesta, puntajeAsistencia, puntajeExamen, puntajeMateriales, promedioString);

        }
    }

    private void reportePromedioAnualMeritoDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {

        ArrayList<Merito> listaColumnaPeriodo = null;
        ArrayList<Merito> lista = null;
        MeritoServices servicios1 = new MeritoServices();
        String codigoPeriodoAcademico = request.getParameter("periodo");

        listaColumnaPeriodo = servicios1.listaColumnaPeriodo(codigoPeriodoAcademico);
        lista = servicios1.listaTablaMerito(codigoPeriodoAcademico);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        if (lista.size() == 0) {
            pw.println(0);
        } else {
            pw.println("<div style='border: 1px solid #CCCCCC;'>");
            pw.println("<div class='table-header'>");
            pw.println("<table width='100%' height='50'>");
            pw.println("<tbody>");
            pw.println("<tr>");
            pw.println("<td>Reporte</td>");
            pw.println("<td align='right'>");
            pw.println("<button class='btn btn-sm btn-warning'  type='button' onclick='exportar();'>");
            pw.println("<i class='ace-icon fa fa-file-excel-o icon-on-right bigger-110'></i>");
            pw.println("Exportar Reporte");
            pw.println("</button>");
            pw.println("</td>");
            pw.println("<td width='10'></td>");
            pw.println("</tr>");
            pw.println("</tbody>");
            pw.println("</table>");
            pw.println("</div>");
            pw.println("<div>");
            pw.println("<div class='dataTables_wrapper form-inline no-footer' id='sample-table-2_wrapper'>");
            pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='datos' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
            pw.println("<thead>");
            pw.println("<tr role='row'>");
            pw.println("<th width='50' class='center' rowspan='1' colspan='1' >N°</th>");
            pw.println("<th width='400' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
            if (listaColumnaPeriodo.size() != 0) {
                int contar = 1;
                for (int p = 0; p < listaColumnaPeriodo.size(); p++) {
                    int[] numR = {1, 2, 3, 4, 5, 6, 7};
                    String[] numRo = {"I", "II", "III", "VI", "V", "VI", "VII"};
                    for (int n = 0; n < numRo.length; n++) {
                        if (numR[n] == contar) {
                            String nombreExam = "PLANA BIMESTRE " + (numRo[n]);
                            pw.println("<th width='250' class='center' rowspan='1' colspan='1'>" + nombreExam + "</th>");
                        }
                    }
                    contar++;
                }
                int contar2 = 1;
                for (int p2 = 0; p2 < listaColumnaPeriodo.size(); p2++) {
                    int[] numR = {1, 2, 3, 4, 5, 6, 7};
                    String[] numRo = {"I", "II", "III", "VI", "V", "VI", "VII"};
                    for (int n = 0; n < numRo.length; n++) {
                        if (numR[n] == contar2) {
                            String nombreEnc = "ENCUESTA BIMESTRE " + (numRo[n]);
                            pw.println("<th width='250' class='center' rowspan='1' colspan='1'>" + nombreEnc + "</th>");
                        }
                    }
                    contar2++;
                }
            }
            pw.println("<th width='100' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
            pw.println("</tr>");
            pw.println("</thead>");
            pw.println("<tbody>");

            int cont = 1;
            String color = "";
            for (int i = 0; i < lista.size(); i++) {

                String codigoDocente = lista.get(i).getCodigoProfesor();
                String nombreDocente = lista.get(i).getNombreProfesor();
                System.out.println("AAAAA " + codigoDocente.charAt(0));

                if (codigoDocente.charAt(0) == 'P') {
                    if (cont % 2 == 0) {
                        color = "background-color:#FFF7E8;";
                    } else {
                        color = "background-color:#FFFEFB;";
                    }

                }
                pw.println("<tr style='" + color + "'>");
                pw.println("<td align='center' style='vertical-align:middle'>" + cont + "</td>");
                pw.println("<td style='vertical-align:middle'>" + nombreDocente + "</td>");

                String cadena = lista.get(i).getCadena();
                String[] Array1 = cadena.split("#");
                for (int a = 0; a < Array1.length; a++) {
                    if (Array1[a].equals("vacio")) {
                        Array1[a] = "-";
                    } else if (Array1[a].equals("Sin puntaje")) {
                        Array1[a] = "<span class='label label-inverse  arrowed-in arrowed-right'>Sin puntaje</span>";
                    }
                    pw.println("<td align='center' style='vertical-align:middle'>" + Array1[a] + "</td>");
                }
                String promedio = lista.get(i).getPromedio();
                String span = "";
                if (!promedio.equals("-")) {
                    double prom = Double.parseDouble(promedio);

                    if (prom > 8.49 && prom <= 10) {
                        span = "label label-success  arrowed-in arrowed-right";
                    } else if (prom < 8.5) {
                        span = "label label-danger arrowed arrowed-in-right";
                    }
                }

                pw.println("<td align='center' style='vertical-align:middle'><span class='" + span + "'>" + promedio + "</span></td>");
                pw.println("</tr>");
                cont++;
            }

            pw.println("</tbody>");
            pw.println("</table>");
            pw.println("</div>");
            pw.println("</div>");
            pw.println("</div>");
        }

    }

    private void tablaDocentesDisponiblesGeneral4(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String periodo = request.getParameter("periodo");
        String filtro = request.getParameter("apellidoDocente");

        ArrayList<Docente> lista = null;
        DocenteServices servicio = new DocenteServices();
        lista = servicio.filtroDocentesPrimSec(periodo, filtro);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<div style='border: 1px solid #CCCCCC;' >");
        pw.println("<div class='table-header'>");
        pw.println("<table width='100%' height='30' id='datos'>");
        pw.println("<tbody>");
        pw.println("<tr>");
        pw.println("<td>Lista de docentes</td>");
        pw.println("<td align='right'>");
        pw.println("</td>");
        pw.println("<td width='10'></td>");
        pw.println("</tr>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
//            pw.println("<div style='height:300px;'>");
        pw.println("<div style='height: 500px;overflow: auto; position: relative;'>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer'>");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='tablaDocentes' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role='row'>");
        pw.println("<th width='35' class='center' rowspan='1' colspan='1' >N°</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>ZONA</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>INFORME</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
        pw.println("<th width='200' class='center' rowspan='1' colspan='1'>SELECCIÓN</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");
        int cont = 1;
        String color = "";
        for (int i = 0; i < lista.size(); i++) {
            int codigoTipoDocente = lista.get(i).getCod_tip();

            if (codigoTipoDocente == 1) {
                color = "style=''";
            } else { //profesores nuevos
                if (cont % 2 == 0) {
                    color = "style='background-color:#FFF9C0;'";
                } else {
                    color = "style='background-color:#FFFCE0;'";
                }
            }
            pw.println("<tr " + color + ">");
            String codigoDocente = lista.get(i).getCodigoDocente();
            String apeDocente = lista.get(i).getApe_pro();
            String nomDocente = lista.get(i).getNom_pro();
            String nombreCompleto = apeDocente.replace("Ã‘", "Ñ") + ", " + nomDocente.replace("Ã‘", "Ñ");
            String zona = lista.get(i).getZona();
            String informe = lista.get(i).getRespuestaInforme();
            String promedio = lista.get(i).getPuntaje();
            pw.println("<td align='center' style='vertical-align:middle; width:50px;'>" + cont + "</td>");
            pw.println("<td style='vertical-align:middle'>" + nombreCompleto + "</td>");
            pw.println("<td style='vertical-align:middle'>" + zona + "</td>");
            if (informe == null) {
                informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
            } else {
                if (informe.equals("0")) {
                    informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
                } else {
                    informe = "<span class=\"label label-danger arrowed\">Restringido</span>";
                }
            }
            pw.println("<td align='center'  style='vertical-align:middle'>" + informe + "</td>");
            String icono = "";
            if (!promedio.equals("-")) {
                double prom = Double.parseDouble(promedio);

                if (prom > 8.49 && prom <= 10) {
                    icono = "fa fa-arrow-up green";
                } else if (prom < 8.5) {
                    icono = "fa fa-arrow-down red";
                }
            }
            pw.println("<td align='center' style='vertical-align:middle'><i class=\"" + icono + "\"></i>&nbsp;" + promedio + "</td>");
            pw.println("<td align='center' style='vertical-align:middle'>");
            pw.println("<label>");
            pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
            pw.println("<span  class='lbl'></span>");
            pw.println("</label>");
            pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codigoDocente + "'>");
            pw.println("<input type='hidden' id='datos2_" + cont + "' value='" + cont + "#" + nombreCompleto + "'>");
            pw.println("</td>");
            pw.println("</tr>");
            cont++;
        }
//        pw.println("<input type='hidden' id='cantidad' value='"+lista.size()+"'>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div><input type='hidden' id='cantidad' value='" + lista.size() + "'>");
        pw.println("<div style='width:707px;'>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer' >");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='datos' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role='row'>");
        pw.println("<th width='80' class='center' rowspan='1' colspan='1' >N°</th>");
        pw.println("<th width='700' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
        pw.println("<th width='623' class='center' rowspan='1' colspan='1'>ZONA</th>");
        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>INFORME</th>");
        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>SELECCIÓN</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
    }

    private void armarEdicionDoc(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        DisponibilidadServices serviciosDD = new DisponibilidadServices();
        Docente docente = new Docente();
        String codArea = request.getParameter("codArea");
        String codDoc = request.getParameter("codDoc");
        String periodo = request.getParameter("periodo");

        int t_doc = 0;
        int p_doc = 0;

        if (codArea.equals("1")) {
            t_doc = 2;
            p_doc = 5;
        } else if (codArea.equals("2")) {
            t_doc = 2;
            p_doc = 2;
        } else if (codArea.equals("3")) {
            t_doc = 2;
            p_doc = 3;
        } else if (codArea.equals("4")) {
            t_doc = 2;
            p_doc = 4;
        }

        docente = servicios.NombreDocente(codDoc);
        String cadenaDia = serviciosDD.ConsultaDisponibilidad(codDoc, periodo);
        String cadena = "";
        //String dato = request.getParameter("dato");
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        String TM = "";
        String TT = "";
        String TN = "";

        String[] arrayGrupo = cadenaDia.split("-");
        for (int i = 0; i < arrayGrupo.length; i++) {
            String[] arrayTD = arrayGrupo[i].split("#");
            if (arrayTD[0].equals("1")) {
                if (TM.equals("")) {
                    TM += "0-" + arrayTD[1];
                } else {
                    TM += "-" + arrayTD[1];
                }

            } else if (arrayTD[0].equals("2")) {
                if (TT.equals("")) {
                    TT += "0-" + arrayTD[1];
                } else {
                    TT += "-" + arrayTD[1];
                }
            } else if (arrayTD[0].equals("3")) {
                if (TN.equals("")) {
                    TN += "0-" + arrayTD[1];
                } else {
                    TN += "-" + arrayTD[1];
                }
            }
        }

        String[] arrayDisponibilidad = {TM, TT, TN};

        String[] arrayHora = {"07:50 a 14:30", "15:00 a 19:00 ", "19:00 a 22:00"};
        String[] arrayTurno = {"MAÑANA", "TARDE", "NOCHE"};

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "                       <div class=\"table-header\">"
          + "                           <table width=\"100%\" >"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>DOCENTE: " + docente.getApe_pro() + ", " + docente.getNom_pro() + "</td>"
          + "                     <td align=\"right\">"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "                       </div>"
          + "                       <div>"
          + "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORAS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TODOS</th>"
          + "                                       </tr>"
          + "                                   </thead>"
          + "                                   <tbody>");

        int dato = 0;
        int turno = 0;
        int posicion = 1;
        int dia = 0;

        for (int i = 0; i < 3; i++) {
            turno = i + 1;
            pw.println("<tr >"
              + "<td align='center'>" + arrayHora[i] + "</td>"
              + "<td>" + arrayTurno[i] + "</td>");
            for (int j = 1; j <= 6; j++) {
                //int cantidad=0;
                if (arrayDisponibilidad[i] == "") {
                    if (t_doc == turno && p_doc == j) {
                        pw.println("<td align='center' style='background-color:#CDCDCD' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' disabled /></td>");
                    } else {
                        pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                    }

                } else {
                    String[] arrayDias = arrayDisponibilidad[i].split("-");
                    for (int d = 0; d < arrayDias.length; d++) {
                        dia = Integer.parseInt(arrayDias[d]);
                        if (j == dia) {
                            dato = dato + 1;
                        } else {
                            dato = dato + 0;
                        }

                    }
                    int cantidad = serviciosDD.asignadoDisponibilidad(codDoc, j, turno, periodo);
                    System.out.println("cantidad====> " + cantidad);
                    if (cantidad > 0) {
                        if (dato == 1) {
                            if (cadena.equals("")) {
                                cadena = turno + "#" + j;
                            } else {
                                cadena += "-" + turno + "#" + j;
                            }

                            if (t_doc == turno && p_doc == j) {
                                pw.println("<td align='center' valign='middle' style='background-color:#CDCDCD'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked disabled /></td>");
                            } else {
                                pw.println("<td align='center' valign='middle' style='background-color:#9FCEF8'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked disabled /></td>");
                            }

                        } else {

                            if (t_doc == turno && p_doc == j) {
                                pw.println("<td align='center' style='background-color:#CDCDCD' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "'  disabled/></td>");
                            } else {
                                pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                            }

                        }
                    } else {
                        if (dato == 1) {

                            if (t_doc == turno && p_doc == j) {
                                pw.println("<td align='center' style='background-color:#CDCDCD' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked  disabled/></td>");
                            } else {
                                pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' checked /></td>");
                            }

                        } else {

                            if (t_doc == turno && p_doc == j) {
                                pw.println("<td align='center' style='background-color:#CDCDCD' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "'  disabled /></td>");
                            } else {
                                pw.println("<td align='center' valign='middle'><input type='checkbox' value='" + turno + "#" + j + "' name='chk_" + posicion + "' /></td>");
                            }

                        }
                    }
                    dato = 0;

                }
                posicion++;

            }

            pw.println("    <td align='center'><a href='javascript:seleccionar_todo(" + turno + ");'> <img src='imagenes/icons/check_box_vacio.png'  style='width: 25px;'></a>"
              + " </td>"
              + "</tr> ");

        }
        // PG000019
        pw.println("<input type='hidden' id='seleCant' value='" + arrayGrupo.length + "' >");
        pw.println("<!--<td align='center' valign='middle'><a href='javascript:seleccionar_todo();'> <img src='imagenes/icons/check_box.png' style='width: 25px;'></a></td> </tr>-->"
          + "               </tbody>"
          + "           </table> <input type=hidden id='dato' value='1'> <input type='hidden' id='selec' value='" + cadena + "' >"
          + "       </div>"
          + "   </div>"
          + "   <center>"
          + "       <table border='0'>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td style='background-color:#9FCEF8;  border: 1px solid black;'  width='20'> </td>"
          + "               <td width='10'> </td>"
          + "               <td >Este color muestra que ya tiene asignado un  curso en ese día.</td>"
          + "           </tr>"
          + "           <tr>"
          + "               <td height='10' colspan='3'></td>"
          + "           </tr>"
          + "       </table>"
          + "   </center>"
          + "</div>"
          + ""
          + "<br><br>\n"
          + "                                    <center>\n"
          + "                                        <button class=\"btn btn-sm btn-primary\" onclick=\"asignar();\" type=\"button\">\n"
          + "                                            <i class=\"ace-icon fa fa-check icon-on-right bigger-110\"></i> \n"
          + "                                            Registrar disponibilidad \n"
          + "                                        </button>\n"
          + "                                    </center>");

    }

    private void verificarExisteRegistroDatosDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String codigoDocente = request.getParameter("codDocente");

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        int dato = 0;
        DocenteServices docenteServicios = new DocenteServices();
        dato = docenteServicios.cantidadDocenteDatos(codigoDocente);

        if (dato >= 1) {
            pw.print("1");
        } else {
            pw.print("0");
        }

    }

    private void listarDocentePorArea(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();

        PlanaServices serviciosPlana = new PlanaServices();
        PlanaDocenteServices serviciosPD = new PlanaDocenteServices();

        ArrayList<Docente> lista = null;
        ArrayList<Plana> listaPlana = null;
        ArrayList<PlanaDocente> listaPD = null;

        String codigoArea = request.getParameter("codigoArea");
        String codigoPeriodo = request.getParameter("codigoPeriodo");
        String apellidoDocente = request.getParameter("apellidoDocente");

        int cantRegistro = 0;
        int cantidadAsignada = 0;
        listaPlana = serviciosPlana.cargarPlana(codigoArea);

        String codigosPlana = "";
        String codPlana = "";
        String codDocente = "";
        int asignado = 0;
        String cadenaCodigoDocente = "";
        int verificarCruce = 0;

        //---------------datos de la pginacion----------------------
        int cant = Integer.parseInt(request.getParameter("cantidad"));
        int pagina = Integer.parseInt(request.getParameter("pagina"));
        int inicio = (pagina - 1) * cant;

        lista = servicios.listaDocentesPorArea(codigoArea, apellidoDocente, inicio, cant);
        cantRegistro = servicios.cantListaDocentePorArea(codigoArea, apellidoDocente);

        //--------------CALCULO DE PAGINADO---------
        int numero = cantRegistro / cant;
        int resto = cantRegistro % cant;
        if (resto > 0) {
            numero = numero + 1;
        }

        //----------------------------------------------
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<div style=\"border: 1px solid #CCCCCC;\">"
          + "   <div class=\"table-header\">"
          + "       <table width=\"100%\" height=\"60\">"
          + "             <tbody>"
          + "                 <tr>"
          + "                     <td>Listado de Docentes</td>"
          + "                     <td align=\"right\">"
          + "                         <button class=\"btn btn-sm btn-warning\" onclick=\"validar_asignar();\" type=\"button\">"
          + "                                               <i class=\"ace-icon fa fa-check icon-on-right bigger-110\"></i>"
          + "                                               Asignar Plana"
          + "                                           </button>"
          + "                     </td>"
          + "                     <td width=\"10\"></td>"
          + "                 </tr>"
          + "             </tbody>"
          + "         </table>"
          + "     </div>"
          + "     <div>"
          + "       <div class=\"dataTables_wrapper form-inline n o-footer\" id=\"sample-table-2_wrapper\">"
          + "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >"
          + "                                   <thead>"
          + "                                       <tr role=\"row\">"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >N°</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">APELLIDOS</th>"
          + "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRES</th>");
        int canti = 0;
        for (int i = 0; i < listaPlana.size(); i++) {
            canti++;
            pw.println("<th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">" + listaPlana.get(i).getNom_pla() + "</th>");
            if (codigosPlana == "") {
                codigosPlana += listaPlana.get(i).getCod_pla();
            } else {
                codigosPlana += "#" + listaPlana.get(i).getCod_pla();
            }

        }
        String[] ArrayCodPlana = codigosPlana.split("#");
        pw.println("    </tr>"
          + "   </thead>"
          + "<tbody>");
        int cont_ini = 0;
        int cont_fin = 0;
        int cont = inicio + 1;

        //CODIGOS DE DOCENTES
        for (int i = 0; i < lista.size(); i++) {
            if (cadenaCodigoDocente.equals("")) {
                cadenaCodigoDocente += lista.get(i).getCodigoDocente();
            } else {
                cadenaCodigoDocente += "," + lista.get(i).getCodigoDocente();
            }
        }

        listaPD = serviciosPD.consultarAsignados(cadenaCodigoDocente, codigoPeriodo);

        for (int i = 0; i < lista.size(); i++) {
            if (i == 0) {
                cont_ini = cont;
            }
            pw.println("<tr>");
            pw.println("   <td align='center'>" + cont + "</td>"
              + "   <td>" + lista.get(i).getApe_pro() + "</td>"
              + "   <td>" + lista.get(i).getNom_pro() + "</td>");

            for (int j = 0; j < listaPlana.size(); j++) {
                int dato = j + 1;
                //consultar area y docente
                codPlana = "" + listaPlana.get(j).getCod_pla();
                codDocente = "" + lista.get(i).getCodigoDocente();
                int valor = 0;
                for (int x = 0; x < listaPD.size(); x++) {
                    if (listaPD.get(x).getCodigoPlana() == listaPlana.get(j).getCod_pla()) {
                        if (listaPD.get(x).getCodigoDocente().equals(lista.get(i).getCodigoDocente())) {
                            valor = 1;
                        }
                    }
                }

                if (valor == 1) {
//                    verificarCruce = servicios.verificarCruces(codDocente, codArea);
//                    if (verificarCruce == 0) {
//                        pw.println("<td align='center' valign='middle' >"
//                                + "     <div id='div_" + codPlana + "_" + codDocente + "'>"
//                                + "         <a href=\"javascript:verificarCruces(" + codPlana + "," + codDocente + "," + codPlana + "," + cont + ");\" class=\"regular\" >"
//                                + "             <img src=\"imagenes/icons/check_box.png\" style=\"width: 23px;\"/>"
//                                + "         </a>"
//                                + "     </div>"
//                                + "</td>");
//                    } else {
                    pw.println("<td align='center' valign='middle'  style='background-color:#D0EAFF'>"
                      + "     <div id='div_" + codPlana + "_" + codDocente + "'>"
                      + "         <a href=\"javascript:verificarCruces(" + codPlana + "," + codDocente + "," + codPlana + "," + cont + ");\" class=\"regular\" >"
                      + "             <img style=\"width:25px\" src=\"imagenes/icons/check_box.png\" />"
                      + "         </a>"
                      + "     </div>"
                      + "</td>");
//
//                    }
//
                } else {
                    pw.println("<td align='center' valign='middle'><input type='checkbox' class ='validate[required]' name='" + codPlana + "_docente_" + cont + "' value='" + codPlana + "_" + codDocente + "'  /></td>");
                }
                valor = 0;
            }

            pw.println(" </tr>");
            cont++;
        }

        cont_fin = cont - 1;
        canti = canti + 3;
        if (cont == 1) {
            pw.println("<tr><td colspan='" + canti + "' align='center'>No hay docente para asignar</td></tr>");
        }
        int cantidad = cont - 1;
        pw.println("</tbody>"
          + "			</table>"
          + "                       <input type='hidden' id='codPlanas' value='" + codigosPlana + "' />"
          + "                       <input type='hidden' id='cantidad' value='" + cantidad + "' />"
          + "			</table>");

        //::::::::::::::: PIE ::::::::::::::::
        if (cantRegistro >= cantidad) {

            pw.println("<div class='row'>"
              + "<div class='col-xs-6'>"
              + "<div class='dataTables_info' id='sample-table-2_info' role='status' aria-live='polite'> "
              + "Mostrando del " + cont_ini + " al " + cont_fin + " de " + cantRegistro + " Docente(s)"
              + "</div> "
              + "</div> "
              + "<div class='col-xs-6'> "
              + "<div class='dataTables_paginate paging_simple_numbers' id='sample-table-2_paginate'>"
              + "<ul class='pagination'>");

            int anterior = pagina - 1;
            int siguiente = pagina + 1;
            if (pagina > 1) {
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:listarDocentes(" + 1 + ");'> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a href='javascript:listarDocentes(" + anterior + ");'>Anterior</a>"
                  + "</li>");

                //pw.println("<li><a href=\"javascript:buscarAula(" + anterior + ");\"><span>Anterior</span></a></li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a> << </a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button previous disabled' id='sample-table-2_previous' aria-controls='sample-table-2'> "
                  + "<a>Anterior</a>"
                  + "</li>");
            }

            //for(int i = 1; i<=numero; i++){
            if (numero > 5) {
                if (pagina > 2) {
                    if (numero >= pagina + 5) {
                        for (int i = pagina - 2; i < pagina + 3; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li ><a href=\"javascript:buscarAula(" + i + ");\" style='background-color:#00A9FB'><span>" + i + "</span></a></li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                                //pw.println("<li><a href=\"javascript:buscarAula(" + i + ");\" ><span>" + i + "</span></a></li>");
                            }
                        }
                    } else {
                        if (pagina == numero) {
                            for (int i = pagina - 4; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 1) {
                            for (int i = pagina - 3; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 2) {
                            for (int i = pagina - 2; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 3) {
                            for (int i = pagina - 1; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        } else if (pagina == numero - 4) {
                            for (int i = pagina; i <= numero; i++) {
                                if (pagina == i) {
                                    pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                } else {
                                    pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                      + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                      + "</li>");
                                }
                            }
                        }
                    }
                } else {
                    if (pagina == 1) {
                        for (int i = pagina; i < pagina + 5; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    } else {
                        for (int i = pagina - 1; i < pagina + 4; i++) {
                            if (pagina == i) {
                                pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            } else {
                                pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                                  + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                                  + "</li>");
                            }
                        }
                    }
                }
            } else {
                for (int i = 1; i <= numero; i++) {
                    if (pagina == i) {
                        pw.println("<li tabindex='0' class='paginate_button active' aria-controls='sample-table-2'>"
                          + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    } else {
                        pw.println("<li tabindex='0' class='paginate_button' aria-controls='sample-table-2'>"
                          + "<a href='javascript:listarDocentes(" + i + ");'>" + i + "</a>"
                          + "</li>");
                    }
                }
            }
            //}

            if (pagina < numero) {
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:listarDocentes(" + siguiente + ");'>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a href='javascript:listarDocentes(" + numero + ");'> >> </a>"
                  + "</li>");
            } else {
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a>Siguiente</a>"
                  + "</li>");
                pw.println("<li tabindex='0' class='paginate_button next disabled' id='sample-table-2_next' aria-controls='sample-table-2'>"
                  + "<a> >> </a>"
                  + "</li>");
            }
            pw.println("</ul>"
              + "</div>"
              + "</div>"
              + "</div>");
        }

        //::::::::::::::: PIE ::::::::::::::::
        pw.println("</div>"
          + "</div>"
          + "</div>");

        /*
         "			</div>" +
         "			</td></tr></table>" +
         "			<table >" +
         "                       <tr>        "+
         "			<td colspan='8' align='center'></td>" +
         "                       </tr>        "+
         "                       <tr>        "+
         "			<td  width='15'  style='background-color:#D0EAFF;  border: 1px solid; border-color: #000000;' >  " +
         "			</td> " +
         "			<td>  " +
         "			: Este color indica que no se puede quitar la selección debido a que tiene un horario asignado." +
         "			</td>      " +
         "                       </tr>        "+
         "			</table>"
         + "<input type='hidden' id='codAreas' value='"+codigosArea+"' />"
         + "<input type='hidden' id='cantidad' value='"+cantidad+"' />"); */
    }

    private void registrarPlanaDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
        int insert = 0;
        PlanaServices servicios = new PlanaServices();
        String dato = request.getParameter("datos");
        String codigoPeriodo = request.getParameter("codigoPeriodo");
        System.out.println("dato => " + dato);
        String[] ArrayGrande = dato.split("#");

        for (int i = 0; i < ArrayGrande.length; i++) {
            String[] ArrayChico = ArrayGrande[i].split("_");
            insert = servicios.registrarPlanaDocente(ArrayChico[0], ArrayChico[1], codigoPeriodo);
        }

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        if (insert > 0) {
            pw.print("1");
        } else {
            pw.print("0");
        }

    }

    private void quitarPlanaDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {

        PlanaDocenteServices servicios = new PlanaDocenteServices();
        String codigoDocente = request.getParameter("codigoDocente");
        String codigoPlana = request.getParameter("codigoPlana");
        String codigoPeriodo = request.getParameter("codigoPeriodo");
        int dato = servicios.quitarPlanaDocente(codigoDocente, codigoPlana, codigoPeriodo);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        if (dato > 0) {
            pw.print("1");
        } else {
            pw.print("0");
        }

    }

    private void verificarCrucesPorPeriodo(HttpServletRequest request, HttpServletResponse response) throws IOException {
        DocenteServices servicios = new DocenteServices();
        String codigoArea = request.getParameter("codigoArea");
        String codigoDocente = request.getParameter("codigoDocente");
        String codigoPeriodo = request.getParameter("codigoPeriodo");
        int dato = servicios.verificarCrucesPorPeriodo(codigoDocente, codigoArea, codigoPeriodo);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.println(dato);

    }

    private void tablaDocentesDisponiblesGeneral5(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String periodo = request.getParameter("periodo");
        String filtro = request.getParameter("apellidoDocente");
        String cadenaAulas = request.getParameter("cadenaAulas");
        ArrayList<Docente> lista = null;
        DocenteServices servicio = new DocenteServices();
        System.out.println("cadenaAulas=>" + cadenaAulas);
        lista = servicio.filtroDocentesPrimSec(periodo, filtro, cadenaAulas);

        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();

        pw.println("<div style='border: 1px solid #CCCCCC;' >");
        pw.println("<div class='table-header'>");
//        pw.println("<table width='100%'  id='datos'>");
        pw.println("<table width='100%' height='30' id='datos'>");
        pw.println("<tbody>");
        pw.println("<tr>");
        pw.println("<td>Lista de docentes</td>");
        pw.println("<td align='right'>");
        pw.println("</td>");
        pw.println("<td width='10'></td>");
        pw.println("</tr>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
//            pw.println("<div style='height:300px;'>");
        pw.println("<div style='height: 500px;overflow: auto; position: relative;'>");
//        pw.println("<div style=''>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer'>");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='tablaDocentes' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
        pw.println("<thead>");
        pw.println("<tr role='row'>");
        pw.println("<th width='35' class='center'>N°</th>");
        pw.println("<th width='400' class='center'>DOCENTE</th>");
        pw.println("<th width='400' class='center'>ZONA</th>");
        pw.println("<th width='400' class='center'>CANTIDAD</th>");
        pw.println("<th width='200' class='center'>NOTA EXAMEN</th>");
        pw.println("<th width='200' class='center'>NOTA ENCUESTA</th>");
        pw.println("<th width='200' class='center'>ACCIÓN</th>");
        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");
        int cont = 1;
        String color = "";
        for (int i = 0; i < lista.size(); i++) {
            int codigoTipoDocente = lista.get(i).getCod_tip();

            if (codigoTipoDocente == 1) {
                color = "style=''";
            } else { //profesores nuevos
                if (cont % 2 == 0) {
                    color = "style='background-color:#FFF9C0;'";
                } else {
                    color = "style='background-color:#FFFCE0;'";
                }
            }
            pw.println("<tr " + color + ">");
            String codigoDocente = lista.get(i).getCodigoDocente();
            String apeDocente = lista.get(i).getApe_pro();
            String nomDocente = lista.get(i).getNom_pro();
            String nombreCompleto = apeDocente.replace("Ã‘", "Ñ") + ", " + nomDocente.replace("Ã‘", "Ñ");
            String zona = lista.get(i).getZona();
            String notaExamen = lista.get(i).getNotaExamen();
            String notaEncuesta = lista.get(i).getNotaEncuesta();
            int cantidad = lista.get(i).getCantidad();
            String icono = "";
            if (!notaExamen.equals("")) {
                double notaExa = Double.parseDouble(notaExamen);
                if (notaExa >= 9) {
                    icono = "fa fa-arrow-up green";
                } else if (notaExa > 8.49 && notaExa < 9) {
                    icono = "fa fa-arrow-up orange";
                } else if (notaExa < 8.5) {
                    icono = "fa fa-arrow-down red";
                }
            }

            pw.println("<td class='text-center align-middle' style='width:50px;'>" + cont + "</td>");
            pw.println("<td class='align-middle'>" + nombreCompleto + "</td>");
            pw.println("<td class='align-middle'>" + zona + "</td>");
            pw.println("<td class='text-center align-middle'>" + cantidad + "</td>");
            pw.println("<td class='text-center align-middle'><i class='" + icono + "'></i>" + notaExamen + "</td>");
            pw.println("<td class='text-center align-middle'>" + notaEncuesta + "</td>");
//            if (informe == null) {
//                informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
//            } else {
//                if (informe.equals("0")) {
//                    informe = "<span class=\"label label-success arrowed\">Habilitado</span>";
//                } else {
//                    informe = "<span class=\"label label-danger arrowed\">Restringido</span>";
//                }
//            }
//            pw.println("<td align='center'  style='vertical-align:middle'>" + informe + "</td>");

//            if (!promedio.equals("-")) {
//                double prom = Double.parseDouble(promedio);
//
//                if (prom > 8.49 && prom <= 10) {
//                    icono = "fa fa-arrow-up green";
//                } else if (prom < 8.5) {
//                    icono = "fa fa-arrow-down red";
//                }
//            }
//            pw.println("<td align='center' style='vertical-align:middle'><i class=\"" + icono + "\"></i>&nbsp;" + promedio + "</td>");
            pw.println("<td align='center' style='vertical-align:middle'>");
            pw.println("<label>");
            pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
            pw.println("<span  class='lbl'></span>");
            pw.println("</label>");
            pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codigoDocente + "'>");
            pw.println("<input type='hidden' id='datos2_" + cont + "' value='" + cont + "#" + nombreCompleto + "'>");
            pw.println("</td>");
            pw.println("</tr>");
            cont++;
        }
        pw.println("<input type='hidden' id='cantidad' value='" + lista.size() + "'>");
        pw.println("</tbody>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
        pw.println("</div><input type='hidden' id='cantidad' value='" + lista.size() + "'>");
        pw.println("<div style='width:707px;'>");
        pw.println("<div class='fixed-table-container-inner extrawrap dataTables_wrapper form-inline no-footer' >");
        pw.println("<table class='table table-striped table-bordered table-hover dataTable no-footer' id='datos' role='grid' aria-describedby='sample-table-2_info' style='font-size:11px;' >");
//        pw.println("<thead>");
//        pw.println("<tr role='row'>");
//        pw.println("<th width='80' class='center' rowspan='1' colspan='1' >N°</th>");
//        pw.println("<th width='700' class='center' rowspan='1' colspan='1'>DOCENTE</th>");
//        pw.println("<th width='623' class='center' rowspan='1' colspan='1'>ZONA</th>");
//        pw.println("<th width='400' class='center' rowspan='1' colspan='1'>INFORME</th>");
//        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>PROMEDIO</th>");
//        pw.println("<th width='280' class='center' rowspan='1' colspan='1'>SELECCIÓN</th>");
//        pw.println("</tr>");
//        pw.println("</thead>");
        pw.println("</table>");
        pw.println("</div>");
        pw.println("</div>");
    }

    private void darDeBaja(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        HttpSession session_actual = request.getSession(true);
        Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
        String codigo = request.getParameter("codigo");
        String periodo = request.getParameter("periodo");
        DocenteServices service = new DocenteServices();
        String respuesta = service.darDeBaja(codigo, periodo, usuario.getCodigoUsuario());
        pw.print(respuesta);
    }

}
