<?php

include 'conector.php';session_start();
date_default_timezone_set('America/Bogota');
if(isset($_SESSION["user"])&& $_SESSION["tipo"]=='A'){
$curso='Todos';
$anno=date("Y");




  $class1="class=\"active\"";
  $class2="";
  $act2="";
  $class3="";
  $act3="";
  $act1=" active ";
  $class4="";
  $act4="";
  $class5="";
  $act5="";

if(isset($_POST['val1'])&&!empty($_POST['val1'])){


$sel_sexo="SELECT sexo,(COUNT(*)) FROM estudiante where estado_est='A' "; 
if(isset($_POST['cur1'])&&!empty($_POST['cur1'])){
	$sel_curso="select nombre from curso where curso_id=".$_POST['cur1']." ";
	if($res_sel_curso=mysql_query($sel_curso)){
		$rs_sc=mysql_fetch_array($res_sel_curso);
		$curso=$rs_sc[0];
	}
	$sel_sexo.="and curso_id='".$_POST['cur1']."'";
}	
$sel_sexo.="GROUP BY sexo order by sexo";
if($res_sel_sexo=mysql_query($sel_sexo)){
	while($rs_mas=mysql_fetch_array($res_sel_sexo)){
	
	if($rs_mas[0]=='Masculino'){$m=$rs_mas[1];}
	if($rs_mas[0]=='Femenino'){$f=$rs_mas[1];}
	
	
	}


}

}

if(isset($_POST['val2'])&&!empty($_POST['val2'])){
  $class1="";
  $class2="class=\"active\"";
  $act1="";
  $act2=" active ";
  $class3="";
  $act3="";
  $class4="";
  $act4="";
  $class5="";
  $act5="";


}

if(isset($_POST['val3'])&&!empty($_POST['val3'])){
  $class1="";
  $class3="class=\"active\"";
  $act1="";
  $act3=" active ";
  $class2="";
  $act2="";
  $class4="";
  $act4="";
  $class5="";
  $act5="";

}
if(isset($_POST['val4'])&&!empty($_POST['val4'])){
  $class1="";
  $class4="class=\"active\"";
  $act1="";
  $act4=" active ";
  $class2="";
  $act2="";
  $class3="";
  $act3="";
  $class5="";
  $act5="";

$nom_curso='Todos';
if(isset($_POST['cur4'])&&!empty($_POST['cur4'])){
	$curso_consulta="and pensum.class_id=".$_POST['cur4'];

$select_nombre="select nombre from curso where curso_id=".$_POST['cur4']." ";
//echo "alert('$select_nombre');";

if($res_select_nombre=mysql_query($select_nombre)){
$rs_curso=mysql_fetch_array($res_select_nombre);
$nom_curso=$rs_curso[0];
}

}

$sel_pla="select * from planilla where anno='$anno' and estado='A' order by anno,periodo";
$fil_sel_pla=0;
if($res_sel_pla=mysql_query($sel_pla)){
	$fil_sel_pla=mysql_num_rows($res_sel_pla);}
if($fil_sel_pla>0){
	$aux2=$fil_sel_pla;
	while($rs_spl=mysql_fetch_array($res_sel_pla)){	
	
		$sel_datos="Select a.periodo,(SELECT  count(*) from planilla_consulta b where b.periodo=a.periodo and b.pensum=a.pensum  and (b.def)<70 ) as 'bajo',
		(SELECT count(c.def) from planilla_consulta c where c.periodo=a.periodo and c.pensum=a.pensum  and (c.def)>=70 && (c.def)<=79) as 'basico',
		(SELECT count(d.def) from planilla_consulta d where d.periodo=a.periodo and d.pensum=a.pensum  and (d.def)>=80 && (d.def)<=94) as 'alto',
		(SELECT count(e.def) from planilla_consulta e where e.periodo=a.periodo and e.pensum=a.pensum  and (e.def)>=95 && (e.def)<=100) as 'sup'
		    from planilla_consulta a,pensum
		    where	 a.periodo in(".$rs_spl[0].")
			".$curso_consulta."						
		    and a.pensum=pensum.subject_id							
			group by a.periodo,a.pensum";

		$filas_datos=0;
		if($res_sel_datos=mysql_query($sel_datos)){
			$filas_datos=mysql_num_rows($res_sel_datos);
		
			if($filas_datos>0){
				$bajo=0;
				$basico=0;
				$alto=0;
				$sup=0;
				$acum=0;
				$aux3=$filas_datos;
				while($rs_datos=mysql_fetch_array($res_sel_datos)){
					$per=$rs_datos[0];
					$bajo+=$rs_datos[1];
					$basico+=$rs_datos[2];
					$alto+=$rs_datos[3];
					$sup+=$rs_datos[4];
					$acum+=$rs_datos[1]+$rs_datos[2]+$rs_datos[3]+$rs_datos[4];
				}
//			echo $acum." ACUM<br>";
		$cadena.="<tr><th>P$rs_spl[2] - $rs_spl[1] </th><td>".round(($bajo/$acum*100),0)."</td><td>".round($basico/$acum*100)."</td><td>".round($alto/$acum*100)."</td><td>".round($sup/$acum*100)."</td></tr>";
			
			}
		
		
		
		}
	
	
	$aux2--;
	}
		
		
}
}
if(isset($_POST['val5'])&&!empty($_POST['val5'])){
  $class1="";
  $class5="class=\"active\"";
  $act1="";
  $act5=" active ";
  $class2="";
  $act2="";
  $class3="";
  $act3="";
  $class4="";
  $act4="";
}
 
echo "
<!DOCTYPE html>
<html lang=\"en\">
  <head>
    <meta charset=\"utf-8\">
    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
    <meta name=\"description\" content=\"\">
    <meta name=\"author\" content=\"\">
    <link rel=\"shortcut icon\" href=\"assets/ico/favicon.ico\">
	<style>
	</style>
    <title>Gr&aacute;ficos</title>
    <!-- Custom styles for this template -->
    <link href=\"offcanvas.css\" rel=\"stylesheet\">
    <link rel='stylesheet' href='js/css/jquery-ui-1.9.2.custom.css' />

    <!-- Bootstrap core CSS -->
    <link href=\"dist/css/bootstrap.min.css\" rel=\"stylesheet\">
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'></script>

  


    <!-- Just for debugging purposes. Don't actually copy this line! -->
    <!--[if lt IE 9]><script src=\"../../assets/js/ie8-responsive-file-warning.js\"></script><![endif]-->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>
      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>
	<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>

	
   
    <![endif]-->
	<style type='text/css'>
	${demo.css}
	</style>
<script type='text/javascript'>

function muestra_cart(t){

	document.getElementById('val5').value=1;
	if(t==1){
	if(document.getElementById('cu5').value=='XX'){
		alert('Debe seleccionar curso');return false;
		}else{document.getElementById('cur5').value=document.getElementById('cu5').value;}
	}
	document.forms['mostrar_cart'].submit();
}
function muestra_ind_cur(t){

	document.getElementById('val4').value=1;
	if(t==1){
	if(document.getElementById('cu4').value=='XX'){
		alert('Debe seleccionar curso');return false;
		}else{document.getElementById('cur4').value=document.getElementById('cu4').value;}
	}
	document.forms['mostrar_ind'].submit();
}
function muestra_def_est(){
	document.getElementById('val3').value=1;
	if(document.getElementById('buscar').value==''){alert('Debe digitar el nombre');return false;}
		else{
		var mystr = document.getElementById('buscar').value;
		var myarr = mystr.split(' - ');var t_id = myarr[0];
		document.getElementById('est3').value=t_id;
		}
	document.forms['mostrar_def_est'].submit();
}
function muestra_def_curso(){
	document.getElementById('val2').value=1;
	//if(document.getElementById('cu1').value=='XX'){	alert('Debe seleccionar curso');return false;	}else{document.getElementById('cur1').value=document.getElementById('cu1').value;}
	document.forms['mostrar_def'].submit();

}
function muestra_curso(t){
	document.getElementById('val1').value=1;
	if(t==1){
		if(document.getElementById('cu1').value=='XX'){
		alert('Debe seleccionar curso');return false;
		}else{document.getElementById('cur1').value=document.getElementById('cu1').value;}
	}
	document.forms['listar_asignatura'].submit();
}
  
";

if(isset($_POST['val1'])&&!empty($_POST['val1'])){
echo "
$(function () {
    var categories = ['1', '2', '3', '4',
            '5', '6', '7', '8', '9',
            '10', '11', '12', '13', '14',
            '15', '16', '17', '18', '19',
            '20', '21 + '];
    $(document).ready(function () {
        $('#container').highcharts({
            chart: {
                type: 'bar'
            },
            title: {
                text: 'Distrib. Poblacional Estudiantes'
            },
            subtitle: {
                text: 'Colegio La Esperanza - Curso:<b>".$curso."'
            },
            xAxis: [{
                categories: categories,
                reversed: false,
                labels: {
                    step: 1
                }
            }, { // mirror axis on right side
                opposite: true,
                reversed: false,
                categories: categories,
                linkedTo: 0,
                labels: {
                    step: 1
                }
            }],
            yAxis: {
                title: {
                    text: null
                },
                labels: {
                    formatter: function () {
                        return (Math.abs(this.value) / 1) + '';
                    }
                },
                min: -30,
                max: 30
            },

            plotOptions: {
                series: {
                    stacking: 'normal'
                }
            },

            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + ', edad ' + this.point.category + '</b><br/>' +
                        'Poblacion: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
                }
            },
	credits: {
            enabled: false
        	},
            series: [{
                name: 'Hombres "; echo $m; echo "',
                data: [";
                
                $cad='';
	for($i=1;$i<=20;$i++){
                if($i<20){
                	$sel_mas="SELECT TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE()) AS edad,
				(COUNT(*)*-1)
				FROM estudiante 
				where estado_est='A'and sexo='Masculino' and TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE())=$i ";
			if(isset($_POST['cur1'])&&!empty($_POST['cur1'])){
				$sel_mas.="and curso_id='".$_POST['cur1']."'";
			}	
				$sel_mas.="GROUP BY edad";
		}
		if($i==20){
                	$sel_mas="SELECT TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE()) AS edad,
				(COUNT(*)*-1)
				FROM estudiante 
				where estado_est='A' and sexo='Masculino'and TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE())>=$i ";
			if(isset($_POST['cur1'])&&!empty($_POST['cur1'])){
				$sel_mas.="and curso_id='".$_POST['cur1']."'";
			}	
				$sel_mas.="GROUP BY edad";

		}

                if($res_sel_mas=mysql_query($sel_mas)){
                	$rs_mas=mysql_fetch_array($res_sel_mas);
                	if($rs_mas[1]=='')$aux=0;
                	if($rs_mas[1]!='')$aux=$rs_mas[1];
                	if($i<20){ $cad.=$aux.",";}
                	if($i==20){ $cad.=$aux."";}
                	
                }
	}        
               
                 echo   $cad;
                    
                    
                    
echo                  "]
            }, {
                name: 'Mujeres "; echo $f; echo "',
                data: [
                ";
                
                $cad2='';
		for($i=1;$i<=20;$i++){
	                if($i<20){
	                	$sel_mas2="
	                	SELECT TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE()) AS edad,
						(COUNT(*))
						FROM estudiante 
						where estado_est='A' and sexo='Femenino' and TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE())=$i ";
				if(isset($_POST['cur1'])&&!empty($_POST['cur1'])){
					$sel_mas2.="and curso_id='".$_POST['cur1']."'";
				}	
					$sel_mas2.="GROUP BY edad";

			}
			if($i==20){
	                	$sel_mas2="SELECT TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE()) AS edad,
						(COUNT(*))
						FROM estudiante 
						where estado_est='A' and sexo='Femenino' and TIMESTAMPDIFF(YEAR, f_nacimiento, CURDATE())>=$i ";
				if(isset($_POST['cur1'])&&!empty($_POST['cur1'])){
					$sel_mas2.="and curso_id='".$_POST['cur1']."'";
				}	
					$sel_mas2.="GROUP BY edad";

			}
	
	                if($res_sel_mas2=mysql_query($sel_mas2)){
	                	$rs_mas2=mysql_fetch_array($res_sel_mas2);
	                	if($rs_mas2[1]=='')$aux2=0;
	                	if($rs_mas2[1]!='')$aux2=$rs_mas2[1];
	                	if($i<20){ $cad2.=$aux2.",";}
	                	if($i==20){ $cad2.=$aux2."";}
	                	
	                }
		}        
	               
	                 echo   $cad2;
                    
                    
                    
                    echo "
                
                ]
            }]
        });
    });

});";
}
if(isset($_POST['val2'])&&!empty($_POST['val2'])){
echo "
$(function () {
    $('#container2').highcharts({
        chart: {
            type: 'line'
        },
        title: {
            text: 'Promedio de Cursos por Periodos',
            x: -20 //center
        },
        subtitle: {
            text: 'Colegio La Esperanza',
            x: -20
        },
        xAxis: {
            categories: [";
 
            	$sel_pla="select nombre from curso order by orden";
		$fil_sel_pla=0;
		if($res_sel_pla=mysql_query($sel_pla)){
			$fil_sel_pla=mysql_num_rows($res_sel_pla);}
		$cad='';
		if($fil_sel_pla>0){
			$aux1=$fil_sel_pla;
			while($rs_sp=mysql_fetch_array($res_sel_pla)){
				if($aux1==1){
				$grafor=$rs_sp[0];$cad.="'$grafor'";
				}else{
				$grafor=$rs_sp[0];$cad.="'$grafor',";
				}
			$aux1--;
			}		
            echo $cad;

		}
echo                "]
        },
        yAxis: {
            title: {
                text: 'Prom. Calificaciones'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            crosshairs: true,
            shared: true
        },
        plotOptions: {
            spline: {
                marker: {
                    radius: 4,
                    lineColor: '#666666',
                    lineWidth: 1
                }
            }
        },
        series: [";

	
	$sel_pla="select * from planilla where anno='$anno' and estado='A' order by anno,periodo";
	$fil_sel_pla=0;
		if($res_sel_pla=mysql_query($sel_pla)){
			$fil_sel_pla=mysql_num_rows($res_sel_pla);}
		if($fil_sel_pla>0){
			$aux2=$fil_sel_pla;
			while($rs_spl=mysql_fetch_array($res_sel_pla)){
					
			                     $sel_est="select curso.nombre,IFNULL(avg(def),0) from curso,pensum
				                     left join planilla_consulta on planilla_consulta.pensum=pensum.subject_id
							and planilla_consulta.periodo='$rs_spl[0]'
							                      where curso.curso_id=pensum.class_id
							group by curso.nombre
							order by curso.orden";
							
						$fil_sel_est=0;
						if($res_sel_est=mysql_query($sel_est)){
						
							$fil_sel_est=mysql_num_rows($res_sel_est);}
						$cad3='';
						if($fil_sel_est>0){
							$aux3=$fil_sel_est;
							while($rs_se=mysql_fetch_array($res_sel_est)){
				
								if($aux3==1){
								$grafor3=$rs_se[1];$cad3.=round($grafor3, 0);
								}else{
								$grafor3=$rs_se[1];$cad3.=round($grafor3, 0).",";
								}
				
							$aux3--;
							}	

						}				
				
				
				$grafor2=$rs_spl[1]."-".$rs_spl[2];$cad2.="{name: '$grafor2',data: [$cad3]}";	
				
				
				
				if($aux2>1){
				$cad2.=",";
				}

			$aux2--;
			}	
		echo $cad2;
		}

        
echo     "]
    });
});";
}
if(isset($_POST['val3'])&&!empty($_POST['val3'])){

$select_nombre="select nombre,curso_id from estudiante where estudiante_id=".$_POST['est3']." ";
//echo "alert('$select_nombre');";
if($res_select_nombre=mysql_query($select_nombre)){
$rs_nom=mysql_fetch_array($res_select_nombre);
}
echo "
$(function () {

    $('#container3').highcharts({

        chart: {
            polar: false,
            type: 'line'
        },

        title: {
            text: 'Notas Definitivas x Periodo',
            x: -50
        },
        subtitle: {
            text: '"; echo $rs_nom[0]."<br>"; echo "',
            x: -50
        },

        pane: {
            size: '95%'
        },

        xAxis: {
            categories: [";
 
            	$sel_pla="select distinct asignatura.sigla from planilla_consulta a,pensum,asignatura 
				where estudiante=".$_POST['est3']."
				and pensum.subject_id=a.pensum
				and pensum.asignatura_id=asignatura.subject_id 
				group by pensum.subject_id";
		$fil_sel_pla=0;
		if($res_sel_pla=mysql_query($sel_pla)){
			$fil_sel_pla=mysql_num_rows($res_sel_pla);}
		$cad='';
		if($fil_sel_pla>0){
			$aux1=$fil_sel_pla;
			while($rs_sp=mysql_fetch_array($res_sel_pla)){
				if($aux1==1){
				$grafor=$rs_sp[0];$cad.="'$grafor'";
				}else{
				$grafor=$rs_sp[0];$cad.="'$grafor',";
				}
			$aux1--;
			}		
            echo $cad;

		}
		echo "],
            tickmarkPlacement: 'on',
            lineWidth: 0
        },

        yAxis: {
            gridLineInterpolation: 'polygon',
            lineWidth: 0,
            min: 0
        },

        tooltip: {
            shared: true,
            pointFormat: '<span style=\"color:{series.color}\">{series.name}: <b>{point.y:,.0f}</b><br/>'
        },
	 credits: {
            enabled: false
        },
        legend: {
            align: 'right',
            verticalAlign: 'top',
            y: 70,
            layout: 'vertical'
        },

        series: [";

      		$sel_pla2="select * from planilla where anno='$anno' and estado='A' order by anno,periodo";
		$fil_sel_pla2=0;
		if($res_sel_pla2=mysql_query($sel_pla2)){$fil_sel_pla2=mysql_num_rows($res_sel_pla2);}            	


		$sel_cod_pen="select distinct pensum.subject_id from planilla_consulta a,pensum
			where estudiante=".$_POST['est3']."
			and pensum.subject_id=a.pensum
			group by pensum.subject_id
			order by pensum.subject_id";
		
		
		if($fil_sel_pla2>0){
		$aux2=$fil_sel_pla2;
			while($rs_spl2=mysql_fetch_array($res_sel_pla2)){
		
				$fil_sel_cod=0;
				if($res_sel_cod_pen=mysql_query($sel_cod_pen)){$fil_sel_cod=mysql_num_rows($res_sel_cod_pen);}            	
				if($fil_sel_cod>0){
					$aux3=$fil_sel_cod;
					$cad3='';
					while($rs_scp=mysql_fetch_array($res_sel_cod_pen)){
						
						$sel_def="select asignatura.nombre,a.periodo,IFNULL(avg(def),0) from planilla_consulta a,pensum,asignatura,planilla 
								where estudiante=".$_POST['est3']."
								and planilla.id=".$rs_spl2[0]."
								and pensum.subject_id=".$rs_scp[0]."
								and planilla.id=a.periodo
								and pensum.subject_id=a.pensum
								and pensum.asignatura_id=asignatura.subject_id 
								group by asignatura.nombre,a.periodo";
						if($res_sel_def=mysql_query($sel_def)){
						
							$rs_def=mysql_fetch_array($res_sel_def);
							
							$grafor3=$rs_def[2];
							if($aux3==1){
								$cad3.=round($grafor3, 0);
							}else{
								$cad3.=round($grafor3, 0).",";
							}
						
						}
						$aux3--;	
					}
				}
				$grafor2=$rs_spl2[1]."-".$rs_spl2[2];$cad2.="{name: '$grafor2',data: [$cad3],pointPlacement: 'on'}";
				
				if($aux2>1){
				$cad2.=",";
				}
				
				$aux2--;
				
			}
//			$cad2.=",{name: 'Global',data: [1,2,3,4,5,6,7,8,9],pointPlacement: 'on'}";
		echo $cad2;
		}
	
echo 		"]

    });
});";

}

if(isset($_POST['val4'])&&!empty($_POST['val4'])){
echo"
$(function () {
    $('#container4').highcharts({
        data: {
            table: document.getElementById('datatable')
        },
        chart: {
            type: 'column'
        },
        title: {
            text: 'Distribucion de Indicadores - Curso: <b>".$nom_curso." '
        },
        yAxis: {
            allowDecimals: false,
            title: {
                text: '% de Estudiantes'
            }
        },
	credits: {
            enabled: false
        	},
        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + '</b><br/>' +
                    '<b>' + this.point.y + '%</b> ' + this.point.name.toLowerCase();
            }
        }
    });
});
";
}
if(isset($_POST['val5'])&&!empty($_POST['val5'])){

$nom_curso2='Todos';
if(isset($_POST['cur5'])&&!empty($_POST['cur5'])){
	$curso_consulta2="and e.curso_id=".$_POST['cur5'];

$select_nombre2="select nombre from curso where curso_id=".$_POST['cur5']." ";
//echo "alert('$select_nombre');";

if($res_select_nombre2=mysql_query($select_nombre2)){
$rs_curso2=mysql_fetch_array($res_select_nombre2);
$nom_curso2=$rs_curso2[0];
}

}
echo "$(function () {
    $('#container5').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Pagos y Saldos - Curso: <b>".$nom_curso2."'
        },
        xAxis: {
            categories: ['MATRICULA', 'PENSION', 'LIBROS', 'UNIFORMES', 'OTROS']
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Pagos y Saldos'
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            }
        },
        legend: {
            align: 'right',
            x: -70,
            verticalAlign: 'top',
            y: 20,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
            borderColor: '#CCC',
            borderWidth: 1,
            shadow: true
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.x + '</b><br/>' +
                    this.series.name + ': ' + this.y + '<br/>' +
                    'Total: ' + this.point.stackTotal;
            }
        },
        plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                    style: {
                        textShadow: '0 0 3px black, 0 0 3px black'
                    }
                }
            }
        },";
        




        
        $cad_d='';$cad_i='';
        $conceptos = array('M', 'P', 'L', 'U', 'O');
        $au=sizeof($conceptos);
        for($i=0;$i<sizeof($conceptos);$i++){
        
	        	$sel_valores="select p.titulo,p.valor,ifnull(sum(d.valor),0) as abono,(p.valor-ifnull(sum(d.valor),0)) as saldo 
						from estudiante e,pagos_detalle d RIGHT join pagos p
						on p.id=d.pago 
						where 
						 e.estudiante_id=p.estudiante
						 and p.titulo='".$conceptos[$i]."'
						".$curso_consulta2."
						group by p.id,p.titulo,p.valor
						";
			
			

			

        	if($res_sel_valores=mysql_query($sel_valores)){
        		$filas_val=mysql_num_rows($res_sel_valores);
        		if($filas_val>0){
        		$deb=0;
        		$ing=0;
        			while($rs_fv=mysql_fetch_array($res_sel_valores)){
        				$deb+=$rs_fv[3];
        				$ing+=$rs_fv[2];
        			
        			}

        			$cad_d.=$deb;
        			$cad_i.=$ing;
        			if($au>1){$cad_d.=",";$cad_i.=",";}
        		}
     	        	if($filas_val==0){
        		$cad_d.=0;
        			$cad_i.=0;
        			if($au>1){$cad_d.=",";$cad_i.=",";}
        		
        		}
        	
        	
        	
        	
        	
        	}
        
        
        
        
        $au--;
        
        }
        
        
        
        
        
        
 echo	"       
        series: [{
            name: 'Ingreso',
            data: [".$cad_i."]
        }, {
            name: 'Debe',
            data: [".$cad_d."]
        }]
    });
});";

}




