/*
 * 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.util.ArrayList;
import java.util.Arrays;
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 org.json.JSONArray;
import org.json.JSONObject;
import pe.siso.horario.Beans.AreaDocente;
import pe.siso.horario.Beans.Aula;
import pe.siso.horario.Beans.Bloque;
import pe.siso.horario.Beans.Clase;
import pe.siso.horario.Beans.Curso;
import pe.siso.horario.Beans.Docente;
import pe.siso.horario.Beans.Grupo;
import pe.siso.horario.Beans.Horario;
import pe.siso.horario.Beans.PeriodoAcademico;
import pe.siso.horario.Beans.Usuario;
import pe.siso.horario.Services.AreaDocenteServices;
import pe.siso.horario.Services.AulaServices;
import pe.siso.horario.Services.BloqueServices;
import pe.siso.horario.Services.ClaseServices;
import pe.siso.horario.Services.CursoServices;
import pe.siso.horario.Services.DocenteServices;
import pe.siso.horario.Services.HorarioServices;
import pe.siso.horario.Services.SedeServices;

/**
 *
 * @author fcelestino
 */
public class ServletHorario extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String param = request.getParameter("Accion");
		if ("armarRegistroAsig".equals(param)) {
			armarRegistroAsig(request, response);
		} else if ("cargarGrupoBloque".equals(param)) {
			cargarGrupoBloque(request, response);
		} else if ("listarVistaDobleDisponibilidad".equals(param)) {
			listarVistaDobleDisponibilidad(request, response);
		} else if ("armarGrupoHorario".equals(param)) {
			armarGrupoHorario(request, response);
		} else if ("armarGrupoHorarioAsig".equals(param)) {
			armarGrupoHorarioAsig(request, response);
		} else if ("registrarGrupoBloq".equals(param)) {
			registrarGrupoBloq(request, response);
		} else if ("armarAsignacionCursoDoc".equals(param)) {
			armarAsignacionCursoDoc(request, response);
		} else if ("registrarAsigCurDoceHorario".equals(param)) {
			registrarAsigCurDoceHorario(request, response);
		} else if ("armarGrupoHorarioVer".equals(param)) {
			armarGrupoHorarioVer(request, response);
		} else if ("armarDetalleHorario".equals(param)) {
			armarDetalleHorario(request, response);
		} else if ("armarGrupoHorarioAsigReal".equals(param)) {
			armarGrupoHorarioAsigReal(request, response);
		} else if ("verCruce".equals(param)) {
			verCruce(request, response);
		} else if ("verHorarioReporte".equals(param)) {
			verHorarioReporte(request, response);
		} else if ("verHorarioDocente".equals(param)) {
			verHorarioDocente(request, response);
		} else if ("consultarExistenciaHorarioRegistrado".equals(param)) {
			consultarExistenciaHorarioRegistrado(request, response);
		} else if ("armarEditarBloqueAsignado".equals(param)) {
			armarEditarBloqueAsignado(request, response);
		} else if ("editarGrupoBloqAsignado".equals(param)) {
			editarGrupoBloqAsignado(request, response);
		} else if ("limpiarRegistro".equals(param)) {
			limpiarRegistro(request, response);
		} else if ("consultarCursos".equals(param)) {
			consultarCursos(request, response);
		} else if ("consultarCursosEditar".equals(param)) {
			consultarCursosEditar(request, response);
		} else if ("armarHorarioAulas".equals(param)) {
			armarHorarioAulas(request, response);
		} else if ("armarGrupoHorarioGenerar".equals(param)) {
			armarGrupoHorarioGenerar(request, response);
		} else if ("sessionArmadoHorario".equals(param)) {
			sessionArmadoHorario(request, response);
		} else if ("armadoHorarioGeneral".equals(param)) {
			armadoHorarioGeneral(request, response);
		} else if ("cargarGrupoBloqueArmado".equals(param)) {
			cargarGrupoBloqueArmado(request, response);
		} else if ("armarAsignacionCursoDocGeneral".equals(param)) {
			armarAsignacionCursoDocGeneral(request, response);
		} else if ("consultarCursosGeneral".equals(param)) {
			consultarCursosGeneral(request, response);
		} else if ("registrarAsigCurDoceHorarioGeneral".equals(param)) {
			registrarAsigCurDoceHorarioGeneral(request, response);
		} else if ("verCruceIndividual".equals(param)) {
			verCruceIndividual(request, response);
		} else if ("registrarAsigCurDoceHorarioGeneralMasivo".equals(param)) {
			registrarAsigCurDoceHorarioGeneralMasivo(request, response);
		} else if ("verCruceMasivo".equals(param)) {
			verCruceMasivo(request, response);
		} else if ("EliminarHorarioCurso".equals(param)) {
			EliminarHorarioCurso(request, response);
		} else if ("armarAsignacionCursoDocGeneralEdit".equals(param)) {
			armarAsignacionCursoDocGeneralEdit(request, response);
		} else if ("armadoHorarioGeneralVer".equals(param)) {
			armadoHorarioGeneralVer(request, response);
		} else if ("eliminarHorarioTodoAula".equals(param)) {
			eliminarHorarioTodoAula(request, response);
		}else if("eliminarBloqueGrupoAula".equals(param)){
                    eliminarBloqueGrupoAula(request,response);
                } else if ("armarHistorial".equals(param)) {
			armarHistorial(request, response);
		} else if ("armarHorarioAulas2".equals(param)) {
			armarHorarioAulas2(request, response);
		} else if ("cargarGrupoBloqueArmado2".equals(param)) {
			cargarGrupoBloqueArmado2(request, response);
		} else if ("armarGrupoHorarioGenerar2".equals(param)) {
			armarGrupoHorarioGenerar2(request, response);
		} else if ("sessionArmadoHorario2".equals(param)) {
			sessionArmadoHorario2(request, response);
		} else if ("armadoHorarioGeneral2".equals(param)) {
			armadoHorarioGeneral2(request, response);
		} else if ("armarAsignacionCursoDocGeneral2".equals(param)) {
			armarAsignacionCursoDocGeneral2(request, response);
		} else if ("armarAsignacionCursoDocGeneral3".equals(param)) {
			armarAsignacionCursoDocGeneral3(request, response);
		} else if ("registrarAsigCurDoceHorarioGeneral2".equals(param)) {
			registrarAsigCurDoceHorarioGeneral2(request, response);
		}else if("registrarAsigCurDoceHorarioGeneral2Personalizado".equals(param)){
		 registrarAsigCurDoceHorarioGeneral2Personalizado(request,response);
		} else if ("armarAsignacionCursoDocGeneralEdit2".equals(param)) {
			armarAsignacionCursoDocGeneralEdit2(request, response);
		} else if ("armarAsignacionCursoDocGeneralEdit3".equals(param)) {
			armarAsignacionCursoDocGeneralEdit3(request, response);
		} else if ("registrarAsigCurDoceHorarioGeneralMasivo2".equals(param)) {
			registrarAsigCurDoceHorarioGeneralMasivo2(request, response);
		} else if ("armadoHorarioGeneral2Ver".equals(param)) {
			armadoHorarioGeneral2Ver(request, response);
		} else if ("sessionArmadoHorario3".equals(param)) {
			sessionArmadoHorario3(request, response);
		} else if ("listarGrupoAulas".equals(param)) {
			listarGrupoAulas(request, response);
		} else if ("EliminarHorarioCursoMasivo".equals(param)) {
			EliminarHorarioCursoMasivo(request, response);
		} else if ("verHorarioDocente2".equals(param)) {
			verHorarioDocente2(request, response);
		} else if ("armarAsignacionCursoDocGeneralEdit4".equals(param)) {
			armarAsignacionCursoDocGeneralEdit4(request, response);
		} else if ("verHorarioVerificar".equals(param)) {
			verHorarioVerificar(request, response);
		} else if ("verHorarioDocenteDni".equals(param)) {
			verHorarioDocenteDni(request, response);
		} else if ("verHorarioDocentePeriodo".equals(param)) {
			verHorarioDocentePeriodo(request, response);
		}else if("verHistorialCambioDiario".equals(param)){
			verHistorialCambioDiario(request,response);
		}else if("updateCambioCurso".equals(param)){
			updateCambioCurso(request,response);
		}else if("updateDisponibilidad".equals(param)){
			updateDisponibilidad(request,response);
		}else if("rollbackDisponibilidad".equals(param)){
			rollbackDisponibilidad(request,response);
		}else if("verHorarioDocenteDni2".equals(param)){
			verHorarioDocenteDni2(request,response);
		}else if("registrarConformidad".equals(param)){
			registrarConformidad(request,response);
		}else if("listarVistaDobleDisponibilidad2".equals(param)){
			listarVistaDobleDisponibilidad2(request,response);
		}else if("listarVistaDobleDisponibilidadSinZona".equals(param)){
			listarVistaDobleDisponibilidadSinZona(request,response);
		}else if("insertarNuevaHoras".equals(param)){
			insertarNuevaHoras(request,response);
		}else if("mostrarNuevaHoras".equals(param)){
			mostrarNuevaHoras(request,response);
		}else if("deshabilitarHorario".equals(param)){
                    deshabilitarHorario(request,response);
                }else if("updateGrupoAula".equals(param)){
                    updateGrupoAula(request,response);
                }
	}

	private void armarRegistroAsig(HttpServletRequest request, HttpServletResponse response) throws IOException {
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		lista = servicio.cargarBloque();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		pw.println("<div  class='col-sm-12'></div>");
		pw.println("<div  class='col-sm-3'></div>");

		pw.println("<div  class='col-sm-6'>"
			+ "     <label>Bloque<span style='color:red;'>*</span></label><br>"
			+ "     <select id='cmbBloque' class='form-control validate[required]' onChange='cargarGrupo2();limpiar();'>"
			+ "         <option value=''>Seleccione</option>");
		for (int i = 0; i < lista.size(); i++) {
			pw.println("<option value='" + lista.get(i).getCod_blo() + "'>" + lista.get(i).getNom_blo() + "</option>");
		}
		pw.println("            </select><br>"
			+ "     <label>Grupo<span style='color:red;'>*</span></label><br>"
			+ "     <span id='divGrupoSelect2' >"
			+ "         <select id='cmbGrupoBloque2' class='form-control validate[required]'>"
			+ "             <option value=''>Seleccione</option>"
			+ "         </select>"
			+ "     </span> <br>"
			+ "     <center>"
			+ "         <button class=\"btn btn-sm btn-primary\" onclick=\"validar_bloque_grupo();\" type=\"button\">"
			+ "             <i class=\"ace-icon fa fa-eye icon-on-right bigger-110\"></i>\n"
			+ "             Mostrar Bloque\n"
			+ "         </button>"
			+ "     </center><br>");
		pw.println("</div>");

		pw.println("<div  class='col-sm-3'></div>");

		/*
         pw.println("<table cellpadding='0' cellspacing='0' border='0' width='100%'>"
                 + "    <tr><td align='center'>"
                 + "    <table><tr><td align='center'>"
                 + "    <fieldset>"
                 + "        <legend class=\"sttitupanel\">Busqueda de aulas por sede</legend>"
                 + "    <table cellpadding='0' cellspacing='0' border='0' >"
                 + "    <tr>"
                 + "        <td><b>Bloque :</b></td>"
                 + "        <td width='10'></td>"
                 + "        <td>"
                 + "            <select id='cmbBloque' class='form-control validate[required]' onChange='cargarGrupo2();limpiar();'>"
                 + "                <option value=''>Seleccione</option>");
                                        for(int i=0; i<lista.size();i++){
                                            pw.println("<option value='"+lista.get(i).getCod_blo()+"'>"+lista.get(i).getNom_blo()+"</option>");
                                        }
                                
        pw.println("            </select> "
                 + "        </td>"
                 + "    </tr>"
                 + "    <tr><td colspan='3' height='10'></td></tr>"
                 + "    <tr>"
                 + "        <td><b>Grupo:</b></td>"
                 + "        <td width='10'></td>"
                 + "        <td>"
                 + "            <span id='divGrupoSelect2' >"
                 + "                <select id='cmbGrupoBloque2' class='form-control validate[required]'>"
                 + "                    <option value=''>Seleccione</option>"
                 + "                </select>"
                 + "            </span> "
                 + "        </td>"
                 + "    </tr>"
                 + "    <tr><td colspan='3' height='10'></td></tr>"
                 + "    <tr>"
                 + "        <td colspan='3' align='center'>"
                 + "            <div class=\"buttons\" style=\"display: inline-block;\"> " 
                 + "                <a href=\"javascript:validar_bloque_grupo();\" class=\"regular\" > " 
                 + "                    <img src=\"imagenes/icons/zoom.png\" />Mostrar bloque " 
                 + "                </a> " 
                 + "            </div>"
                 + "        </td>"
                 + "    </tr>"
                 + "</table>"
                 + "</fieldset>"
                 + "<fieldset class=\"tblFooters\"></fieldset>"
                 + "</td></tr></table>"
                + "</td></tr>"
                + "</table>");*/
	}

	private void cargarGrupoBloque(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String nombre = request.getParameter("nombre");
		String accion = request.getParameter("accion");
		String codBlo = request.getParameter("codBlo");
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		lista = servicio.BusquedaBloque(codBlo);
		response.setContentType("text/html");

		PrintWriter pw = response.getWriter();

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

	private void armarGrupoHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codGruBlo = request.getParameter("codGruBlo");
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		lista = servicio.consultarDetalleBloque(codGruBlo);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cont = 1;
		if (!codGruBlo.equals("")) {

			pw.println("<br><br><br><br><br><br><br><br><br><br>");
			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           Bloque"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			for (int i = 0; i < lista.size(); i++) {
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>"
						+ "    <td height='20' colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>"
						+ "    <td height='40' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('1');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('2');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('3');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('4');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('5');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('6');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "</tr>");
				}
				cont++;
			}

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

	private void armarGrupoHorarioAsig(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codalua = request.getParameter("codalua");
		BloqueServices servicio = new BloqueServices();
		HorarioServices servicios1 = new HorarioServices();
		ArrayList<Bloque> lista = null;
		String codGruBlo = servicios1.consultarCodigoGrupo(codalua);

		lista = servicio.consultarDetalleBloque(codGruBlo);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cont = 1;
		int blo = 1;
		if (!codGruBlo.equals("")) {
			pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">\n"
				+ "	    <tr>\n"
				+ "               <td height=\"10\"></td>\n"
				+ "           </tr>\n"
				+ "           <tr><td width=\"750\">\n"
				+ "                   <div class=\"datagrid\">\n"
				+ "                           <table border='1'>\n"
				+ "                                   <thead>\n"
				+ "                                       <tr >\n"
				+ "                                           <th>HORARIO</th>\n"
				+ "                                           <th>LUNES</th>\n"
				+ "                                           <th>MARTES</th>\n"
				+ "                                           <th>MIÉRCOLES</th>\n"
				+ "                                           <th>JUEVES</th>\n"
				+ "                                           <th>VIERNES</th>\n"
				+ "                                           <th>SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			for (int i = 0; i < lista.size(); i++) {
				String ini = lista.get(i).getHor_ini();
				String fin = lista.get(i).getHor_fin();
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20'>" + ini + " a " + fin + "</td>"
						+ "    <td height='20' colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>");
					pw.println("    <td height='40'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>");
					for (int dia = 1; dia <= 6; dia++) {
						String diaAct = "" + dia;
						String bloAct = "" + blo;
						int cant = servicios1.cantidadAsignado(codalua, diaAct, bloAct);
						if (cant > 0) {
							pw.println("    <td align='center' width='90' ><a href=\"javascript:verDetalleHorario('" + codalua + "','" + blo + "','" + dia + "','" + ini + "','" + fin + "');\" class='regular' ><img src='imagenes/icons/calendar-task.png'/></a></td>");
						} else {
							pw.println("    <td align='center' width='90' ><a href=\"javascript:asignarHorarioCurso('" + blo + "','" + dia + "','" + ini + "','" + fin + "');\" class='regular' ><img src='imagenes/icons/table_add.png'/></a></td>");
						}

					}
					/*pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','1','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");
                    pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','2','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");
                    pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','3','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");
                    pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','4','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");
                    pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','5','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");
                    pw.println("    <td align='center' ><a href=\"javascript:asignarHorarioCurso('"+blo+"','6','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/table.png'/></a></td>");*/
					pw.println("</tr>");
					blo++;
				}
				cont++;
			}

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

	private void registrarGrupoBloq(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices servicios = new HorarioServices();
		String codGruBlo = request.getParameter("codGruBlo");
		String codAula = request.getParameter("codigosAula");
		int dato = servicios.registrarGrupoBloque(codGruBlo, codAula);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

	private void armarAsignacionCursoDoc(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String nombreDia = "";
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String Turno = "";
		if (CodTurno.equals("1")) {
			Turno = "MAÑANA";
		} else if (CodTurno.equals("2")) {
			Turno = "TARDE";
		} else if (CodTurno.equals("3")) {
			Turno = "NOCHE";
		}

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		pw.println("<table width='100%'>"
			+ "     <tr>"
			+ "         <td align='center'>"
			+ "             <table border='0' cellpadding='0' cellspacing='0'>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "         <tr>"
			+ "                     <td><b>Horario</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td > " + horaIni + "<b> a </b>" + horaFin + "</td>"
			+ "          </tr>"
			+ "          <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                     <td><b>Día</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td >" + nombreDia + "</td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "                 <tr>"
			+ "                     <td><b>Turno</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>" + Turno + "<input id='cmbTurno' type='hidden' value='" + CodTurno + "'></td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Curso</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divCursoCombo'>"
			+ "                             <select>"
			+ "                                 <option>seleccione</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Docente</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divDocenteCombo'>"
			+ "                             <select>"
			+ "                                 <option>seleccione</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "             </table>"
			+ "         </td>"
			+ "     </tr>"
			+ "</table>");
	}

	private void registrarAsigCurDoceHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices servicios = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");

		int dato = servicios.registrarAsigCurDoceHorario(codAula, dia, bloq, Hini, Hfin, codTurno, codCurso, codDocente);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);

	}

	private void armarGrupoHorarioVer(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codalua = request.getParameter("codalua");
		BloqueServices servicio = new BloqueServices();
		HorarioServices servicios1 = new HorarioServices();
		ArrayList<Bloque> lista = null;
		String codGruBlo = servicios1.consultarCodigoGrupo(codalua);

		lista = servicio.consultarDetalleBloque(codGruBlo);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cont = 1;
		int blo = 1;
		if (!codGruBlo.equals("")) {

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           Bloque"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			/*
            pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">\n" +
    "	    <tr>\n" +
    "               <td height=\"10\"></td>\n" +
    "           </tr>\n" +
    "           <tr><td width=\"750\">\n" +
    "                   <div class=\"datagrid\">\n" +
    "                           <table border='1'>\n" +
    "                                   <thead>\n" +
    "                                       <tr >\n" +
    "                                           <th>HORARIO</th>\n" +
    "                                           <th>LUNES</th>\n" +
    "                                           <th>MARTES</th>\n" +
    "                                           <th>MIÉRCOLES</th>\n" +
    "                                           <th>JUEVES</th>\n" +
    "                                           <th>VIERNES</th>\n" +
    "                                           <th>SÁBADO</th>\n" +
    "                                       </tr>\n" +
    "                                   </thead>\n" +
    "                                   <tbody>");*/
			for (int i = 0; i < lista.size(); i++) {
				String ini = lista.get(i).getHor_ini();
				String fin = lista.get(i).getHor_fin();
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20' align='center'>" + ini + " a " + fin + "</td>"
						+ "    <td height='20' colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>");
					pw.println("    <td height='40' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("    <td align='center' ><img src='imagenes/icons/table.png'/></td>");
					pw.println("</tr>");
					blo++;
				}
				cont++;
			}

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

	private void armarDetalleHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codalua = request.getParameter("codAula");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");

		HorarioServices servicio = new HorarioServices();
		DocenteServices servicioDoc = new DocenteServices();
		CursoServices servicioCur = new CursoServices();

		Docente docente = new Docente();
		Horario horario = new Horario();
		Curso curso = new Curso();

		horario = servicio.consultarDatosAsignados(codalua, dia, bloq);
		String codDoc = horario.getCodigoDocente_HorarioCursoDoc();
		String codCur = horario.getCodidoCurso_HorarioCursoDoc();

		docente = servicioDoc.NombreDocente(codDoc);
		String NombreCompleto = docente.getApe_pro() + ", " + docente.getNom_pro();

		curso = servicioCur.NombreCurso(codCur);
		String NombreCurso = curso.getNom_cur();
		String NombrePlana = curso.getNom_pla();
		String NombreArea = curso.getNom_are();

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("<table>"
			+ "     <tr>"
			+ "         <td><b>DOCENTE ASIGNADO:</b></td>"
			+ "         <td>" + NombreCompleto + "</td>"
			+ "     </tr>"
			+ "     <tr>"
			+ "         <td><b>CURSO ASIGNADO:</b></td>"
			+ "         <td>" + NombreCurso + "</td>"
			+ "     </tr>"
			+ "     <tr>"
			+ "         <td><b>PLANA ASIGNADO:</b></td>"
			+ "         <td>" + NombrePlana + "</td>"
			+ "     </tr>"
			+ "     <tr>"
			+ "         <td><b>AREA ASIGNADO:</b></td>"
			+ "         <td>" + NombreArea + "</td>"
			+ "     </tr>"
			+ "</table>");

	}

	private void armarGrupoHorarioAsigReal(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codalua = request.getParameter("codalua");
		BloqueServices servicio = new BloqueServices();
		HorarioServices servicios1 = new HorarioServices();
		Bloque bloque = new Bloque();
		CursoServices servicios2 = new CursoServices();
		DocenteServices servicioDoc = new DocenteServices();
		ArrayList<Bloque> lista = null;
		//String codGruBlo = servicios1.consultarCodigoGrupo(codalua);
		bloque = servicios1.consultarCodigoGrupoTurno(codalua);
		String codGruBlo = bloque.getCod_gru();
		String codTurno = bloque.getTur_gru();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String NomTurno = "";

		if (codTurno.equals("1")) {
			NomTurno = "MAÑANA";
		} else if (codTurno.equals("2")) {
			NomTurno = "TARDE";
		} else if (codTurno.equals("3")) {
			NomTurno = "NOCHE";
		}

		lista = servicio.consultarDetalleBloque(codGruBlo);
		int cont = 1;
		int blo = 1;
		if (!codGruBlo.equals("")) {

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

			for (int i = 0; i < lista.size(); i++) {
				String ini = lista.get(i).getHor_ini();
				String fin = lista.get(i).getHor_fin();
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20' width='50' align='center'>" + ini + " a " + fin + "</td>"
						+ "    <td height='20'  colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>");
					pw.println("    <td height='40' style='vertical-align: middle;' width='120' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>");
					for (int dia = 1; dia <= 6; dia++) {
						String diaAct = "" + dia;
						String bloAct = "" + blo;
						int cant = servicios1.cantidadAsignado(codalua, diaAct, bloAct);
						if (cant > 0) {
							//pw.println("    <td align='center' ><a href=\"javascript:verDetalleHorario('"+codalua+"','"+blo+"','"+dia+"','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/calendar-task.png'/></a></td>");
							Horario horario = new Horario();
							horario = servicios1.consultarDatosAsignados(codalua, diaAct, bloAct);
							String codCur = horario.getCodidoCurso_HorarioCursoDoc();
							String codDoc = horario.getCodigoDocente_HorarioCursoDoc();
							String codHorario = horario.getCodHorarioCursoDoc();
							Docente docente = new Docente();
							docente = servicioDoc.NombreDocente(codDoc);
							String NombreCompleto = docente.getApe_pro() + ", " + docente.getNom_pro();

							Curso curso = new Curso();
							//horario = servicios1.consultarDatosAsignados(codalua, diaAct, bloAct);

							curso = servicios2.NombreCurso(codCur);
							String NombreCurso = curso.getNom_cur();
							String NombrePlana = curso.getNom_pla();
							String NombreArea = curso.getNom_are();
							String color = curso.getColor_plana();
							//pw.println("    <td align='center' style='background-color:#A0F3D6' width='90'>"+NombreCurso+"</td>");
							pw.println("    <td width='100' align='center' style='vertical-align: middle; font-size:10px; background-color:" + color + "; cursor: pointer;'  onclick=\"editarHorarioCurso('" + codalua + "','" + blo + "','" + dia + "','" + ini + "','" + fin + "','" + codTurno + "','" + codDoc + "','" + codCur + "')\" ><b>Curso:  </b>" + NombreCurso + "<br> <b>Docente: </b>" + NombreCompleto + " </td>");
							/*pw.println("    <td align='center' class='tooltip' title='  <table>"
                                    + "                                                     <tr>"
                                    + "                                                         <td><center><img src=\"imagenes/icons/book_link1.png\" /></center></td>"
                                    + "                                                         <td><h3>DATOS ASIGNADOS</h3></td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td><b>DOCENTE: </b></td>"
                                    + "                                                         <td>"+NombreCompleto+"</td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td><b>CURSO: </b></td>"
                                    + "                                                         <td>"+NombreCurso+"</td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td><b>PLANA: </b></td>"
                                    + "                                                         <td>"+NombrePlana+"</td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td><b>ÁREA: </b></td>"
                                    + "                                                         <td>"+NombreArea+"</td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td ></td>"
                                    + "                                                         <td><b></b></td>"
                                    + "                                                     </tr>"
                                    + "                                                     <tr>"
                                    + "                                                         <td></td>"
                                    + "                                                         <td><b>Click para editar</b></td>"
                                    + "                                                     </tr>"
                                    + "                                                 </table>' "  // verDetalleHorario
                                    + "         style='background-color:"+color+"; cursor: pointer;' width='100' onclick=\"editarHorarioCurso('"+codalua+"','"+blo+"','"+dia+"','"+ini+"','"+fin+"','"+codTurno+"','"+codDoc+"','"+codCur+"')\" ><b>Curso:  </b>"+NombreCurso+ "<br> <b>Docente: </b>"+NombreCompleto+" </td>");*/
						} else {
							pw.println("    <td id='sinCurso' width='100' align='center'  style='vertical-align: middle; cursor: pointer;' onclick=\"asignarHorarioCurso('" + blo + "','" + dia + "','" + ini + "','" + fin + "','" + codTurno + "')\"><label style='color:#BF1A2D;'>SIN CURSO</label></td>");
							//pw.println("    <td   style='cursor: pointer; vertical-align: middle;'  align='center' width='90' onclick=\"asignarHorarioCurso('"+blo+"','"+dia+"','"+ini+"','"+fin+"','"+codTurno+"')\" ><label style='color:red;' >SIN CURSO</label></td>");
							/*pw.println("    <td class='tooltip'  title='<table>"
                                    + "                                     <tr>"
                                    + "                                         <td>"
                                    + "                                             Click para asignar curso y docente"
                                    + "                                         </td>"
                                    + "                                     </tr>"
                                    + "                                 </table>'  style='cursor: pointer;'  align='center' width='100' onclick=\"asignarHorarioCurso('"+blo+"','"+dia+"','"+ini+"','"+fin+"','"+codTurno+"')\" ><label style='color:red;' >SIN CURSO</label></td>");*/
						}

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

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

	private void verCruce(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices servicios = new HorarioServices();
		ArrayList<Aula> lista = new ArrayList<Aula>();
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codDocente = request.getParameter("codDocente");
		String codHorario = request.getParameter("codHorario");
		lista = servicios.verCruce(dia, Hini, Hfin, codDocente);
		String nombreDia = "";
		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("<br><center><table><tr><td><b>CRUCE DE HORARIOS</b><br>El docente cuenta con los siguientes cursos asignados el dia <b>" + nombreDia + " </b> :</td></tr><tr>"
			+ "<td>"
			+ "<table  cellpadding=\"0\" cellspacing=\"0\">\n"
			+ "	    <tr>\n"
			+ "               <td height=\"10\"></td>\n"
			+ "           </tr>\n"
			+ "           <tr><td width=\"400\">\n"
			+ "                   <div class=\"datagrid\">\n"
			+ "                           <table border='1'>\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>INICIO</th>\n"
			+ "                                           <th>FIN</th>\n"
			+ "                                           <th>CURSO</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String[] arrayIni = lista.get(i).getHoraInicio().split(":");
			String[] arrayFin = lista.get(i).getHoraFin().split(":");
			pw.println("<tr>");
			pw.println("    <td align='center'>" + cont + "</td>");
			pw.println("    <td align='center'>" + arrayIni[0] + ":" + arrayIni[1] + "</td>");
			pw.println("    <td align='center'>" + arrayFin[0] + ":" + arrayFin[1] + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreCurso() + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreLocal() + "</td>");
			pw.println("</tr>");
			cont++;
		}

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

	}

	private void verHorarioReporte(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codalua = request.getParameter("codalua");
		String nom = request.getParameter("nom");
		String periodo = request.getParameter("periodo");

		BloqueServices servicio = new BloqueServices();
		HorarioServices servicios1 = new HorarioServices();
		Bloque bloque = new Bloque();
		CursoServices servicios2 = new CursoServices();
		DocenteServices servicioDoc = new DocenteServices();
		ArrayList<Bloque> lista = null;
		//String codGruBlo = servicios1.consultarCodigoGrupo(codalua);
		bloque = servicios1.consultarCodigoGrupoTurno(codalua, periodo);
		String codGruBlo = bloque.getCod_gru();
		String codTurno = bloque.getTur_gru();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		lista = servicio.consultarDetalleBloque(codGruBlo);
		int cont = 1;
		int blo = 1;
		if (!codGruBlo.equals("")) {

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           " + nom + " "
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			for (int i = 0; i < lista.size(); i++) {
				String ini = lista.get(i).getHor_ini();
				String fin = lista.get(i).getHor_fin();
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20' align='center'>" + ini + " a " + fin + "</td>"
						+ "    <td height='20' colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>");
					pw.println("    <td height='40' width='120' align='center' style='vertical-align: middle;' >" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>");
					for (int dia = 1; dia <= 6; dia++) {
						String diaAct = "" + dia;
						String bloAct = "" + blo;
						int cant = servicios1.cantidadAsignado(codalua, diaAct, bloAct, periodo);
						if (cant > 0) {
							//pw.println("    <td align='center' ><a href=\"javascript:verDetalleHorario('"+codalua+"','"+blo+"','"+dia+"','"+ini+"','"+fin+"');\" class='regular' ><img src='imagenes/icons/calendar-task.png'/></a></td>");
							Horario horario = new Horario();
							horario = servicios1.consultarDatosAsignados(codalua, diaAct, bloAct, periodo);
							String codCur = horario.getCodidoCurso_HorarioCursoDoc();
							String codDoc = horario.getCodigoDocente_HorarioCursoDoc();
							Docente docente = new Docente();
							docente = servicioDoc.NombreDocente(codDoc);
							String NombreCompleto = docente.getApe_pro() + ", " + docente.getNom_pro();

							Curso curso = new Curso();
							//horario = servicios1.consultarDatosAsignados(codalua, diaAct, bloAct);
							curso = servicios2.NombreCurso(codCur);
							String NombreCurso = curso.getNom_cur();
							String NombrePlana = curso.getNom_pla();
							String NombreArea = curso.getNom_are();
							String color = curso.getColor_plana();
							//pw.println("    <td align='center' style='background-color:#A0F3D6' width='90'>"+NombreCurso+"</td>");
							pw.println("    <td align='left' style='background-color:" + color + "; font-size:10px; vertical-align: middle;' width='150'  ><font color='#040404'><b>Curso: </b>" + NombreCurso + "</font><br><font color='#040404'><b>Docente: </b>" + NombreCompleto + "</font></td>");
						} else {
							//pw.println("    <td align='center' width='90' ><label style='color:#BF1A2D;'>SIN CURSO</label></td>");
							pw.println("    <td id='sinCurso' align='center' width='150' style='vertical-align: middle;'  ><label style='color:red;'  >SIN CURSO</label></td>");
						}

					}

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

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

	private void verHorarioDocente(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codDocente = request.getParameter("codDocente");
		String nombre = request.getParameter("nombre");
		String periodo = request.getParameter("periodo");

		HorarioServices servicios = new HorarioServices();
		ArrayList<Horario> lista = new ArrayList<Horario>();
		lista = servicios.horarioDocente(codDocente, periodo);
		CursoServices servicios2 = new CursoServices();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <b>DOCENTE: </b>" + nombre + " "
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int blo = 1;
		int cont = 1;
		int cantMayor = 0;
		String dia = "";
		String cadenaLun = "";
		String cadenaMar = "";
		String cadenaMier = "";
		String cadenaJue = "";
		String cadenaVier = "";
		String cadenaSab = "";

		for (int i = 0; i < lista.size(); i++) {
			dia = lista.get(i).getDia_HorarioCursoDoc();
			String[] arrayIni = lista.get(i).getHini_HorarioCursoDoc().split(":");
			String[] arrayFin = lista.get(i).getHfin_HorarioCursoDoc().split(":");

			String Hora = arrayIni[0] + ":" + arrayIni[1] + " a " + arrayFin[0] + ":" + arrayFin[1];

			if (dia.equals("1")) {
				if (cadenaLun.equals("")) {
					cadenaLun += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";
				} else {
					cadenaLun += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";
				}
			} else if (dia.equals("2")) {
				if (cadenaMar.equals("")) {
					cadenaMar += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				} else {
					cadenaMar += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				}
			} else if (dia.equals("3")) {
				if (cadenaMier.equals("")) {
					cadenaMier += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				} else {
					cadenaMier += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				}
			} else if (dia.equals("4")) {
				if (cadenaJue.equals("")) {
					cadenaJue += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				} else {
					cadenaJue += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				}
			} else if (dia.equals("5")) {
				if (cadenaVier.equals("")) {
					cadenaVier += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				} else {
					cadenaVier += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				}
			} else if (dia.equals("6")) {
				if (cadenaSab.equals("")) {
					cadenaSab += "<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				} else {
					cadenaSab += "#<b>" + lista.get(i).getNombreCurso() + "</b><br><font color='black'><b>Sede: </b>" + lista.get(i).getNombreSede() + "<br> <b>Hora: </b>" + Hora + "</font>";;
				}
			}
		}

		//ARRAY
		String[] arrayLun = cadenaLun.split("#");
		String[] arrayMar = cadenaMar.split("#");
		String[] arrayMier = cadenaMier.split("#");
		String[] arrayJue = cadenaJue.split("#");
		String[] arrayVier = cadenaVier.split("#");
		String[] arraySab = cadenaSab.split("#");

		int[] cantDias = {arrayLun.length, arrayMar.length, arrayMier.length, arrayJue.length, arrayVier.length, arraySab.length};
		for (int i = 0; i < cantDias.length; i++) {
			if (cantDias[i] > cantMayor) {
				cantMayor = cantDias[i];
			}
		}

		for (int i = 0; i < cantMayor; i++) {
			pw.println("<tr >");
			pw.println("<td height='40' width='8' align='center' style='vertical-align:middle;'>" + cont + "°</td>");
			for (int d = 1; d <= 6; d++) {
				if (d == 1) {
					if (arrayLun.length > 0) {
						if (arrayLun.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayLun[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 2) {
					if (arrayMar.length > 0) {
						if (arrayMar.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayMar[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 3) {
					if (arrayMier.length > 0) {
						if (arrayMier.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayMier[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 4) {
					if (arrayJue.length > 0) {
						if (arrayJue.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayJue[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 5) {
					if (arrayVier.length > 0) {
						if (arrayVier.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayVier[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 6) {
					if (arraySab.length > 0) {
						if (arraySab.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arraySab[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				}
			}
			cont++;
			pw.println("</tr>");
		}

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

		pw.println("         </div>\n"
			+ "     </div>"
			+ " </div>");
	}

	private void consultarExistenciaHorarioRegistrado(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codAula = request.getParameter("codAula");
		HorarioServices servicios = new HorarioServices();
		int dato = servicios.consultarExistenciaHorarioRegistrado(codAula);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

	private void armarEditarBloqueAsignado(HttpServletRequest request, HttpServletResponse response) throws IOException {
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		ArrayList<Bloque> listaGrupo = null;
		Bloque bloque = new Bloque();
		String codAula = request.getParameter("codAula");
		String accion = request.getParameter("accion");
		bloque = servicio.consultarDatosGrupoBloque(codAula);
		lista = servicio.cargarBloque();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		pw.println("<div  class='col-sm-12'></div>");
		pw.println("<div  class='col-sm-3'></div>");

		pw.println("<div  class='col-sm-6'>"
			+ "     <label>Bloque<span style='color:red;'>*</span></label><br>"
			+ "     <select id='cmbBloque3' class='form-control validate[required]' onChange='cargarGrupo3();limpiar();'>"
			+ "         <option value=''>Seleccione</option>");
		for (int i = 0; i < lista.size(); i++) {
			if (lista.get(i).getCod_blo() == bloque.getCod_blo()) {
				pw.println("<option value='" + lista.get(i).getCod_blo() + "' selected>" + lista.get(i).getNom_blo() + "</option>");
			} else {
				pw.println("<option value='" + lista.get(i).getCod_blo() + "'>" + lista.get(i).getNom_blo() + "</option>");
			}

		}
		pw.println("            </select><br>"
			+ "     <label>Grupo<span style='color:red;'>*</span></label><br>"
			+ "     <span id='divGrupoSelect3' >");

		String codBlo = "" + bloque.getCod_blo();

		listaGrupo = servicio.BusquedaBloque(codBlo);

		pw.println("        <select id='cmbGrupoBloque3' class='form-control validate[required]'>"
			+ "             <option value=''>Seleccione</option>");
		for (int i = 0; i < listaGrupo.size(); i++) {
			if (listaGrupo.get(i).getCod_gru().equals(bloque.getCod_gru())) {
				pw.println("<option value='" + listaGrupo.get(i).getCod_gru() + "' selected>" + listaGrupo.get(i).getNom_gru() + "</option>");
			} else {
				pw.println("<option value='" + listaGrupo.get(i).getCod_gru() + "'>" + listaGrupo.get(i).getNom_gru() + "</option>");
			}
		}
		pw.println("        </select>"
			+ "     </span> <br>"
			+ "     <center>"
			+ "         <button class=\"btn btn-sm btn-primary\" onclick=\"validar_bloque_grupo2();\" type=\"button\">"
			+ "             <i class=\"ace-icon fa fa-eye icon-on-right bigger-110\"></i>\n"
			+ "             Mostrar Bloque\n"
			+ "         </button>"
			+ "     </center><br>");
		pw.println("</div>");

		pw.println("<div  class='col-sm-3'></div>");

	}

	private void editarGrupoBloqAsignado(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codGruBlo = request.getParameter("codGruBlo");
		String codAula = request.getParameter("codAula");
		BloqueServices servicios = new BloqueServices();
		int dato = servicios.editarGrupoBloqAsignado(codAula, codGruBlo);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

	private void limpiarRegistro(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Turno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String codAula = request.getParameter("codAula");
		String codDoc = request.getParameter("codDoc");
		String codCur = request.getParameter("codCur");
		HorarioServices servicios = new HorarioServices();

		servicios.limpiarRegistro(codAula, dia, bloq, horaIni, horaFin, Turno, codCur, codDoc);

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

	}

	private void consultarCursos(HttpServletRequest request, HttpServletResponse response) throws IOException {
		int dato = 0;
		HorarioServices servicio = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String Turno = request.getParameter("Turno");
		String codCurso = request.getParameter("codCurso");
		dato = servicio.consultarCursos(codAula, Turno, codCurso);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		if (dato == 0) { //no existe el codigo cursos 
			pw.println("0");
		} else { //existe el codigo
			pw.println("1");
		}

	}

	private void consultarCursosEditar(HttpServletRequest request, HttpServletResponse response) throws IOException {
		/*int dato=0;
        HorarioServices servicio= new HorarioServices();
        String codAula=request.getParameter("codAula");
        String Turno = request.getParameter("Turno");
        String codCurso = request.getParameter("codCurso");
        String bloq = request.getParameter("bloq");
        String dia = request.getParameter("dia");
        dato=servicio.consultarCursos(codAula, Turno, codCurso, bloq, dia);
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter(); 
        
        if(dato==0){ //no existe el codigo cursos en otro dia
        pw.println("0");
        }else{ //existe el codigo
        pw.println("1");
        }*/
		System.out.println("No se usa 'consultarCursosEditar()' line:1220 ");
	}

	private void armarHorarioAulas(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codAulas = request.getParameter("codAulas");
		int cantSelec = Integer.parseInt(request.getParameter("cantSelec"));
		String cantSe = request.getParameter("cantSelec");

		BloqueServices servicioBlo = new BloqueServices();
		int cantBlo = servicioBlo.consultaBloque(cantSe);
		ArrayList<Bloque> lista = null;
		lista = servicioBlo.cargarBloque();

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

		int res = 3;

		if (cantBlo == 0) {
			res = 0;
		} else {
			int cantGru = servicioBlo.consultaGrupo(cantSe);
			if (cantGru == 0) {
				res = 1;
			}
		}

		if (res == 0) {
			pw.println(0);
		} else if (res == 1) {
			pw.println(1);
		} else {
			pw.println("<center >"
				+ " <table border='0' width='300'>"
				+ "     <tr>"
				+ "         <td colspan='3' height='20'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td><b>Bloque: </b> <span style='color:red;'>*</span></td>"
				+ "         <td width='10'></td>"
				+ "         <td>");
			if (cantSelec == 1) {
				pw.println("<select id='bloque' class='form-control validate[required]' onchange='cargarGrupo();'>");
				pw.println("<option value=''>Seleccione</option>");
				for (int i = 0; i < lista.size(); i++) {
					pw.println("<option value='" + lista.get(i).getCod_blo() + "'>" + lista.get(i).getNom_blo() + "</option>");
				}
				pw.println("</select>");
			} else {
				for (int i = 0; i < lista.size(); i++) {
					if (lista.get(i).getCod_blo() == cantSelec) {
						pw.println("<input type='hidden' id='bloque' value='" + lista.get(i).getCod_blo() + "' >");
						pw.println("<label>" + lista.get(i).getNom_blo() + "</label>");
					}
				}
			}
			pw.println("         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' height='15'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td><b>Turno: </b> <span style='color:red;'>*</span></td>"
				+ "         <td width='10'></td>"
				+ "         <td>"
				+ "             <div id='divTurno'>"
				+ "                 <select id='turno' class='form-control validate[required]' onchange=\"primeracargarGrupo();\">"
				+ "                     <option value=''>seleccione</option>"
				+ "                     <option value='1'>MAÑANA</option>"
				+ "                     <option value='2'>TARDE</option>"
				+ "                     <option value='3'>NOCHE</option>"
				+ "                     <option value='4'>MAÑANA - TARDE</option>"
				+ "                     <option value='5'>TARDE - NOCHE</option>"
				+ "                     <option value='6'>TODOS</option>"
				+ "                 </select>"
				+ "             </div>"
				+ "         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' height='15'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td><b>Grupo: </b> <span style='color:red;'>*</span></td>"
				+ "         <td width='10'></td>"
				+ "         <td>"
				+ "             <div id='divGrupo'>"
				+ "                 <select id='grupo' class='form-control validate[required]'>"
				+ "                     <option value=''>seleccione</option>"
				+ "                 </select>"
				+ "             </div>"
				+ "         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' height='15'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' align='center'>"
				+ "             <button class=\"btn btn-sm btn-primary\" onclick=\"validar_mostrarHorario();\" type=\"button\">"
				+ "                 <i class=\"ace-icon fa fa-eye icon-on-right bigger-110\"></i>"
				+ "                  Vista previa"
				+ "             </button>"
				+ "         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3'></td>"
				+ "     </tr>"
				+ "</table>"
				+ "</center>");
		}

	}

	private void armarGrupoHorarioGenerar(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codGruBlo = request.getParameter("codGruBlo");
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		lista = servicio.consultarDetalleBloque(codGruBlo);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cont = 1;
		if (!codGruBlo.equals("")) {

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           Bloque"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			for (int i = 0; i < lista.size(); i++) {
				if (cont % 2 == 0) {
					pw.println("<tr class=\"alt\">"
						+ "    <td height='20' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>"
						+ "    <td height='20' colspan='6' align='center'>R E C E S O</td>"
						+ "</tr>");
				} else {
					pw.println("<tr>"
						+ "    <td height='40' align='center'>" + lista.get(i).getHor_ini() + " a " + lista.get(i).getHor_fin() + "</td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('1');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('2');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('3');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('4');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('5');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "    <td align='center' ><!--<a href=\"javascript:asignarCursoDocente('6');\" class='regular' >--><img src='imagenes/icons/table.png'/><!--</a>--></td>"
						+ "</tr>");
				}
				cont++;
			}

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

	private void sessionArmadoHorario(HttpServletRequest request, HttpServletResponse response) {
		Horario horario = new Horario();
		int cantSelec = Integer.parseInt(request.getParameter("cantSelec"));
		String codAulas = request.getParameter("codAulas");
		int bloque = Integer.parseInt(request.getParameter("bloque"));
		int grupo = Integer.parseInt(request.getParameter("grupo"));

		horario.setArmarHoraio_cantidad(cantSelec);
		horario.setArmarHoraio_codAulas(codAulas);
		horario.setArmarHoraio_codBlo(bloque);
		horario.setArmarHoraio_codGru(grupo);

		HttpSession session_actual = request.getSession(true);
		
		session_actual.setAttribute("armandoHorario", horario);
	}
	

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

		HttpSession session_actual = request.getSession(true);
		PeriodoAcademico periodo = (PeriodoAcademico) session_actual.getAttribute("periodo");

		AulaServices servicios = new AulaServices();
		BloqueServices serviciosBlo = new BloqueServices();
		HorarioServices serviciosHor = new HorarioServices();

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		String codAulas = request.getParameter("codAulas");
		int codBlo = Integer.parseInt(request.getParameter("codBlo"));
		int codGru = Integer.parseInt(request.getParameter("codGru"));
		String codGrupo = request.getParameter("codGru");
		String datoTD = "";
		String[] aulas = codAulas.split("#");

		Bloque datosGrupo = new Bloque();
		datosGrupo = serviciosBlo.consultarTurno(codGrupo);
		String nomTurno = "";
		if (datosGrupo.getTur_gru().equals("1")) {
			nomTurno = "MAÑANA";
		} else if (datosGrupo.getTur_gru().equals("2")) {
			nomTurno = "TARDE";
		} else if (datosGrupo.getTur_gru().equals("3")) {
			nomTurno = "NOCHE";
		} else if (datosGrupo.getTur_gru().equals("4")) {
			nomTurno = "MAÑANA - TARDE";
		} else if (datosGrupo.getTur_gru().equals("5")) {
			nomTurno = "TARDE - NOCHE";
		} else if (datosGrupo.getTur_gru().equals("6")) {
			nomTurno = "TODOS";
		}
		

		String min_ini = "";
		String max_fin = "";
		String horas_ini = "";
		String horas_fin = "";
		int contGenral = 1;
		for (int i = 0; i < cantidad; i++) {
			String nomAula = servicios.consultarAula(aulas[i]);

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> Turno: " + nomTurno + "</td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			ArrayList<Bloque> lista = new ArrayList<Bloque>();
			lista = serviciosBlo.consultarDetalleBloque(codGrupo);
			int cont = 1;
			int posBlo = 1;
			String codPeriodo = "" + periodo.getCodigoPeriodo();
			ArrayList<Horario> ListaHorario = new ArrayList<Horario>();
			ListaHorario = serviciosHor.consultarDatosHorario(aulas[i], codPeriodo);
			//horario = serviciosHor.consultarDatosHorario(codAulas, nomAula, horas_fin);
			for (int j = 0; j < lista.size(); j++) {
				if (i == 0 && j == 0) {
					min_ini = lista.get(j).getHor_ini();
				}
				if (i == 0 && j == lista.size() - 1) {
					max_fin = lista.get(j).getHor_fin();
				}

				if (cont % 2 == 0) {
					pw.println("<tr style='background-color:#B8E0F3;'>"
						+ "     <td align='center'  style='vertical-align: middle;' width='200' >" + lista.get(j).getHor_ini() + " a " + lista.get(j).getHor_fin() + "</td>"
						+ "     <td colspan='6' align='center'> R E C E S O </td>"
						+ " </tr>");
				} else {

					pw.println("<tr>"
						+ "     <td align='center' style='vertical-align: middle;'>" + lista.get(j).getHor_ini() + " a " + lista.get(j).getHor_fin() + "</td>");

					if (ListaHorario.size() == 0) {
						for (int x = 1; x < 7; x++) {
							pw.println("     <td id='sinCurso' width='150' align='center' style='vertical-align: middle; cursor: pointer;' onclick=\"alerta1('" + aulas[i] + "','" + posBlo + "','" + x + "','" + lista.get(j).getHor_ini() + "','" + lista.get(j).getHor_fin() + "','" + datosGrupo.getTur_gru() + "','" + contGenral + "')\"><label style='color:red;'><div id='curso_" + contGenral + "_" + posBlo + "_" + x + "'>SIN CURSO</div></label></td>");
						}
					} else {
						for (int x = 1; x < 7; x++) {
							for (int h = 0; h < ListaHorario.size(); h++) {
								int pos = Integer.parseInt(ListaHorario.get(h).getH_posicionBloque());
								int dia = Integer.parseInt(ListaHorario.get(h).getH_dia());
								String aulaAct = ListaHorario.get(h).getH_codigoAula();
								if (aulas[i].equals(aulaAct) && posBlo == pos && dia == x) {
									datoTD = "<td width='150' align='center'> "
										+ "<div class=\"inline pull-center position-relative dropdown-hover\">\n"
										+ "                                                       <p class=\"btn btn-minier bigger btn-primary \">\n"
										+ "                                                           <i class=\"ace-icon fa fa-cog icon-only bigger-120\"></i>\n"
										+ "                                                           <b>Acción</b>"
										+ "							</p>\n"
										+ "                                                       <ul class=\"dropdown-menu dropdown-only-icon dropdown-yellow dropdown-caret dropdown-close dropdown-menu-right\">\n"
										+ "                                                           <li>\n"
										+ "                                                               <a title=\"Editar\" class=\"tooltip-success\" href=\"javascript:editar('" + aulas[i] + "','" + posBlo + "','" + x + "','" + lista.get(j).getHor_ini() + "','" + lista.get(j).getHor_fin() + "','" + datosGrupo.getTur_gru() + "','" + contGenral + "','" + ListaHorario.get(h).getH_codigoDocente() + "','" + ListaHorario.get(h).getH_codigoCurso() + "','" + ListaHorario.get(h).getH_clase() + "');\" data-original-title=\"Mark&nbsp;as&nbsp;done\" data-rel=\"tooltip\">\n"
										+ "                                                                   <span class=\"green\">\n"
										+ "                                                                       <i class=\"ace-icon fa fa-pencil bigger-110\"></i>\n"
										+ "                                                                       Editar"
										+ "                                                                   </span>\n"
										+ "                                                               </a>\n"
										+ "                                                           </li>\n"
										+ "                                                           <li>\n"
										+ "                                                               <a title=\"Eliminar\" class=\"tooltip-error\" href=\"javascript:eliminar('" + ListaHorario.get(h).getH_codigoHorarioCursoDocente() + "');\" data-original-title=\"Delete\" data-rel=\"tooltip\">\n"
										+ "                                                                   <span class=\"red\">\n"
										+ "                                                                       <i class=\"ace-icon fa fa-trash-o bigger-110\"></i>\n"
										+ "                                                                       Eliminar"
										+ "                                                                   </span>\n"
										+ "                                                               </a>\n"
										+ "                                                           </li>\n"
										+ "                                                       </ul>\n"
										+ "                                                   </div>"
										+ "<br>"
										+ "<b>" + ListaHorario.get(h).getH_nombreCurso() + "</b><br>" + ListaHorario.get(h).getH_apellidosDocente() + ", " + ListaHorario.get(h).getH_nombreDocente() + "</td>";
									break;
								} else {
									datoTD = "<td id='sinCurso' width='150' align='center' style='vertical-align: middle; cursor: pointer;' onclick=\"alerta1('" + aulas[i] + "','" + posBlo + "','" + x + "','" + lista.get(j).getHor_ini() + "','" + lista.get(j).getHor_fin() + "','" + datosGrupo.getTur_gru() + "','" + contGenral + "')\"><label style='color:red;'><div id='curso_" + contGenral + "_" + posBlo + "_" + x + "'>SIN CURSO</div></label></td>";
								}
							}
							pw.println(datoTD);

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

					if (i == 0) {
						if (horas_ini == "") {
							horas_ini = lista.get(j).getHor_ini();
							horas_fin = lista.get(j).getHor_fin();
						} else {
							horas_ini = horas_ini + "#" + lista.get(j).getHor_ini();
							horas_fin = horas_fin + "#" + lista.get(j).getHor_fin();
						}
					}

					posBlo++;
				}
				cont++;
			}

			pw.println("                </tbody>"
				+ "             </table>"
				+ "         </div>"
				+ "     <table width='100%'>"
				+ "         <tr>"
				+ "             <td></td>"
				+ "             <td align='right' valign='middle' height='40'>"
				+ "                   <a title=\"Eliminar\" style=\"text-decoration:none\" href=\"javascript:EliminarTodoAula('" + aulas[i] + "','" + codPeriodo + "');\"  >\n"
				+ "                                           <span class=\"red\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash bigger-130\"></i>\n"
				+ "                                               Eliminar el horario del aula"
				+ "                                           </span>\n"
				+ "                                        </a>\n"
				+ "             </td>"
				+ "             <td width='15'></td>"
				+ "         </tr>"
				+ "     </table>"
				+ "</div>"
				+ "</div><br><br>");
			contGenral++;
		}
		pw.println("   <input type='hidden' id='hora_inicio' value='" + min_ini + "'>"
			+ "<input type='hidden' id='hora_termino' value='" + max_fin + "'>"
			+ "<input type='hidden' id='cadenaHorasIni' value='" + horas_ini + "'>"
			+ "<input type='hidden' id='cadenaHorasFin' value='" + horas_fin + "'>");
	}

	private void cargarGrupoBloqueArmado(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String nombre = request.getParameter("nombre");
		String accion = request.getParameter("accion");
		String codBlo = request.getParameter("codBlo");
		String turno = request.getParameter("turno");
		BloqueServices servicio = new BloqueServices();
		ArrayList<Bloque> lista = null;
		lista = servicio.BusquedaBloque(codBlo, turno);

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

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

	private void armarAsignacionCursoDocGeneral(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		ClaseServices servicio = new ClaseServices();
		ArrayList<Clase> listaClase = null;
		listaClase = servicio.cargarClase();
		String nombreDia = "";
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String Turno = "";
		String horario = "";
		if (CodTurno.equals("1")) {
			Turno = "MAÑANA";
		} else if (CodTurno.equals("2")) {
			Turno = "TARDE";
		} else if (CodTurno.equals("3")) {
			Turno = "NOCHE";
		} else if (CodTurno.equals("4")) {
			Turno = "MAÑANA - TARDE";
		} else if (CodTurno.equals("5")) {
			Turno = "TARDE - NOCHE";
		} else if (CodTurno.equals("6")) {
			Turno = "TODOS";
		}

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}

		pw.println("<table width='100%'>"
			+ "     <tr>"
			+ "         <td align='center'>"
			+ "             <table border='0' cellpadding='0' cellspacing='0'>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "         <tr>"
			+ "                     <td><b>Horario:</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td > " + horario + "</td>"
			+ "          </tr>"
			+ "          <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                     <td><b>Día:</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td >" + nombreDia + "</td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "                 <tr>"
			+ "                     <td><b>Turno: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>" + Turno + "<input id='cmbTurno' type='hidden' value='" + CodTurno + "'></td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Curso: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divCursoCombo'>"
			+ "                             <select class='form-control'>"
			+ "                                 <option>seleccione</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Docente: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divDocenteCombo'>"
			+ "                             <select class='form-control'>"
			+ "                                 <option>seleccione</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Tipo de clase: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divTipClase'>"
			+ "                             <select id='idClase' form-control'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaClase.size(); i++) {
			pw.println("<option value='" + listaClase.get(i).getCodigoClase() + "'>" + listaClase.get(i).getNombreClase() + "</option>");
		}
		pw.println("</select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "             </table>"
			+ "         </td>"
			+ "     </tr>"
			+ "</table>");
	}

	private void consultarCursosGeneral(HttpServletRequest request, HttpServletResponse response) throws IOException {
		int dato = 0;
		int datoact = 0;
		HorarioServices servicio = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String Turno = request.getParameter("Turno");
		String codCurso = request.getParameter("codCurso");
		String periodo = request.getParameter("periodo");
		String editar = request.getParameter("editar");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String codAulas = request.getParameter("codAulas");
		String opcion = request.getParameter("opcion");
		String historial = request.getParameter("historial");

		String[] arrayAulas = codAulas.split("#");

		if (editar.equals("1")) {
			dato = servicio.consultarCursos(codAula, Turno, codCurso, bloq, dia, periodo);
		} else {
			if (opcion.equals("1")) {
				for (int i = 0; i < arrayAulas.length; i++) {
					datoact = servicio.consultarCursos(arrayAulas[i], Turno, codCurso, periodo);
					dato = dato + datoact;
					System.out.println("---" + i + "-->>>" + dato);
				}
			} else {
				dato = servicio.consultarCursos(codAula, Turno, codCurso, periodo);
			}
		}

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

		if (dato == 0) { //no existe el codigo cursos 
			pw.println("0");
		} else { //existe el codigo
			if(historial.equals("cambioDia")){
				pw.println("0");
			}else{
					pw.println("1");
			}
		
		}
	}

	private void registrarAsigCurDoceHorarioGeneral(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		HorarioServices servicios = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		String codGru = request.getParameter("codGru");
		int codClase = Integer.parseInt(request.getParameter("codClase"));
		System.out.println("akiiiiiiiiiiiiiiiiiiiiiiiii");
		int dato = 0;//servicios.registrarAsigCurDoceHorario(codAula, dia, bloq, Hini, Hfin, codTurno, codCurso, codDocente,periodo,codGru,codUsuario,codClase);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

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

		ArrayList<Aula> lista = new ArrayList<Aula>();
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
//		String codaula = request.getParameter("codaula");
//		String posicionBloque = request.getParameter("posBloque");
		//traer el hora inicio y fin dependiendo del aula
		
		//String dia, String codAula, String periodo, String posicionbloque
//		JSONObject recibeHorario=servicios.consultarHorarioByAula(dia,codaula,periodo,posicionBloque);
//		String horaInicio=recibeHorario.getString("hor_ini");
//		String horaFin=recibeHorario.getString("hor_fin");
		
//		System.out.println("horaInicio de verCruceIndividual: "+horaInicio);
//		System.out.println("horaFin de verCruceIndividual: "+horaFin);
		
		
		
		
		lista = servicios.verCruceIndividual(dia, Hini, Hfin, codDocente, periodo);
		System.out.println("lista de verCruceIndividual"+lista);
	 
			String nombreDia = "";
		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}
		PrintWriter pw = response.getWriter();
		response.setContentType("text/html");
		
		pw.println("<br><center><table><tr><td><b>CRUCE DE HORARIOS</b><br>El docente cuenta con los siguientes cursos asignados el dia <b>" + nombreDia + " </b> :</td></tr><tr>"
			+ "<td>"
			+ "<table  cellpadding=\"0\" cellspacing=\"0\">\n"
			+ "	    <tr>\n"
			+ "               <td height=\"80\"></td>\n"
			+ "           </tr>\n"
			+ "           <tr><td width=\"400\">");

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\"  >\n"
			+ "Lista de cruces"
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">INICIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">FIN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">CURSO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String[] arrayIni = lista.get(i).getHoraInicio().split(":");
			String[] arrayFin = lista.get(i).getHoraFin().split(":");
			pw.println("<tr>");
			pw.println("    <td align='center'>" + cont + "</td>");
			pw.println("    <td align='center'>" + arrayIni[0] + ":" + arrayIni[1] + "</td>");
			pw.println("    <td align='center'>" + arrayFin[0] + ":" + arrayFin[1] + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreCurso() + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreGrado() + " " + lista.get(i).getNombre() + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreLocal() + "</td>");
			pw.println("</tr>");
			cont++;
		}

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

	private void registrarAsigCurDoceHorarioGeneralMasivo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		HorarioServices servicios = new HorarioServices();
		String cadenaTotal = request.getParameter("cadenaTotal");
		String hora_inicio = request.getParameter("hora_inicio");
		String hora_termino = request.getParameter("hora_termino");
		String dia = request.getParameter("dia");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		String codGru = request.getParameter("codGru");
		int clase = Integer.parseInt(request.getParameter("codClase"));

		int dato = servicios.registrarAsigCurDoceHorarioMasivo(cadenaTotal, hora_inicio, hora_termino, dia, codTurno, codCurso, codDocente, periodo, codGru, codUsuario, clase);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

	private void verCruceMasivo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices servicios = new HorarioServices();
		ArrayList<Aula> lista = new ArrayList<Aula>();
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		lista = servicios.verCruceMasivio(dia, Hini, Hfin, codDocente, periodo);
		String nombreDia = "";
		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("<br><center><table><tr><td><b>CRUCE DE HORARIOS</b><br>El docente cuenta con los siguientes cursos asignados el dia <b>" + nombreDia + " </b> :</td></tr><tr>"
			+ "<td>"
			+ "<table  cellpadding=\"0\" cellspacing=\"0\">\n"
			+ "	    <tr>\n"
			+ "               <td height=\"80\"></td>\n"
			+ "           </tr>\n"
			+ "           <tr><td width=\"400\">");
		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\"  >\n"
			+ "Lista de cruces"
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">INICIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">FIN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">CURSO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String[] arrayIni = lista.get(i).getHoraInicio().split(":");
			String[] arrayFin = lista.get(i).getHoraFin().split(":");
			pw.println("<tr>");
			pw.println("    <td align='center'>" + cont + "</td>");
			pw.println("    <td align='center'>" + arrayIni[0] + ":" + arrayIni[1] + "</td>");
			pw.println("    <td align='center'>" + arrayFin[0] + ":" + arrayFin[1] + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreCurso() + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreGrado() + " " + lista.get(i).getNombre() + "</td>");
			pw.println("    <td align='center'>" + lista.get(i).getNombreLocal() + "</td>");
			pw.println("</tr>");
			cont++;
		}

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

	private void EliminarHorarioCurso(HttpServletRequest request, HttpServletResponse response) {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		String codHorarioCursoDocente = request.getParameter("codHorarioCursoDocente");
		HorarioServices servicios = new HorarioServices();

		servicios.eliminarHorarioCurso(codHorarioCursoDocente, codUsuario);
	}

	private void armarAsignacionCursoDocGeneralEdit(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		String periodo = request.getParameter("periodo");
		String codigoDocente = request.getParameter("codigoDocente");
		int codigoCurso = Integer.parseInt(request.getParameter("codigoCurso"));
		String codcurso = request.getParameter("codigoCurso");
		int clase = Integer.parseInt(request.getParameter("clase"));

		ClaseServices servicioCla = new ClaseServices();
		ArrayList<Clase> listaCla = null;
		listaCla = servicioCla.cargarClase();

		CursoServices servCurso = new CursoServices();
		ArrayList<Curso> listaCurso = null;
		AreaDocenteServices servDocente = new AreaDocenteServices();
		ArrayList<AreaDocente> listaDocente = null;
		listaCurso = servCurso.cargarCurso();
		listaDocente = servDocente.cargarDocentesDisponibles(CodTurno, dia, codcurso, periodo);

		String nombreDia = "";
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String Turno = "";
		String horario = "";
		if (CodTurno.equals("1")) {
			Turno = "MAÑANA";
		} else if (CodTurno.equals("2")) {
			Turno = "TARDE";
		} else if (CodTurno.equals("3")) {
			Turno = "NOCHE";
		}

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}

		pw.println("<table width='100%'>"
			+ "     <tr>"
			+ "         <td align='center'>"
			+ "             <table border='0' cellpadding='0' cellspacing='0'>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "         <tr>"
			+ "                     <td><b>Horario: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td > " + horario + "</td>"
			+ "          </tr>"
			+ "          <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                     <td><b>Día: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td >" + nombreDia + "</td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "                 <tr>"
			+ "                     <td><b>Turno: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>" + Turno + "<input id='cmbTurno' type='hidden' value='" + CodTurno + "'></td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Curso: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divCursoCombo'>"
			+ "                             <select id='cmbCurso' class='form-control' onChange='cargarDocentesDisponibles(" + opcion + "," + bloq + "," + dia + "); recargar();'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaCurso.size(); i++) {
			if (listaCurso.get(i).getCod_cur() == codigoCurso) {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "' selected>" + listaCurso.get(i).getNom_cur() + "</option>");
			} else {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "'>" + listaCurso.get(i).getNom_cur() + "</option>");
			}
		}
		pw.println("                    </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Docente: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divDocenteCombo'>"
			+ "                             <select id='cmbDocDisp' class='form-control'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaDocente.size(); i++) {
			if (listaDocente.get(i).getCodigoDocente().equals(codigoDocente)) {
				pw.println("<option value='" + listaDocente.get(i).getCodigoDocente() + "' selected>" + listaDocente.get(i).getApellidoDocente() + ", " + listaDocente.get(i).getNombreDocente() + "</option>");
			} else {
				pw.println("<option value='" + listaDocente.get(i).getCodigoDocente() + "'>" + listaDocente.get(i).getApellidoDocente() + ", " + listaDocente.get(i).getNombreDocente() + "</option>");
			}
		}

		pw.println("                    </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Tipo de clase: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			
			+ "                     </td>"
			+ "                 </tr>"
			+ "             </table>"
			+ "         </td>"
			+ "     </tr>"
			+ "</table>");
	}

	private void armadoHorarioGeneralVer(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		PeriodoAcademico periodo = (PeriodoAcademico) session_actual.getAttribute("periodo");

		AulaServices servicios = new AulaServices();
		BloqueServices serviciosBlo = new BloqueServices();
		HorarioServices serviciosHor = new HorarioServices();

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		String codAulas = request.getParameter("codAulas");
		int codBlo = Integer.parseInt(request.getParameter("codBlo"));
		int codGru = Integer.parseInt(request.getParameter("codGru"));
		String codGrupo = request.getParameter("codGru");
		String datoTD = "";
		String[] aulas = codAulas.split("#");

		Bloque datosGrupo = new Bloque();
		datosGrupo = serviciosBlo.consultarTurno(codGrupo);
		String nomTurno = "";
		if (datosGrupo.getTur_gru().equals("1")) {
			nomTurno = "MAÑANA";
		} else if (datosGrupo.getTur_gru().equals("2")) {
			nomTurno = "TARDE";
		} else if (datosGrupo.getTur_gru().equals("3")) {
			nomTurno = "NOCHE";
		}

		String min_ini = "";
		String max_fin = "";
		String horas_ini = "";
		String horas_fin = "";
		int contGenral = 1;
		for (int i = 0; i < cantidad; i++) {
			String nomAula = servicios.consultarAula(aulas[i]);

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> Turno: " + nomTurno + "</td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");

			ArrayList<Bloque> lista = new ArrayList<Bloque>();
			lista = serviciosBlo.consultarDetalleBloque(codGrupo);
			int cont = 1;
			int posBlo = 1;
			String codPeriodo = "" + periodo.getCodigoPeriodo();
			ArrayList<Horario> ListaHorario = new ArrayList<Horario>();
			ListaHorario = serviciosHor.consultarDatosHorario(aulas[i], codPeriodo);
			//horario = serviciosHor.consultarDatosHorario(codAulas, nomAula, horas_fin);
			for (int j = 0; j < lista.size(); j++) {
				if (i == 0 && j == 0) {
					min_ini = lista.get(j).getHor_ini();
				}
				if (i == 0 && j == lista.size() - 1) {
					max_fin = lista.get(j).getHor_fin();
				}

				if (cont % 2 == 0) {
					pw.println("<tr style='background-color:#B8E0F3;'>"
						+ "     <td align='center'  style='vertical-align: middle;' >" + lista.get(j).getHor_ini() + " a " + lista.get(j).getHor_fin() + "</td>"
						+ "     <td colspan='6' align='center'> R E C E S O </td>"
						+ " </tr>");
				} else {

					pw.println("<tr>"
						+ "     <td align='center' style='vertical-align: middle;'>" + lista.get(j).getHor_ini() + " a " + lista.get(j).getHor_fin() + "</td>");

					if (ListaHorario.size() == 0) {
						for (int x = 1; x < 7; x++) {
							pw.println("     <td id='sinCurso' width='150' align='center' style='vertical-align: middle;' ><label style='color:red;'>SIN CURSO</label></td>");
						}
					} else {
						for (int x = 1; x < 7; x++) {
							for (int h = 0; h < ListaHorario.size(); h++) {
								int pos = Integer.parseInt(ListaHorario.get(h).getH_posicionBloque());
								int dia = Integer.parseInt(ListaHorario.get(h).getH_dia());
								String aulaAct = ListaHorario.get(h).getH_codigoAula();
								if (aulas[i].equals(aulaAct) && posBlo == pos && dia == x) {
									datoTD = "<td width='150' align='center'> "
										+ "<b>" + ListaHorario.get(h).getH_nombreCurso() + "</b><br>" + ListaHorario.get(h).getH_apellidosDocente() + ", " + ListaHorario.get(h).getH_nombreDocente() + "</td>";
									break;
								} else {
									datoTD = "<td id='sinCurso' width='150' align='center' style='vertical-align: middle; ' ><label style='color:red;'>SIN CURSO</label></td>";
								}
							}
							pw.println(datoTD);

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

					if (i == 0) {
						if (horas_ini == "") {
							horas_ini = lista.get(j).getHor_ini();
							horas_fin = lista.get(j).getHor_fin();
						} else {
							horas_ini = horas_ini + "#" + lista.get(j).getHor_ini();
							horas_fin = horas_fin + "#" + lista.get(j).getHor_fin();
						}
					}

					posBlo++;
				}
				cont++;
			}

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

	}

	private void eliminarHorarioTodoAula(HttpServletRequest request, HttpServletResponse response) {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		String codAula = request.getParameter("codAula");
		String periodo = request.getParameter("periodo");
		HorarioServices servicios = new HorarioServices();

		servicios.eliminarHorarioTodoAula(codAula, periodo, codUsuario);
	}

	private void armarHistorial(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String periodo = request.getParameter("periodo");
		String aula = request.getParameter("aula");
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		HorarioServices servicio = new HorarioServices();
		ArrayList<Horario> lista = new ArrayList<Horario>();
		lista = servicio.historial(periodo, aula);

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "         Listado del historial  "
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\" style='font-size:11px;'>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >BLOQUE/GRUPO</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">USUARIO</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DÍA</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">POSICIÓN</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">HORARIO</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CURSO</th>\n"
			+/*
"                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">DOCENTE</th>\n" + 
"                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>\n" + */ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">FECHA<BR>HORA</th>\n"
			+ "                                           <th style='padding:1px;' tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ACCIÓN</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		String nomdia = "";
		String turno = "";
		String tr = "";
		for (int i = 0; i < lista.size(); i++) {

			if (lista.get(i).getH_dia().equals("1")) {
				nomdia = "LUNES";
				tr = "9DDAC8";
			} else if (lista.get(i).getH_dia().equals("2")) {
				nomdia = "MARTES";
				tr = "F4F5AB";
			} else if (lista.get(i).getH_dia().equals("3")) {
				nomdia = "MIÉRCOLES";
				tr = "FC9AA5";
			} else if (lista.get(i).getH_dia().equals("4")) {
				nomdia = "JUEVES";
				tr = "B9CAFF";
			} else if (lista.get(i).getH_dia().equals("5")) {
				nomdia = "VIERNES";
				tr = "FFDDB9";
			} else if (lista.get(i).getH_dia().equals("6")) {
				nomdia = "SÁBADO";
				tr = "CD8BC5";
			}

			String[] horIni = lista.get(i).getH_horarioInicio().split(":");
			String[] horFin = lista.get(i).getH_horarioFinal().split(":");

			if (lista.get(i).getH_codigoTurno().equals("1")) {
				turno = "MAÑANA";
			} else if (lista.get(i).getH_codigoTurno().equals("2")) {
				turno = "TARDE";
			} else if (lista.get(i).getH_codigoTurno().equals("3")) {
				turno = "NOCHE";
			}

			String[] fecha = lista.get(i).getH_fecha().split("-");
			String fechaReg = fecha[2] + "/" + fecha[1] + "/" + fecha[0];
			String[] hora = lista.get(i).getH_hora().split(":");
			String horaReg = "";
			int horaInt = Integer.parseInt(hora[0]);
			int minInt = Integer.parseInt(hora[1]);
			String horaStr = "";
			if (horaInt > 11 && minInt > 0) {
				horaInt = horaInt - 12;
				if (horaInt < 10) {
					horaStr = "0" + horaInt;
				}
				horaReg = horaStr + ":" + hora[1] + " PM";
			} else {
				horaReg = hora[0] + ":" + hora[1] + " AM";
			}

			pw.println("<tr style='background-color:#" + tr + "; font-size:11px;'>"
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + lista.get(i).getH_nombreGrupo() + "</td>"
				+ "     <td style='vertical-align: middle; padding:1px;'>" + lista.get(i).getH_nombreUsuario() + "</td>"
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + nomdia + "</td>"
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + lista.get(i).getH_posicionBloque() + "°</td>"
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + horIni[0] + ":" + horIni[1] + "<BR>" + horFin[0] + ":" + horFin[1] + "</td>"
				+ "     <td style='vertical-align: middle; padding:1px;'>" + lista.get(i).getH_nombreCurso() + "</td>"
				/*   + "     <td style='vertical-align: middle; padding:1px;'>"+lista.get(i).getH_apellidosDocente()+", "+lista.get(i).getH_nombreDocente()+" </td>" 
                    + "     <td style='vertical-align: middle; padding:1px;' align='center'>"+turno+"</td>" */
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + fechaReg + "<BR>" + horaReg + "</td>"
				+ "     <td style='vertical-align: middle; padding:1px;' align='center'>" + lista.get(i).getH_accion() + "</td>"
				+ "</tr>");
		}

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

	}

	private void armarHorarioAulas2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codAulas = request.getParameter("codAulas");
		int cantSelec = 1;
		String cantSe = request.getParameter("cantSelec");

		BloqueServices servicioBlo = new BloqueServices();
		int cantBlo = servicioBlo.consultaBloque(cantSe);
		ArrayList<Bloque> lista = null;
		lista = servicioBlo.cargarBloque();

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

		int res = 3;

		if (cantBlo == 0) {
			res = 0;
		} else {
			int cantGru = servicioBlo.consultaGrupo(cantSe);
			if (cantGru == 0) {
				res = 1;
			}
		}

		if (res == 0) {
			pw.println(0);
		} else if (res == 1) {
			pw.println(1);
		} else {
			pw.println("<center >"
				+ " <table border='0' width='300'>"
				+ "     <tr>"
				+ "         <td colspan='3' height='20'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td><b>Bloque: </b> <span style='color:red;'>*</span></td>"
				+ "         <td width='10'></td>"
				+ "         <td>");
			if (cantSelec == 1) {
				pw.println("<select id='bloque' class='form-control validate[required]' onchange='primeracargarGrupo();'>");
				pw.println("<option value=''>Seleccione</option>");
				for (int i = 0; i < lista.size(); i++) {
					pw.println("<option value='" + lista.get(i).getCod_blo() + "'>" + lista.get(i).getNom_blo() + "</option>");
				}
				pw.println("</select>");
			} else {
				for (int i = 0; i < lista.size(); i++) {
					if (lista.get(i).getCod_blo() == cantSelec) {
						pw.println("<input type='hidden' id='bloque' value='" + lista.get(i).getCod_blo() + "' >");
						pw.println("<label>" + lista.get(i).getNom_blo() + "</label>");
					}
				}
			}
			pw.println("         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' height='15'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td><b>Grupo: </b> <span style='color:red;'>*</span></td>"
				+ "         <td width='10'></td>"
				+ "         <td>"
				+ "             <div id='divGrupo'>"
				+ "                 <select id='grupo' class='form-control validate[required]'>"
				+ "                     <option value=''>seleccione</option>"
				+ "                 </select>"
				+ "             </div>"
				+ "         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' height='15'></td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3' align='center'>"
				+ "             <button class=\"btn btn-sm btn-primary\" onclick=\"validar_mostrarHorario();\" type=\"button\">"
				+ "                 <i class=\"ace-icon fa fa-eye icon-on-right bigger-110\"></i>"
				+ "                  Vista previa"
				+ "             </button>"
				+"           </td>"
			  + "         <td colspan='3' align='center'>"
				//+ "             <button class=\"btn btn-sm btn-primary\" onclick=\"abrirPlanAcademico();\" type=\"button\">"
				//+ "                 <i class=\"ace-icon fa fa-graduation icon-on-right bigger-110\"></i>"
				//+ "                  Plan Academico"
				//+ "             </button>"
				+ "         </td>"
				+ "     </tr>"
				+ "     <tr>"
				+ "         <td colspan='3'></td>"
				+ "     </tr>"
				+ "</table>"
				+ "</center>");
		}
	}

	private void cargarGrupoBloqueArmado2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String nombre = request.getParameter("nombre");
		String accion = request.getParameter("accion");
		String codBlo = request.getParameter("codBlo");
		BloqueServices servicio = new BloqueServices();
		ArrayList<Grupo> lista = null;
		lista = servicio.BusquedaListaBloqueHorario(codBlo);

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

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

	private void armarGrupoHorarioGenerar2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codigo = request.getParameter("codGruBlo");
		BloqueServices servicios = new BloqueServices();
		Grupo grupo = new Grupo();
		grupo = servicios.BusquedaDatosBloqueHorario(codigo);

		String cadena = grupo.getCadena();
		String nombreGru = grupo.getNombreGrupo();

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

		String[] array1 = cadena.split("!");
		int x = 0;

		for (int i = 0; i < array1.length; i++) {
			String[] array2 = array1[i].split("#");
			if (x < Integer.parseInt(array2[0])) {
				x = Integer.parseInt(array2[0]);
			}

		}
		
		if(codigo.equals("56")){
			
					pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n HORARIO " + nombreGru + " "
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >LUNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
//			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		String HorIni = "";
		String HorFin = "";
		int contenido = 0;
		for (int t = 1; t <= x; t++) {
			pw.println("<tr>");
			for (int i = 1; i <= 5; i++) {
				for (int j = 0; j < array1.length; j++) {
					String[] array2 = array1[j].split("#");
					if (array2[2].equals("" + i)) {
						if (Integer.parseInt(array2[0]) >= t) {
							String[] horas = array2[3].split("¡");
							int h = t - 1;
							String[] hora = horas[h].split("-");
							HorIni = hora[0];
							HorFin = hora[1];
							contenido = 1;
						}
					}
				}

				if (contenido == 1) {
					pw.println("<td align='center' style=' vertical-align:middle;'>" + HorIni + "<br>" + HorFin + "</td>");
				} else {
					pw.println("<td align='center' style='color:red; background-color:#F5A9A9; vertical-align:middle;'>SIN HORARIO</td>");
				}

				contenido = 0;

			}
			pw.println("</tr>");
		}
			
		}else{
		  		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n HORARIO " + nombreGru + " "
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >LUNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		String HorIni = "";
		String HorFin = "";
		int contenido = 0;
		for (int t = 1; t <= x; t++) {
			pw.println("<tr>");
			for (int i = 1; i <= 6; i++) {
				for (int j = 0; j < array1.length; j++) {
					String[] array2 = array1[j].split("#");
					if (array2[2].equals("" + i)) {
						if (Integer.parseInt(array2[0]) >= t) {
							String[] horas = array2[3].split("¡");
							int h = t - 1;
							String[] hora = horas[h].split("-");
							HorIni = hora[0];
							HorFin = hora[1];
							contenido = 1;
						}
					}
				}

				if (contenido == 1) {
					pw.println("<td align='center' style=' vertical-align:middle;'>" + HorIni + "<br>" + HorFin + "</td>");
				} else {
					pw.println("<td align='center' style='color:red; background-color:#F5A9A9; vertical-align:middle;'>SIN HORARIO</td>");
				}

				contenido = 0;

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



		pw.println("</table><br>"
			+ "<br>"
			+ "<input type='hidden' id='codBloqMax'value='" + x + "'>"
			+ "<input type='hidden' id='cadenaGrupo'value='" + cadena + "'>"
			+ "");

	}

	private void sessionArmadoHorario2(HttpServletRequest request, HttpServletResponse response) {
		Horario horario = new Horario();
		int cantSelec = Integer.parseInt(request.getParameter("cantSelec"));
		String codAulas = request.getParameter("codAulas");
		String cadena = request.getParameter("cadena");
		String codigo = request.getParameter("codigo");
		String cadenaAulas = request.getParameter("cadenaAulas");

		horario.setArmarHoraio_cantidad(cantSelec);
		horario.setArmarHoraio_codAulas(codAulas);
		horario.setArmarHoraio_cadena(cadena);
		horario.setArmarHoraio_codigo(codigo);
		horario.setArmarHoraio_cadenaAulas(cadenaAulas);

		HttpSession session_actual = request.getSession(true);
		session_actual.setAttribute("armandoHorario", horario);
	}

	private void armadoHorarioGeneral2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		PeriodoAcademico periodo = (PeriodoAcademico) session_actual.getAttribute("periodo");
		int codPeriodo = periodo.getCodigoPeriodo();
		
		AulaServices servicios = new AulaServices();
		BloqueServices serviciosBlo = new BloqueServices();
		HorarioServices serviciosHor = new HorarioServices();
                SedeServices sedeServices = new SedeServices();
                

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		String codAulas = request.getParameter("codAulas");
		String codigo = request.getParameter("codigo");
		
		String cadena = request.getParameter("cadena");
		String cadenaAulasGrabada = request.getParameter("cadenaAulas");
		String datoTD = "";
		String[] aulas = codAulas.split("#");
		int codigonuevo=6;
		if(codigo.equals("56")){
		  codigonuevo=5;
		}
		

		//REGISTRAR GRUPO AULAS
		String cadenaAulas = "";
		if (cadenaAulasGrabada.equals("")) {
			cadenaAulas = codAulas.replace("#", ",");
		} else {
			cadenaAulas = cadenaAulasGrabada;
		}

		System.out.println("cadenaAulas>>>>>> " + cadenaAulas);
                //obtener el nombre de la sede de las aulas
                  int codigoSede = sedeServices.obtenerCodigoSede(cadenaAulas);
                
		int codigoGrupoAulas = serviciosHor.registrarGrupoAula(codPeriodo, cadenaAulas, aulas.length, codigo);
                System.out.println("codigoGrupoAulas>>>>>> " + codigoGrupoAulas);
		//REGISTRAR GRUPO AULAS

		// GUARDAR MAXIMOS Y MINIMOS HORARIOS POR DIA
		// GUARDAR CADENA DE HORARIOS INICIALES Y FINALES POR DIA
		String min_ini_1 = "";
		String min_ini_2 = "";
		String min_ini_3 = "";
		String min_ini_4 = "";
		String min_ini_5 = "";
		String min_ini_6 = "";
		String max_fin_1 = "";
		String max_fin_2 = "";
		String max_fin_3 = "";
		String max_fin_4 = "";
		String max_fin_5 = "";
		String max_fin_6 = "";
		String horas_ini_1 = "";
		String horas_ini_2 = "";
		String horas_ini_3 = "";
		String horas_ini_4 = "";
		String horas_ini_5 = "";
		String horas_ini_6 = "";
		String horas_fin_1 = "";
		String horas_fin_2 = "";
		String horas_fin_3 = "";
		String horas_fin_4 = "";
		String horas_fin_5 = "";
		String horas_fin_6 = "";
		int contGenral = 1;

		// ---- CADENA -------------------------//
		String[] array1 = cadena.split("!");
		int x = 0;

		for (int i = 0; i < array1.length; i++) {
			String[] array2 = array1[i].split("#");
			System.out.println("array2 -->"+ Arrays.toString(array2));
			if (x < Integer.parseInt(array2[0])) {
				  x = Integer.parseInt(array2[0]);
			}

		}
		// ---- CADENA ------------------------//

		for (int i = 0; i < cantidad; i++) {
			String nomAula = servicios.consultarAula(aulas[i]);

			if(codigonuevo == 5){
					pw.println("<input type='hidden' id='cadenaAulasHorario' value='" + cadenaAulas + "'><div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> </td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >VIERNES</th>\n"
//				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");
			}else{
			  	pw.println("<input type='hidden' id='cadenaAulasHorario' value='" + cadenaAulas + "'><div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> </td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");
			}
		
			
			
			
			String codPeriodo2 = "" + codPeriodo;

			String HorIni = "";
			String HorFin = "";
			int dia1 = 0;
			int dia2 = 0;
			int dia3 = 0;
			int dia4 = 0;
			int dia5 = 0;
			int dia6 = 0;
			int cont_dia1 = 1;
			int cont_dia2 = 1;
			int cont_dia3 = 1;
			int cont_dia4 = 1;
			int cont_dia5 = 1;
			int cont_dia6 = 1;
			int diaPos = 0;
			int diaGen = 0;
			int contenido = 0;
			for (int t = 1; t <= x; t++) {
				pw.println("<tr>");
				String bloqueGrupoDia = "";
				for (int f = 1; f <= codigonuevo; f++) {
					for (int j = 0; j < array1.length; j++) {
						String[] array2 = array1[j].split("#");

						if (array2[2].equals("" + f)) {
							if (Integer.parseInt(array2[0]) >= t) {
								String[] horas = array2[3].split("¡");
								int h = t - 1;
								String[] hora = horas[h].split("-");
								HorIni = hora[0];
								HorFin = hora[1];
								bloqueGrupoDia = array2[0];
								if (f == 1) {
									dia1++;
									diaPos = dia1;
									diaGen = f;
								} else if (f == 2) {
									dia2++;
									diaPos = dia2;
									diaGen = f;
								} else if (f == 3) {
									dia3++;
									diaPos = dia3;
									diaGen = f;
								} else if (f == 4) {
									dia4++;
									diaPos = dia4;
									diaGen = f;
								} else if (f == 5) {
									dia5++;
									diaPos = dia5;
									diaGen = f;
								} else if (f == 6) {
									dia6++;
									diaPos = dia6;
									diaGen = f;
								}
								contenido = 1;
							}
						}
					}
					String dia = "" + f;
					String posicion = "" + diaPos;

					if (contenido == 1) {

						Horario DatosHorario = new Horario();
						Horario obj = new Horario();
						Horario obj2 = new Horario();
						String examen = "";
						String valor="";
						String codigoDocente="";
						String nota_encuesta = "";
						DatosHorario = serviciosHor.consultarDatosHorarioAulaPorPosicionDiaria(aulas[i], codPeriodo2, dia, posicion);
						
					  if(DatosHorario.getCelularDocente() == null){
					          DatosHorario.setCelularDocente("No registrado");
                                           }
						
						if(DatosHorario.getCodigoPlana() == null){
							//System.out.println("No hay plana");
						     obj.setExamen(" No evaluado ");
								
						}else{
                                                    int codigoACambiar = Integer.parseInt(codPeriodo2);
                                                    int resta = codigoACambiar - 1;
                                                    String codigoCambiado=String.valueOf(resta);
                                                    obj = serviciosHor.verDocenteExamenEncuesta(DatosHorario.getH_codigoDocente(), DatosHorario.getCodigoPlana());
                                                    if(obj.getExamen() == null){
                                                            obj.setExamen(" No evaluado ");
                                                    }
						}
												
					   pw.println("<td align='center'  style='width:4%; color:white; background-color:#62A8D1; vertical-align:middle; font-size: 10px; '>" + HorIni + "<br>" + HorFin + "</td>");
					
						if (i == 0) {
							if (dia.equals("1")) {
								if (cont_dia1 == 1) {
									min_ini_1 = HorIni;
									cont_dia1++;
								}
								max_fin_1 = HorFin;
								if (horas_ini_1.equals("")) {
									horas_ini_1 = HorIni;
									horas_fin_1 = HorFin;
								} else {
									horas_ini_1 += "#" + HorIni;
									horas_fin_1 += "#" + HorFin;
								}
							} else if (dia.equals("2")) {
								if (cont_dia2 == 1) {
									min_ini_2 = HorIni;
									cont_dia2++;
								}
								max_fin_2 = HorFin;
								if (horas_ini_2.equals("")) {
									horas_ini_2 = HorIni;
									horas_fin_2 = HorFin;
								} else {
									horas_ini_2 += "#" + HorIni;
									horas_fin_2 += "#" + HorFin;
								}
							} else if (dia.equals("3")) {
								if (cont_dia3 == 1) {
									min_ini_3 = HorIni;
									cont_dia3++;
								}
								max_fin_3 = HorFin;
								if (horas_ini_3.equals("")) {
									horas_ini_3 = HorIni;
									horas_fin_3 = HorFin;
								} else {
									horas_ini_3 += "#" + HorIni;
									horas_fin_3 += "#" + HorFin;
								}
							} else if (dia.equals("4")) {
								if (cont_dia4 == 1) {
									min_ini_4 = HorIni;
									cont_dia4++;
								}
								max_fin_4 = HorFin;
								if (horas_ini_4.equals("")) {
									horas_ini_4 = HorIni;
									horas_fin_4 = HorFin;
								} else {
									horas_ini_4 += "#" + HorIni;
									horas_fin_4 += "#" + HorFin;
								}
							} else if (dia.equals("5")) {
								if (cont_dia5 == 1) {
									min_ini_5 = HorIni;
									cont_dia5++;
								}
								max_fin_5 = HorFin;
								if (horas_ini_5.equals("")) {
									horas_ini_5 = HorIni;
									horas_fin_5 = HorFin;
								} else {
									horas_ini_5 += "#" + HorIni;
									horas_fin_5 += "#" + HorFin;
								}
							} else if (dia.equals("6")) {
								if (cont_dia6 == 1) {
									min_ini_6 = HorIni;
									cont_dia6++;
								}
								max_fin_6 = HorFin;
								if (horas_ini_6.equals("")) {
									horas_ini_6 = HorIni;
									horas_fin_6 = HorFin;
								} else {
									horas_ini_6 += "#" + HorIni;
									horas_fin_6 += "#" + HorFin;
								}
							}
						}
                                                 
						if (DatosHorario.getH_estado() == null) {
							pw.println("<td id='sinCurso' align='center' style='width:12%; vertical-align:middle; cursor: pointer;' onclick=\"alerta1('" + cantidad + "','" + bloqueGrupoDia + "','" + aulas[i] + "','" + diaPos + "'," + diaGen + ",'" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "')\" >"
								+ "     <label style='color: red;'><div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'>SIN CURSO </div></label>"
								+ " </td>");

                                                } else {

							pw.println("<td align='center' style='width:12%; vertical-align:middle;>"
								+ "     <label >"
								+ "         <div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'> "
								+ "<div class=\"inline pull-center position-relative dropdown-hover\">\n"
								+ "                                                       <p id=\"accionHorario\" class=\"btn btn-minier bigger btn-primary \">\n"
								+ "                                                           <i class=\"ace-icon fa fa-cog icon-only bigger-120\"></i>\n"
								+ "                                                           <b>Acción</b>"
								+ "							</p>\n"
								+ "                                                       <ul class=\"dropdown-menu dropdown-only-icon dropdown-yellow dropdown-caret dropdown-close dropdown-menu-right\">\n"
								+ "                                                           <li>\n"
								+ "                                                               <a title=\"Editar\" class=\"tooltip-success\" href=\"javascript:editar('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','" + diaGen + "','" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "','" + DatosHorario.getH_clase() + "','editar' );\" data-original-title=\"Mark&nbsp;as&nbsp;done\" data-rel=\"tooltip\">\n"
								+ "                                                                   <span class=\"green\">\n"
								+ "                                                                       <i class=\"ace-icon fa fa-pencil bigger-110\"></i>\n"
								+ "                                                                       Editar"
								+ "                                                                   </span>\n"
								+ "                                                               </a>\n"
								+ "                                                           </li>\n"
								+ "                                                           <li>\n"
								+ "                                                               <a title=\"Editar\" class=\"tooltip-success\" href=\"javascript:cambioFijo('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','" + diaGen + "','" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "','" + DatosHorario.getH_clase() + "','cambioFijo' );\" data-original-title=\"Mark&nbsp;as&nbsp;done\" data-rel=\"tooltip\">\n"
								+ "                                                                   <span class=\"green\">\n"
								+ "                                                                       <i class=\"ace-icon fa fa-pencil bigger-110\"></i>\n"
								+ "                                                                       Cambio fijo"
								+ "                                                                   </span>\n"
								+ "                                                               </a>\n"
								+ "                                                           </li>\n"
								+ "                                                           <li>\n"
								+ "                                                               <a title=\"Editar\" class=\"tooltip-success\" href=\"javascript:cambioDia('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','" + diaGen + "','" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "','" + DatosHorario.getH_clase() + "','cambioDia' );\" data-original-title=\"Mark&nbsp;as&nbsp;done\" data-rel=\"tooltip\">\n"
								+ "                                                                   <span class=\"green\">\n"
								+ "                                                                       <i class=\"ace-icon fa fa-pencil bigger-110\"></i>\n"
								+ "                                                                       Cambio dia"
								+ "                                                                   </span>\n"
								+ "                                                               </a>\n"
								+ "                                                           </li>\n"
								+ "                                                           <li>\n"
								+ "                                                               <a title=\"Editar\" class=\"tooltip-success\" href=\"javascript:cambioCurso('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','"+codPeriodo2+"','"+diaGen+"','" + DatosHorario.getH_codigoCurso() + "','"+ DatosHorario.getH_codigoDocente()+"');\" data-original-title=\"Mark&nbsp;as&nbsp;done\" data-rel=\"tooltip\">\n"
								+ "                                                                   <span class=\"green\">\n"
								+ "                                                                       <i class=\"ace-icon fa fa-pencil bigger-110\"></i>\n"
								+ "                                                                       Cambio curso"
								+ "                                                                   </span>\n"
								+ "                                                               </a>\n"
								+ "                                                           </li>\n"
								+ "                                                           <li>\n"
								+ "                                                               <a title=\"Eliminar\" class=\"tooltip-error\" href=\"javascript:eliminar('" + DatosHorario.getH_codigoHorarioCursoDocente() + "','" + DatosHorario.getH_codigoAula() + "');\" data-original-title=\"Delete\" data-rel=\"tooltip\">\n"
								+ "                                                                   <span class=\"red\">\n"
								+ "                                                                       <i class=\"ace-icon fa fa-trash-o bigger-110\"></i>\n"
								+ "                                                                       Eliminar"
								+ "                                                                   </span>\n"
								+ "                                                               </a>\n"
								+ "                                                           </li>\n");

							if (cantidad > 1) {
								pw.println(
									"   <li>\n"
									+ "    <a title=\"Eliminar\" class=\"tooltip-error\" href=\"javascript:eliminarMasivo('" + DatosHorario.getH_codigoAula() + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "');\" data-original-title=\"Delete\" data-rel=\"tooltip\">\n"
									+ "     <span class=\"red\">\n"
									+ "     <i class=\"ace-icon fa fa-trash-o bigger-110\"></i>\n"
									+ "     Eliminación secuencial"
									+ "   </span>\n"
									+ " </a>\n"
									+ " </li>\n"
								);
							}
                                                        
                                                        if(DatosHorario.getH_estado().equals("4")){
                                                            pw.println(
								
								"</ul>\n"
								+ "             </div><br><br>"
								+ "             <b style='font-size:15px'>" + DatosHorario.getH_nombreCurso() + "</b> "
								+ "             <br>  ");
                                                            
                                                        }else{
                                                          	pw.println(
								"</ul>\n"
								+ "             </div><br>"
								+ "             <b>" + DatosHorario.getH_nombreCurso() + "</b> "
								+ "             <br>" + DatosHorario.getH_apellidosDocente() + ", " + DatosHorario.getH_nombreDocente()+ " "
								+ "             <br> Prom.ENC :" + obj.getExamen() + " <br> Cel : " + DatosHorario.getCelularDocente());
                                                        }

							 if(DatosHorario.getCodigoReemplazo() != 0){
                                                             
							   pw.println(" <span data-rel=\"tooltip\" ><a id='verCambioDia' href='javascript:historyChangeDay("+diaGen+","+DatosHorario.getH_codigoDocente()+");' "
							   + " title='Ver Historial Cambio Dia' style='margin-left:40px;'><i class=\"ace-icon fa fa-eye icon-on-right bigger-110\" style=\"color:red;\"></i></a></span>");
							 }		
					
						       if(DatosHorario.getH_estado().equals("4")){
                                                       
                                                       }else{
                                                       	  pw.println(
                                                                  
							    "<span data-rel=\"tooltip\" ><a id='verCambioDia' href='javascript:clickHoraActualUpdate("+DatosHorario.getH_codigoAula()+","+posicion+","+codPeriodo2+","+diaGen+");' "
							  + " title='Editar Hora entrada y salida' style='margin-left:40px;'><i class=\"fa fa-clock-o bigger-110\"></i></a></span>");
                                                       
                                                       }

								pw.println(	
							   " </div>"
								+ "     </label>"
								+ " </td>"
							);
							
							
							
							
						}

					} else {
						pw.println("<td align='center' style='color:red; background-color:#F5A9A9; vertical-align:middle; width:16%;' colspan='2' >SIN HORARIO</td>");
					}
					contenido = 0;
				}
				pw.println("</tr>");
			}

			pw.println("                </tbody>"
				+ "             </table>"
				+ "         </div>"
				+ "     <table width='100%'>"
				+ "         <tr>"
				+ "             <td></td>"
				+ "             <td align='right' valign='middle' height='40'>"
				+ "                   <a id=\"tachoEliminar\" title=\"Eliminar\" style=\"text-decoration:none\" href=\"javascript:EliminarTodoAula('" + aulas[i] + "','" + codPeriodo + "');\"  >\n"
				+ "                                           <span class=\"red\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash bigger-130\"></i>\n"
				+ "                                               Eliminar el horario del aula"
				+ "                                           </span>\n"
				+ "                                        </a>\n"
				+ "             </td>"
                                        	+ "             <td align='right' valign='middle' height='40' style=\"width:134px\">"
				+ "                   <a id=\"tachoEliminar\" title=\"Eliminar bloque\" style=\"text-decoration:none\" href=\"javascript:EliminarTodoElAula('" + aulas[i] + "','" + codPeriodo + "');\"  >\n"
				+ "                                           <span class=\"blue\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash bigger-130\"></i>\n"
				+ "                                               Eliminar todo el aula"
				+ "                                           </span>\n"
				+ "                                        </a>\n"
				+ "             </td>"
				+ "             <td width='15'></td>"
				+ "         </tr>"
				+ "     </table>"
				+ "</div>"
				+ "</div><br><br>");
			contGenral++;
		}
                pw.println("<center><td>      <button class=\"btn btn-sm btn-danger\" onclick=\"agregarAula("+codigoSede+");\" type=\"button\" id=\"regresar\">\n" +
"										<i class=\"ace-icon fa fa-cogs icon-on-right bigger-110\"></i>\n" +
"										Agregar Aula\n" +
"									</button></td></center>");

		pw.println("<input type='hidden' id='hora_inicio_1' value='" + min_ini_1 + "'>"
			+ "<input type='hidden' id='hora_termino_1' value='" + max_fin_1 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_1' value='" + horas_ini_1 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_1' value='" + horas_fin_1 + "'>");
		pw.println(" <br>");
		pw.println("   <input type='hidden' id='hora_inicio_2' value='" + min_ini_2 + "'>"
			+ "<input type='hidden' id='hora_termino_2' value='" + max_fin_2 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_2' value='" + horas_ini_2 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_2' value='" + horas_fin_2 + "'>");
		pw.println(" <br>");
		pw.println("   <input type='hidden' id='hora_inicio_3' value='" + min_ini_3 + "'>"
			+ "<input type='hidden' id='hora_termino_3' value='" + max_fin_3 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_3' value='" + horas_ini_3 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_3' value='" + horas_fin_3 + "'>");
		pw.println(" <br>");
		pw.println("   <input type='hidden' id='hora_inicio_4' value='" + min_ini_4 + "'>"
			+ "<input type='hidden' id='hora_termino_4' value='" + max_fin_4 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_4' value='" + horas_ini_4 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_4' value='" + horas_fin_4 + "'>");
		pw.println(" <br>");
		pw.println("   <input type='hidden' id='hora_inicio_5' value='" + min_ini_5 + "'>"
			+ "<input type='hidden' id='hora_termino_5' value='" + max_fin_5 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_5' value='" + horas_ini_5 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_5' value='" + horas_fin_5 + "'>");
		pw.println(" <br>");
		pw.println("   <input type='hidden' id='hora_inicio_6' value='" + min_ini_6 + "'>"
			+ "<input type='hidden' id='hora_termino_6' value='" + max_fin_6 + "'>"
			+ "<input type='hidden' id='cadenaHorasIni_6' value='" + horas_ini_6 + "'>"
			+ "<input type='hidden' id='cadenaHorasFin_6' value='" + horas_fin_6 + "'>");

		pw.println(" <input type='hidden' id='grupoAulas' value='" + codigoGrupoAulas + "'>");
	}

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

		String dia = request.getParameter("dia");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");

		ClaseServices servicio = new ClaseServices();
		ArrayList<Clase> listaClase = null;
		listaClase = servicio.cargarClase();
		String nombreDia = "";
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String Turno = "";
		String horario = "";

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}

		pw.println("<table width='100%'>"
			+ "     <tr>"
			+ "         <td align='center'>"
			+ "             <table border='0' cellpadding='0' cellspacing='0'>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "         <tr>"
			+ "                     <td><b>Horario:</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td > " + horario + "</td>"
			+ "          </tr>"
			+ "          <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                     <td><b>Día:</b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td >" + nombreDia + "</td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "                 <tr>"
			+ "                     <td><b>Curso: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divCursoCombo'>"
			+ "                             <select class='form-control'>"
			+ "                                 <option value=''>[Seleccione]</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Docente: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divDocenteCombo'>"
			+ "                             <select class='form-control'>"
			+ "                                 <option value=''>[Seleccione]</option>"
			+ "                             </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
//			+ "                     <td><b>Tipo de clase: </b><span style='color:red;'>*</span></td>"
//			+ "                     <td width='20'></td>"
//			+ "                     <td>"
//			+ "                     </td>"
			+ "                 </tr>"
			+ "             </table>"
			+ "         </td>"
			+ "     </tr>"
			+ "</table>");
	}

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

		String dia = request.getParameter("dia");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		String periodo = request.getParameter("periodo");

		ClaseServices servicio = new ClaseServices();
		ArrayList<Clase> listaClase = null;
		listaClase = servicio.cargarClase();
		String nombreDia = "";
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		String Turno = "";
		String horario = "";

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}
		pw.println("<div class='row'>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-2'></div>");
		pw.println("<div class='col-sm-8 infobox-container'>");
		pw.println("<div class='infobox infobox-green' >");
		pw.println("<div class='infobox-icon'>");
		pw.println("<i class='ace-icon fa fa-clock-o'></i>");
		pw.println("</div>");
                
		pw.println("<div class='infobox-data'>");
		pw.println("<span class='infobox-data-number'>Horario</span>");
		pw.println("<div class='infobox-content'>" + horario + "</div>");
		pw.println("</div>");
		pw.println("</div>");
                
                
		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'>Día</span>");
		pw.println("<div class='infobox-content'>" + nombreDia + "</div>");
		pw.println("</div>");
		pw.println("</div>");
                
                // examen semanal
                    pw.println("<div class='infobox infobox-blue' style=\"margin-right:75px\">");
                    pw.println("<div class='infobox-data'>");
                    pw.println("<span class='infobox-data-number' style='font-size: 18px;text-align:center;'>Examen Semanal</span>");
                    pw.println("<div class='infobox-content center'><input type='checkbox' id='chkExamenSemanal' onchange='checkExamenSemanal()'/></div>");


                    pw.println("</div>");
                    pw.println("</div>");
                    
                    
                
                //fin examen semanal
                // libre
                       pw.println("<div class='infobox infobox-blue' style=\"margin-right:16px\">");
                    pw.println("<div class='infobox-data'>");
                    pw.println("<span class='infobox-data-number' style='font-size: 18px;text-align:center;'>Libre</span>");
                    pw.println("<div class='infobox-content center'><input type='checkbox' id='chkBloqueLibre' onchange='checkLibre()'/></div>");


                    pw.println("</div>");
                    pw.println("</div>");
                
                
                // fin libre
		pw.println("<div class='col-sm-2'></div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-12' style='height:40px;'><hr></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Curso: </b><span style='color:red;'>*</span>");
                pw.println("<div id='divCursoCombo'>");
                pw.println("<select class='form-control'>");
                pw.println("<option value=''>[Seleccione]</option>");
                pw.println("</select>");
                pw.println("</div>");
		pw.println("</div>");
                        pw.println("<div class='col-sm-2'>");
                        pw.println("<b>Tipo de clase: </b><span style='color:red;'>*</span><br>");
                                pw.println("<div id='divTipClase'>");
                                pw.println("<select id='idClase' form-control'>");
                                pw.println("<option value=''>[Seleccione]</option>");
                                for (int i = 0; i < listaClase.size(); i++) {
                                        if (listaClase.get(i).getCodigoClase() == 1) {
                                                pw.println("<option selected value='" + listaClase.get(i).getCodigoClase() + "'>" + listaClase.get(i).getNombreClase() + "</option>");
                                        }
                                        pw.println("<option value='" + listaClase.get(i).getCodigoClase() + "'>" + listaClase.get(i).getNombreClase() + "</option>");
                                }
                                pw.println("</select>");
                                pw.println("</div>");
                        pw.println("</div>");
		pw.println("<div class='col-sm-3'>");
		pw.println("<b>Filtro por docente: </b>");
		pw.println("<input id='txtApeDocente' class=\"form-control\" style='text-transform:uppercase;' onkeyup=\"doSearch();\" type=\"text\" >\n"+ " ");
		pw.println("</div>");
		
		pw.println("<div class='col-sm-3'>");
		pw.println("<b>Filtro por Zona: </b>");
		pw.println("<input id='txtZona' class=\"form-control\" style='text-transform:uppercase;' onkeyup=\"doSearch2();\" type=\"text\" >\n"
			+ "                    ");
		pw.println("</div>");

		pw.println("<div class='col-sm-12' style='height:20px;'></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div id='divDocenteCombo' >");

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

	}

	private void registrarAsigCurDoceHorarioGeneral2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		HorarioServices servicios = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		String codGru = request.getParameter("codGru");
		String grupoAulas = request.getParameter("grupoAulas");
		String historial = request.getParameter("historial");
		String motivoCambio = request.getParameter("motivoCambio");
		String observacion = request.getParameter("observacion");
		String condicionTrabajador = request.getParameter("condicionTrabajador");
		String horaAviso = request.getParameter("horaAviso");
		String recuperacion = request.getParameter("recuperacion");
		int codClase = Integer.parseInt(request.getParameter("codClase"));
		String fechafin=request.getParameter("fechafin");
		String cadenaTotal=request.getParameter("cadenaTotal");
		String avance=request.getParameter("avance");
		String fechainicio=request.getParameter("fechainicio");
		String fecha_recuperacio=request.getParameter("fecha_recuperacion");
		
		String aula_recuperacion=request.getParameter("aula_recuperacion");
		
		String curso_recuperacion=request.getParameter("curso_recuperacion");
		String docente_recuperacion=request.getParameter("docente_recuperacion");
		String fecha_aviso=request.getParameter("fecha_aviso");
		
		System.out.println("esto es demasiado sadd");
		int dato = servicios.registrarAsigCurDoceHorario(codAula, dia, bloq, Hini, Hfin, codTurno, codCurso, codDocente, periodo, codGru, codUsuario, codClase, grupoAulas, historial, motivoCambio, observacion, condicionTrabajador, horaAviso, recuperacion);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}
	
		private void registrarAsigCurDoceHorarioGeneral2Personalizado(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		HorarioServices servicios = new HorarioServices();
		String codAula = request.getParameter("codAula");
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String Hini = request.getParameter("Hini");
		String Hfin = request.getParameter("Hfin");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		String codGru = request.getParameter("codGru");
		String grupoAulas = request.getParameter("grupoAulas");
		String historial = request.getParameter("historial");
		String motivoCambio = request.getParameter("motivoCambio");
		String observacion = request.getParameter("observacion");
		String condicionTrabajador = request.getParameter("condicionTrabajador");
		String horaAviso = request.getParameter("horaAviso");
		String recuperacion = request.getParameter("recuperacion");
		int codClase = Integer.parseInt(request.getParameter("codClase"));
		String fechafin=request.getParameter("fechafin");
		String cadenaTotal=request.getParameter("cadenaTotal");
		String avance=request.getParameter("avance");
		String fechainicio=request.getParameter("fechainicio");
		String fecha_recuperacio=request.getParameter("fecha_recuperacion");
		
		String aula_recuperacion=request.getParameter("aula_recuperacion");
		
		String curso_recuperacion=request.getParameter("curso_recuperacion");
		String docente_recuperacion=request.getParameter("docente_recuperacion");
		String fecha_aviso=request.getParameter("fecha_aviso");
		String horaInicioRecuperacion=request.getParameter("horaInicioRecuperacion");
		String horaFinRecuperacion=request.getParameter("horaFinRecuperacion");
		
		System.out.println("esto es demasiado sadd");
	        JSONObject recibeHorario=servicios.consultarHorarioByAula(dia,codAula,periodo,bloq);
		String horaInicio=recibeHorario.getString("hor_ini");
		String horaFin=recibeHorario.getString("hor_fin");
                
		
		int dato = servicios.registrarAsigCurDoceHorarioPersonalizado(codAula, dia, bloq, horaInicio, horaFin, codTurno, codCurso, codDocente, periodo, codGru, codUsuario, codClase, grupoAulas, historial, motivoCambio, observacion, condicionTrabajador, horaAviso, recuperacion,fechafin,fechainicio,cadenaTotal,avance,fecha_recuperacio,curso_recuperacion,aula_recuperacion,docente_recuperacion,fecha_aviso,horaInicioRecuperacion,horaFinRecuperacion);
		System.out.println("retorno de registrarAsigCurDoceHorarioPersonalizado: "+dato);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}
	

	private void armarAsignacionCursoDocGeneralEdit2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		String periodo = request.getParameter("periodo");
		String codigoDocente = request.getParameter("codigoDocente");
		int codigoCurso = Integer.parseInt(request.getParameter("codigoCurso"));
		String codcurso = request.getParameter("codigoCurso");
		int clase = Integer.parseInt(request.getParameter("clase"));

		ClaseServices servicioCla = new ClaseServices();
		ArrayList<Clase> listaCla = null;
		listaCla = servicioCla.cargarClase();

		CursoServices servCurso = new CursoServices();
		ArrayList<Curso> listaCurso = null;
		AreaDocenteServices servDocente = new AreaDocenteServices();
		ArrayList<AreaDocente> listaDocente = null;
		DocenteServices servcioDoce = new DocenteServices();
		listaCurso = servCurso.cargarCurso();
                
		listaDocente = servDocente.cargarDocentesDisponibles(CodTurno, dia, codcurso, periodo);

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

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}

		pw.println("<table width='100%'>"
			+ "     <tr>"
			+ "         <td align='center'>"
			+ "             <table border='0' cellpadding='0' cellspacing='0'>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "         <tr>"
			+ "                     <td><b>Horario: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td > " + horario + "</td>"
			+ "          </tr>"
			+ "          <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                     <td><b>Día: </b></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td >" + nombreDia + "</td>"
			+ "          </tr>"
			+ "         <tr>"
			+ "                 <td td height='10' colspan='3'> </td>"
			+ "          </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Curso: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divCursoCombo'>"
			+ "                             <select id='cmbCurso' class='form-control' onChange='cargarDocentesDisponibles(" + opcion + "," + bloq + "," + dia + "); recargar();'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaCurso.size(); i++) {
			if (listaCurso.get(i).getCod_cur() == codigoCurso) {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "' selected>" + listaCurso.get(i).getNom_cur() + "</option>");
			} else {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "'>" + listaCurso.get(i).getNom_cur() + "</option>");
			}
		}
		pw.println("                    </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Docente: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divDocenteCombo'>"
			+ "                             <select id='cmbDocDisp' class='form-control'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaDocente.size(); i++) {
			if (listaDocente.get(i).getCodigoDocente().equals(codigoDocente)) {
				pw.println("<option value='" + listaDocente.get(i).getCodigoDocente() + "' selected>" + listaDocente.get(i).getApellidoDocente() + ", " + listaDocente.get(i).getNombreDocente() + "</option>");
			} else {
				pw.println("<option value='" + listaDocente.get(i).getCodigoDocente() + "'>" + listaDocente.get(i).getApellidoDocente() + ", " + listaDocente.get(i).getNombreDocente() + "</option>");
			}
		}

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

			listaDocentePrimaria = servcioDoce.cargarDocentePrimaria(codigoCursoP);
			codigoDocente = codigoDocente.replace("P", "");
			for (int i = 0; i < listaDocentePrimaria.size(); i++) {
				if (listaDocentePrimaria.get(i).getCodigoDocentePrimaria().equals(codigoDocente)) {
					pw.println("<option value='P" + listaDocentePrimaria.get(i).getCodigoDocentePrimaria() + "' selected>" + listaDocentePrimaria.get(i).getApellidosDocentePrimaria() + ", " + listaDocentePrimaria.get(i).getNombreDocentePrimaria() + "</option>");
				} else {
					pw.println("<option value='P" + listaDocentePrimaria.get(i).getCodigoDocentePrimaria() + "'>" + listaDocentePrimaria.get(i).getApellidosDocentePrimaria() + ", " + listaDocentePrimaria.get(i).getNombreDocentePrimaria() + "</option>");
				}
			}

		}

		pw.println("                    </select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "                 <tr><td height='10' colspan='3'></td></tr>"
			+ "                 <tr>"
			+ "                     <td><b>Tipo de clase: </b><span style='color:red;'>*</span></td>"
			+ "                     <td width='20'></td>"
			+ "                     <td>"
			+ "                         <div id='divTipClase'>"
			+ "                             <select id='idClase'  form-control'>"
			+ "                                 <option>seleccione</option>");
		for (int i = 0; i < listaCla.size(); i++) {
			if (listaCla.get(i).getCodigoClase() == clase) {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "' selected>" + listaCla.get(i).getNombreClase() + "</option>");
			} else {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "'>" + listaCla.get(i).getNombreClase() + "</option>");
			}
		}
		pw.println("</select>"
			+ "                         </div>"
			+ "                     </td>"
			+ "                 </tr>"
			+ "             </table>"
			+ "         </td>"
			+ "     </tr>"
			+ "</table>");
	}

	private void armarAsignacionCursoDocGeneralEdit3(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		String periodo = request.getParameter("periodo");
		String codigoDocente = request.getParameter("codigoDocente");
		int codigoCurso = Integer.parseInt(request.getParameter("codigoCurso"));
		String codcurso = request.getParameter("codigoCurso");
		int clase = Integer.parseInt(request.getParameter("clase"));

		ClaseServices servicioCla = new ClaseServices();
		ArrayList<Clase> listaCla = null;
		listaCla = servicioCla.cargarClase();

		CursoServices servCurso = new CursoServices();
		ArrayList<Curso> listaCurso = null;
		AreaDocenteServices servDocente = new AreaDocenteServices();
		ArrayList<AreaDocente> listaDocente = null;
		DocenteServices servcioDoce = new DocenteServices();
		listaCurso = servCurso.cargarCurso();
		listaDocente = servDocente.cargarDocentesDisponibles(CodTurno, dia, codcurso, periodo);

		ArrayList<Docente> listaFiltro = null;
		listaFiltro = servcioDoce.filtroDocentesPrimSec(periodo);

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

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}
		pw.println("<div class='row'>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-2'></div>");
		pw.println("<div class='col-sm-8 infobox-container'>");
		pw.println("<div class='infobox infobox-green' >");
		pw.println("<div class='infobox-icon'>");
		pw.println("<i class='ace-icon fa fa-clock-o'></i>");
		pw.println("</div>");
		pw.println("<div class='infobox-data'>");
		pw.println("<span class='infobox-data-number'>Horario</span>");
		pw.println("<div class='infobox-content'>" + horario + "</div>");
		pw.println("</div>");
		pw.println("</div>");
		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'>Día</span>");
		pw.println("<div class='infobox-content'>" + nombreDia + "</div>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-2'></div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-12' style='height:40px;'><hr></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Curso: </b><span style='color:red;'>*</span>");
		pw.println("<div id='divCursoCombo'>");
		pw.println("<select id='cmbCurso' class='form-control' onChange='cargarDocentesDisponibles(" + opcion + "," + bloq + "," + dia + "); recargar();'>");
		pw.println("<option>[Seleccione]</option>");
		for (int i = 0; i < listaCurso.size(); i++) {
			if (listaCurso.get(i).getCod_cur() == codigoCurso) {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "' selected>" + listaCurso.get(i).getNom_cur() + "</option>");
			} else {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "'>" + listaCurso.get(i).getNom_cur() + "</option>");
			}
		}
		pw.println("</select>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Tipo de clase: </b><span style='color:red;'>*</span><br>");
		pw.println("<div id='divTipClase'>");
		pw.println("<select id='idClase'  form-control'>");
		pw.println("<option value=''>[Seleccione]</option>");
		for (int i = 0; i < listaCla.size(); i++) {
			if (listaCla.get(i).getCodigoClase() == clase) {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "' selected>" + listaCla.get(i).getNombreClase() + "</option>");
			} else {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "'>" + listaCla.get(i).getNombreClase() + "</option>");
			}
		}
		pw.println("</select>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Filtro por docente: </b>");
		pw.println("<input id='txtApeDocente' class=\"form-control\" style='text-transform:uppercase;' onkeyup=\"doSearch();\" type=\"text\" >\n");
		pw.println("</div>");
		pw.println("<div class='col-sm-12' style='height:20px;'></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div id='divDocenteCombo'>");
		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: 200px;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 < listaFiltro.size(); i++) {
			int codigoTipoDocente = listaFiltro.get(i).getCod_tip();
			String codDocente = listaFiltro.get(i).getCodigoDocente();
			if (codigoTipoDocente == 1) {
				color = "style=''";
			} else { //profesores nuevos
				if (cont % 2 == 0) {
					color = "style='background-color:#FFF9C0;'";
				} else {
					color = "style='background-color:#FFFCE0;'";
				}
			}
			if (codDocente.equals(codigoDocente)) {
				color = "style='background-color:#FFB695;'";
			}

			pw.println("<tr " + color + ">");

			String apeDocente = listaFiltro.get(i).getApe_pro();
			String nomDocente = listaFiltro.get(i).getNom_pro();
			String nombreCompleto = apeDocente.replace("Ã‘", "Ñ") + ", " + nomDocente.replace("Ã‘", "Ñ");
			String zona = listaFiltro.get(i).getZona();
			String informe = listaFiltro.get(i).getRespuestaInforme();
			String promedio = listaFiltro.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>");
			if (codDocente.equals(codigoDocente)) {

				pw.println("<input name='checkbox" + cont + "' checked  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
			
                        } else {
                            
				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='" + codDocente + "'>");
			pw.println("<input type='hidden' id='datos2_" + cont + "' value='" + cont + "#" + nombreCompleto + "'>");
			pw.println("</td>");
			pw.println("</tr>");
			cont++;
		}
		pw.println("</tbody>");
		pw.println("</table>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("</div><input type='hidden' id='cantidad' value='" + listaFiltro.size() + "'>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("</div>");

	}

	private void registrarAsigCurDoceHorarioGeneralMasivo2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		HorarioServices servicios = new HorarioServices();
		String cadenaTotal = request.getParameter("cadenaTotal");
		String hora_inicio = request.getParameter("hora_inicio");
		String hora_termino = request.getParameter("hora_termino");
		String dia = request.getParameter("dia");
		String codTurno = request.getParameter("codTurno");
		String codCurso = request.getParameter("codCurso");
		String codDocente = request.getParameter("codDocente");
		String periodo = request.getParameter("periodo");
		String codGru = request.getParameter("codGru");
		String grupoAulas = request.getParameter("grupoAulas");
		String fecha_inicio = request.getParameter("fecha_inicio");
		System.out.println("FECHA INICIO --->>>>"+fecha_inicio);
		int clase = Integer.parseInt(request.getParameter("codClase"));

		int dato = servicios.registrarAsigCurDoceHorarioMasivo2(cadenaTotal, hora_inicio, hora_termino, dia, codTurno, codCurso, codDocente, periodo, codGru, codUsuario, clase, grupoAulas);
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println(dato);
	}

	private void armadoHorarioGeneral2Ver(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HttpSession session_actual = request.getSession(true);
		PeriodoAcademico periodo = (PeriodoAcademico) session_actual.getAttribute("periodo");
		int codPeriodo = periodo.getCodigoPeriodo();

		AulaServices servicios = new AulaServices();
		BloqueServices serviciosBlo = new BloqueServices();
		HorarioServices serviciosHor = new HorarioServices();

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		String codAulas = request.getParameter("codAulas");
		String codigo = request.getParameter("codigo"); // codigo grupo 
		int codigonuevo=6;
		if(codigo.equals("56")){
			codigonuevo=5;
		}

		Horario horarioCadenaGrupo = new Horario();
		horarioCadenaGrupo = serviciosHor.consultarCadenaGH(codigo);

		String cadena = horarioCadenaGrupo.getCadena();
		int maxGru = horarioCadenaGrupo.getMaxGrupo();

		String datoTD = "";
		String[] aulas = codAulas.split("#");

		//REGISTRAR GRUPO AULAS
		String cadenaAulas = codAulas.replace("#", ",");

		// GUARDAR MAXIMOS Y MINIMOS HORARIOS POR DIA
		// GUARDAR CADENA DE HORARIOS INICIALES Y FINALES POR DIA
		String min_ini_1 = "";
		String min_ini_2 = "";
		String min_ini_3 = "";
		String min_ini_4 = "";
		String min_ini_5 = "";
		String min_ini_6 = "";
		String max_fin_1 = "";
		String max_fin_2 = "";
		String max_fin_3 = "";
		String max_fin_4 = "";
		String max_fin_5 = "";
		String max_fin_6 = "";
		String horas_ini_1 = "";
		String horas_ini_2 = "";
		String horas_ini_3 = "";
		String horas_ini_4 = "";
		String horas_ini_5 = "";
		String horas_ini_6 = "";
		String horas_fin_1 = "";
		String horas_fin_2 = "";
		String horas_fin_3 = "";
		String horas_fin_4 = "";
		String horas_fin_5 = "";
		String horas_fin_6 = "";
		int contGenral = 1;

		// ---- CADENA -------------------------//
		String[] array1 = cadena.split("!");
		int x = 0;

		for (int i = 0; i < array1.length; i++) {
			String[] array2 = array1[i].split("#");
			if (x < Integer.parseInt(array2[0])) {
				x = Integer.parseInt(array2[0]);
			}

		}
		// ---- CADENA ------------------------//

		for (int i = 0; i < cantidad; i++) {
			String nomAula = servicios.consultarAula(aulas[i]);
       if(codigonuevo == 5){
				 			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> </td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >VIERNES</th>\n"
//				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");
			 }else{
			   			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><span class='badge badge-warning'>" + contGenral + "</span> &nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                       <i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i> </td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");
			 }

			
			
			
			
			String codPeriodo2 = "" + codPeriodo;

			String HorIni = "";
			String HorFin = "";
			int dia1 = 0;
			int dia2 = 0;
			int dia3 = 0;
			int dia4 = 0;
			int dia5 = 0;
			int dia6 = 0;
			int cont_dia1 = 1;
			int cont_dia2 = 1;
			int cont_dia3 = 1;
			int cont_dia4 = 1;
			int cont_dia5 = 1;
			int cont_dia6 = 1;
			int diaPos = 0;
			int diaGen = 0;
			int contenido = 0;
			for (int t = 1; t <= x; t++) {
				pw.println("<tr>");
				String bloqueGrupoDia = "";
				for (int f = 1; f <= codigonuevo; f++) {
					for (int j = 0; j < array1.length; j++) {
						String[] array2 = array1[j].split("#");

						if (array2[2].equals("" + f)) {
							if (Integer.parseInt(array2[0]) >= t) {
								String[] horas = array2[3].split("¡");
								int h = t - 1;
								String[] hora = horas[h].split("-");
								HorIni = hora[0];
								HorFin = hora[1];
								bloqueGrupoDia = array2[0];
								if (f == 1) {
									dia1++;
									diaPos = dia1;
									diaGen = f;
								} else if (f == 2) {
									dia2++;
									diaPos = dia2;
									diaGen = f;
								} else if (f == 3) {
									dia3++;
									diaPos = dia3;
									diaGen = f;
								} else if (f == 4) {
									dia4++;
									diaPos = dia4;
									diaGen = f;
								} else if (f == 5) {
									dia5++;
									diaPos = dia5;
									diaGen = f;
								} else if (f == 6) {
									dia6++;
									diaPos = dia6;
									diaGen = f;
								}
								contenido = 1;
							}
						}
					}
					String dia = "" + f;
					String posicion = "" + diaPos;

					if (contenido == 1) {

						Horario DatosHorario = new Horario();
						DatosHorario = serviciosHor.consultarDatosHorarioAulaPorPosicionDiaria(aulas[i], codPeriodo2, dia, posicion);
						// TRAER SU NO DE ENCUESTA Y NOTA DE EXAMEN
						pw.println("<td align='center' style='width:4%; color:white; background-color:#62A8D1; vertical-align:middle; font-size: 10px; '>" + HorIni + "<br>" + HorFin + "</td>");

						if (i == 0) {
							if (dia.equals("1")) {
								if (cont_dia1 == 1) {
									min_ini_1 = HorIni;
									cont_dia1++;
								}
								max_fin_1 = HorFin;
								if (horas_ini_1.equals("")) {
									horas_ini_1 = HorIni;
									horas_fin_1 = HorFin;
								} else {
									horas_ini_1 += "#" + HorIni;
									horas_fin_1 += "#" + HorFin;
								}
							} else if (dia.equals("2")) {
								if (cont_dia2 == 1) {
									min_ini_2 = HorIni;
									cont_dia2++;
								}
								max_fin_2 = HorFin;
								if (horas_ini_2.equals("")) {
									horas_ini_2 = HorIni;
									horas_fin_2 = HorFin;
								} else {
									horas_ini_2 += "#" + HorIni;
									horas_fin_2 += "#" + HorFin;
								}
							} else if (dia.equals("3")) {
								if (cont_dia3 == 1) {
									min_ini_3 = HorIni;
									cont_dia3++;
								}
								max_fin_3 = HorFin;
								if (horas_ini_3.equals("")) {
									horas_ini_3 = HorIni;
									horas_fin_3 = HorFin;
								} else {
									horas_ini_3 += "#" + HorIni;
									horas_fin_3 += "#" + HorFin;
								}
							} else if (dia.equals("4")) {
								if (cont_dia4 == 1) {
									min_ini_4 = HorIni;
									cont_dia4++;
								}
								max_fin_4 = HorFin;
								if (horas_ini_4.equals("")) {
									horas_ini_4 = HorIni;
									horas_fin_4 = HorFin;
								} else {
									horas_ini_4 += "#" + HorIni;
									horas_fin_4 += "#" + HorFin;
								}
							} else if (dia.equals("5")) {
								if (cont_dia5 == 1) {
									min_ini_5 = HorIni;
									cont_dia5++;
								}
								max_fin_5 = HorFin;
								if (horas_ini_5.equals("")) {
									horas_ini_5 = HorIni;
									horas_fin_5 = HorFin;
								} else {
									horas_ini_5 += "#" + HorIni;
									horas_fin_5 += "#" + HorFin;
								}
							} else if (dia.equals("6")) {
								if (cont_dia6 == 1) {
									min_ini_6 = HorIni;
									cont_dia6++;
								}
								max_fin_6 = HorFin;
								if (horas_ini_6.equals("")) {
									horas_ini_6 = HorIni;
									horas_fin_6 = HorFin;
								} else {
									horas_ini_6 += "#" + HorIni;
									horas_fin_6 += "#" + HorFin;
								}
							}
						}

						if (DatosHorario.getH_estado() == null) {
							pw.println("<td id='sinCurso' align='center' style='width:12%; vertical-align:middle; cursor: pointer;' onclick=\"alerta1('" + cantidad + "','" + bloqueGrupoDia + "','" + aulas[i] + "','" + diaPos + "'," + diaGen + ",'" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "')\" >"
								+ "     <label style='color: red;'><div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'>SIN CURSO </div></label>"
								+ " </td>");

						} else {
							pw.println("<td align='center' style='width:12%; vertical-align:middle; cursor: pointer;' onclick=\"editar('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','" + diaGen + "','" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "','" + DatosHorario.getH_clase() + "' )\" >"
								+ "     <label >"
								+ "         <div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'> "
								+ "             <b>" + DatosHorario.getH_nombreCurso() + "</b> "
								+ "             <br>" + DatosHorario.getH_apellidosDocente() + ", " + DatosHorario.getH_nombreDocente() + " "
								+ "         </div>"
								+ "     </label>"
								+ " </td>");
						}

					} else {
						pw.println("<td align='center' style='color:red; background-color:#F5A9A9; vertical-align:middle; width:16%;' colspan='2' >SIN HORARIO</td>");
					}
					contenido = 0;
				}
				pw.println("</tr>");
			}

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

	}

	private void sessionArmadoHorario3(HttpServletRequest request, HttpServletResponse response) {
		HorarioServices serviciosHor = new HorarioServices();
		int cantSelec = Integer.parseInt(request.getParameter("cantSelec"));
		String codAulas = request.getParameter("codAulas");
		String cadenaAulas = request.getParameter("cadenaAulas");
		//String cadena = request.getParameter("cadena");
		String codigo = request.getParameter("codigo");

		Horario horarioCadenaGrupo = new Horario();
		horarioCadenaGrupo = serviciosHor.consultarCadenaGH(codigo);

		String cadena = horarioCadenaGrupo.getCadena();
		int maxGru = horarioCadenaGrupo.getMaxGrupo();
		Horario horario = new Horario();

		horario.setArmarHoraio_cantidad(cantSelec);
		horario.setArmarHoraio_codAulas(codAulas);
		horario.setArmarHoraio_codigo(codigo);
		horario.setArmarHoraio_cadena(cadena);
		horario.setArmarHoraio_cadenaAulas(cadenaAulas);

		HttpSession session_actual = request.getSession(true);
		session_actual.setAttribute("armandoHorario", horario);
	}

	private void listarGrupoAulas(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codAulas = request.getParameter("codAulas");
		String periodo = request.getParameter("periodo");
		String codigoGrupo = request.getParameter("codigoGrupo");
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		HorarioServices servicioHor = new HorarioServices();
		ArrayList<Horario> lista = null;
		String cadenaCodAulas = servicioHor.limbiarGrupoAulasVacias(codAulas, periodo);
		lista = servicioHor.listaGrupoAulas(codAulas, periodo);

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <tbody>");
		int cont = 1;
		System.out.println("ssssssssssss " + lista.size());
		for (int i = 0; i < lista.size(); i++) {
			String cadenaAula = lista.get(i).getGA_cadena();
			String cadenaAula2 = lista.get(i).getGA_cadena().replace(",", "#");
			String cantidad = lista.get(i).getGA_cantidad();
			pw.println("<tr>"
				+ "     <th colspan='2' style='background-color:#307ECC; color:white;'>GRUPO N" + cont + "°</th>"
				+ "     <th colspan='2' style='background-color:#307ECC; color:white;'>" + cantidad + " AULA(S)</th>"
				+ "     <th colspan='5' style='background-color:#307ECC; color:white;'> "
				+ "         <div class=\"pull-right action-buttons\">\n"
				+ "             <a class=\"white\" href=\"javascript:editarGrupo('" + cantidad + "','" + cadenaAula2 + "','" + codigoGrupo + "')\">\n"
				+ "                 <i class=\"ace-icon fa fa-cogs  bigger-100\"> Agrupacion</i>\n"
				+ "             </a>\n"
				+ "         </div>"
				+ "     </th>"
				+ " </tr>"
				+ " <tr>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>SEDE</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>TIPO CENTRO</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>CENTRO</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>NIVEL</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>TIPO GRADO</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>GRADO</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>SECCIÓN</th>"
				//				+ "     <th style='background-color:#8AB4DD; color:white;'>NOMBRE</th>"
				+ "     <th style='background-color:#8AB4DD; color:white;'>TURNO</th>"
				+ "</tr>");

			AulaServices servicioAula = new AulaServices();
			ArrayList<Aula> listaAula = null;
			listaAula = servicioAula.listarAula(cadenaAula, periodo);
			for (int j = 0; j < listaAula.size(); j++) {
				pw.println("<tr>"
					+ "     <td>" + listaAula.get(j).getNombreLocal() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreTipoCentro() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreCentro() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreNivel() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreTipoGrado() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreGrado() + "</td>"
					//					+ "     <td>" + listaAula.get(j).getNombreSeccion() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombre() + "</td>"
					+ "     <td>" + listaAula.get(j).getNombreTurno() + "</td>"
					+ "</tr>");
			}
			cont++;
		}

		pw.println("                </tbody>"
			+ "             </table>"
			+ "         </div>"
			+ "</div>"
			+ "</div>"
			+ "<input id='cadenaAulas' type='hidden' value='" + cadenaCodAulas + "'>");

	}

	private void EliminarHorarioCursoMasivo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codAulas = request.getParameter("codAulas");
		String codCur = request.getParameter("codCur");
		String periodo = request.getParameter("periodo");

		HorarioServices servicios = new HorarioServices();
		int dato = servicios.eliminarMasivo(codAulas, codCur, periodo);

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

		pw.println(dato);

	}

	private void verHorarioDocente2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codDocente = request.getParameter("codDocente");
		String nombre = request.getParameter("nombre");
		String periodo = request.getParameter("periodo");

		HorarioServices servicios = new HorarioServices();
		ArrayList<Horario> lista = null;
		lista = servicios.horarioDocenteReducido(codDocente, periodo);
		CursoServices servicios2 = new CursoServices();
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <b>DOCENTE: </b>" + nombre + " "
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <table class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr role=\"row\">\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\" >HORARIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">LUNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MARTES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">MIÉRCOLES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">JUEVES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">VIERNES</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SÁBADO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int blo = 1;
		int cont = 1;
		int cantMayor = 0;
		String dia = "";
		String cadenaLun = "";
		String cadenaMar = "";
		String cadenaMier = "";
		String cadenaJue = "";
		String cadenaVier = "";
		String cadenaSab = "";

		for (int i = 0; i < lista.size(); i++) {
			dia = lista.get(i).getDia_HorarioCursoDoc();
			String DatosAula = "<font face='Calibri' color='black' style='font-size:11px'>" + lista.get(i).getGTS() + "</font>";

			if (dia.equals("1")) {
				if (cadenaLun.equals("")) {
					cadenaLun += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaLun += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			} else if (dia.equals("2")) {
				if (cadenaMar.equals("")) {
					cadenaMar += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaMar += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b>" + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			} else if (dia.equals("3")) {
				if (cadenaMier.equals("")) {
					cadenaMier += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaMier += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			} else if (dia.equals("4")) {
				if (cadenaJue.equals("")) {
					cadenaJue += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaJue += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			} else if (dia.equals("5")) {
				if (cadenaVier.equals("")) {
					cadenaVier += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaVier += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			} else if (dia.equals("6")) {
				if (cadenaSab.equals("")) {
					cadenaSab += "<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				} else {
					cadenaSab += "#<b>" + lista.get(i).getNombreSede() + " - " + lista.get(i).getNombreNivel() + " - " + lista.get(i).getNombreTurno() + "</b><br> " + lista.get(i).getNombreCurso() + "<br>" + DatosAula;
				}
			}
		}

		//ARRAY
		String[] arrayLun = cadenaLun.split("#");
		String[] arrayMar = cadenaMar.split("#");
		String[] arrayMier = cadenaMier.split("#");
		String[] arrayJue = cadenaJue.split("#");
		String[] arrayVier = cadenaVier.split("#");
		String[] arraySab = cadenaSab.split("#");

		int[] cantDias = {arrayLun.length, arrayMar.length, arrayMier.length, arrayJue.length, arrayVier.length, arraySab.length};
		System.out.println("CANTIDAD DE DIAS : "+cantDias.length);
		for (int i = 0; i < cantDias.length; i++) {
			if (cantDias[i] > cantMayor) {
				cantMayor = cantDias[i];
			}
		}
		System.out.println("CANTIDAD MAYOR : "+cantMayor);

		for (int i = 0; i < cantMayor; i++) {
			pw.println("<tr >");
			pw.println("<td height='40' width='8' align='center' style='vertical-align:middle;'>" + cont + "°</td>");
			for (int d = 1; d <= 6; d++) {
				if (d == 1) {
					if (arrayLun.length > 0) {
						if (arrayLun.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayLun[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 2) {
					if (arrayMar.length > 0) {
						if (arrayMar.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayMar[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 3) {
					if (arrayMier.length > 0) {
						if (arrayMier.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayMier[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 4) {
					if (arrayJue.length > 0) {
						if (arrayJue.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayJue[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 5) {
					if (arrayVier.length > 0) {
						if (arrayVier.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arrayVier[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				} else if (d == 6) {
					if (arraySab.length > 0) {
						if (arraySab.length >= cont) {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'>" + arraySab[i] + "</td>");
						} else {
							pw.println("    <td height='45' width='90' align='center' style='vertical-align:middle;'></td>");
						}
					}
				}
			}
			cont++;
			pw.println("</tr>");
		}

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

		pw.println("         </div>\n"
			+ "     </div>"
			+ " </div>");
	}

	private void armarAsignacionCursoDocGeneralEdit4(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String bloq = request.getParameter("bloq");
		String dia = request.getParameter("dia");
		String CodTurno = request.getParameter("Turno");
		String horaIni = request.getParameter("Hini");
		String horaFin = request.getParameter("Hfin");
		String opcion = request.getParameter("opcion");
		String periodo = request.getParameter("periodo");
		String historial = request.getParameter("historial");
		String codigoDocente = request.getParameter("codigoDocente");
		int codigoCurso = Integer.parseInt(request.getParameter("codigoCurso"));
		String codcurso = request.getParameter("codigoCurso");
		int clase = Integer.parseInt(request.getParameter("clase"));
		String filtro = "";
		String cadenaAulas = request.getParameter("cadenaAulas");
		System.out.println("armarAsignacionCursoDocGeneralEdit4 cadenaAulas=> " + cadenaAulas);
		ClaseServices servicioCla = new ClaseServices();
		ArrayList<Clase> listaCla = null;
		listaCla = servicioCla.cargarClase();

		CursoServices servCurso = new CursoServices();
		ArrayList<Curso> listaCurso = null;
		AreaDocenteServices servDocente = new AreaDocenteServices();
		ArrayList<AreaDocente> listaDocente = null;
		DocenteServices servcioDoce = new DocenteServices();
		listaCurso = servCurso.cargarCurso();
		listaDocente = servDocente.cargarDocentesDisponibles(CodTurno, dia, codcurso, periodo);

		ArrayList<Docente> listaFiltro = null;
		listaFiltro = servcioDoce.filtroDocentesPrimSec(periodo, filtro, cadenaAulas);
		
		Docente docenteName=new Docente();
		docenteName=servcioDoce.NombreDocente(codigoDocente);


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

		if (dia.equals("1")) {
			nombreDia = "Lunes";
		} else if (dia.equals("2")) {
			nombreDia = "Martes";
		} else if (dia.equals("3")) {
			nombreDia = "Miércoles";
		} else if (dia.equals("4")) {
			nombreDia = "Jueves";
		} else if (dia.equals("5")) {
			nombreDia = "Viernes";
		} else if (dia.equals("6")) {
			nombreDia = "Sábado";
		}

		if (opcion.equals("1")) {
			horario = "Todo el turno";
		} else {
			horario = horaIni + "<b> a </b>" + horaFin;
		}
		pw.println("<div class='row'>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-2'></div>");
//		pw.println("<div class='col-sm-1'></div>");
		if(historial.equals("cambioFijo") || historial.equals("cambioDia")){
					
								pw.println("<div class=\"width-60 label label-info label-xlg arrowed-in arrowed-in-right\">");
						        pw.println("<div class=\"inline position-relative\">");
										pw.println("<a href=\"#\" style='pointer-events:none;cursor:default;' class=\"user-title-label dropdown-toggle\" data-toggle=\"dropdown\">");
												pw.println("<i class=\"ace-icon fa fa-circle orange\"></i>");
												pw.println("&nbsp;");
												pw.println("<span class=\"white\" id='txtNombre'>"+docenteName.getApe_pro()+", "+docenteName.getNom_pro()+"</span>");
						       pw.println("</a>");
							
							        pw.println("</div>");
							    
							    pw.println("</div>");
		}

		
		
		
		pw.println("<div class='col-sm-21 infobox-container' style=\"margin-top:20px\">");
		pw.println("<div class='infobox infobox-green' >");
		pw.println("<div class='infobox-icon'>");
		pw.println("<i class='ace-icon fa fa-clock-o'></i>");
		pw.println("</div>");
		pw.println("<div class='infobox-data'>");
		pw.println("<span class='infobox-data-data'>Horario</span>");
		pw.println("<div class='infobox-content'>" + horario + "</div>");
		pw.println("</div>");
		pw.println("</div>");
		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'>Día</span>");
		pw.println("<div class='infobox-content'>" + nombreDia + "</div>");
		pw.println("</div>");
		pw.println("</div>");
		
		
			pw.println("<div class='col-xs-12' style='margin-top:10px;'>");
		
					if(historial.equals("cambioDia")){
					  	 pw.println("<button type='button' class=\"btn btn-xs btn-success\" id='datepickerFechaFinButton' onclick='verfechaFin();' title='Seleccione fecha final de labores del docente'>\n" +
												"	<i class=\"ace-icon fa fa-pencil-square-o\"></i>\n" +
												"\n" +
												"	Fecha en la que falto\n" +
												"<i class=\"ace-icon fa fa-calendar icon-on-right\"></i>\n" +
												"											"
						            + " </button>");
					}else{
					  	 pw.println("<button type='button' class=\"btn btn-xs btn-warning\" id='datepickerFechaFinButton' onclick='verfechaFin();' title='Seleccione fecha final de labores del docente'>\n" +
												"	<i class=\"ace-icon fa-pencil-square-o\"></i>\n" +
												"\n" +
												"	Fecha Final de trabajo\n" +
												"<i class=\"ace-icon fa fa-calendar icon-on-right\"></i>\n" +
												"											"
						            + " </button>");
					}
				
	  pw.println("<input type='hidden' id='recibeFechaFin' style='margin-top:5px;'>");
		pw.println("<input type='hidden' id='recibeFechaInicio' style='margin-top:5px;'>");
		pw.println("<input type='hidden' id='recibeFechaFaltaAviso' style='margin-top:5px;'>");	
		pw.println("</div>");
		
	
		
		
		
		pw.println("<div class='col-sm-2'></div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-12' style='height:40px;'><hr></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Curso: </b><span style='color:red;'>*</span>");
		pw.println("<div id='divCursoCombo'>");
		pw.println("<select id='cmbCurso' class='form-control' onChange='cargarDocentesDisponibles(" + opcion + "," + bloq + "," + dia + "); recargar();'>");
		pw.println("<option>[Seleccione]</option>");
		for (int i = 0; i < listaCurso.size(); i++) {
			if (listaCurso.get(i).getCod_cur() == codigoCurso) {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "' selected>" + listaCurso.get(i).getNom_cur() + "</option>");
			} else {
				pw.println("<option value='" + listaCurso.get(i).getCod_cur() + "'>" + listaCurso.get(i).getNom_cur() + "</option>");
			}
		}
		pw.println("</select>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Seccion: </b><span style='color:red;'>*</span><br>");
		pw.println("<div id='divTipClase'>");
		pw.println("<select id='idClase' form-control' style=\"width:7em;\">");
	
		
		
		for (int i = 0; i < listaCla.size(); i++) {
			if (listaCla.get(i).getCodigoClase() == clase) {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "' selected>" + listaCla.get(i).getNombreClase() + "</option>");
			} else {
				pw.println("<option value='" + listaCla.get(i).getCodigoClase() + "'>" + listaCla.get(i).getNombreClase() + "</option>");
			}
		}
		pw.println("</select>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("<div class='col-sm-4'>");
		pw.println("<b>Filtro por docente: </b>");
		pw.println("<input id='txtApeDocente' class=\"form-control\" style='text-transform:uppercase;' onkeyup=\"doSearch();\" type=\"text\" placeholder=\"Buscar docente..\" >\n");
		pw.println("<label id='lblCadenaAulas' style='display:none;'>"+cadenaAulas+"</label>");
		pw.println("</div>");
		
		
		
		if(historial.equals("cambioFijo")){
			
					pw.println("<div class='col-sm-4'>");
					pw.println("<b>Motivo de cambio: </b><span style='color:red;'>*</span>");
					pw.println("<select id='cboMotivoCambio' required style=\"width: 21.5em;\">");
					pw.println("<option>[SELECCIONE]</option>");
					pw.println("<option value='RENUNCIA'>RENUNCIA</option>");
					pw.println("<option value='ENCUESTA'>ENCUESTA</option>");
                                        pw.println("<option value='ESTUDIOS'>ESTUDIOS</option>");
					pw.println("<option value='INFORME'>INFORME</option>");
					pw.println("<option value='VIAJE'>VIAJE</option>");
					pw.println("<option value='INFORME'>SALUD</option>");
					pw.println("<option value='LABOR ADMINISTRATIVA'>LABOR ADMINISTRATIVA</option>");
					pw.println("</select>");
					pw.println("</div>");
		}else{
			
			  pw.println("<div class='col-sm-4'>");
					pw.println("<b>Motivo de cambio: </b><span style='color:red;'>*</span>");
					pw.println("<select id='cboMotivoCambio2' required style=\"width: 21.5em;\" onchange='validarCombo();'>");
					pw.println("<option>[SELECCIONE]</option>");
					pw.println("<option value='SALUD'>SALUD</option>");
					pw.println("<option value='DECESO FAMILIAR'>DECESO FAMILIAR</option>");
					pw.println("<option value='ESTUDIOS'>ESTUDIOS</option>");
					pw.println("<option value='NO AVISO'>NO AVISO</option>");
					pw.println("<option value='VIAJE'>VIAJE</option>");
					pw.println("<option value='NO CORRESPONDE'>NO CORRESPONDE</option>");
					pw.println("</select>");
					pw.println("</div>");
					pw.println("<div class=\"col-sm-3\">\n" +
"																							<div class=\"form-group\">\n" +
"																									<b>Hora y Fecha en la que aviso:</b>\n" +
"																									<input type='time'  id=\"txtHoraAviso\" style='font-size: 10pt;height: 2.5em;'>\n" +
"                                                 <button type='button' class=\"btn btn-xs btn-success\" id='datepickerFechaFaltaAvisoButton' onclick='verfechaFaltaAviso();' title='Elegir fecha fin del docente'><i class='ace-icon fa fa-calendar'></i></button>\n" +
"																							</div>\n" +
"																				</div>");
						    
					pw.println("<div class=\"col-sm-3\">\n" +
"																								<div class=\"form-group\">\n" +
"																										<b>Observacion:</b>\n" +
"																										<textarea class=\"form-control\" id=\"txtObservacion\" style=\"font-size: 10pt;height: 3em;width:22.5em;resize: none;\"></textarea>\n" +
"																								</div>\n" +
"																				</div>");
				
			
		    
		  }
		
		

		
		
		pw.println("<div class='col-sm-12' style='height:20px;'></div>");
		pw.println("<div class='col-sm-12'>");
		pw.println("<div id='divDocenteCombo'>");
		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 Disponibles</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: 200px;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='400' class='center'>CANTIDAD</th>");
		pw.println("<th width='200' class='center'>NOTA PLANA</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'>NOTA PROMEDIO</th>");
		pw.println("<th width='200' class='center'>ELEGIR</th>");
		pw.println("</tr>");
		pw.println("</thead>");
		pw.println("<tbody>");
		int cont = 1;
		String color = "";
		for (int i = 0; i < listaFiltro.size(); i++) {
			int codigoTipoDocente = listaFiltro.get(i).getCod_tip();
			String codDocente = listaFiltro.get(i).getCodigoDocente();
			if (codigoTipoDocente == 1) {
				color = "style=''";
			} else { //profesores nuevos
				if (cont % 2 == 0) {
					color = "style='background-color:#FFF9C0;'";
				} else {
					color = "style='background-color:#FFFCE0;'";
				}
			}
			if (codDocente.equals(codigoDocente)) {
				color = "style='background-color:#FFB695;'";
			}

			pw.println("<tr " + color + ">");

			String apeDocente = listaFiltro.get(i).getApe_pro();
			String nomDocente = listaFiltro.get(i).getNom_pro();
			String nombreCompleto = apeDocente.replace("Ã‘", "Ñ") + ", " + nomDocente.replace("Ã‘", "Ñ");
			String zona = listaFiltro.get(i).getZona();
			String notaExamen = listaFiltro.get(i).getNotaExamen();
			String notaEncuesta = listaFiltro.get(i).getNotaEncuesta();
			String notaPlana = listaFiltro.get(i).getNotaPlana();
			String notaPromedio = listaFiltro.get(i).getNotaPromedio();
			int cantidad = listaFiltro.get(i).getCantidad();
			String icono = "";
			if (!notaPromedio.equals("")) {
				double notaExa = Double.parseDouble(notaPromedio);
				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 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>");
			pw.println("<td class='text-center align-middle'>" + cantidad + "</td>");
			pw.println("<td class='text-center align-middle'>" + notaPlana + "</td>");
			pw.println("<td class='text-center align-middle'>" + notaExamen + "</td>");
			pw.println("<td class='text-center align-middle'>" + notaEncuesta + "</td>");
			pw.println("<td class='text-center align-middle'><i class='" + icono + "'></i>" + notaPromedio + "</td>");

			pw.println("<td align='center' style='vertical-align:middle'>");
			pw.println("<label>");
			if (codDocente.equals(codigoDocente)) {
			

//				pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);' disabled>");
				pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' disabled>");
//				pw.println("<input name='checkbox" + cont + "' checked id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
			} else {
					if(historial.equals("cambioFijo") || historial.equals("cambioDia")){
						pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);abrirModal(this);'>");
					
				}else{
					  	pw.println("<input name='checkbox" + cont + "'  id='checkbox" + cont + "' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);'>");
					}
				
//				pw.println("<input name='checkbox" + cont + "'  id='checkbox' class='ace' type='checkbox' value='" + cont + "' onclick='verificar_uno(this);abrirModal(this);'>");
			
			}
			pw.println("<span  class='lbl'></span>");
			pw.println("</label>");
			pw.println("<input type='hidden' id='datos_" + cont + "' value='" + codDocente + "'>");
			pw.println("<input type='hidden' id='datos2_" + cont + "' value='" + cont + "#" + nombreCompleto + "'>");
			pw.println("</td>");
			pw.println("</tr>");
			cont++;
		}
		pw.println("</tbody>");
		pw.println("</table>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("</div><input type='hidden' id='cantidad' value='" + listaFiltro.size() + "'>");
		pw.println("</div>");
		pw.println("</div>");
		pw.println("</div>");
	}

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

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

		AulaServices servicios = new AulaServices();

		String codigoPeriodoAcademico = request.getParameter("codigoPeriodoAcademico");
		String codigoAula = request.getParameter("codigoAula");
		String nombreAula = request.getParameter("nombreAula");
		int cantidad = 1;
		String codigo = request.getParameter("codigo");

		HorarioServices serviciosHor = new HorarioServices();
		Horario horarioCadenaGrupo = new Horario();
		horarioCadenaGrupo = serviciosHor.consultarCadenaGH(codigoAula, codigoPeriodoAcademico);

		String cadena = horarioCadenaGrupo.getCadena();
		int maxGru = horarioCadenaGrupo.getMaxGrupo();

		String datoTD = "";
		String[] aulas = codigoAula.split("#");

		//REGISTRAR GRUPO AULAS
		String cadenaAulas = codigoAula.replace("#", ",");

		// GUARDAR MAXIMOS Y MINIMOS HORARIOS POR DIA
		// GUARDAR CADENA DE HORARIOS INICIALES Y FINALES POR DIA
		String min_ini_1 = "";
		String min_ini_2 = "";
		String min_ini_3 = "";
		String min_ini_4 = "";
		String min_ini_5 = "";
		String min_ini_6 = "";
		String max_fin_1 = "";
		String max_fin_2 = "";
		String max_fin_3 = "";
		String max_fin_4 = "";
		String max_fin_5 = "";
		String max_fin_6 = "";
		String horas_ini_1 = "";
		String horas_ini_2 = "";
		String horas_ini_3 = "";
		String horas_ini_4 = "";
		String horas_ini_5 = "";
		String horas_ini_6 = "";
		String horas_fin_1 = "";
		String horas_fin_2 = "";
		String horas_fin_3 = "";
		String horas_fin_4 = "";
		String horas_fin_5 = "";
		String horas_fin_6 = "";
		int contGenral = 1;

		// ---- CADENA -------------------------//
		String[] array1 = cadena.split("!");
		int x = 0;

		for (int i = 0; i < array1.length; i++) {
			String[] array2 = array1[i].split("#");
			if (x < Integer.parseInt(array2[0])) {
				x = Integer.parseInt(array2[0]);
			}

		}
		// ---- CADENA ------------------------//

		for (int i = 0; i < cantidad; i++) {
			String nomAula = servicios.consultarAula(aulas[i]);

			pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
				+ "                       <div class=\"table-header\">\n"
				+ "                           <table width='100%'>"
				+ "                               <tr>"
				+ "                                   <td><i class='ace-icon fa fa-calendar icon-on-right bigger-110'></i>&nbsp;&nbsp;" + nomAula + "</td>"
				+ "                                   <td align='right' >"
				+ "                                   <!--<span class='badge badge-warning'> "
				+ "                                       <div class=\"pull-right action-buttons\">\n"
				+ "                                           <a class=\"red\" href=\"#\">\n"
				+ "                                               <i class=\"ace-icon fa fa-trash-o bigger-150\"></i>\n"
				+ "                                           </a>\n"
				+ "                                       </div>"
				+ "                                   </span>-->"
				+ "                                        </td>"
				+ "                                   </td>"
				+ "                                   <td width='10' ></td>"
				+ "                               </tr>"
				+ "                           </table>"
				+ "                       </div>\n"
				+ "                       <div>\n"
				+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
				+ "                               <table  class=\"table table-striped table-bordered table-hover dataTable no-footer\" id=\"sample-table-2\" role=\"grid\" aria-describedby=\"sample-table-2_info\" >\n"
				+ "                                   <thead>\n"
				+ "                                       <tr role=\"row\">\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >LUNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MARTES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >MIÉRCOLES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >JUEVES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >VIERNES</th>\n"
				+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\" width='16%' >SÁBADO</th>\n"
				+ "                                       </tr>\n"
				+ "                                   </thead>\n"
				+ "                                   <tbody>");
			String codPeriodo2 = "" + codigoPeriodoAcademico;
			String HorIni = "";
			String HorFin = "";
			int dia1 = 0;
			int dia2 = 0;
			int dia3 = 0;
			int dia4 = 0;
			int dia5 = 0;
			int dia6 = 0;
			int cont_dia1 = 1;
			int cont_dia2 = 1;
			int cont_dia3 = 1;
			int cont_dia4 = 1;
			int cont_dia5 = 1;
			int cont_dia6 = 1;
			int diaPos = 0;
			int diaGen = 0;
			int contenido = 0;
			for (int t = 1; t <= x; t++) {
				pw.println("<tr>");
				String bloqueGrupoDia = "";
				for (int f = 1; f <= 6; f++) {
					for (int j = 0; j < array1.length; j++) {
						String[] array2 = array1[j].split("#");

						if (array2[2].equals("" + f)) {
							if (Integer.parseInt(array2[0]) >= t) {
								String[] horas = array2[3].split("¡");
								int h = t - 1;
								String[] hora = horas[h].split("-");
								HorIni = hora[0];
								HorFin = hora[1];
								bloqueGrupoDia = array2[0];
								if (f == 1) {
									dia1++;
									diaPos = dia1;
									diaGen = f;
								} else if (f == 2) {
									dia2++;
									diaPos = dia2;
									diaGen = f;
								} else if (f == 3) {
									dia3++;
									diaPos = dia3;
									diaGen = f;
								} else if (f == 4) {
									dia4++;
									diaPos = dia4;
									diaGen = f;
								} else if (f == 5) {
									dia5++;
									diaPos = dia5;
									diaGen = f;
								} else if (f == 6) {
									dia6++;
									diaPos = dia6;
									diaGen = f;
								}
								contenido = 1;
							}
						}
					}
					String dia = "" + f;
					String posicion = "" + diaPos;

					if (contenido == 1) {

						Horario DatosHorario = new Horario();
						DatosHorario = serviciosHor.consultarDatosHorarioAulaPorPosicionDiaria(aulas[i], codPeriodo2, dia, posicion);

						pw.println("<td align='center' style='width:4%; color:white; background-color:#62A8D1; vertical-align:middle; font-size: 10px; '>" + HorIni + "<br>" + HorFin + "</td>");

						if (i == 0) {
							if (dia.equals("1")) {
								if (cont_dia1 == 1) {
									min_ini_1 = HorIni;
									cont_dia1++;
								}
								max_fin_1 = HorFin;
								if (horas_ini_1.equals("")) {
									horas_ini_1 = HorIni;
									horas_fin_1 = HorFin;
								} else {
									horas_ini_1 += "#" + HorIni;
									horas_fin_1 += "#" + HorFin;
								}
							} else if (dia.equals("2")) {
								if (cont_dia2 == 1) {
									min_ini_2 = HorIni;
									cont_dia2++;
								}
								max_fin_2 = HorFin;
								if (horas_ini_2.equals("")) {
									horas_ini_2 = HorIni;
									horas_fin_2 = HorFin;
								} else {
									horas_ini_2 += "#" + HorIni;
									horas_fin_2 += "#" + HorFin;
								}
							} else if (dia.equals("3")) {
								if (cont_dia3 == 1) {
									min_ini_3 = HorIni;
									cont_dia3++;
								}
								max_fin_3 = HorFin;
								if (horas_ini_3.equals("")) {
									horas_ini_3 = HorIni;
									horas_fin_3 = HorFin;
								} else {
									horas_ini_3 += "#" + HorIni;
									horas_fin_3 += "#" + HorFin;
								}
							} else if (dia.equals("4")) {
								if (cont_dia4 == 1) {
									min_ini_4 = HorIni;
									cont_dia4++;
								}
								max_fin_4 = HorFin;
								if (horas_ini_4.equals("")) {
									horas_ini_4 = HorIni;
									horas_fin_4 = HorFin;
								} else {
									horas_ini_4 += "#" + HorIni;
									horas_fin_4 += "#" + HorFin;
								}
							} else if (dia.equals("5")) {
								if (cont_dia5 == 1) {
									min_ini_5 = HorIni;
									cont_dia5++;
								}
								max_fin_5 = HorFin;
								if (horas_ini_5.equals("")) {
									horas_ini_5 = HorIni;
									horas_fin_5 = HorFin;
								} else {
									horas_ini_5 += "#" + HorIni;
									horas_fin_5 += "#" + HorFin;
								}
							} else if (dia.equals("6")) {
								if (cont_dia6 == 1) {
									min_ini_6 = HorIni;
									cont_dia6++;
								}
								max_fin_6 = HorFin;
								if (horas_ini_6.equals("")) {
									horas_ini_6 = HorIni;
									horas_fin_6 = HorFin;
								} else {
									horas_ini_6 += "#" + HorIni;
									horas_fin_6 += "#" + HorFin;
								}
							}
						}
                                                
                                                
                                               
                                                String codigoEstado=DatosHorario.getH_estado();
                                                System.out.println("codigoEstado------>"+codigoEstado);
                                                 
						if (DatosHorario.getH_estado() == null) {
//                            if (diaGen == 6) {
//                                pw.println("<td></td>");
//                            } else {
				                   pw.println("<td id='sinCurso' align='center' style='width:12%; vertical-align:middle; cursor: pointer;' onclick=\"alerta1('" + cantidad + "','" + bloqueGrupoDia + "','" + aulas[i] + "','" + diaPos + "'," + diaGen + ",'" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "')\" >"
								+ " <label style='color: red;'><div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'>SIN CURSO </div></label>"
								+ " </td>");
//                            }

                                                 }else {
							pw.println("<td align='center' style='width:12%; vertical-align:middle; cursor: pointer;' onclick=\"editar('" + DatosHorario.getH_codigoAula() + "','" + diaPos + "','" + diaGen + "','" + HorIni + "','" + HorFin + "','" + codigo + "','" + contGenral + "','" + DatosHorario.getH_codigoDocente() + "','" + DatosHorario.getH_codigoCurso() + "','" + DatosHorario.getH_clase() + "' )\" >"
								+ "     <label  style='font-size:10px;'>"
								+ "         <div id='curso_" + contGenral + "_" + diaPos + "_" + diaGen + "'> "
								+ "             <b>" + DatosHorario.getH_nombreCurso() + "</b><br> "
								+ "             <b>Cel: 123456789</b><br> "
								+ "             <b>Prom Ex. 8.3</b><br> "
								+ "             <b>Prom Enc. 8.3</b> "
								+ "             <br>" + DatosHorario.getH_apellidosDocente() + ", " + DatosHorario.getH_nombreDocente() + " "
								+ "         </div>"
								+ "     </label>"
								+ " </td>");
						}

					} else {
						pw.println("<td align='center' style='color:red; background-color:#F5A9A9; vertical-align:middle; width:16%;' colspan='2' >SIN HORARIO</td>");
					}
					contenido = 0;
				}
				pw.println("</tr>");
			}
			pw.println("                </tbody>"
				+ "             </table>"
				+ "         </div>"
				+ "</div>"
				+ "</div>"
				+ "<br>");
			contGenral++;
		}
	}

	private void listarVistaDobleDisponibilidad(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter pw = response.getWriter();
		JSONObject json = new JSONObject(request.getParameter("json"));
		HorarioServices service = new HorarioServices();
		JSONObject jReponse = service.listarVistaDobleDisponibilidad(json);
		pw.print(jReponse);
	}

	private void verHorarioDocenteDni(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject(request.getParameter("json"));
		HorarioServices srv = new HorarioServices();
		JSONObject recb = srv.listarVistaHorarioDocenteDni(json);
		out.print(recb);

	}
	
	private void verHorarioDocenteDni2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject(request.getParameter("json"));
		HorarioServices srv = new HorarioServices();
		JSONObject recb = srv.listarVistaHorarioDocenteDni2(json);
		out.print(recb);
	}

	private void verHorarioDocentePeriodo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter out = response.getWriter();
		JSONObject json = new JSONObject();
		json.put("codigoPeriodo", request.getParameter("codigoPeriodo"));
		json.put("codigoProfesor", request.getParameter("codigoProfesor"));

		HorarioServices srv = new HorarioServices();
		JSONObject rcv = srv.listarVistaHorarioDisponibilidad(json);
		out.print(rcv);
	}

	private void verHistorialCambioDiario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/html");
		DocenteServices srv = new DocenteServices();
		PrintWriter pw = response.getWriter();
		
		String cadenaAulas=request.getParameter("cadenaAula");
		String dia=request.getParameter("dia");
		String codigoDocente=request.getParameter("codigoDocente");
		ArrayList<Horario> lista = srv.listarCambiosDiaDocente(cadenaAulas,dia,codigoDocente);
		 if(lista.size() == 0){
			 pw.println("<strong>No hay cambio dia </strong>");
			 
		 }else{
		   		 for(Horario horario : lista){
						Docente docente2 = srv.NombreDocente(horario.getH_codigoDocente());

						pw.println(""
							+ "<form>"
									+"<table border='1' width='100%;'>"
											+ "<thead>"
													+ "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center'>Reemplazo</th>"
													+ "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center'>Curso</th>"
													+ "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center'>Fecha Cambio</th>"
						             	+ "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center'>Hora Cambio</th>"
						            	+ "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center'>Horario</th>"
							            + "<th width:'40%' style='background-color:#245E99;color:#EDE6E4;' class='center' >Responsable Cambio</th>"
											+ "</thead>"
							      +"<hr>"
							       +"<tbody style='margin:5px;'>"
										
													+"<td  style=\"padding:5px;width:'40%'\">"+docente2.getApe_pro()+" "+docente2.getNom_pro()+"</td>"
														+"<td  style=\"padding:5px;width:'40%'\">"+horario.getH_nombreCurso()+"</td>"
															+"<td  style=\"padding:5px;width:'40%'\">"+horario.getH_fecha()+"</td>"
																+"<td  style=\"padding:5px;width:'40%'\">"+horario.getH_hora()+"</td>"
															+"<td  style=\"padding:5px;width:'40%'\">"+horario.getH_horarioInicio()+" - "+horario.getH_horarioFinal()+"</td>"
																+"<td  style=\"padding:5px;width:'40%'\">"+horario.getH_codigoUsuario()+"</td>"
											+"</tbody>"
									+"</table>"
							+ "</form>");
					}
		 }
		 

		 
	}

	private void updateCambioCurso(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/html");
		
		String codAula=request.getParameter("codAula");
		String codigoCursoNuevo=request.getParameter("codigoCursoNuevo");
		String posBloque=request.getParameter("posBloque");
		String periodo=request.getParameter("periodo");
		String dia=request.getParameter("dia");
		int dato=services.updateCambioCurso(codAula, periodo, dia, posBloque, codigoCursoNuevo);
		pw.println(dato);
		
	  
	}

	private void updateDisponibilidad(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/html");
		
		String codDocente=request.getParameter("codDocente");
		String turno=request.getParameter("turno");
		String dia=request.getParameter("diaBloquear");
		String periodo=request.getParameter("periodo");
	
		int dato=services.updateDisponibilidad(codDocente, periodo, turno, dia);
		pw.println(dato);
	}

	private void rollbackDisponibilidad(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/html");
		
		String codDocente=request.getParameter("codDocente");
		String turno=request.getParameter("turno");
		String dia=request.getParameter("diaBloquear");
		String periodo=request.getParameter("periodo");
	
		int dato=services.rollbackDisponibilidad(codDocente, periodo, turno, dia);
		pw.println(dato);
	}

	private void registrarConformidad(HttpServletRequest request, HttpServletResponse response) throws IOException {
		
		JSONArray json = new JSONArray(request.getParameter("json"));
//		String codDocente=request.getParameter("codDocente");
		response.setContentType("application/json");
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		JSONObject rcv = new JSONObject();
		
		
		
	}

	private void listarVistaDobleDisponibilidad2(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter pw = response.getWriter();
		JSONObject json = new JSONObject(request.getParameter("json"));
		HorarioServices service = new HorarioServices();
		JSONObject jReponse = service.listarVistaDobleDisponibilidad2(json);
		pw.print(jReponse);
	}
	private void listarVistaDobleDisponibilidadSinZona(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("application/json");
		PrintWriter pw = response.getWriter();
		JSONObject json = new JSONObject(request.getParameter("json"));
		HorarioServices service = new HorarioServices();
		JSONObject jReponse = service.listarVistaDobleDisponibilidadSinZona(json);
		pw.print(jReponse);
	}

	private void insertarNuevaHoras(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/html");
		JSONObject json = new JSONObject(request.getParameter("json"));
		int jReponse = services.insertarNuevaHoras(json);
		pw.println(jReponse);
		
	}
	private void mostrarNuevaHoras(HttpServletRequest request, HttpServletResponse response) throws IOException {
		HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/json");
		JSONObject json = new JSONObject(request.getParameter("json"));
		
		JSONObject jReponse = services.mostrarNuevaHoras(json);
		pw.println(jReponse);
		
	}

    private void deshabilitarHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
       HorarioServices services=new HorarioServices();
		PrintWriter pw=response.getWriter();
		response.setContentType("application/json");
		JSONObject json = new JSONObject(request.getParameter("json"));
		
		JSONObject jReponse = services.deshabilitarHorario(json);
		pw.println(jReponse);
    }

    private void eliminarBloqueGrupoAula(HttpServletRequest request, HttpServletResponse response) {
        	HttpSession session_actual = request.getSession(true);
		Usuario usuario = (Usuario) session_actual.getAttribute("usuario");
		int codUsuario = usuario.getCodigoUsuario();
		String codAula = request.getParameter("codAula");
		String periodo = request.getParameter("periodo");
		HorarioServices servicios = new HorarioServices();

		servicios.eliminarBloqueGrupoAula(codAula, periodo, codUsuario);
        
    }

    private void updateGrupoAula(HttpServletRequest request, HttpServletResponse response) {
           
                HorarioServices servicios = new HorarioServices();
                
		String codAulas = request.getParameter("codAulas");
		String periodo = request.getParameter("periodo");
		String cantidad = request.getParameter("cantidad");
		String codAulasAntiguo = request.getParameter("codAulasAntiguo");
		

		servicios.updateGrupoAula(codAulas,cantidad,periodo,codAulasAntiguo);
    }
	
	

	

}
