<?php require_once('Connections/conn.php'); ?>
<?php
session_start();
$cedula_usuario=$_SESSION['CEDULA_USUARIO'];
$sede_usuario=$_SESSION['SEDE_USUARIO'];
 
header("Content-Type:text/html; charset=utf-8");

mysql_select_db($database_conn, $conn);
mysql_query ("SET NAMES 'utf8'");
$query_rstDocentes = "SELECT docentes.id_docente, docentes.apellidos,docentes.nombres FROM docentes ORDER BY apellidos,nombres";
$rstDocentes = mysql_query($query_rstDocentes, $conn) or die(mysql_error());
$row_rstDocentes = mysql_fetch_assoc($rstDocentes);
$totalRows_rstDocentes = mysql_num_rows($rstDocentes);

if($sede_usuario=='14'){
   $query_rstSede = "SELECT sedes.codigo, sedes.nombre_sede FROM sedes  ORDER BY sedes.nombre_sede";
 }
 else{
   $query_rstSede = "SELECT sedes.codigo, sedes.nombre_sede FROM sedes WHERE codigo='$sede_usuario'";
 
}  
$rstSede = mysql_query($query_rstSede, $conn) or die(mysql_error());
$row_rstSede = mysql_fetch_assoc($rstSede);
$totalRows_rstSede = mysql_num_rows($rstSede);


$query_rstPeriodos = "SELECT  periodos.id_periodo, periodos.codigo FROM periodos ORDER BY periodos.id_periodo desc";
$rstPeriodos = mysql_query($query_rstPeriodos, $conn) or die(mysql_error());
$row_rstPeriodos = mysql_fetch_assoc($rstPeriodos);
$totalRows_rstPeriodos = mysql_num_rows($rstPeriodos);



$query_rstMaterias = "SELECT materias.id_materia, materias.nombre_materia FROM materias ORDER BY materias.nombre_materia";
$rstMaterias = mysql_query($query_rstMaterias, $conn) or die(mysql_error());
$row_rstMaterias = mysql_fetch_assoc($rstMaterias);
$totalRows_rstMaterias = mysql_num_rows($rstMaterias);


$query_rstSecciones = "SELECT secciones.id_seccion FROM secciones";
$rstSecciones = mysql_query($query_rstSecciones, $conn) or die(mysql_error());
$row_rstSecciones = mysql_fetch_assoc($rstSecciones);
$totalRows_rstSecciones = mysql_num_rows($rstSecciones);


$query_rstCarreras = "SELECT id_carrera, nombre_carrera FROM carreras ORDER BY nombre_carrera";
$rstCarreras = mysql_query($query_rstCarreras, $conn) or die(mysql_error());
$row_rstCarreras = mysql_fetch_assoc($rstCarreras);
$totalRows_rstCarreras = mysql_num_rows($rstCarreras);



 session_start();
  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 -- imprime deuda</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>
</head>
<body>
<table class="bd" width="100%" align="center"><tr><td class="hr"><h2 align="left">Relación de Deudas </h2></td></tr></table>
<form name="form1" method="post" action="">
  <table width="40%" border="0" align="center" id="carga" cellpadding="1" cellspacing="10" style="border:1px solid #ccc;">
    
    <tr>
      <td width="74"><div align="right">Sede:</div></td>
      <td width="290"><select name="sede" id="sede">
         <option value="0">Seleccione...</option>
        <?php
do {  
?>
        <option value="<?php echo $row_rstSede['codigo']?>"><?php echo $row_rstSede['nombre_sede']?></option>
        <?php
} while ($row_rstSede = mysql_fetch_assoc($rstSede));
  $rows = mysql_num_rows($rstSede);
  if($rows > 0) {
      mysql_data_seek($rstSede, 0);
	  $row_rstSede = mysql_fetch_assoc($rstSede);
  }
?>
      </select>
      <div align="left"></div></td>
	  </tr>
	  <tr>
      <td width="74"><div align="right">Cohorte:</div></td>
      <td colspan="3"><select name="id_periodo" id="id_periodo" >
	   <option value="0">Todas las cohortes...</option>
          <?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($rstPeridos);
  }
?>
        </select>
        &nbsp;&nbsp;Secci&oacute;n:<label>
        <select name="seccion" id="seccion" >
          <option value="0">Todas...</option>
          <option value="A">A</option>
          <option value="B">B</option>
          <option value="C">C</option>
          <option value="D">D</option>
          <option value="E">E</option>
		  <option value="U">U</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
        </select></label>
        <div align="right"></div>      </td>
    </tr>
    <tr>
      <td><div align="right">Programa:</div></td>
      <td colspan="3"><label>
        <select name="id_carrera" id="id_carrera" style="width:580px">
		 <option value="0">Todos los programas...</option>
          <?php
do {  
?>
          <option value="<?php echo $row_rstCarreras['id_carrera']?>"><?php echo $row_rstCarreras['nombre_carrera']?>&nbsp;&nbsp;(CÓDIGO&nbsp;<?php echo $row_rstCarreras['id_carrera']?>)</option>
          <?php
} while ($row_rstCarreras = mysql_fetch_assoc($rstCarreras));
  $rows = mysql_num_rows($rstCarreras);
  if($rows > 0) {
      mysql_data_seek($rstCarreras, 0);
	  $row_rstCarreras = mysql_fetch_assoc($rstCarreras);
  }
?>
        </select>
      </label></td>
    </tr>
    
    <tr>
      <td height="34" colspan="4"><div align="center">
        <label>
        <input name="Enviar" type="button" id="Enviar" value="Imprimir Relaci&oacute;n" onClick="imprimir()" >
        </label>
      </div></td>
    </tr>
  </table>
    <div align="center"></div>
  <div align="center"></div>
</form>
<p>&nbsp;</p>
</body>

 <script type="text/javascript">
	var nav4 = window.Event ? true : false;
	function soloNum(evt)
	{	
	// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57, ','= 44, '.'= 46
		var key = nav4 ? evt.which : evt.keyCode;	
		//var str=obj.value;
	
		return (key == 8 || key == 13 || (key >= 48 && key <= 57));
	}
	
	
	
</script>
 <?php
mysql_free_result($rstDocentes);

mysql_free_result($rstSede);

mysql_free_result($rstPeriodos);

mysql_free_result($rstMaterias);

mysql_free_result($rstSecciones);

mysql_free_result($rstCarreras);
?>

<script type="text/javascript">
 function imprimir()
 {
    if(document.form1.sede.value==0){
	   alert("El campo <<Sede>> es obligatorio");
	   document.form1.sede.focus();
	   return false;
	}
 	url="modelo/class_pdf/relacion_deuda.php?sede="+document.form1.sede.value+"&carrera="+document.form1.id_carrera.value+"&id_periodo="+document.form1.id_periodo.value+"&seccion="+document.form1.seccion.value;
	window.open(url);
 }
</script>