echo		"</script>  
    
    
    
  </head>

  <body>
    <div class=\"navbar navbar-fixed-top navbar-inverse\" role=\"navigation\">
      <div class=\"container\">
  
          <a class=\"\" href=\"general.php\"><img src='img/logo1.png' style='margin-top:5px'></a>
  
       
       <a href=\"index.php\"><img src='img/salir.png' style='float:right;margin-top:15px'>
             	          <span style='float:right;margin-right:10px; margin-top:15px' class='label label-success'><span class='glyphicon glyphicon-user'></span> ".$_SESSION["user"]."</span>
       </a>
      </div><!-- /.container -->
    </div><!-- /.navbar -->


    <div class=\"container\">

      <div class=\"row row-offcanvas row-offcanvas-left\">

       <div class=\"col-xs-6 col-sm-3 sidebar-offcanvas\" id=\"sidebar\" role=\"navigation\">
          <div class=\"list-group\">
            <a href=\"general.php\" class=\"list-group-item \" data-rel='popover' data-content='Dashboard' data-original-title><span class=\"glyphicon glyphicon-home\"></span> General</a>
            <a href=\"estudiantes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-th\"></span> Estudiantes</a>
            <a href=\"docentes.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-user\"></span> Docentes</a>
            <a href=\"acudiente.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-user\"></span> Acudiente</a>            
            <a href=\"asignaturas.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-book\"></span> Asignaturas</a>
            <a href=\"cursos.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-list\"></span> Cursos</a>
            <a href=\"pensum.php\" class=\"list-group-item\"><span class=\"glyphicon glyphicon-edit\"></span> Pensum</a>                        
            <a href=\"logros.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Logros</a>                        
            <a href=\"observaciones.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Observaciones</a>         
            <a href=\"horario.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Horario</a> 
            <a href=\"planilla.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Planilla Notas</a>            
            <a href=\"planilla_obs.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Planilla Obs.</a>                        
            <a href=\"pagos.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-list\"></span> Pagos</a>           
            <a href=\"reportes.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-file\"></span> Reportes</a>            
