<?php
if (isset($_SESSION['usuario'])){
$user=$_SESSION['usuario'];
}
else{
?>
<script>
location.href="index.php?errorusuario=3";
</script>
<?php }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
<script>
function nuevo()
{window.open ('nvousuario.php');}

function enviarstatus()
{	
 status=document.getElementById('status').value;	
 location.href='main.php?a=474&status='+status;
}
</script>
</head>

<body>
<table width="950" border="0" align="center">
  <tr>
    <td><span class="style10">ALUMNOS</span></td>
  </tr>
  <tr>
    <td><table width="100%" height="0" border="0" cellpadding="0" cellspacing="10">
      <tr>
         <td width="10%" valign="top"><form id="form3" name="form3" method="post" action="main.php?a=4741">
          <input name="Submit2" type="submit" class="boton2" value="Nuevo Alumno" />
        </form>        </td>
        <td width="10%" valign="top">&nbsp;</td>
        <td width="80%" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3" align="center" valign="top"><hr width="100%" size="1" noshade="noshade" color="#0D3356"></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="10">
  <tr>
    <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><span class="style10">Listado de Alumnos</span>

          <p class="linkabc"><a href="main.php?a=474&amp;letra=a" class="linkabc">A</a> <a href="main.php?a=474&amp;letra=b" class="linkabc">B</a> <a href="main.php?a=474&amp;letra=c" class="linkabc">C</a> <a href="main.php?a=474&amp;letra=d" class="linkabc">D</a> <a href="main.php?a=474&amp;letra=e" class="linkabc">E</a> <a href="main.php?a=474&amp;letra=f" class="linkabc">F</a> <a href="main.php?a=474&amp;letra=g" class="linkabc">G</a> <a href="main.php?a=474&amp;letra=h" class="linkabc">H</a> <a href="main.php?a=474&amp;letra=i" class="linkabc">I</a> <a href="main.php?a=474&amp;letra=j" class="linkabc">J</a> <a href="main.php?a=474&amp;letra=k" class="linkabc">K</a> <a href="main.php?a=474&amp;letra=l" class="linkabc">L</a> <a href="main.php?a=474&amp;letra=m" class="linkabc">M</a> <a href="main.php?a=474&amp;letra=n" class="linkabc">N</a> <a href="main.php?a=474&amp;letra=&ntilde;" class="linkabc">&Ntilde;</a> <a href="main.php?a=474&amp;letra=o" class="linkabc">O</a> <a href="main.php?a=474&amp;letra=p" class="linkabc">P</a> <a href="main.php?a=474&amp;letra=q" class="linkabc">Q</a> <a href="main.php?a=474&amp;letra=r" class="linkabc">R</a> <a href="main.php?a=474&amp;letra=s" class="linkabc">S</a> <a href="main.php?a=474&amp;letra=t" class="linkabc">T</a> <a href="main.php?a=474&amp;letra=u" class="linkabc">U</a> <a href="main.php?a=474&amp;letra=v" class="linkabc">V</a> <a href="main.php?a=474&amp;letra=w" class="linkabc">W</a> <a href="main.php?a=474&amp;letra=x" class="linkabc">X</a> <a href="main.php?a=474&amp;letra=y" class="linkabc">Y</a> <a href="main.php?a=474&amp;letra=z" class="linkabc">Z</a>

                 <!-- <select name="select" class="cuadrotexto" id="select">
                    <option value="A" selected="selected">A</option>
                    <option value="B">B</option>
                    <option value="C">C</option>
                    <option value="D">D</option>
                    <option value="E">E</option>
                    <option value="F">F</option>
                    <option value="G">G</option>
                    <option value="H">H</option>
                    <option value="I">I</option>
                    <option value="J">J</option>
                    <option value="K">K</option>
                    <option value="L">L</option>
                    <option value="M">M</option>
                    <option value="N">N</option>
                    <option value="&Ntilde;">&Ntilde;</option>
                    <option value="O">O</option>
                    <option value="P">P</option>
                    <option value="Q">Q</option>
                    <option value="R">R</option>
                    <option value="S">S</option>
                    <option value="T">T</option>
                    <option value="U">U</option>
                    <option value="V">V</option>
                    <option value="W">W</option>
                    <option value="X">X</option>
                    <option value="Y">Y</option>
                    <option value="Z">Z</option>
                  </select>
                  -->
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="main.php?a=474&semestre">Ordenar por Semestre</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Estatus:&nbsp;&nbsp;<select name="status" class="cuadrotexto" id="status" onChange="enviarstatus()" >
                	  <option value="0" selected>Seleccione</option>
                      <option value="Activo">Activo</option>
                      <option value="Inactivo">Inactivo</option>
                      <option value="Baja">Baja</option>
                      <option value="Egresado">Egresado</option>
                    </select></p>
          <div>
