<?php require_once('Connections/cn.php'); ?>
<?php
session_start();
//Impide que la página sea vista desde el navegador.
	if (!isset($_SESSION['MM_Username'])) {
      	header ("Location: modulos/inicio/index.php");
	  }
$cedula_usuario=$_SESSION['CEDULA_USUARIO'];

mysql_select_db($database_cn, $cn);
$query_rstAlumnos = "SELECT alumnos.id_alumno, alumnos.apellidos, alumnos.nombres FROM alumnos WHERE cedula='$cedula_usuario'";
$rstAlumnos = mysql_query($query_rstAlumnos, $cn) or die(mysql_error());
$row_rstAlumnos = mysql_fetch_assoc($rstAlumnos);
$totalRows_rstAlumnos = mysql_num_rows($rstAlumnos);
$id_alumno=$row_rstAlumnos['id_alumno'];

mysql_select_db($database_cn, $cn);
$query_rstCarreras = "Select
carreras.nombre_carrera,
historial_alumnos.id_carrera
From
carreras
Inner Join historial_alumnos ON historial_alumnos.id_carrera = carreras.id_carrera
Where
historial_alumnos.id_alumno = '$id_alumno'";
$rstCarreras = mysql_query($query_rstCarreras, $cn) or die(mysql_error());
$row_rstCarreras = mysql_fetch_assoc($rstCarreras);
$totalRows_rstCarreras = mysql_num_rows($rstCarreras);
mysql_select_db($database_cn, $cn);
// Cargo los datos de los Alumnos.

$query_rstSedes = "Select
sedes.nombre_sede,
historial_alumnos.sede
From
sedes
Inner Join historial_alumnos ON historial_alumnos.sede = sedes.codigo
Where
historial_alumnos.id_alumno = '$id_alumno'";
$rstSedes = mysql_query($query_rstSedes, $cn) or die(mysql_error());
$row_rstSedes = mysql_fetch_assoc($rstSedes);
$totalRows_rstSedes = mysql_num_rows($rstSedes);
mysql_select_db($database_cn, $cn);

$query_rstPeriodos = "Select
periodos.codigo,
historial_alumnos.id_periodo
From
periodos
Inner Join historial_alumnos ON historial_alumnos.id_periodo = periodos.id_periodo
Where
historial_alumnos.id_alumno = '$id_alumno'";
$rstPeriodos = mysql_query($query_rstPeriodos, $cn) or die(mysql_error());
$row_rstPeriodos = mysql_fetch_assoc($rstPeriodos);
$totalRows_rstPeriodos = mysql_num_rows($rstPeriodos);


			
// Datos de las Carreras.

  if (isset($_GET["order"])) $order = @$_GET["order"];
  if (isset($_GET["type"])) $ordtype = @$_GET["type"];

  if (isset($_POST["filter"])) $filter = @$_POST["filter"];
  if (isset($_POST["filter_field"])) $filterfield = @$_POST["filter_field"];
  $wholeonly = false;
  if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"];

  if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"];
  if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"];
  if (!isset($filter) && isset($_SESSION["filter"])) $filter = $_SESSION["filter"];
  if (!isset($filterfield) && isset($_SESSION["filter_field"])) $filterfield = $_SESSION["filter_field"];

?>

<html>
<head>
<title>sadce -- carga de calificaciones</title>
<meta name="generator" http-equiv="content-type" content="text/html">
<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #FFFFCF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
<script src="jquery.min.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
</head>

<body>
<table class="bd" width="100%" align="center"><tr><td class="hr"><h2 align="left">Abono a Deuda</h2></td></tr></table>
<form name="situacion" method="post" action="">
  <table width="70%" border="0" align="center" id="carga" cellpadding="1" cellspacing="10" style="border:1px solid #ccc;">
    
    <tr>
      <td width="58">Alumno:</td>
      <td colspan="4"><label>
       <div align="left">
         <select name="id_alumno" style="width:500px">
           <?php
do {  
?>
           <option value="<?php echo $row_rstAlumnos['id_alumno']?>"><?php echo $row_rstAlumnos['apellidos'].', '.$row_rstAlumnos['nombres']?></option>
           <?php
} while ($row_rstAlumnos = mysql_fetch_assoc($rstAlumnos));
  $rows = mysql_num_rows($rstAlumnos);
  if($rows > 0) {
      mysql_data_seek($rstAlumnos, 0);
	  $row_rstAlumnos = mysql_fetch_assoc($rstAlumnos);
  }
?>
         </select> 
        </div>
      </label></td>
    </tr>
    <tr>
      <td><div align="left">Carrera:</div></td>
      <td colspan="4"><label>
        <div align="left">
          <select name="id_carrera" style="width:500px">
            <?php
do {  
?>
            <option value="<?php echo $row_rstCarreras['id_carrera']?>"><?php echo $row_rstCarreras['nombre_carrera']?></option>
            <?php
} while ($row_rstCarrera = mysql_fetch_assoc($rstCarreras));
  $rows = mysql_num_rows($rstCarreras);
  if($rows > 0) {
      mysql_data_seek($rstCarreras, 0);
	  $row_rstCarreras = mysql_fetch_assoc($rstCarreras);
  }
?>
          </select>
          </div>
      </label></td>
    </tr>
    <tr>
      <td>Sede:</td>
      <td colspan="2"><select name="id_sede" >
        <?php
do {  
?>
        <option value="<?php echo $row_rstSedes['sede']?>"><?php echo $row_rstSedes['nombre_sede']?></option>
        <?php
} while ($row_rstSedes = mysql_fetch_assoc($rstSedes));
  $rows = mysql_num_rows($rstSedes);
  if($rows > 0) {
      mysql_data_seek($rstSedes, 0);
	  $row_rstSedes = mysql_fetch_assoc($rstSedes);
  }
?>
      </select></td>
      <td width="132"><div align="right">Periodo</div></td>
      <td width="198"><div align="left">
        <select name="id_periodo" >
          <?php
do {  
?>
          <option value="<?php echo $row_rstPeriodos['id_periodo']?>"><?php echo $row_rstPeriodos['codigo']?></option>
          <?php
} while ($row_rstPeriodos = mysql_fetch_assoc($rstPeriodos));
  $rows = mysql_num_rows($rstPeriodos);
  if($rows > 0) {
      mysql_data_seek($rstPeriodos, 0);
	  $row_rstPeriodos = mysql_fetch_assoc($rstPeriodos);
  }
?>
        </select>
      </div></td>
    </tr>
    
    <tr>
      <td height="34" colspan="5"><div align="center">
        <label>
        <input name="Enviar" type="button" id="Enviar" value="Consultar" onClick="abonar()" >
        </label>
      </div></td>
    </tr>
  </table>
    <div align="center"></div>
    <div align="center"></div>
    <div align="center"></div>
  <div align="center"></div>
</form>
<p>&nbsp;</p>
<?php
?>
</body>
</html>
<?php
mysql_free_result($rstAlumnos);

mysql_free_result($rstCarreras);
?>

<script type="text/javascript">
 function abonar()
 {  
 
    window.document.location="abono_alumno.php?carrera="+document.situacion.id_carrera.value+"&alumno="+document.situacion.id_alumno.value;
 
 	
	//window.location=url;
 }
</script>