<a href=\"eventos.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-edit\"></span> Eventos</a>
            <a href=\"est.php\" class=\"list-group-item active\"><span class=\"glyphicon glyphicon-signal\"></span> Estad&iacute;sticas</a>
            <a href=\"config.php\" class=\"list-group-item \"><span class=\"glyphicon glyphicon-wrench\"></span> Configuraci&oacute;n</a>
          </div>
        </div><!--/span-->

        <div class=\"col-xs-12 col-sm-9\">
          <p class=\"pull-left visible-xs\">
            <button type=\"button\" class=\"btn btn-primary btn-xs\" data-toggle=\"offcanvas\">menu</button>
          </p>
    
	<div class=\"panel panel-default\">
	<br>";
echo $men;
echo    "<!-- Nav tabs -->
	<ul class=\"nav nav-tabs\">
		<li >&nbsp;</li>
	  <li $class1 ><a href=\"#home\" data-toggle=\"tab\">Demogr&aacute;fico</a></li>
	  <li $class2 ><a href=\"#profile\" data-toggle=\"tab\">Promedio Cursos</a></li>
	  <li $class3 ><a href=\"#backup\" data-toggle=\"tab\">Promedios de Estudiante</a></li>	  
	  <li $class4 ><a href=\"#indicadores\" data-toggle=\"tab\">Indicadores x Cursos</a></li>	  	  
	  <li $class5 ><a href=\"#cartera\" data-toggle=\"tab\">Cartera</a></li>	  
	</ul>
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
		<div class=\"tab-pane fade in $act5 \" id=\"cartera\">
			<form name='mostrar_cart' id='mostrar_cart' method='post' action='est.php#cartera' target='' >
			<input type='hidden' name='val5' id='val5' value='".$val5."'>	
			<input type='hidden' name='cur5' id='cur5' value='".$cur5."'>				
			
			<div class=\"page\">
				<fieldset>
					<legend>
						<br><span class=\"glyphicon glyphicon-plus\"></span> Recaudo y Cartera
					</legend>
						
				</fieldset>
				<fieldset>
				<select id='cu5' name='cu5' class='form-control2' style='width:24%;margin-right: 10px;margin-bottom: 10px;float:left'>";
				
					$select_curso4='select curso_id,nombre
					from curso order by orden';
					$res_select_curso4=mysql_query($select_curso4);
					echo "<option value='XX' >Seleccione Curso</option>";
					while($r_sc4=mysql_fetch_array($res_select_curso4)){
					$sel1='  ';
					//if($edit_est[11]==$r_sc4[0]){$sel1=' selected ';}
					//echo "hola";
							echo '<option value="'.$r_sc4[0].'"  '.$sel1.'>'.$r_sc4[1].' </option>';
					}
					
