/*
 * 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 javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import pe.siso.horario.Beans.Aula;
import pe.siso.horario.Beans.Horario;
import pe.siso.horario.Beans.Sede;
import pe.siso.horario.Services.AulaServices;
import pe.siso.horario.Services.HorarioServices;

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

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String param = request.getParameter("Accion");
		if ("listadoAulaTotal".equals(param)) {
			listadoAulaTotal(request, response);
		} else if ("registarAula".equals(param)) {
			registarAula(request, response);
		} else if ("consultarAula".equals(param)) {
			consultarAula(request, response);
		} else if ("cargarAulaEncuesta".equals(param)) {
			cargarAulaEncuesta(request, response);
		} else if ("listaAula".equals(param)) {
			listaAula(request, response);
		} else if ("listadoAulaTotalDirage".equals(param)) {
			listadoAulaTotalDirage(request, response);
		} else if ("listaAulaDirage".equals(param)) {
			listaAulaDirage(request, response);
		} else if ("listadoAulaTotalDirageAsiHor".equals(param)) {
			listadoAulaTotalDirageAsiHor(request, response);
		} else if ("listaAulaDirageAsiHor".equals(param)) {
			listaAulaDirageAsiHor(request, response);
		} else if ("listaAulaDirageAsiBlo".equals(param)) {
			listaAulaDirageAsiBlo(request, response);
		} else if ("listadoAulaTotalDirageAsiBlo".equals(param)) {
			listadoAulaTotalDirageAsiBlo(request, response);
		} else if ("listarAulasBloque".equals(param)) {
			listarAulasBloque(request, response);
		} else if ("listarAulasHorario".equals(param)) {
			listarAulasHorario(request, response);
		} else if ("crearSession".equals(param)) {
			crearSession(request, response);
		} else if ("consultarNomAula".equals(param)) {
			consultarNomAula(request, response);
		} else if ("reporteAulasHorario".equals(param)) {
			reporteAulasHorario(request, response);
		} else if ("listarAulasTotal".equals(param)) {
			listarAulasTotal(request, response);
		} else if ("listarTablaAula".equals(param)) {
			listarTablaAula(request, response);
		}
	}

	private void listadoAulaTotal(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> lista = null;

		lista = servicios.listaAulas();

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

		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 >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                           <th>TIPO CENTRO</th>\n"
			+ "                                           <th>CENTRO</th>\n"
			+ "                                           <th>NIVEL</th>\n"
			+ "                                           <th>TIPO GRADO</th>\n"
			+ "                                           <th>GRADO</th>\n"
			+ "                                           <th>SECCIÓN</th>\n"
			+ "                                           <th>TURNO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {

			if (cont % 2 == 0) {
				pw.println("<tr class=\"alt\" >");
			} else {
				pw.println("<tr >");
			}
			pw.println("    <td>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ " </tr>");
			cont++;
		}

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

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

	private void registarAula(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		Aula claseAula = new Aula();
		String codSede = request.getParameter("codSede");
		String codTipoCentro = request.getParameter("codTipoCentro");
		String codCentro = request.getParameter("codCentro");
		String codNivel = request.getParameter("codNivel");
		String codTipoGrado = request.getParameter("codTipoGrado");
		String codGrado = request.getParameter("codGrado");
		String codSeccion = request.getParameter("codSeccion");
		String codTurno = request.getParameter("codTurno");
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		int aula = 0;
		int dato = servicios.registrarAula(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno);

		if (dato == 1) {
			aula = servicios.consultarAula(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno);
			String cantidad = servicios.cantidadUsuariosAula();

			String codAula = "" + aula;
			String nombreUusario = "Encuestador";
			String usuario = "Encuestador" + cantidad;
			String clave = codAula + "clave" + cantidad;

			HttpSession session_actual = request.getSession(true);
			claseAula.setCodigoAula(aula);
			claseAula.setCodigoLocal(codSede);

			session_actual.setAttribute("sesionAula", claseAula);
			/*String codAula = ""+aula;
             String nombreUusario = "TUTOR";
             String usuario = "tutor"+cantidad;
             String clave = codAula+"clave"+cantidad;
			 */

			servicios.crearUsuarioEncuestador(codSede, codAula, nombreUusario, usuario, clave, cantidad);

		}

		pw.println(dato);

	}

	private void consultarAula(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		String codAula = request.getParameter("codAula");
		String aula = servicios.consultarAula(codAula);

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("<select class='sttxt2'>");
		pw.println("<option>" + aula + "</option>");
		pw.println("</select>");

	}

	private void cargarAulaEncuesta(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> lista = new ArrayList<Aula>();
		String accion = request.getParameter("accion");
		String nombre = request.getParameter("nombre");
		String codEncuesta = request.getParameter("codEncuesta");
		String codSede = request.getParameter("codSede");

		lista = servicios.listaAulasEncuestadas(codSede, codEncuesta);

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("<select  class='validate[required]' onChange='" + accion + "' id='" + nombre + "'>");
		pw.println("<option value=''>Seleccione</option>");
		pw.println("<option value='todo'>TODAS LAS AULAS</option>");
		for (int i = 0; i < lista.size(); i++) {
			pw.println("<option value='" + lista.get(i).getCodigoAula() + "'>" + lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "</option>");
		}
		pw.println("</select>");
	}

	private void listaAula(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> lista = null;
		String codigoLocal = request.getParameter("codLocal");

		int pagina = Integer.parseInt(request.getParameter("pagina"));
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));

		int inicio = (pagina - 1) * cantidad;
		int cantRegistro = 0;

		if (codigoLocal.equals("todo")) {
			lista = servicios.listaAulas(inicio, cantidad);
			cantRegistro = servicios.CantlistaAulas();

		} else {
			lista = servicios.listaAulas(codigoLocal, inicio, cantidad);
			cantRegistro = servicios.CantlistaAulas(codigoLocal);
		}

		//--------------CALCULO DE PAGINADO---------
		int numero = cantRegistro / cantidad;
		int resto = cantRegistro % cantidad;
		if (resto > 0) {
			numero = numero + 1;
		}
		//------------------------------------------------
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"agregarAula();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-plus-circle icon-on-right bigger-110\"></i>\n"
			+ "                                               Agregar Aula\n"
			+ "                                           </button>"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportar();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar Aulas\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SECCIÓN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont_ini = 0;
		int cont_fin = 0;
		int cont = inicio + 1;
		for (int i = 0; i < lista.size(); i++) {
			if (i == 0) {
				cont_ini = cont;
			}
			if (cont % 2 == 0) {
				pw.println("<tr class=\"alt\" >");
			} else {
				pw.println("<tr >");
			}
			pw.println("    <td align='center'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ " </tr>");
			cont++;
		}
		cont_fin = cont - 1;
		if (cont == 1) {
			pw.println("<tr><td colspan='9' align='center'>No hay aulas registradas</td></tr>");
		}

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

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

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

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

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

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

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

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

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

		//::::::Aqui es el código para romper la sesión actual del aula
		HttpSession session_actual = request.getSession(true);
		session_actual.getAttribute("sesionAula");

		if (session_actual.getAttribute("sesionAula") != null) {
			session_actual.removeAttribute("sesionAula");

		}
		System.out.println(session_actual + "----" + session_actual);

	}

	private void listadoAulaTotalDirage(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> lista = null;

		lista = servicios.listaAulasDirage();

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

		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 >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                           <th>TIPO CENTRO</th>\n"
			+ "                                           <th>CENTRO</th>\n"
			+ "                                           <th>NIVEL</th>\n"
			+ "                                           <th>TIPO GRADO</th>\n"
			+ "                                           <th>GRADO</th>\n"
			+ "                                           <th>SECCIÓN</th>\n"
			+ "                                           <th>TURNO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {

			if (cont % 2 == 0) {
				pw.println("<tr class=\"alt\" >");
			} else {
				pw.println("<tr >");
			}
			pw.println("    <td>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ " </tr>");
			cont++;
		}

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

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

	}

	private void listaAulaDirage(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> listaGeneral = null;
		ArrayList<Aula> lista = null;
		Sede claseSede = new Sede();
		String codigoLocal = request.getParameter("codLocal");
		int pagina = Integer.parseInt(request.getParameter("pagina"));
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));

		int inicio = (pagina - 1) * cantidad;
		int cantRegistros = 0;

		if (codigoLocal.equals("todo")) {
			//listaGeneral=servicios.listaAulasDirage();
			lista = servicios.listaAulasDirage(inicio, cantidad); // consultar con el LIMIT inicio, cantidad
			cantRegistros = servicios.CantlistaAulasDirageSede(); // consultar la cantidad total sin LIMIT
			//Para la sesion de todas 
			//HttpSession session_actual = request.getSession(true);
			// claseSede.setCodigoSede(codigoSede);
			// session_actual.setAttribute("sesionSede", claseSede);
		} else {
			//listaGeneral=servicios.listaAulasDirage(codigoLocal);  
			lista = servicios.listaAulasDirage(codigoLocal, inicio, cantidad); // consultar con el LIMIT inicio, cantidad
			cantRegistros = servicios.CantlistaAulasDirageSede(codigoLocal); // consultar la cantidad total sin LIMIT
			//session 

			int codigoSede = Integer.parseInt(codigoLocal);
			HttpSession session_actual = request.getSession(true);
			claseSede.setCodigoSede(codigoSede);
			session_actual.setAttribute("sesionSede", claseSede);

		}

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

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"agregarAula();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-plus-circle icon-on-right bigger-110\"></i>\n"
			+ "                                               Agregar Aula\n"
			+ "                                           </button>"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportar();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar Aulas\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SECCIÓN</th>\n"
