<?php
	session_start();

			include 'SQL/conexion.php';

			$lvl=$_GET["lvl"];
			$sql = "SELECT CV_CCT as Clave, ".($lvl=="Superior"?"MUNICIPIO":$lvl=="Media"?"MUNICIPIO":"C_NOM_MUN")." as Municipio, NOMBRECT as Institucion, COUNT(respuesta.id_respuesta) AS Respuestas FROM ".$lvl." LEFT JOIN respuesta ON CV_CCT = respuesta.clave_escuela GROUP BY CV_CCT, NOMBRECT;";
//			$result = $conn->query($sql)

	
	if (!isset($_SESSION["userType"]) || $_SESSION["userType"] != 965){

?>

					<!-- Nested Row within Card Body -->
					<div class="row align-center" >
						<div class="col-xl-4 col-md-6 col-centered">
							<div class="p-5">
								<div class="text-center">
									<i class="fas fa-user-lock fa-4x"></i>
									<h1 class="h4 text-gray-900 mb-4">Login as root</h1>
									<?php
										/*
											if($_SESSION["userType"] == -1)
												echo '<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Ingresa el nombre de usuario</div>';
											else if($_SESSION["userType"] == -2)
												echo '<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Nombre de usuario incorrecto</div>';
											else if($_SESSION["userType"] == -3)
												echo '<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Ingresa la incorrecta</div>';
											else if($_SESSION["userType"] == -4)
												echo '<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Contraseña incorrecta</div>';
										*/
										if($_SESSION["userType"] < 0)
											echo '<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Nombre de usuario y contraseña incorrectos</div>';
												

											
									?>									
								</div>
								<form id="lform" class="user" action="/#cf" method="post">
									<div class="form-group">
										<input type="username" class="form-control form-control-user" name="username" id="username" aria-describedby="userHelp" placeholder="Enter you Username...">
									</div>
									<div class="form-group">
										<input type="password" class="form-control form-control-user" name="password" id="password" placeholder="Password">
									</div>
									<a href="#cf" class="btn btn-primary btn-user btn-block" onclick="$('#lform').submit();">
										Login
									</a>
								</form>
							</div>
						</div>
					</div>
					
					
					<script>
					$('#username').focus();
					
					$('input').keydown( function(e) {
							var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
							if(key == 13) {
								e.preventDefault();
								var inputs = $(this).closest('form').find(':input:visible');
								if(inputs.eq( inputs.index(this)+ 1 ).length){
									inputs.eq( inputs.index(this)+ 1 ).focus();
								}else{
									$('#lform').submit();
								}
							}
						});				
					
					</script>
					
<?php
	}else{
		echo "<script> UpdatePage('config.php') </script>";
	}
?>