echo					"</select>			
						
			<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_cart(1)'> Consultar</button>     
			<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_cart(2)'> Consultar Todos</button>     
			<div id='container5' style='min-width: 210px; height: 500px; margin: 0 auto'></div>				
				</fieldset>

			</div>
		</form>
	</div>

	<div class=\"tab-pane fade in $act4 \" id=\"indicadores\">
			<form name='mostrar_ind' id='mostrar_ind' method='post' action='est.php#indicadores' target='' >
			<input type='hidden' name='val4' id='val4' value='".$val4."'>	
			<input type='hidden' name='cur4' id='cur4' value='".$cur4."'>				
			
			<div class=\"page\">
				<fieldset>
					<legend>
						<br><span class=\"glyphicon glyphicon-plus\"></span> Indicadores x Curso          
					
					
					</legend>
					<select id='cu4' name='cu4' class='form-control2' style='width:24%;margin-right: 10px;margin-bottom: 10px;float:left'>";
				
					$select_curso4='select curso_id,nombre
					from curso order by orden';
					$res_select_curso4=mysql_query($select_curso4);
					echo "<option value='XX' >Seleccione Curso</option>";
					while($r_sc4=mysql_fetch_array($res_select_curso4)){
					$sel1='  ';
					//if($edit_est[11]==$r_sc4[0]){$sel1=' selected ';}
					//echo "hola";
							echo '<option value="'.$r_sc4[0].'"  '.$sel1.'>'.$r_sc4[1].' </option>';
					}
					
