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


mysql_select_db($database_conn, $conn);
 mysql_query ("SET NAMES 'utf8'");
$query_rstAlumnos = "SELECT id_alumno,cedula,apellidos,nombres FROM alumnos ORDER BY apellidos,nombres";
$rstAlumnos = mysql_query($query_rstAlumnos, $conn) or die(mysql_error());
$totalRows_rstAlumnos = mysql_num_rows($rstAlumnos);

if($totalRows_rstAlumnos >0)
{
    $array_id = array();
	$array_alumno = array();
	$code=0;
	while($alumno = mysql_fetch_assoc($rstAlumnos))
		{
			$array_id[$code] = $alumno["id_alumno"];		
			$array_alumno[$code]=  $alumno["apellidos"].', '.$alumno["nombres"];	
			$code += 1;
		}
}
			
// Datos de las Carreras.

 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 -- 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=utf-8" />
</head>
<script>
$(document).ready(function(){
	$("#id_alumno").change(function(){
		$.post("carga_carreras_alumno.php",{ id:$(this).val() },function(data){$("#id_carrera").html(data);})
	});
})
</script>
<body>
<table class="bd" width="100%" align="center"><tr><td class="hr"><h2 align="left">Pagos por Participante </h2></td></tr></table>
<form name="situacion" method="post" action="">
  <table width="40%" border="0" align="center" id="carga" cellpadding="1" cellspacing="10" style="border:1px solid #ccc;">
    
    <tr>
      <td width="10%">Participante:</td>
      <td colspan="5"><label>
        <select name="id_alumno" id="id_alumno" style="width:580px">
		<option value="0">Seleccione...</option>
         <?php
 			for($i=0;$i<count($array_alumno);$i++) {
  			echo "<option value=".$array_id[$i].">".$array_alumno[$i]."</option>" ;
			} 
		  ?> 
		 </select>
      </label></td>
    </tr>
    <tr>
      <td>Desde</td>
      <td width="15%"><label>
        <input name="fdesde" type="text" size="10" maxlength="10" onKeyUp="mascara(this,'-',patron,true)" onBlur="return esFechaValida(this.value)">
      </label></td>
      <td width="11%">Hasta:</td>
      <td width="44%"><div align="left">
          <label>
          <input name="fhasta" type="text" size="10" maxlength="10" onKeyUp="mascara(this,'-',patron,true)" onBlur="return esFechaValida(this.value)">
          </label>
      </div></td>
      <td width="7%"><div align="right"></div></td>
      <td width="13%">&nbsp;</td>
    </tr>
    
    <tr>
      <td height="34" colspan="6"><div align="center">
        <label>
        <input name="Enviar" type="button" id="Enviar" value="Consultar" onClick="imprimir_pagos_alum()" >
        </label>
      </div></td>
    </tr>
  </table>
    <div align="center"></div>
  <div align="center"></div>
</form>
<p>&nbsp;</p>
<?php
?>
</body>
</html>

<script type="text/javascript">
 function imprimir_pagos_alum()
 {  
 	url="modelo/class_pdf/pagos_alumno.php?id_alumno="+document.situacion.id_alumno.value+"&fdesde="+document.situacion.fdesde.value+"&fhasta="+document.situacion.fhasta.value;
	window.open(url);
	//window.location=url;
 }
</script>

<script>
function esFechaValida(fecha){
    if (fecha != undefined && fecha != "" ){
       
    	var dia  =  parseInt(fecha.substring(0,2),10);
		var mes  =  parseInt(fecha.substring(3,5),10);
		var anio =  parseInt(fecha.substring(6,10),10);
	
		if (isNaN(dia) || isNaN(mes) || isNaN(anio)) {
		   alert("Formato de fecha no v�lido");
		   document.addAlumno.fechanac.focus();
       return false;
	 }
	
    switch(mes){
        case 1:
			numDias=31;
            break;
        case 3:
			numDias=31;
            break;
        case 5:
			numDias=31;
            break;
        case 7:
			numDias=31;
            break;
        case 8: 
			numDias=31;
            break;
        case 10:
			numDias=31;
            break;
        case 12:
            numDias=31;
            break;
        case 4: case 6: case 9: case 11:
            numDias=30;
            break;
        case 2:
           if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
            break;
        default:
            alert("Error en fecha introducida (Mes Inv�lido)");
			document.addAlumno.fechanac.focus();
            return false;
    }
 
        if (dia>numDias || dia==0){
            alert("Error en fecha introducida (D�a Inv�lido)");
            document.addAlumno.fechanac.focus();
			return false;
        }
        return true;
    }
}
 
function comprobarSiBisisesto(anio){
if ( ( anio % 100 != 0) && ((anio % 4 == 0) || (anio % 400 == 0))) {
    return true;
    }
else {
    return false;
    }
}
</script>

<script type="text/javascript">
var patron = new Array(2,2,4)
var patron1= new Array(1,2)
var patron2 = new Array(1,3,3,3,3)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}
</script>