//			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NOMBRE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont_ini = 0;
		int cont_fin = 0;
		int cont = inicio + 1;
		for (int i = 0; i < lista.size(); i++) {
			if (i == 0) {
				cont_ini = cont;
			}
			if (cont % 2 == 0) {
				pw.println("<tr class=\"alt\" >");
			} else {
				pw.println("<tr >");
			}
			pw.println("    <td align='center'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
//				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombre() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ " </tr>");
			cont++;
		}

		cont_fin = cont - 1;

		if (cont == 1) {
			pw.println("<tr><td colspan='9' align='center'>No hay aulas registradas en secundaria</td></tr>");
		}

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

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

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

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

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

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

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

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

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

		if (session_actual.getAttribute("sesionAula") != null) {
			session_actual.removeAttribute("sesionAula");

		}

	}

	private void listadoAulaTotalDirageAsiHor(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		HorarioServices servicios1 = new HorarioServices();
		ArrayList<Aula> lista = null;
		String accion1 = "";
		String accion2 = "";
		lista = servicios.listaAulasDirage();

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

		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 >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                           <th>TIPO CENTRO</th>\n"
			+ "                                           <th>CENTRO</th>\n"
			+ "                                           <th>NIVEL</th>\n"
			+ "                                           <th>TIPO GRADO</th>\n"
			+ "                                           <th>GRADO</th>\n"
			+ "                                           <th>SECCIÓN</th>\n"
			+ "                                           <th>TURNO</th>\n"
			+ "                                           <th>ASIGNAR BLOQUE</th>\n"
			+ "                                           <th>ASIGNAR HORARIO</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String aula = "" + lista.get(i).getCodigoAula();
			int cant = servicios1.consultarCantGrupoBloque(aula);
			String nom = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			if (cant == 0) {
				accion1 = "<a href=\"javascript:asignar('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/table.png' /></a>";
				accion2 = "";
			} else {
				accion1 = "<a href=\"javascript:asignar('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/tick.png' /></a>";
				accion2 = "<a href=\"javascript:asignarHorario('" + lista.get(i).getCodigoAula() + "');\" class='regular' ><img src='imagenes/icons/calendar-task.png' /></a>";
			}

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

			pw.println("    <td height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' >" + accion1 + "</td>"
				+ "    <td align='center' valign='middle' >" + accion2 + "</td>"
				+ " </tr>");
			cont++;
		}

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

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

	}

	private void listaAulaDirageAsiHor(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		ArrayList<Aula> lista = null;
		String codigoLocal = request.getParameter("codLocal");

		lista = servicios.listaAulasDirage(codigoLocal);

		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		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 >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                           <th>TIPO CENTRO</th>\n"
			+ "                                           <th>CENTRO</th>\n"
			+ "                                           <th>NIVEL</th>\n"
			+ "                                           <th>TIPO GRADO</th>\n"
			+ "                                           <th>GRADO</th>\n"
			+ "                                           <th>SECCIÓN</th>\n"
			+ "                                           <th>TURNO</th>\n"
			+ "                                           <th>ASIGNAR</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String nom = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			if (cont % 2 == 0) {
				pw.println("<tr class=\"alt\" >");
			} else {
				pw.println("<tr >");
			}
			pw.println("    <td>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' ><a href=\"javascript:asignar('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' >\n"
				+ "                                    <img src='imagenes/icons/table.png' /> "
				+ "                               </a>"
				+ " </tr>");
			cont++;
		}

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

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

	private void listaAulaDirageAsiBlo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		//AulaServices servicios = new AulaServices();
		//ArrayList<Aula> lista = null;
		String codSede = request.getParameter("codSede");

		AulaServices servicios = new AulaServices();
		HorarioServices servicios1 = new HorarioServices();
		ArrayList<Aula> lista = null;
		String accion1 = "";
		String accion2 = "";
		lista = servicios.listaAulasDirage(codSede);

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

		pw.println("<table  cellpadding=\"0\" cellspacing=\"0\">\n"
			+ "	    <tr>\n"
			+ "               <td height=\"10\"></td>\n"
			+ "           </tr>\n"
			+ "           <tr><td width=\"100%\">\n"
			+ "                   <div class=\"datagrid\">\n"
			+ "                           <table >\n"
			+ "                                   <thead>\n"
			+ "                                       <tr >\n"
			+ "                                           <th>N°</th>\n"
			+ "                                           <th>SEDE</th>\n"
			+ "                                           <th>TIPO CENTRO</th>\n"
			+ "                                           <th>CENTRO</th>\n"
			+ "                                           <th>NIVEL</th>\n"
			+ "                                           <th>TIPO GRADO</th>\n"
			+ "                                           <th>GRADO</th>\n"
			+ "                                           <th>SECCIÓN</th>\n"
			+ "                                           <th>TURNO</th>\n"
			+ "                                           <th>ASIGNAR BLOQUE</th>\n"
			+ "                                           <th>SELECIONE</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>"
			+ "                                       <tr>"
			+ "                                           <td></td>"
			+ "                                           <td align='center'></td>"
			+ "                                           <td align='center'><div id='divTipoCentro'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divCentro'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divNivel'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divTipoGrado'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divGrado'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divSeccion'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'><div id='divTurno'><select><option>Seleccione</option></select></div></td>"
			+ "                                           <td align='center'></td>"
			+ "                                           <td align='center'><a href=\"javascript:seleccionarTodo();\" class='regular' ><img src='imagenes/icons/check_box.png' /></a></td>"
			+ "                                       </tr>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			String aula = "" + lista.get(i).getCodigoAula();
			int cant = servicios1.consultarCantGrupoBloque(aula);
			String nom = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			if (cant == 0) {
				accion1 = "<a href=\"javascript:asignar('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/table.png' /></a>";
			} else {
				accion1 = "<a href=\"javascript:asignar('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/tick.png' /></a>";
			}

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

			pw.println("    <td height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' >" + accion1 + "</td>"
				+ "    <td align='center' valign='middle' ><input name='' type='checkbox' value=''></td>"
				+ " </tr>");
			cont++;
		}

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

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

	private void listadoAulaTotalDirageAsiBlo(HttpServletRequest request, HttpServletResponse response) throws IOException {
		response.setContentType("text/html");
		PrintWriter pw = response.getWriter();
		pw.println("sasasa");
	}

	private void listarAulasBloque(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicio = new AulaServices();
		String codSede = request.getParameter("codSede");
		String codTipoCentro = request.getParameter("codTipoCentro");
		String codCentro = request.getParameter("codCentro");
		String codNivel = request.getParameter("codNivel");
		String codTipoGrado = request.getParameter("codTipoGrado");
		String codGrado = request.getParameter("codGrado");
		String codSeccion = request.getParameter("codSeccion");
		String codTurno = request.getParameter("codTurno");

		//------------------datos de paginacion---------------------------
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		int pagina = Integer.parseInt(request.getParameter("pagina"));

		ArrayList<Aula> lista = null;
		int inicio = (pagina - 1) * cantidad;
		int cantRegistro = 0;

		lista = servicio.listarAulasBloque(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno, inicio, cantidad);
		cantRegistro = servicio.cantlistarAulasBloque(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno);

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

		HorarioServices servicios1 = new HorarioServices();
		String accion1 = "";
		String edicion = "";

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"calculoPrevio();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-plus-circle icon-on-right bigger-110\"></i>\n"
			+ "                                               Asignar Bloque\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SECCIÓN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SELECIONE TODOS <br><a href=\"javascript:seleccionarTodo();\" class='regular' ><img src='imagenes/icons/check_box.png' /></a></th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">EDITAR</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont_ini = 0;
		int cont_fin = 0;
		int cont = inicio + 1;
		for (int i = 0; i < lista.size(); i++) {
			if (i == 0) {
				cont_ini = cont;
			}
			String aula = "" + lista.get(i).getCodigoAula();
			int cant = servicios1.consultarCantGrupoBloque(aula);
			String nom = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			if (cant == 0) {
				accion1 = "<input name='chk_" + cont + "' type='checkbox' value='" + aula + "'>";
				edicion = "---";
			} else {
				accion1 = "<a href=\"javascript:asignarHorario('" + lista.get(i).getCodigoAula() + "');\" class='regular' ><img src='imagenes/icons/zoom.png' /></a>";
				edicion = "<a href=\"javascript:editar('" + lista.get(i).getCodigoAula() + "');\" class='regular' ><img src='imagenes/icons/page_edit.png' /></a>";
			}

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

			pw.println("   <td align='center' height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' >" + accion1 + "  </td>"
				+ "    <td align='center' valign='middle' >" + edicion + "</td>"
				+ " </tr>");
			cont++;
		}

		cont_fin = cont - 1;

		if (cont == 1) {
			pw.println("<tr><td colspan='11' align='center'>No hay aulas registradas en secundaria</td></tr>");
		}

		int cantidad2 = cont - 1;

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

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

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

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

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

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

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

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

		pw.println("<input type='hidden' value='1' id='dato'/>"
			+ "<input type='hidden' value='" + cantidad2 + "' id='cantidad'/>"
			+ "<input type='hidden' value='" + pagina + "' id='numpagina'/>");

	}

	private void listarAulasHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicio = new AulaServices();
		Horario horario = new Horario();
		String codSede = request.getParameter("codSede");
		String codTipoCentro = request.getParameter("codTipoCentro");
		String codCentro = request.getParameter("codCentro");
		String codNivel = request.getParameter("codNivel");
		String codTipoGrado = request.getParameter("codTipoGrado");
		String codGrado = request.getParameter("codGrado");
		String codSeccion = request.getParameter("codSeccion");
		String codTurno = request.getParameter("codTurno");
		ArrayList<Aula> lista = null;
		//--------------datos de la paginacion ---------------

		int canti = Integer.parseInt(request.getParameter("cantidad"));
		int pagina = Integer.parseInt(request.getParameter("pagina"));

		int inicio = (pagina - 1) * canti;
		int cantRegistro = 0;

		//=============CALCULO DE PAGINADO=============
		lista = servicio.listarAulasHorario(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno, inicio, canti);
		cantRegistro = servicio.cantlistarAulasHorario(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno);

		int numero = cantRegistro / canti;
		int resto = cantRegistro % canti;
		if (resto > 0) {
			numero = numero + 1;
		}

		//listaGeneral=servicios.listaAulasDirage();
		/*else{
         //listaGeneral=servicios.listaAulasDirage(codigoLocal);  
         lista=servicios.listaAulasDirage(codigoLocal,inicio,cantidad); // consultar con el LIMIT inicio, cantidad
         cantRegistros = servicios.CantlistaAulasDirageSede(codigoLocal); // consultar la cantidad total sin LIMIT
         } */
		//------------------funciones de paginado------------------------------
		HorarioServices servicios1 = new HorarioServices();

		String accion1 = "";
		String accion2 = "";
		String accion3 = "";

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodo();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar todo\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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=\"2\" colspan=\"1\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SECCIÓN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TURNO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\">CANTIDAD DE CURSOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">ASIGNAR<br>HORARIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">EXPORTAR</th>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ASIGNADOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">FALTANTES</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont = inicio + 1;
		int cont_ini = 0;
		int cont_fin = 0;
		int cant = 0;
		int codigo = 0;
		int numCursos = 0;
		int sinAsignar = 0;
		for (int i = 0; i < lista.size(); i++) {
			if (i == 0) {
				cont_ini = cont;
			}
			// int total=lista.size();

			String aula = "" + lista.get(i).getCodigoAula();
			cant = servicios1.consultacantidadCursos(aula);
			codigo = servicios1.consultacantCursosSinAsignar(aula);
			numCursos = codigo * 6;
			sinAsignar = numCursos - cant;
			String nom = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			String nombreAula = lista.get(i).getNombreLocal() + " :: " + lista.get(i).getNombreTipoCentro() + " :: " + lista.get(i).getNombreCentro() + " :: " + lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: ";

			accion2 = "<b><font color='#062031'>Asignados:" + cant + "</font> <font color='red'>  Faltantes:" + sinAsignar + "</font> </b>";
			accion1 = "<a href=\"javascript:asignarHorario('" + lista.get(i).getCodigoAula() + "');\" class='regular' ><img src='imagenes/icons/calendar-task.png' /></a>";
			if (cant == 0) {
				accion3 = "---";
			} else {
				accion3 = "<a href=\"javascript:exportar('" + lista.get(i).getCodigoAula() + "','" + nombreAula + "','" + lista.get(i).getCodigoTurno() + "');\" class='regular' ><img src='imagenes/icons/export_excel.png' /></a>";
			}

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

			pw.println("   <td align='center' height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' ><b>" + cant + "</b></td>"
				+ "    <td align='center' valign='middle' ><b>" + sinAsignar + "</b></td>"
				+ "    <td align='center' valign='middle' >" + accion1 + "</td>"
				+ "    <td align='center' valign='middle' >" + accion3 + "</td>"
				+ " </tr>");
			cont++;
		}

		cont_fin = cont - 1;

		if (cont == 1) {
			pw.println("<tr><td colspan='13' align='center'>No hay aulas con bloques asignados</td></tr>");
		}

		int cantidad = cont - 1;

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

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

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

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

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

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

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

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

		pw.println("<input type='hidden' value='1' id='dato'/>"
			+ "<input type='hidden' value='" + cantidad + "' id='cantidad'/>");
	}

	private void crearSession(HttpServletRequest request, HttpServletResponse response) {
		Aula aula = new Aula();
		int codalua = Integer.parseInt(request.getParameter("codalua"));
		aula.setCodigoAula(codalua);
		HttpSession session_actual = request.getSession(true);
		session_actual.setAttribute("aula", aula);
	}

	private void consultarNomAula(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicios = new AulaServices();
		String codAula = request.getParameter("codAula");
		String aula = servicios.consultarAula(codAula);

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

	private void reporteAulasHorario(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicio = new AulaServices();
		Horario horario = new Horario();
		String codSede = request.getParameter("codSede");
		String periodo = request.getParameter("periodo");

		ArrayList<Aula> lista = null;

		HorarioServices servicios1 = new HorarioServices();

		String accion1 = "";
		String accion2 = "";
		String accion3 = "";
		//------------------------datos de paginacion--------------------------------
		int pagina = Integer.parseInt(request.getParameter("pagina"));
		int canti = Integer.parseInt(request.getParameter("cantidad"));

		int inicio = (pagina - 1) * canti;

		int cantRegistro = 0;
		lista = servicio.reporteAulasHorarioPeriodo(codSede, periodo, inicio, canti);
		cantRegistro = servicio.cantidadreporteAulasHorario(codSede, periodo);

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

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodo();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar todo\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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=\"2\" colspan=\"1\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SECCIÓN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TURNO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\">CANTIDAD DE CURSOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">VER HORARIO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">EXPORTAR</th>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ASIGNADOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">FALTANTES</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont = inicio + 1;
		int cant = 0;
		int codigo = 0;
		int numCursos = 0;
		int sinAsignar = 0;
		int cont_ini = 0;
		int cont_fin = 0;
		for (int i = 0; i < lista.size(); i++) {
			// int total=lista.size();
			if (i == 0) {
				cont_ini = cont;
			}
			String aula = "" + lista.get(i).getCodigoAula();
			cant = servicios1.consultacantidadCursos(aula, periodo);
			codigo = servicios1.consultacantCursosSinAsignar(aula, periodo);
			numCursos = codigo * 6;
			sinAsignar = numCursos - cant;

			String nom = lista.get(i).getNombreLocal() + " :: " + lista.get(i).getNombreTipoCentro() + " :: " + lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: " + lista.get(i).getNombreTurno() + "";
			String nombreAula = lista.get(i).getNombreLocal() + " :: " + lista.get(i).getNombreTipoCentro() + " :: " + lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: ";
			String nombreAula2 = lista.get(i).getNombreNivel() + " :: " + lista.get(i).getNombreTipoGrado() + " :: " + lista.get(i).getNombreGrado() + " :: " + lista.get(i).getNombreSeccion() + " :: ";
			if (cant > 0) {
				accion2 = "<b><font color='#062031'>Asignados:" + cant + "</font> <font color='red'>  Faltantes:" + sinAsignar + "</font> </b>";
				accion1 = "<a href=\"javascript:armarHorario('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/zoom.png' /></a>";
				accion3 = "<a href=\"javascript:exportar('" + lista.get(i).getCodigoAula() + "','" + lista.get(i).getNombreLocal() + "','" + lista.get(i).getNombreTipoCentro() + "','" + nombreAula2 + "','" + lista.get(i).getCodigoTurno() + "','" + lista.get(i).getCodigoLocal() + "');\" class='regular' ><img src='imagenes/icons/export_excel.png' /></a>";

			} else {
				accion2 = "<b><font color='#062031'>Asignados:" + cant + "</font> <font color='red'>  Faltantes:" + sinAsignar + "</font> </b>";
				accion1 = "<a href=\"javascript:armarHorario('" + lista.get(i).getCodigoAula() + "','" + nom + "');\" class='regular' ><img src='imagenes/icons/zoom.png' /></a>";
				accion3 = "--";

			}

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

			pw.println("   <td align='center' height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center' valign='middle' >" + cant + "</td>"
				+ "    <td align='center' valign='middle' >" + sinAsignar + "</td>"
				+ "    <td align='center' valign='middle' >" + accion1 + "</td>"
				+ "    <td align='center' valign='middle' >" + accion3 + "</td>"
				+ " </tr>");
			cont++;
		}

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

		int cantidad = cont - 1;

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

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

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

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

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

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

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

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

		pw.println("<input type='hidden' value='1' id='dato'/>"
			+ " <input type='hidden' value='" + cantidad + "' id='cantidad'/>");
	}

	private void listarAulasTotal(HttpServletRequest request, HttpServletResponse response) throws IOException {
		AulaServices servicio = new AulaServices();
		HorarioServices servicioH = new HorarioServices();
		String codSede = request.getParameter("codSede");
		String codTipoCentro = request.getParameter("codTipoCentro");
		String codCentro = request.getParameter("codCentro");
		String codNivel = request.getParameter("codNivel");
		String codTipoGrado = request.getParameter("codTipoGrado");
		String codGrado = request.getParameter("codGrado");
		String codSeccion = request.getParameter("codSeccion");
		String codTurno = request.getParameter("codTurno");
		String periodo = request.getParameter("periodo");

		//------------------datos de paginacion---------------------------
		int cantidad = Integer.parseInt(request.getParameter("cantidad"));
		int pagina = Integer.parseInt(request.getParameter("pagina"));

		ArrayList<Aula> lista = null;
		int inicio = (pagina - 1) * cantidad;
		int cantRegistro = 0;

		lista = servicio.listarAulasBloque(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno, inicio, cantidad);
		cantRegistro = servicio.cantlistarAulasBloque(codSede, codTipoCentro, codCentro, codNivel, codTipoGrado, codGrado, codSeccion, codTurno);

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

		HorarioServices servicios1 = new HorarioServices();
		String accion1 = "";
		String edicion = "";

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\"  >\n "
			+ "                           <table width=\"100%\" height=\"60\">"
			+ "             <tbody>"
			+ "                 <tr>"
			+ "                     <td>Listado de Aulas</td>"
			+ "                     <td align=\"right\">"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodoSede();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar horarios de la Sede\n"
			+ "                                           </button>"
			+ "                         <button class=\"btn btn-sm btn-warning\" onclick=\"exportarTodo();\" type=\"button\">\n"
			+ "                                               <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110\"></i>\n"
			+ "                                               Exportar todo\n"
			+ "                                           </button>"
			+ "                     </td>"
			+ "                     <td width=\"10\"></td>"
			+ "                 </tr>"
			+ "             </tbody>"
			+ "         </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=\"2\" colspan=\"1\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">CENTRO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">SECCIÓN</th>\n"
//			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">NOMBRE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">TURNO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">HISTORIAL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"2\">CANTIDAD DE CURSOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">ACCIÓN</th>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ASIGNADOS</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">FALTANTES</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");

		int cont_ini = 0;
		int cont_fin = 0;
		int cont = inicio + 1;
		int cantidadH = 0;
		int cantidadHCero = 0;
		String codAula = "";
		String Horario = "";
		String AccionH = "";
		String faltantes = "";
		String asignador = "";
		String historial = "";
		String nom = "";
		String nombreAula = "";

		for (int i = 0; i < lista.size(); i++) {
			if (i == 0) {
				cont_ini = cont;
			}
			codAula = "" + lista.get(i).getCodigoAula();

			//cantidadHCero = servicioH.cantidadHorarioCero(codAula, periodo);
			nom = " <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "<td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "<td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "<td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "<td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "<td>" + lista.get(i).getNombreGrado() + "</td>"
//				+ "<td>" + lista.get(i).getNombreSeccion() + "</td>"
								+ "<td>" + lista.get(i).getNombre() + "</td>"
				+ "<td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "<td width=50 align=center><a title=Remover class=regular href=javascript:remover(" + codAula + ");><img src=imagenes/icons/cross.png ></a> </td>";

			nombreAula = lista.get(i).getNombreLocal() + " :: "
				+ lista.get(i).getNombreTipoCentro() + " :: "
				+ lista.get(i).getNombreCentro() + " :: "
				+ lista.get(i).getNombreNivel() + " :: "
				+ lista.get(i).getNombreTipoGrado() + " :: "
				+ lista.get(i).getNombreGrado() + " :: "
//				+ lista.get(i).getNombreSeccion() + " :: ";
				+ lista.get(i).getNombre() + " :: ";

			cantidadH = servicioH.cantidadHorario(codAula, periodo);
			if (cantidadH > 0) {
				Horario datosHorario = null;
				datosHorario = servicioH.consultarDatosHorarioAula(codAula, periodo);
				Horario = "<a class=\"regular\" href=\"javascript:verHorario(1,'" + codAula + "','" + datosHorario.getH_codigoGrupo() + "');\" title='Ver horario'>"
					+ "     <i class=\"ace-icon fa fa-search icon-on-right bigger-110\"></i>"
					+ "</a> &nbsp;&nbsp; "
					+ "<a class=\"regular\" href=\"javascript:editar(1,'" + codAula + "','" + datosHorario.getH_codigoGrupo() + "');\" title='Editar'>"
					+ "     <i class=\"ace-icon fa fa-pencil icon-on-right bigger-110 orange\"></i>"
					+ "</a> &nbsp;&nbsp; "
					+ "<a class=\"regular\" href=\"javascript:exportar(1,'" + codAula + "','" + datosHorario.getH_codigoGrupo() + "','" + periodo + "');\" title='exportar'>"
					+ "     <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110 green\"></i>"
					+ "</a> &nbsp;&nbsp;"
					+ "<!--<a class=\"regular\" href=\"javascript:agregar('" + codAula + "','" + nom + "');\" title='Agregar'>"
					+ "     <i class=\"ace-icon fa fa-external-link  icon-on-right bigger-110 dark\"></i>"
					+ "</a>-->";
				//AccionH = "<i class=\"ace-icon fa fa-ban icon-on-right bigger-110\" title='Sin acción'></i>";
				int codBlo = servicioH.codigoBloque(datosHorario.getH_codigoGrupo());
				int asig = servicioH.cantidaCursosAsignados(codAula, periodo);
				Horario datosCadena = new Horario();
				datosCadena = servicioH.consultarCadenaGH(datosHorario.getH_codigoGrupo());

				String cadena = datosCadena.getCadena();
				String[] arrayCadena1 = cadena.split("!");
				int datoCadenaBloCant = 0;
				for (int x = 0; x < arrayCadena1.length; x++) {
					String[] arrayCadena2 = arrayCadena1[x].split("#");
					datoCadenaBloCant = datoCadenaBloCant + Integer.parseInt(arrayCadena2[0]);

				}

				int falta = datoCadenaBloCant - asig;

				faltantes = "<b>" + falta + "</b>";

				asignador = "<b>" + asig + "</b>";

			} else {
				Horario = "<a class=\"regular\" href=\"javascript:validar_armado_individual(1,'" + codAula + "');\" title='Agregar'>"
					+ "     <i class=\"ace-icon fa fa-calendar icon-on-right bigger-110 red\"></i>"
					+ "</a> &nbsp;&nbsp; "
					+ "<a class=\"regular\" href=\"javascript:agregar('" + codAula + "','" + nom + "');\" title='Agregar'>"
					+ "     <i class=\"ace-icon fa fa-external-link  icon-on-right bigger-110 green\"></i>"
					+ "</a>";

				faltantes = "<b>0</b>";
				asignador = "<b>0</b>";

			}

			int hist = servicioH.cantidaAulaConHistorial(codAula, periodo);
			if (hist > 0) {
				historial = "<a title=\"Ver historial\" class=\"regular\" href=\"javascript:historial('" + codAula + "');\">"
					+ "     <i class=\"ace-icon fa fa-clock-o icon-on-right bigger-110\"></i>"
					+ " </a> &nbsp;&nbsp; "
					+ " <a class=\"regular\" href=\"javascript:exportarHistorial('" + codAula + "');\" title='exportar'>"
					+ "     <i class=\"ace-icon fa fa-file-excel-o icon-on-right bigger-110 green\"></i>"
					+ " </a>";
			} else {
				historial = "<i class=\"ace-icon fa fa-ban icon-on-right bigger-110  \" ></i>";
			}

			pw.println("<tr>"
				+ "    <td align='center' height='30'>" + cont + "</td>"
				+ "    <td>" + lista.get(i).getNombreLocal() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreCentro() + "</td>"
				+ "    <td>" + lista.get(i).getNombreNivel() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTipoGrado() + "</td>"
				+ "    <td>" + lista.get(i).getNombreGrado() + "</td>"
//				+ "    <td align='center'>" + lista.get(i).getNombreSeccion() + "</td>"
				+ "    <td align='center'>" + lista.get(i).getNombre() + "</td>"
				+ "    <td>" + lista.get(i).getNombreTurno() + "</td>"
				+ "    <td align='center'> " + historial + " </td>"
				+ "    <td align='center'>" + asignador + "</td>"
				+ "    <td align='center'>" + faltantes + "</td>"
				+ "    <td align='center' valign='middle' > " + Horario + " </td>"
				+ " </tr>");
			cont++;
		}

		cont_fin = cont - 1;

		if (cont == 1) {
			pw.println("<tr><td colspan='11' align='center'>No hay aulas registradas en secundaria</td></tr>");
		}

		int cantidad2 = cont - 1;

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

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

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

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

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

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

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

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

		pw.println("<input type='hidden' value='1' id='dato'/>"
			+ "<input type='hidden' value='" + cantidad2 + "' id='cantidad'/>"
			+ "<input type='hidden' value='" + pagina + "' id='numpagina'/>");

		pw.println("<center><table>"
			+ "     <tr>"
			+ "         <td widht='300'>");

		pw.println("<br><br><div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\"  >\n"
			+ "         Leyenda"
			+ "                       </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\">ICONO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"2\" colspan=\"1\">DESCRIPCIÓN</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-clock-o bigger-110 blue\"></i></td>\n"
			+ "                                           <td>El icono sirve para visualizar historial de movimientos del horario.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-file-excel-o bigger-110 green\"></i></td>\n"
			+ "                                           <td>El icono sirve para exportar tanto el historial como el horario del aula seleccionada.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-calendar  bigger-110 red\"></i></td>\n"
			+ "                                           <td>El icono sirve para armar un nuevo horario individual para el aula seleccionada.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-external-link  bigger-110 green\"></i></td>\n"
			+ "                                           <td>El icono sirve para agregar al grupo de aulas para la generacion del horario en grupos.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-search  bigger-110 blue\"></i></td>\n"
			+ "                                           <td>El icono sirve para visualizar el horario del aula seleccionada.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-pencil  bigger-110 orange\"></i></td>\n"
			+ "                                           <td>El icono sirve para realizar una edición en el horario del aula seleccionada.</td>\n"
			+ "                                       </tr>\n"
			+ "                                       <tr>\n"
			+ "                                           <td align='center'><i class=\"ace-icon fa fa-ban  bigger-110 dark\"></i></td>\n"
			+ "                                           <td>El icono indica que no se puede realizar alguna acción.</td>\n"
			+ "                                       </tr>\n"
			+ "                                   </tbody>\n"
			+ "                                   </thead>\n"
			+ "                                   </div>");

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

	}

	private void listarTablaAula(HttpServletRequest request, HttpServletResponse response) throws IOException {
		String codigoPeriodo = request.getParameter("codigoPeriodo");
		String codigoSede = request.getParameter("codigoSede");

		ArrayList<Aula> lista = null;
		AulaServices servicioAula = new AulaServices();
		lista = servicioAula.listadoAulas(codigoSede, codigoPeriodo);

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

		pw.println("<div style=\"border: 1px solid #CCCCCC;\">\n"
			+ "                       <div class=\"table-header\">\n"
			+ "                           <table width='100%' >"
			+ "                                   <tr>"
			+ "                                       <td>Listado de aulas</td>"
			+ "                                       <td width='10px'></td>"
			+ "                                   </tr>"
			+ "                           </table>"
			+ "                       </div>\n"
			+ "                       <div>\n"
			+ "                           <div class=\"dataTables_wrapper form-inline no-footer\" id=\"sample-table-2_wrapper\">\n"
			+ "                               <!--<div class=\"row\">\n"
			+ "                                   <div class=\"col-xs-12\">\n"
			+ "                                       <div class=\"dataTables_length\" id=\"sample-table-2_length\"></div>\n"
			+ "                                   </div>\n"
			+ "                               </div>-->\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\" >N°</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SEDE</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">NIVEL</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TIPO GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">GRADO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">SECCIÓN</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">TURNO</th>\n"
			+ "                                           <th tabindex=\"0\" class=\"center\" rowspan=\"1\" colspan=\"1\">ACCIÓN</th>\n"
			+ "                                       </tr>\n"
			+ "                                   </thead>\n"
			+ "                                   <tbody>");
		int cont = 1;
		for (int i = 0; i < lista.size(); i++) {
			int codigoAula = lista.get(i).getCodigoAula();
			String nombreSede = lista.get(i).getNombreLocal();
			String nombreNivel = lista.get(i).getNombreNivel();
			String nombreTipoGrado = lista.get(i).getNombreTipoGrado();
			String nombreGrado = lista.get(i).getNombreGrado();
			String nombreSeccion = lista.get(i).getNombreSeccion();
			String nombreTurno = lista.get(i).getNombreTurno();

			pw.println("                                    <tr>");
			pw.println("                                        <td class='text-center'>" + cont + "</td>");
			pw.println("                                        <td>" + nombreSede + "</td>");
			pw.println("                                        <td>" + nombreNivel + "</td>");
			pw.println("                                        <td>" + nombreTipoGrado + "</td>");
			pw.println("                                        <td>" + nombreGrado + "</td>");
			pw.println("                                        <td>" + nombreSeccion + "</td>");
			pw.println("                                        <td>" + nombreTurno + "</td>");
			pw.println("                                        <td class='text-center'><a href=\"javascript:verificarHorario('" + codigoAula + "');\" class=\"regular\"><img src=\"imagenes/icons/table_add.png\"></a></td>");
			pw.println("                                    </tr>");
			cont++;
		}

		if (lista.size() == 0) {
			pw.println("                                    <tr class='text-center'><td colspan='8'>No hay aulas con horario para este periodo</td></tr>");
		}

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

}