echo					"</select>			
						
			<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_ind_cur(1)'> Consultar</button>     
			<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_ind_cur(2)'> Consultar Todos</button>     
			<div id='container4' style='min-width: 310px; height: 400px; margin: 0 auto'></div>	
				</fieldset>
			<fieldset>


			<div align='center'>
			<table id='datatable' class='table table-striped table-bordered ' style='width:70%;'>
				<thead>
					<tr>
						<th></th>
						<th>BAJO</th>
						<th>BASICO</th>
						<th>ALTO</th>
						<th>SUPERIOR</th>
					</tr>
				</thead>
				<tbody>".$cadena."
					
					
				</tbody>
			</table>
			</div>

							
			</fieldset>

			</div>
		</form>
	</div>
	<div class=\"tab-pane fade in $act3 \" id=\"backup\">
			<form name='mostrar_def_est' id='mostrar_def_est' method='post' action='est.php#backup' target='' >
			<input type='hidden' name='val3' id='val3' value='".$val3."'>	
			<input type='hidden' name='est3' id='est3' value='".$est3."'>				
			
			<div class=\"page\">
				<fieldset>
					<legend>
						<br><span class=\"glyphicon glyphicon-plus\"></span> Promedios de Estudiante          
					</legend>			
			<input type='text' id='buscar' name='buscar'  value='' placeholder='...Digite parte del nombre' class='form-control2'  style='width:24%;margin-bottom: 10px;float:left' onclick='this.value=\"\"'>			
			<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_def_est()'> Consultar</button>     
			<div id='container3' style='min-width: 400px; max-width: 800px; height: 400px; margin: 0 auto'></div>	
				</fieldset>
			<fieldset>



							
			</fieldset>

			</div>
		</form>
	</div>

	<div class=\"tab-pane fade in $act2 \" id=\"profile\">
		<form name='mostrar_def' id='mostrar_def' method='post' action='est.php#profile' target='' >
		<input type='hidden' name='val2' id='val2' value='".$val2."'>	
		<input type='hidden' name='nombre_usuario2' id='nombre_usuario2' value='".$nombre_usuario2."'>	
		<input type='hidden' name='cuenta_usuario2' id='cuenta_usuario2' value='".$cuenta_usuario2."'>	
		<input type='hidden' name='clave_usuario2' id='clave_usuario2' value='".$clave_usuario2."'>					
		<input type='hidden' name='tipo_usuario2' id='tipo_usuario2' value='".$tipo_usuario2."'>
		
		<div class=\"page\">
			<fieldset>
				<legend>
					<br><span class=\"glyphicon glyphicon-plus\"></span> Promedio de Cursos Por Periodo
				</legend>			
		<button type='button' class='btn btn-info btn-xs' style='margin-left: 10px;' onclick='muestra_def_curso()'> Consultar</button>     
			<div id='container2' style='min-width: 310px; height: 400px; margin: 0 auto'></div>
			</fieldset>
		
		
		 
		

		<fieldset>
		<legend>
					<br>
					
		</legend>	
			
		</fieldset>
			
			<br>
		</div>
	</form>
