<?php
 include '../conector.php';
session_start();

if(isset($_SESSION["user"])&& $_SESSION["tipo"]=='D'){

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


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

 	
 		$select_asig3="
select distinct asignatura.nombre,id_nota.registro,planilla_detalle.codigo_pensum 
					 from estudiante,pensum,curso,planilla_detalle,asignatura,id_nota 
					 where pensum.class_id=".$_POST['cur9']."  
					 and planilla_detalle.tipo_nota='D'
					 and planilla_detalle.planilla=".$_POST['per9']." 
					 and pensum.class_id=curso.curso_id 
					 and pensum.asignatura_id=".$_POST['mat9']."
					 and estudiante.curso_id=pensum.class_id 
					 and pensum.estado='A' 
					 and planilla_detalle.codigo_pensum=pensum.subject_id 
					 and planilla_detalle.codigo_est=estudiante.estudiante_id 
					 and asignatura.subject_id=pensum.asignatura_id 
					and planilla_detalle.id_nota=id_nota.id					 
					 order by planilla_detalle.id_nota
 	";
 	
 	
 	//echo $select_asig3."<br>";
 	$rs_select_asig3=mysql_query($select_asig3);
	$num_filas_asig3 = mysql_num_rows($rs_select_asig3);	
/******************************************************/	
$select_curso_est2="select distinct estudiante.estudiante_id,estudiante.nombre,(select nombre_archivo from upload where upload.codigo=estudiante.estudiante_id and clase='F') as foto,
 			 curso.codigo
			from estudiante,pensum,curso
			where pensum.class_id=".$_POST['cur9']."
			and pensum.asignatura_id=".$_POST['mat9']."
			and pensum.class_id=curso.curso_id
            		and estudiante.curso_id=pensum.class_id
            		and pensum.estado='A'
			order by estudiante.nombre";

//echo $select_curso_est."<br>";
 $res_select_curso_est2=mysql_query($select_curso_est2);
$num_filas_cur2 = mysql_num_rows($res_select_curso_est2);	

			if($num_filas_cur2>0){
			
			while($rs_curso2=mysql_fetch_array($res_select_curso_est2)){
				
			if(!empty($rs_curso2[2])&&isset($rs_curso2[2])){$foto3="<div align=center><img style='border-radius: 50%;
						-moz-border-radius: 50%;
						-webkit-border-radius: 50%;
						-khtml-border-radius: 50%;
						border: 2px solid #cee6fb;
						 overflow: hidden;'  src='img/foto/".$rs_curso2[2]."' width='50px' height='50px' ></div>";}
			else{$foto3="<div align=center><img style='border-radius: 50%;
						-moz-border-radius: 50%;
						-webkit-border-radius: 50%;
						-khtml-border-radius: 50%;
						border: 2px solid #cee6fb;
						 overflow: hidden;'  src='img/foto/anon.png' width='50px' height='50px' ></div>";}
				
				$tabla_consolidado_mat.="
				<div class='table-responsive2' align='center' style='margin:10px auto'>
					<table class='table table-striped table-bordered ' style='width:100%;'>
					
					<tr style='font-size:12px;'>
						<th>Foto</th><th colspan=''>Nombre</th><th colspan='1'><button type=\"button\" onclick=\"imprime_bol_p(
						".$_POST['cur5'].",".$_POST['per5'].",".$rs_curso2[0]."
						)\" >pdf</button></th>
					</tr>
					<tr style='font-size:10px'>
						<td>$foto3</td><td colspan=''>$rs_curso2[1]</td>
					</tr>";
		     	$select_pens2=" select distinct pensum.subject_id
            from estudiante,pensum,curso,planilla_detalle,asignatura 
				             where pensum.class_id=".$_POST['cur9']." 
				            and estudiante.estudiante_id=".$rs_curso2[0]." 
				            and planilla_detalle.planilla=".$_POST['per9']." 
				            and pensum.asignatura_id=".$_POST['mat9']."
				            and pensum.class_id=curso.curso_id 
				            and estudiante.curso_id=pensum.class_id 
				            and pensum.estado='A' 
				            and planilla_detalle.codigo_pensum=pensum.subject_id 
				            and planilla_detalle.codigo_est=estudiante.estudiante_id 
				            and asignatura.subject_id=pensum.asignatura_id order by asignatura.sigla";

			$res_select_pens2=mysql_query($select_pens2);
			$num_filas_pen2 = mysql_num_rows($res_select_pens2);	
		
			
			if($num_filas_pen2>0){
		
			$tabla_consolidado_mat.="<tr style='font-size:10px'>
						<th>Asignatura</th>
						<th>RD</th><th>60%</th><th>EI</th><th>EPI</th><th>40%</th><th>N.Global 60% (Parcial)</th>
						<th>C1</th><th>C2</th><th>B1</th><th>B2</th><th>N.Global 60%</th>
						<th>EF</th><th>EPF</th><th>N.Global 40%</th>
						<th>NFP1</th><th>NFP2</th><th>NFP3</th><th>NFP4</th><th>NMPP</th><th>INDICADOR</th><th>ACUM.GRAL</th>
						<th>Cg11</th>
						<th>B3</th>";
			$tabla_consolidado_mat.="<th>Nota Final</th>
						
					</tr>";
			 $registro.="<tr style='font-size:11px'><td>$rs_curso2[3]</td><td>$rs_curso2[0]</td><td>$rs_curso2[1]</td>";$reg_acum=0;
			while($rs_sel_pen2=mysql_fetch_array($res_select_pens2)){
		     	
		     	$select_curso_nota2=" select asignatura.nombre,planilla_detalle.concepto,planilla_detalle.codigo_pensum, IFNULL(comp_1,0), IFNULL(comp_2,0), IFNULL(comp_3,0)
						 from estudiante,pensum,curso,planilla_detalle,asignatura 
						 where pensum.class_id=".$_POST['cur9']." 
						and estudiante.estudiante_id=".$rs_curso2[0]."
						 and planilla_detalle.tipo_nota='D' 
						 and planilla_detalle.planilla=".$_POST['per9']." 
						 and pensum.class_id=curso.curso_id 
						 and pensum.asignatura_id=".$_POST['mat9']." 
						 and estudiante.curso_id=pensum.class_id 
						 and pensum.estado='A' 
						 and planilla_detalle.codigo_pensum=pensum.subject_id 
						 and planilla_detalle.codigo_est=estudiante.estudiante_id 
						 and asignatura.subject_id=pensum.asignatura_id 
						 order by planilla_detalle.id_nota		               ";	
				            
//				            echo $select_curso_nota2."<br>";
				            $res_select_curso_nota2=mysql_query($select_curso_nota2);
					    $num_filas_not2 = mysql_num_rows($res_select_curso_nota2);	
					    
					    
					    	/*********nota final otros periodos*****/
		     	
		     	/*******11-04-2014****QUERY PARA RECORRER PERIODOS PARA LAS DEF*/ 
		
		     	/**************************************/
					   
					    	if($num_filas_not2>0){			
									$materia_pensum='';
									$diario=0;
									$inter=0;
									$final=0;
									$int_prof=0;
									$fin_prof=0;
									$credito1=0;
									$credito2=0;	
									$creditog11=0;
									$total_60=0;
									$creditog11=0;
									$nota_final_p=0;
									//$acum_nota_final_per=0;
									
									$cuarenta_intermedio=0;
									$sesenta_parcial=0;
									$sesenta_global=0;
									$cuarenta_global=0;
							
									//$nota_p1=0;$nota_p2=0;$nota_p3=0;$nota_p4=0;
									//$acum_nota_final_per=0;
									$nota_min=0;
									$acum_gral=0;		

									$ac1=0;$ac2=0;$ac3=0;$ac4=0;$cont=0;

									while($rs_curso_nota2=mysql_fetch_array($res_select_curso_nota2)){
									$cont++;
									$c1=$rs_curso_nota2[3];
									$c2=$rs_curso_nota2[4];
									$c3=$rs_curso_nota2[5];
									$c4=round((($c1+$c2+$c3)/3),0);
									$ac1+=$c1;$ac2+=$c2;$ac3+=$c3;$ac4+=$c4;

									if($c1=='0'){$clase1="style=color:#cccccc";}else{$clase1="";}
									if($c2=='0'){$clase2="style=color:#cccccc";}else{$clase2="";}
									if($c3=='0'){$clase3="style=color:#cccccc";}else{$clase3="";}																		
									if($c4=='0'){$clase4="style=color:red";}else{$clase4="";}									
									
									$registro.="<td><table border=1 cellpadding='0px' cellspacing='0px' style='width:100%;font-size:10px;border-color:#eeeeee'><tr><td align='center' $clase1>".round($c1)."</td><td align='center' $clase2>".round($c2)."</td><td align='center' $clase3>".round($c3)."</td><td align='center' $clase4><strong>".round($c4)."</strong></td></tr></table></td>";
									$reg_acum+=$nota_final;	

																			
									$materia_pensum=$rs_curso_nota2[0];
									$diario+=$rs_curso_nota2[2];
									$inter+=$rs_curso_nota2[3];
									$final+=$rs_curso_nota2[4];
									$int_prof+=$rs_curso_nota2[5];
									$fin_prof+=$rs_curso_nota2[6];
									$credito1+=$rs_curso_nota2[7];
									$credito2+=$rs_curso_nota2[8];
									$creditog11+=$rs_curso_nota2[9];
									
									}
$registro.="<td><table border=1 cellpadding='0px' cellspacing='0px' style='width:100%;font-size:10px;border-color:#eeeeee'><tr><td align='center' >".round(($ac1/$cont),0)."</td><td align='center' >".round(($ac2/$cont),0)."</td><td align='center' >".round(($ac3/$cont),0)."</td><td align='center' ><strong>".round(($ac4/$cont),0)."</strong></td></tr></table></td>
									<td><table border=1 cellpadding='0px' cellspacing='0px' style='width:100%;font-size:10px;border-color:#eeeeee'><tr><td align='center' ><strong>".round((round(($ac4/$cont),0))*0.6,0)."</strong></td></tr></table></td>";
									
									
									$bono1=0;$bono2=0;$bono3=0;
									if($credito1>=0 && $credito1<=54)  {$bono1=0;}
									if($credito1>=55 && $credito1<=59) {$bono1=2.5;}
									if($credito1>=60 && $credito1<=64) {$bono1=5;}
									if($credito1>=65 && $credito1<=69) {$bono1=7.5;}
									if($credito1>=70 && $credito1<=74) {$bono1=10;}
									if($credito1>=75 && $credito1<=79) {$bono1=12.5;}
									if($credito1>=80 && $credito1<=84) {$bono1=15;}
									if($credito1>=85 && $credito1<=89) {$bono1=17.5;}
									if($credito1>=90 && $credito1<=100){$bono1=20;}
									
									if($credito2>=0 && $credito2<=54)  {$bono2=0;}
									if($credito2>=55 && $credito2<=59) {$bono2=2.5;}
									if($credito2>=60 && $credito2<=64) {$bono2=5;}
									if($credito2>=65 && $credito2<=69) {$bono2=7.5;}
									if($credito2>=70 && $credito2<=74) {$bono2=10;}
									if($credito2>=75 && $credito2<=79) {$bono2=12.5;}
									if($credito2>=80 && $credito2<=84) {$bono2=15;}
									if($credito2>=85 && $credito2<=89) {$bono2=17.5;}
									if($credito2>=90 && $credito2<=100){$bono2=20;}
									
									if($creditog11>=0 && $creditog11<=54)  {$bono3=0;}
									if($creditog11>=55 && $creditog11<=59) {$bono3=2.5;}
									if($creditog11>=60 && $creditog11<=64) {$bono3=5;}
									if($creditog11>=65 && $creditog11<=69) {$bono3=7.5;}
									if($creditog11>=70 && $creditog11<=74) {$bono3=10;}
									if($creditog11>=75 && $creditog11<=79) {$bono3=12.5;}
									if($creditog11>=80 && $creditog11<=84) {$bono3=15;}
									if($creditog11>=85 && $creditog11<=89) {$bono3=17.5;}
									if($creditog11>=90 && $creditog11<=100){$bono3=20;}
							
									
									$cuarenta_intermedio=round(($int_prof+$inter)/2)*0.4;
									
									$sesenta_parcial=round(($cuarenta_intermedio+round($diario*0.6))*0.6);
									$sesenta_global=round(($cuarenta_intermedio+round($diario*0.6)+$bono2+$bono1));
									if($sesenta_global>100){$sesenta_global=100;}
									
									$cuarenta_global=round(($final+$fin_prof)/2)*0.4;
									
									$total_60=round($sesenta_global)+round($bono2)+round($bono1);
									if($total_60>100){$total_60=100;}
									
									$nota_final_p=round($sesenta_global*0.6)+$cuarenta_global;
									
									if($nota_final_p>100){$nota_final_p=100;}
									
									if($nota_final_p>=0 && $nota_final_p<=69){$concepto_p='BAJO';} 
									if($nota_final_p>=70 && $nota_final_p<=79){$concepto_p='BASICO';}
									if($nota_final_p>=80 && $nota_final_p<=94){$concepto_p='ALTO';}
									if($nota_final_p>=95 && $nota_final_p<=100){$concepto_p='SUPERIOR';}
									
									if($actual==1){$nota_p1=$nota_final_p;$acum_nota_final_per+=$nota_final_p ;$nota_min=140-$acum_nota_final_per;}
									if($actual==2){$nota_p2=$nota_final_p;$acum_nota_final_per+=$nota_final_p ;$nota_min=210-$acum_nota_final_per;}
									if($actual==3){$nota_p3=$nota_final_p;$acum_nota_final_per+=$nota_final_p ;$nota_min=280-$acum_nota_final_per;}
									if($actual==4){$nota_p4=$nota_final_p;$acum_nota_final_per+=$nota_final_p ;}	
								
									if((round($acum_nota_final_per*0.25)+$bono3)>100)
									{
									$acum_gral=100;
									}
									else{
									$acum_gral=(round($acum_nota_final_per*0.25)+$bono3);
									}
								if(round(round($acum_nota_final_per*0.25)+round($bono3))>100){$nota_final=100;}
								else{$nota_final=round(round($acum_nota_final_per*0.25)+round($bono3));}
								$tabla_consolidado_mat.="<tr style='font-size:11px'>
									<td>".utf8_decode($materia_pensum)."</td>
									<td>".round($c1)." ".round($c2)." ".round($c3)."</td>";	
									if($nota_final=='0'){$clase="style=color:red";}else{$clase="";}
							$tabla_consolidado_mat.="<td $clase>".$nota_final."</td>	
									</tr>
									";
								}		
				}
				
				if($num_filas_asig2>0){$reg_acum=round(($reg_acum/$num_filas_asig2),1);}else{$reg_acum=0;}
				$registro.="<td></td></tr>";
			
			}
			

			$tabla_consolidado_mat.="</table>					
				</div>	";
			}
			
				}else{
				
				$men="<div class=\"alert alert-danger\">
	                    <button type=\"button\" class=\"close\" data-dismiss=\"alert\">X</button>
	                    No existen Registros para este curso
				</div>";
				}	
	
	/******************************************************************************/
$tabla_consolidado_reg2.="<div class='table-responsive2' align='center' style='margin:10px auto'>
					<table id='consolidado_crd' class='table table-striped table-bordered ' style='width:100%;'>
					
					<tr align='center' style='font-size:10px;'>
						<th>Curso</th><th colspan=''>Codigo</th><th>Nombre</th>";
	
	$cont=1;
	while($asig3=mysql_fetch_array($rs_select_asig3)){
	$tabla_consolidado_reg2.="<th align='center'><table border=1 cellpadding='5px' cellspacing='5px' style='width:100%;font-size:10px;border-color:#eee'><tr>Registro ".$cont."</tr><tr><td align='center'>C1</td><td align='center'>C2</td><td align='center'>C3</td><td align='center'><strong>NT</strong></td></tr></table></th>";
	$cont++;			
	}
		$tabla_consolidado_reg2.="<th align='center'><table align='center' border=1 cellpadding='5px' cellspacing='5px' style='width:100%;font-size:10px;border-color:#eee'><tr align='center'>PROMEDIOS</tr><tr><td align='center'>C1</td><td align='center'>C2</td><td align='center'>C3</td><td align='center'><strong>NT</strong></td></tr></table></th><td align='center'><strong>60%</strong></td><th></th></tr>".$registro."<tr><th colspan='29'></th></tr></table></div>	
				<div align='left'>
				
			<button type=\"button\" onclick=\"imprime_r3(".$_POST['cur9'].",".$_POST['per9'].",2,".$_POST['mat9'].")\" >PDF</button></div>
				";
	
  
}  







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>
	
		.btn-file {
		    position: relative;
		    overflow: hidden;
		}
		.btn-file input[type=file] {
		    position: absolute;
		    top: 0;
		    right: 0;
		    min-width: 100%;
		    min-height: 100%;
		    font-size: 999px;
		    text-align: right;
		    filter: alpha(opacity=0);
		    opacity: 0;
		    background: red;
		    cursor: inherit;
		    display: block;
		}
		input[readonly] {
			background-color: white !important;
			cursor: text !important;
		}
	
	
	.fileUpload {
	position: relative;
	overflow: hidden;
	margin: 10px;
	}
	.fileUpload input.upload {
	position: absolute;
	top: 0;
	right: 0;
	margin: 10px;
	padding: 10px;
	font-size: 12px;
	cursor: pointer;
	opacity: 0;
	filter: alpha(opacity=0);
	}
	</style>
    <title>Reporte Diario</title>

    <!-- Bootstrap core CSS -->
    <link href=\"../dist/css/bootstrap.min.css\" rel=\"stylesheet\">

    <!-- Custom styles for this template -->
    <link href=\"../offcanvas.css\" rel=\"stylesheet\">

    <!-- 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>
	<script type='text/javascript' src='../dist/js/bootstrap-filestyle.min.js'> </script>

    <![endif]-->
    <script>

function imprime_r3(cur,per,tip,mat){
var arr = new Array();	
var texto;
var texto2;

for (var i=0;i<document.getElementById('consolidado_crd').rows.length;i++) {
		for (var j=0; j<document.getElementById('consolidado_crd').rows[i].cells.length; j++){
				arr[i]+='|';
				texto=document.getElementById('consolidado_crd').rows[i].cells[j].innerHTML;
				texto2=texto.replace('<table align=\"center\" border=\"1\" cellpadding=\"5px\" cellspacing=\"5px\" style=\"width:100%;font-size:10px;border-color:#eee\">','');
				texto2=texto2.replace('<td align=\"center\">','|');
				texto2=texto2.replace('<td align=\"center\"> ','|');				
				texto2=texto2.replace(' <td align=\"center\">','|');				
				texto2=texto2.replace('<tr align=\"center\">','|');
				texto2=texto2.replace('<tbody>','|');
				texto2=texto2.replace('</tbody>','|');				
				texto2=texto2.replace('<strong>','|');
				texto2=texto2.replace('</strong>','|');				
				texto2=texto2.replace('<tr>','|');								
				texto2=texto2.replace('<td>','|');				
				texto2=texto2.replace('</tr>','|');								
				texto2=texto2.replace('</td>','|');	
				texto2=texto2.replace('<td align=\"center\" >','|');	
				texto2=texto2.replace('</td></tr>','|');				
				texto2=texto2.replace('</td><td align=\"center\">','|');											
				texto2=texto2.replace('<table align=\"center\" border=\"1\" cellpadding=\"5px\" cellspacing=\"5px\" style=\"width:100%;font-size:10px;border-color:#eee\">','|');
				texto2=texto2.replace('<table border=\"1\" cellpadding=\"5px\" cellspacing=\"5px\" style=\"width:100%;font-size:10px;border-color:#eee\">','|');				
				texto2=texto2.replace('<table border=\"1\" cellpadding=\"0px\" cellspacing=\"0px\" style=\"width:100%;font-size:10px;border-color:#eeeeee\">','|');				
				texto2=texto2.replace('<td align=\"center\" style=\"color:#cccccc\">','|');					
				texto2=texto2.replace('<td align=\"center\">','|');
				texto2=texto2.replace('<td align=\"center\"> ','|');				
				texto2=texto2.replace(' <td align=\"center\">','|');	
				texto2=texto2.replace('<tr>','|');			
				texto2=texto2.replace('</td><td align=\"center\">','|');													
				texto2=texto2.replace('</table>','|');							
				texto2=texto2.replace('</td>','|');
				texto2=texto2.replace('<td align=\"center\" style=\"color:#cccccc\">','|');texto2=texto2.replace('</td>','|');				
				texto2=texto2.replace('<td align=\"center\" style=\"color:#cccccc\">','|');texto2=texto2.replace('</td>','|');				
				texto2=texto2.replace('<td align=\"center\" style=\"color:#cccccc\">','|');texto2=texto2.replace('</td>','|');												
				texto2=texto2.replace('<td align=\"center\" style=\"color:red\">','|');texto2=texto2.replace('</td>','|');																
				arr[i]+=texto2;
				
				
			}	
		//alert(arr[i]);
		}

	if(tip==1){
	document.getElementById('val8').value=arr;
	document.getElementById('mat8_2').value=mat;	
	document.forms['frm_csv'].submit();}
	if(tip==2){
	document.getElementById('val9').value=arr;
	if(per=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per9').value=per;}
	if(cur=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur9').value=cur;}
	document.getElementById('mat9_2').value=mat;
	document.frm_pdf.target='_blank';	
	document.forms['frm_pdf'].submit();}
}

function imprime_r2(cur,per,tip,mat){
var arr = new Array();	
for (var i=0;i<document.getElementById('consolidado_cm').rows.length;i++) {
		for (var j=0; j<document.getElementById('consolidado_cm').rows[i].cells.length; j++){
				arr[i]+='|';
				arr[i]+=document.getElementById('consolidado_cm').rows[i].cells[j].innerHTML;
			}	
		}

	if(tip==1){
	document.getElementById('val8').value=arr;
	document.getElementById('mat8').value=mat;	
	document.forms['frm_csv'].submit();}
	if(tip==2){
	document.getElementById('val9').value=arr;
	if(per=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per9').value=per;}
	if(cur=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur9').value=cur;}
	document.getElementById('mat9').value=mat;
	document.frm_pdf.target='_blank';	
	document.forms['frm_pdf'].submit();}
}

function imprime_r1(cur,per,tip){
var arr = new Array();	
for (var i=0;i<document.getElementById('consolidado_c').rows.length;i++) {
		for (var j=0; j<document.getElementById('consolidado_c').rows[i].cells.length; j++){
				arr[i]+='|';
				arr[i]+=document.getElementById('consolidado_c').rows[i].cells[j].innerHTML;
			}	
		}

	if(tip==1){
	document.getElementById('val8').value=arr;	
	document.forms['frm_csv'].submit();}
	if(tip==2){
	document.getElementById('val9').value=arr;
	if(per=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per9').value=per;}
	if(cur=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur9').value=cur;}
	document.frm_pdf.target='_blank';	
	document.forms['frm_pdf'].submit();}
}

function consulta_consolidado_reg(p,c,m){
if(p=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per5').value=p;}
if(c=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur5').value=c;}
if(m=='XX'){alert('Debe seleccionar Una Materia');return false;}else{document.getElementById('mat5').value=m;}
document.getElementById('val5').value=1;
document.forms['consolidado_reg'].submit();
}  
function consulta_consolidado_mat(p,c,m){
if(p=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per4').value=p;}
if(c=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur4').value=c;}
if(m=='XX'){alert('Debe seleccionar Una Materia');return false;}else{document.getElementById('mat4').value=m;}
document.getElementById('val4').value=1;
document.forms['consolidado_mat'].submit();
}  

function consulta_consolidado(p,c){
if(p=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per3').value=p;}
if(c=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur3').value=c;}

document.getElementById('val3').value=1;
document.forms['consolidado_curso'].submit();
}  

function consulta_curso(p,c){
//alert ('per: '+p+'doc: '+d+' pen:'+m+' asig:'+a);
//alert ('per: '+p+'curso: '+c);
if(p=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per1').value=p;}
if(c=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur1').value=c;}
document.forms['listar_curso'].action='reportes.php';
document.listar_curso.target='_self';
document.getElementById('val1').value=1;
document.forms['listar_curso'].submit();
}

function consulta_periodo(p,c){
//alert ('per: '+p+'curso: '+c);

if(p=='XX'){alert('Debe seleccionar Un Periodo');return false;}else{document.getElementById('per2').value=p;}
if(c=='XX'){alert('Debe seleccionar Un Curso');return false;}else{document.getElementById('cur2').value=c;}
document.forms['listar_periodo'].action='reportes.php';
document.listar_periodo.target='_self';
document.getElementById('val2').value=1;
document.forms['listar_periodo'].submit();
}
  
function guardar_nota_materia(est,pen,per,doc,mat){
		alert(est+' '+pen+' '+per+' '+doc );
//		alert(document.getElementById('concepto-'+est).value);
//		alert(document.getElementById('comp1-'+est).value);
//		alert(document.getElementById('comp2-'+est).value);
//		alert(document.getElementById('comp3-'+est).value);


		document.getElementById('per1').value=per;
		document.getElementById('pen1').value=pen;
		document.getElementById('doc1').value=doc;
		document.getElementById('mat1').value=mat;		
		document.getElementById('estudiante').value=est;		
		document.getElementById('concepto').value=document.getElementById('concepto-'+est).value;				
		document.getElementById('componente1').value=document.getElementById('comp1-'+est).value;
		document.getElementById('componente2').value=document.getElementById('comp2-'+est).value;
		document.getElementById('componente3').value=document.getElementById('comp3-'+est).value;
		document.getElementById('pd_1a').value=est;		
		document.getElementById('sel_tipo_nota_1a').value=document.getElementById('sel_tipo_nota').value;
		
		
		document.getElementById('val1').value=6;
		document.forms['listar_curso'].submit();

	





}    

function listar_nota_nueva(pen,per,doc,mat){
//	alert(pen+' '+per+' '+doc );
//alert(mat );
//	alert('id nota '+document.getElementById('sel_tipo_nota').value);
		document.getElementById('per1').value=per;
		document.getElementById('doc1').value=doc;
		document.getElementById('pen1').value=pen;
		document.getElementById('mat1').value=mat;

		document.getElementById('sel_tipo_nota_1a').value=document.getElementById('sel_tipo_nota').value;
		document.getElementById('val1').value=5;
		document.forms['listar_curso'].submit();

}

function borrar_nota_1(pen,per,doc,mat){
	if(confirm('Desea borrar esta nota?')){
		if(confirm('Se borraran las notas diligenciadas, desea continuar?')){

		document.getElementById('per1').value=per;
		document.getElementById('doc1').value=doc;
		document.getElementById('pen1').value=pen;
		document.getElementById('mat1').value=mat;		

		document.getElementById('sel_tipo_nota_1a').value=document.getElementById('sel_tipo_nota').value;
		document.getElementById('val1').value=4;
		document.forms['listar_curso'].submit();
		
		}else{
		return false;
		}
	}else{
	return false;
	}
	

}
function guardar_nota_nueva(pen,per,doc,mat){
	//alert(pen);
	//alert(per);
	//alert(doc);
	//alert(document.getElementById('tipo_nota_1').value);
	//alert(document.getElementById('concepto_1').value);return false;
	if(document.getElementById('tipo_nota_1').value=='XX'){alert('Debe seleccionar tipo de nota valido');return false;}

	document.getElementById('pen_1a').value=pen;
	document.getElementById('per_1a').value=per;
	document.getElementById('tipo_nota_1a').value=document.getElementById('tipo_nota_1').value;	
	document.getElementById('concepto_1a').value=document.getElementById('concepto_1').value;	
	
	document.getElementById('per1').value=per;
	document.getElementById('doc1').value=doc;
	document.getElementById('pen1').value=pen;
	document.getElementById('mat1').value=mat;	
	
	
	document.getElementById('val1').value=3;
	document.perfil_academicos.action='reportes.php#perfil';
	document.forms['listar_curso'].submit();

}    
    
    
function agregar(doc){

	var k,c;
	k=1;c=0;
	var mat= document.getElementById('l_materias4');
	var m1 = document.createElement('option');
	mat.options.length=0;";
	$sel2='false';
	//	$sel2='';
	$TABLA_ASIG = mysql_query("SELECT * FROM pensum where estado='A' order by nombre");
		while($munic = mysql_fetch_array($TABLA_ASIG)) {
		echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);"; 
		echo   "if(doc ==$munic[2]) {";
				$municipios =mysql_query("SELECT * FROM asignatura where subject_id=$munic[4] order by  nombre");
				
				if(isset($municipios)){
				//echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);";  
					while($m12 = mysql_fetch_array($municipios)) {
				
						// if($munic[4]==$_POST['pen1']){$sel2='true';}else{$sel2='false';}
						 echo "mat.options[k] = new Option('".$m12[2]."'+' - '+'".$munic[1]."' , '".$m12[0]."',$sel2,$sel2);  
						 k++;";
					}
				}
			echo"}";
		}
	//<body onload=agregar(document.forms[0].depto.options[document.forms[0].depto.selectedIndex].value);>
echo	"}
function agregar2(doc){

	var k,c;
	k=1;c=0;
	var mat= document.getElementById('l_materias5');
	var m1 = document.createElement('option');
	mat.options.length=0;";
	$sel2='false';
	//	$sel2='';
	$TABLA_ASIG = mysql_query("SELECT * FROM pensum where estado='A' order by nombre");
		while($munic = mysql_fetch_array($TABLA_ASIG)) {
		echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);"; 
		echo   "if(doc ==$munic[2]) {";
				$municipios =mysql_query("SELECT * FROM asignatura where subject_id=$munic[4] order by  nombre");
				
				if(isset($municipios)){
				//echo "mat.options[0] = new Option('Seleccione Materia...', 'XX', false, false);";  
					while($m12 = mysql_fetch_array($municipios)) {
				
						// if($munic[4]==$_POST['pen1']){$sel2='true';}else{$sel2='false';}
						 echo "mat.options[k] = new Option('".$m12[2]."'+' - '+'".$munic[1]."' , '".$m12[0]."',$sel2,$sel2);  
						 k++;";
					}
				}
			echo"}";
		}
	//<body onload=agregar(document.forms[0].depto.options[document.forms[0].depto.selectedIndex].value);>
echo	"}	
function activar_docente(){
	if(document.getElementById('l_periodo').value!='XX')
	{
	document.getElementById('l_docente').disabled=false;
	document.getElementById('l_materias').disabled=false;
	}
	else{
	document.getElementById('l_docente').value='XX'
	//document.getElementById('l_docente').disabled=true;
	document.getElementById('l_materias').value='XX'
	//document.getElementById('l_materias').disabled=true;
	}

}


function imprime_bol_i_l(cur,per,est){
document.getElementById('per1').value=per;
document.getElementById('cur1').value=cur;
document.getElementById('estudiante').value=est;
	document.forms['listar_curso'].action='pdf/generador_l.php';
	document.listar_curso.target='_blank';
	document.forms['listar_curso'].submit();
}    
function imprime_bol_i(cur,per,est){
document.getElementById('per1').value=per;
document.getElementById('cur1').value=cur;
document.getElementById('estudiante').value=est;

	document.forms['listar_curso'].action='pdf/generador.php';
	document.listar_curso.target='_blank';
	document.forms['listar_curso'].submit();
}    
function imprime_bol_p_l(cur,per,est){
document.getElementById('per2').value=per;
document.getElementById('cur2').value=cur;
document.getElementById('estudiante2').value=est;
	document.forms['listar_periodo'].action='pdf/generador2_l.php';
	document.listar_periodo.target='_blank';
	document.forms['listar_periodo'].submit();
}    

function imprime_bol_p(cur,per,est){
document.getElementById('per2').value=per;
document.getElementById('cur2').value=cur;
document.getElementById('estudiante2').value=est;
	document.forms['listar_periodo'].action='pdf/generador2.php';
	document.listar_periodo.target='_blank';
	document.forms['listar_periodo'].submit();
}    



</script>
  
    
    
    
  </head>

  <body>
    <div class=\"navbar navbar-fixed-top navbar-inverse\" role=\"navigation\">
      <div class=\"container\">
        <div class=\"navbar-header\">
          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">
            <span class=\"sr-only\">Toggle navigation</span>
            <span class=\"icon-bar\"></span>
            <span class=\"icon-bar\"></span>
            <span class=\"icon-bar\"></span>
          </button>
           <a class=\"\" href=\"../general.php\"><img src='../img/logo1.png' style='margin-top:5px'></a>
        </div>
        
       <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-12 col-sm-12\">
          <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 $class5 ><a href=\"#registro\" data-toggle=\"tab\">Inf. Curso Reg. Diario</a></li>	  	  

	</ul>
	
	
	<!-- Tab panes -->

	<div class=\"tab-content\">
	<div class=\"tab-pane fade in $act5 \" id=\"registro\">
		<form name='consolidado_reg' id='consolidado_reg' method='post' action='reportes.php#registro' target='' >
		<input type='hidden' name='val5' id='val5' value='".$val5."'>	
		<input type='hidden' name='cur5' id='cur5' value='".$cur5."'>	
		<input type='hidden' name='per5' id='per5' value='".$per5."'>	
		<input type='hidden' name='mat5' id='mat5' value='".$mat5."'>			
		<input type='hidden' name='indice5' id='indice5' value='".$indice5."'>	
		<input type='hidden' name='periodo5' id='periodo5' value='".$periodo5."'>	
		<input type='hidden' name='pensum5' id='pensum5' value='".$pensum5."'>	

		<input type='hidden' name='planilla5' id='planilla5' value='".$planilla5."'>		
		<input type='hidden' name='c1_5' id='c1_5' value='".$c1_5."'>
		<input type='hidden' name='c2_5' id='c2_5' value='".$c2_5."'>
		<input type='hidden' name='c3_5' id='c3_5' value='".$c3_5."'>	
		<input type='hidden' name='concepto5' id='concepto5' value='".$concepto5."'>							

		<input type='hidden' name='tipoa_5' id='tipoa_5' value='".$tipoa_5."'>
		<input type='hidden' name='c1a_5' id='c1a_5' value='".$c1a_5."'>
		<input type='hidden' name='c2a_5' id='c2a_5' value='".$c2a_5."'>
		<input type='hidden' name='c3a_5' id='c3a_5' value='".$c3a_5."'>	
		<input type='hidden' name='conceptoa5' id='conceptoa5' value='".$conceptoa5."'>		
	

	

		<div class=\"page\">
			<fieldset>
			<legend><span class=\"glyphicon glyphicon-th-list\"></span> 
				Consolidado Curso x Reg. Diario
";
				
		
					$select_planilla="select *  from planilla where estado='A' order by anno desc,periodo ";
					$res_select_planilla=mysql_query($select_planilla);
					
//					$select_docente="select teacher_id,nombre  from docente where estado='A' order by nombre ";
//					$res_select_docente=mysql_query($select_docente);
					
					
					echo "
					<select id='l_periodo5' name='l_periodo5' style='margin:20px;font-size: 12px;' disabled>
					<option value='XX' >Seleccione Periodo</option>";
					while($r_sc=mysql_fetch_array($res_select_planilla)){
					$sel1='  ';
					if($_POST['per9']==$r_sc[0]){$sel1=' selected ';}
					//echo "hola";
					echo '<option style="font-size:9px" value="'.$r_sc[0].'"  '.$sel1.'  >P'.$r_sc[2].' - '.$r_sc[1].' </option>';
					}
ECHO				'</select>

			<select style="margin:20px;font-size: 12px;" name="l_curso5" id="l_curso5"  onchange="agregar2(this.options[this.selectedIndex].value);" disabled >';

				$sql_doc="select curso_id,codigo,nombre,estado  from curso where estado='A' order by orden";
				$result_sql_doc=mysql_query($sql_doc);
				echo '<option class="" value="XX" >Seleccione Curso</option>';
				while($r=mysql_fetch_array($result_sql_doc)){
				if( $r[1]==$d){$sel_doc=" selected ";}else{$sel_doc='';} 
				if($_POST['cur9']==$r[0]){$sel_doc=' selected ';}
						echo '<option value="'.$r[0].'"  '.$sel_doc.'>'.$r[1].' - '.$r[2].'</option>';
				}

echo	"</select>
	<select style=\"margin:20px;font-size: 12px;\" name=\"l_materias5\" id=\"l_materias5\" disabled   >";

//if($sel2=='false'){
				//$m2 =mysql_query("SELECT codigo,nombre FROM asignatura ");
				$m2 =mysql_query("SELECT asignatura.subject_id,asignatura.nombre,pensum.subject_id FROM asignatura,pensum
							where pensum.asignatura_id=asignatura.subject_id
							and pensum.class_id=".$_POST['cur9']." 

							");//and pensum.subject_id=".$_POST['pen1']." 
				if(isset($m2)){
				echo '<option class="" value="XX" >Seleccione Materias</option>';
				while($m3=mysql_fetch_array($m2)) {
				$sel_mat='';
						//if($_POST['pen1']==$m3[2]){$sel_mat=' selected ';}
						if($_POST['mat9']==$m3[0]){$sel_mat=' selected ';}
						echo '<option value="'.$m3[0].'" '.$sel_mat.' >'.$m3[1].'</option>';
					}
			
				}
//}			
		
echo			"</select>
			
			</legend>			
		</fieldset>
			

		</div>

	<fieldset>
	<div class='table-responsive'>";
echo $tabla_consolidado_reg2;
echo	"
	</div>
	</fieldset>	
		</form>
	<form id='frm_pdf' name='frm_pdf' method='post' action='../pdf/generador3.php'>
	<input type='hidden' name='val9' id='val9' value='".$val9."'>
	<input type='hidden' name='cur9' id='cur9' value='".$cur9."'>
	<input type='hidden' name='per9' id='per9' value='".$per9."'>
	<input type='hidden' name='mat9' id='mat9' value='".$mat9."'>
	<input type='hidden' name='mat9_2' id='mat9_2' value='".$mat9_2."'>		
	</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=\"https://code.jquery.com/jquery-1.10.2.min.js\"></script>
    <script src=\"../dist/js/bootstrap.min.js\"></script>
    <script src=\"../offcanvas.js\"></script>
  </body>
</html>
";
}else{
echo "<div align='center'>Debe registrase para usar la aplicaci&oacute;n <a href='index.php' > Registrar</a></div>";
}
?>