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

include ("conexion.php");

	$alumno=$_GET['Alumno'];
		
	$cons="SELECT CvePersonal,ApePersonal,NomPersonal,semestre,grupo FROM personal WHERE CvePersonal='$alumno'";
	$res=mysql_query($cons,$conex) or die ("NO SE REALIZO CONS");
	$ape=mysql_result($res,0,'ApePersonal');
	$nom=mysql_result($res,0,'NomPersonal');
	$sem=mysql_result($res,0,'semestre');
	$gpo=mysql_result($res,0,'grupo');
	
	$nombre=$nom." ".$ape;
?>
<!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>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="ucaestilos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {font-size: 14px}
-->
</style>
</head>

<body>
  <table width="950" border="0" align="center">
    <tr>
      <td><p class="style10">ASIGNACI&Oacute;N DE MATERIAS :. </p>      </td>
    </tr>
    <tr>
      <td><HR /></td>
    </tr>
    <tr>
      <td>
      <div align="center">
                        <?php if (isset($_GET['error']))
      $error=$_GET['error'];
 {

	if (isset ($error))
	 {
				  $error=$_GET['error'];
				  
				  if($error==1)
				  {
				  echo "<p class='style3'>ĦRequiere seleccionar materias!</p>";
				  }
	}

}
  ?>

      </div>
      <table width="100%" height="0" border="0" cellpadding="0" cellspacing="10">
        <tr>
          <td width="46%" valign="top"><div align="right" class="style4">
              <div align="left" class="style10">DATOS DEL ALUMNO:</div>
          </div>
              <p> <span class="style4">Matr&iacute;cula: </span><span class="style9"><?php echo $alumno; ?></span><br />
                  <span class="style4">Nombre: </span><span class="style9"><?php echo utf8_encode($nombre); ?></span><br />
                  <span class="style4">Semestre: </span><span class="style9"><?php echo $sem; ?></span><br />
                  <span class="style4">Grupo: </span><span class="style9"><?php echo $gpo; ?></span></p>
            <div align="left" class="style10">MATERIAS ASIGNADAS ACTUALMENTE:</div>
            <p>
              <?php
	  
echo "<table align='center' cellpadding='2' class='tablaBordes' width='100%'>";
echo "<tr class='tablaCabecera' align='center'>";
echo "<td>ID</td>";
echo "<td>Materia</td>";
echo "<td>Eliminar</td>";
echo "</tr>";

			$query="SELECT * FROM asignacionmaterias WHERE idAlumno='$alumno'";
			$result=mysql_query($query,$conex) or die ("No se consultaron las materias");
			$numero_filas=mysql_num_rows($result);
			$numero_campos= mysql_num_fields($result);
			while($fila = mysql_fetch_array($result))
			{
				echo "<tr>";
				
				//ID
				echo "<td class='style1' align='center'>";
				echo $fila[1];
				echo "</td>";
				
				//materia
				$cons2="SELECT materia FROM materias WHERE idMateria ='$fila[1]'";
				$res2=mysql_query($cons2,$conex) or die ("No se consulto nombre de materia");
				$nommateria=mysql_result($res2,0,'materia');
				
				echo "<td class='style1'>";
				echo $nommateria;
				echo "</td>";
				
				//Eliminar
				echo "<td class='style4' align='center'>";
				echo "<a href='deletemateriaalumno.php?materia=".$fila[1]."&Alumno=".$alumno."'> <img src='img/icon_delete.jpg' border='0' ALT='Quitar materia'></a>";
				echo "</td>";

				
				echo "</tr>";
			}
echo "</table>";
mysql_free_result($res);

?>
            </p></td>
          <td width="54%" valign="top" bgcolor="#E9E9E9" ><form id="form1" name="form1" method="post" action="svasignacion.php">
              <p class="style10">Selecciona materias por asignar:</p>
              <p>
                <?php
	  
	  
echo "<table align='center' cellpadding='2' class='tablaBordes' width='90%'>";
echo "<tr class='tablaCabecera' align='center'>";

echo "<td>Seleccionar</td>";
echo "<td>ID</td>";
echo "<td>Materia</td>";


echo "</tr>";


			$query="SELECT * FROM materias ORDER BY materia";
			$result=mysql_query($query,$conex) or die ("No se consultaron las materias");
			$numero_filas=mysql_num_rows($result);
			$numero_campos= mysql_num_fields($result);
			while($fila = mysql_fetch_array($result))
			{
				echo "<tr style='background-color:#FFF;'>";
				
				//IMPRIMO CHECKBOX
				echo "<td class='style1' align='center'>";
				echo "<input name='materias[]' type='checkbox' value='".$fila[0]."' >";
				echo "</td>";
				
				//ID
				echo "<td class='style1' align='center'>";
				echo $fila[0];
				echo "</td>";
				
				//materia
				echo "<td class='style1'>";
				echo utf8_encode($fila[1]);
				echo "</td>";
				
				echo "</tr>";
			}
echo "</table>";

?>
                            </p>
              <input name="matricula" type="hidden" id="matricula" value="<?php echo $alumno; ?>" />
              <table width="100" border="0" align="center" cellpadding="0" cellspacing="10">
                <tr>
                  <td><input name="button" type="button" class="boton2" id="button" onClick="javascript:history.back()" value="Cancelar y regresar" /></td>
                  <td><input name="button2" type="submit" class="boton2" id="button2" value="Asignar seleccionados" /></td>
                </tr>
              </table>
          </form></td>
        </tr>
      </table></td>
    </tr>
  </table>
</body>
</html>