<?php
echo "<table align='center' cellpadding='2' class='tablaBordes' width='100%'>";
echo "<tr class='tablaCabecera' align='center'>";

echo "<td width='100'>Matr&iacute;cula</td>";
echo "<td>Nombre</td>";
echo "<td width='60'>Estatus</td>";
echo "<td width='50'>Semestre</td>";
echo "<td width='50'>Grupo</td>";
echo "<td width='80'>Asignar<br>materias</td>";
echo "<td width='80'>Materias<br>asignadas</td>";
echo "<td width='80'>Modificar<br>datos</td>";
//echo "<td width='50'>Eliminar</td>";

echo "</tr>";
include ("conexion.php");
if (isset($_GET['letra']))
{	
	$letra=$_GET['letra'];
	$cons2="SELECT CvePersonal,ApePersonal,NomPersonal,semestre,grupo,status FROM personal WHERE ApePersonal like '$letra%' AND status = 'Activo' ORDER BY ApePersonal";
}
else
{
	$cons2="SELECT CvePersonal,ApePersonal,NomPersonal,semestre,grupo,status FROM personal WHERE status =    'Activo' ORDER BY semestre ASC,ApePersonal  ASC";	
}

if (isset($_GET['status']))
{	
	$est=$_GET['status'];
	$cons2="SELECT CvePersonal,ApePersonal,NomPersonal,semestre,grupo,status FROM personal WHERE status = '$est' ORDER BY ApePersonal ASC";
}


if (isset($_GET['semestre']))
{	
	$cons2="SELECT CvePersonal,ApePersonal,NomPersonal,semestre,grupo,status FROM personal WHERE status =    'Activo' ORDER BY semestre  ASC,ApePersonal ASC";
}

$res2=mysql_query($cons2,$conex) or die ("No se realizo con exito la consulta de Alumnos");
$numero_filas=mysql_num_rows($res2);
$numero_campos= mysql_num_fields($res2);
while ($fila=mysql_fetch_row($res2)){				  

echo "<tr class='tablaBordes'>";

echo "<td class='style1' align='center'>";
echo $fila[0];
echo "</td>";

echo "<td class='style1'>";
echo $fila[1]." ".$fila[2];
echo "</td>";

echo "<td class='style1' align='center'>";
echo $fila[5];
echo "</td>";

echo "<td class='style1' align='center'>";
echo $fila[3];
echo "</td>";

echo "<td class='style1' align='center'>";
echo $fila[4];
echo "</td>";

//ASIGNAR MATERIAS
echo "<td class='style4' align='center'>";
echo "<a href='main.php?a=4742&Alumno="; echo $fila[0]; echo "'> <img src='img/icon_new.jpg' border='0' ALT='Editar alumno'> </a>";
echo "</td>";

//MATERIAS YA ASIGNADAS
$cons3="SELECT count(idMateria) as total FROM asignacionmaterias WHERE idAlumno='$fila[0]'";
$res3=mysql_query($cons3,$conex) or die ("No se realizó la consulta de materias");
$total=mysql_result($res3,0,'total');
if($total==0){$asignadas="";}
else{$asignadas=$total;}

echo "<td class='style1' align='center'>";
echo $asignadas;
echo "</td>";

//EDITAR DATOS
echo "<td class='style4' align='center'>";
echo "<a href='main.php?a=4743&Alumno="; echo $fila[0]; echo "'> <img src='img/icon_edit.jpg' border='0' ALT='Modificar datos del alumno'> </a>";
echo "</td>";

//Eliminar
/*
echo "<td class='style4' align='center'>";
echo "<a href='deletealumno.php?matricula="; echo $fila[0]; echo "'> <img src='img/icon_delete.jpg' border='0' ALT='Eliminar alumno'> </a>";
echo "</td>";
*/
echo "</tr>";
}
echo "</table>";
?>
            </div>          </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>