<?php require_once('Connections/conn.php'); ?>
<?php
 session_start();
	 $cedula_usuario=$_SESSION['CEDULA_USUARIO'];
	 $cedula=$_POST["cedula"];
	 $SEDE_USUARIO=$_SESSION['SEDE_USUARIO'];

	
// Para tomar los  datos del alumno
// Cargo los datos de los Alumnos.

  mysql_select_db($database_conn, $conn);
  mysql_query ("SET NAMES 'utf8'");
	
  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 -- inscripciones por alumno</title>
<meta name="generator" http-equiv="Content-Type" content="text/html; charset=utf-8">
<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: 14px;
  }
  .bd1 {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 16px;
  }
  .bd2 {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .bd3 {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 15px;
  }
  .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>
<script src="jquery.min.js" type="text/javascript"></script>
<meta name="generator" http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script>
$(document).ready(function(){
	$("#cedula").change(function(){
		$.post("carga_carreras_alumno1.php",{ id:$(this).val() },function(data){$("#id_carrera").html(data);})
	});
	$("#id_carrera").change(function(){
		$.post("carga_sedes_alumno1.php",{ id:$(this).val(),c:$("#cedula").val() },function(data){$("#id_sede").html(data);})
	});
})
</script>

<body>
<?php
 if($cedula=="")
 {
?>
<table class="bd" width="100%" align="center"><tr><td class="hr"><h2 align="left">Consulta de Deuda</h2> </td></tr>
</table>
<form name="form1" enctype="multipart/form-data" action="consultar_deuda.php" method="post">
<p><input type="hidden" name="consultar" value="no"></p>
  <table width="99%" border="0" align="center" id="carga" cellpadding="1" cellspacing="10" style="border:1px solid #ccc;">
    
    <tr>
      <td width="78"><div align="right">Cédula:</div></td>
      <td width="524" colspan="5"><label>
        <input class="bd1" name="cedula" id="cedula"  type="text" size="12" maxlength="20" onBlur="verificar_alumno(this.value,'<?php echo $SEDE_USUARIO ?>')" onKeyPress="return soloNum(event)"><iframe name="frameNuevo" id="frameNuevo" with="0" height="0" frameborder="0" ></iframe>
      </label></td>
    </tr>
    <tr>
      <td>Apellidos:</td>
      <td colspan="5"><input name="apellidos" type="text" id="apellidos" size="35" maxlength="50">
        &nbsp;&nbsp;&nbsp;&nbsp;Nombres:&nbsp;&nbsp;
        <label>
        <input name="nombres" type="text" id="nombres" size="35" maxlength="50">
        </label></td>
    </tr>
    
    <tr>
      <td colspan="6"><div align="center">
        <input type="submit" name="action2" value="Consultar">
      </div>
        <label></label>
      <label></label></td>
    </tr>
  </table>
    <div align="center"></div>
  <div align="center"></div>
</form>
<?php }
else{

  sql_consulta($cedula);
  }
  ?>
</body>
<?php

?>
 <script type="text/javascript">
	function validar_datos()
	{
	 	
		if(document.form1.cedula.value==0){
			alert("El campo <<Cédula>> es obligatorio");
			document.form1.cedula.focus();
			return false;
			}
			return true;
	}
	
</script>

<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));
	}
	
	
	function verificar_alumno(cedula,sede)
    {
 	if (cedula!="")
	 {
	 url="validar_alumno_pago_regular.php?cedula="+cedula+"&sede="+sede;;
	 frameNuevo.location=url;
	 }
}
</script>
 <?php


function sql_consulta($cedula)
{
  global $conn;
  

  mysql_select_db($database_conn, $conn);
  mysql_query ("SET NAMES 'utf8'");
  
  $sql = "SELECT apellidos,nombres FROM alumnos WHERE cedula='$cedula' ";
  $rst = mysql_query($sql, $conn) or die(mysql_error());
  $row = mysql_fetch_assoc($rst);
  $participante=$row['apellidos'].', '.$row['nombres'];
   
  
  $sql = "SELECT * FROM deudas WHERE cedula='$cedula' ";
  $rst = mysql_query($sql, $conn) or die(mysql_error());
  $totalRows = mysql_num_rows($rst);    
?>
<table class="bd" width="100%" align="center"><tr><td class="hr"><h2 align="left">Consulta de Deuda (Bs.)</h2> </td></tr>
</table>

<table class="bd" border="0" cellspacing="1" cellpadding="4" width="100%">
<tr><td class="bd3"><B>PARTICIPANTE: </B><?php echo $participante ?>&nbsp;&nbsp;<B>CEDULA:</B>&nbsp;<?php echo $cedula ?></td></tr>
</table>

<table width="99%" border="1" align="center" id="carga" cellpadding="1" cellspacing="10" style="border:1px solid #ccc;">
<tr>
  <td align="center" class="bd">Programa</td>
  <td align="center" class="bd">Cuota 1</td>
  <td align="center" class="bd">Cuota 2</td>
  <td align="center" class="bd">Cuota 3</td>
  <td align="center" class="bd">Total</td>
</tr>
<?php
$total=0;
for ($i = 0; $i < $totalRows; $i++)
  {
   $deuda_carrera=0;
   $row = mysql_fetch_assoc($rst);
 
   $id_carrera=$row["id_carrera"];
   $sql1 = "SELECT nombre_carrera FROM carreras WHERE id_carrera='$id_carrera' ";
   $rst1 = mysql_query($sql1, $conn) or die(mysql_error());
   $row1 = mysql_fetch_assoc($rst1);
   $nombre_carrera=$row1["nombre_carrera"];
   $deuda_carrera=$row["cuota1"]+$row["cuota2"]+$row["cuota3"];
   $total_deuda=$total_deuda+$deuda_carrera;
?>
  <tr>
	<td class="bd2" align="left"><?php echo $nombre_carrera; ?></td>
	<td class="bd2" align="right"><?php echo number_format($row["cuota1"],2,',','.'); ?></td>
	<td class="bd2" align="right"><?php echo number_format($row["cuota2"],2,',','.'); ?></td>
	<td class="bd2" align="right"><?php echo number_format($row["cuota3"],2,',','.'); ?></td>
	<td class="bd2" align="right"><?php echo number_format($deuda_carrera,2,',','.'); ?></td>
  </tr>
  <?php
}
?>
<tr>
	<td class="bd2" align="left"></td>
	<td class="bd2" align="right"></td>

	<td class="bd" align="right" colspan="2">TOTAL DEUDA:</td>
	<td class="bd" align="right"><?php echo number_format($total_deuda,2,',','.'); ?></td>
  </tr>
</table>
<?php
}

function connect()
{
  $conn = mysql_connect("localhost", "ceula_sadce_admi", "j7BnJdCGzyQBGcud");
  mysql_select_db("ceulac_sadce");
  mysql_query ("SET NAMES 'utf8'");
  return $conn;
}
 
?>