</div>

<div class=\"tab-pane fade in $act1 \" id=\"home\">
	<form name='listar_asignatura' id='listar_asignatura' method='post' action='est.php' target=''>
	<div class=\"page\">
	<input type='hidden' name='val1' id='val1' value='".$val1."'>	
	<input type='hidden' name='cur1' id='cur1' value='".$cur1."'>		
	
		<fieldset>
			<legend><br><span class=\"glyphicon glyphicon-th-list\"></span> 
				Pir&aacute;mide Poblacional          
			</legend>			
<select id='cu1' name='cu1' class='form-control2' style='width:24%;margin-right: 10px;margin-bottom: 10px;float:left'>";
				
					$select_curso4='select curso_id,nombre
					from curso order by orden';
					$res_select_curso4=mysql_query($select_curso4);
					echo "<option value='XX' >Seleccione Curso</option>";
					while($r_sc4=mysql_fetch_array($res_select_curso4)){
					$sel1='  ';
					//if($edit_est[11]==$r_sc4[0]){$sel1=' selected ';}
					//echo "hola";
							echo '<option value="'.$r_sc4[0].'"  '.$sel1.'>'.$r_sc4[1].' </option>';
					}
					
echo					"</select>
				<button type='button' class='btn btn-info btn-xs' onclick='muestra_curso(1)'> Consultar</button>     
				<button type='button' class='btn btn-info btn-xs' onclick='muestra_curso(2)'> Consultar Todos</button>    

		</fieldset>
	</div>
	
	<fieldset>
	<div class='table-responsive'>
	 				

	<div id='container' style='min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto'></div>	

	</div>
	</fieldset>
	
	
	
	</form>

</div>
 
         
        </div><!--/span-->

       
      </div><!--/row-->


</div><!--/row--></div><!--/row--><hr><footer><p>&copy; dise&ntilde;ado por: colegiolaesperanza.com</p></footer>

    </div><!--/.container-->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src=\"js/jquery-ui-1.10.3.custom.js\"></script>
    <script src=\"dist/js/bootstrap.min.js\"></script>
    <script src=\"offcanvas.js\"></script>
    <script src=\"js/highcharts.js\"></script>
    <script src=\"js/modules/data.js\"></script>
    <script src=\"js/modules/exporting.js\"></script>
    <script src='js/highcharts-more.js'></script>

    <script>
      $(function() {
	$( \"#buscar\" ).autocomplete(
	{
		 source:'source.php',		 
		 minLength: 3
	})
}); 
</script>
 

  </body>
</html>
";
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
?>
