<?php
session_start();


//if (isset($_SESSION['user'])&&!empty($_SESSION['user'])) {

/* http://programarenphp.wordpress.com */
/* incluimos primeramente el archivo que contiene la clase fpdf */
include '../conector.php';

$select_est="select estudiante_id,nombre,usuario,clave  from estudiante where curso_id=".$_POST['cur1']." and estado_est='A' order by nombre";
$res_select_est=mysql_query($select_est);
//echo $select_est;
include ('fpdf.php');

class PDF extends FPDF
{
function Header()
{
//if (isset($_SESSION['planilla'])){$planilla=$_SESSION['planilla'];} 

//$today_h = date('d-m-Y');	
$seleccion=$_POST['per1'];	

}
/*//Pie de página
function Footer()
{
$today_h = date('d-m-Y H:i:s');
$this->SetY(-2);
$this->SetFont('Arial','',6.5); 
    $this->Cell(4.5,0.5,'Fecha Generacion: '.$today_h,0,0,'L'); 

   }
  */
}

/* tenemos que generar una instancia de la clase */
  $pdf=new PDF('P','cm','letter');

  	//	session_destroy();  
if($_POST['val1']==1){
while($rs_sest=mysql_fetch_array($res_select_est))
{

$seleccion_pen=" select distinct pensum.subject_id
            from estudiante,pensum,curso,planilla_detalle,asignatura 
				             where pensum.class_id=".$_POST['cur1']." 
				            and estudiante.estudiante_id=".$rs_sest[0]." 
				            and planilla_detalle.planilla=".$_POST['per1']." 
				            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 pensum.nombre";

//echo $rs_sest[0]."<br>";
$pdf->AddPage();

$today_h = date('d-m-Y');	

/*$sel_estudiante="select estu.nombre,estu.usuario,estu.clave,u.nombre_archivo as foto from"
        . " estudiante estu"
        ." left join upload u ON (u.codigo = estu.estudiante_id and u.clase='F')"
        . "where estu.estudiante_id=".$_POST['estudiante']." ";
$res_sel_estudiante=mysql_query($sel_estudiante);
$estudiante=mysql_fetch_array($res_sel_estudiante);*/

$sel_estudiante="select estudiante_id,nombre,usuario,clave  from estudiante where curso_id=".$_POST['cur1']." 
and estudiante_id=".$rs_sest[0]."
and estado_est='A' ";
//echo $sel_estudiante;
$res_sel_estudiante=mysql_query($sel_estudiante);
$estudiante=mysql_fetch_array($res_sel_estudiante);

$sel_curso="select codigo,nombre from curso where curso_id=".$_POST['cur1']." ";
$res_sel_curso=mysql_query($sel_curso);
$curso=mysql_fetch_array($res_sel_curso);

$sel_planilla="select anno,periodo from planilla where id=".$_POST['per1']." ";
$res_sel_planilla=mysql_query($sel_planilla);
$planilla=mysql_fetch_array($res_sel_planilla);

      
	$pdf->Ln(0.2);
	$pdf->SetFillColor(212,212,212);
	$pdf->SetFont('Arial','B',16); 
        $pdf->Cell(9,1,' COLEGIO DE LA ESPERANZA',0,0,'L',TRUE); 
        $pdf->Cell(0.1,1,' ',0,0,'C');
        $pdf->Cell(11.4,1,' INFORME PROCESOS INTERMEDIOS',0,1,'C',TRUE);

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(11.4,0.5,'NOMBRE DEL ALUMNO',0,1,'C',TRUE);

        $pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','',8); 
        /*$pdf->Cell(12.4,2.5,''.utf8_decode($estudiante[0]),0,1,'C',false);
        $imagen_nueva_v = '../img/foto/'.$estudiante[3];
        
        if (file_exists($imagen_nueva_v) && $estudiante[3] != "") {
            $pdf->Image($imagen_nueva_v,9.6,2.3,2.8);
        } else {
            $pdf->Image('../img/foto/estudiante.jpg',9.6,2.3,2.8);
        }
        $pdf->Ln(0.1);*/

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','',8); 
        $pdf->Cell(11.4,0.5,''.utf8_decode($rs_sest[1]),0,1,'C',false);

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(2,0.5,'CODIGO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'CURSO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'FECHA',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'PERIODO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(3,0.5,'AÑO ESCOLAR',0,1,'C',true);        

	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','',8); 
        $pdf->Cell(2,0.5,''.$rs_sest[0],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$curso[0].' - '.$curso[1],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$today_h,0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$planilla[1],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(3,0.5,''.$planilla[0],0,1,'C',false);        

	$pdf->Ln(1.5);
	$pdf->SetFillColor(255,255,255);
	$pdf->Cell(9.1,1.5,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(3.8,0.3,' ',0,0,'C',true);
        $pdf->Cell(3.8,0.3,' ',0,0,'C',true);
        $pdf->Cell(3.8,0.3,'_______________________',0,1,'C',true);

	$pdf->Cell(9.1,0.5,' ',0,0,'C');
	$pdf->SetFont('Arial','b',6); 
        $pdf->Cell(3.8,0.3,'JORGE ALFONSO PEREZ VASQUEZ',0,0,'C',true);
        $pdf->Cell(3.8,0.3,'EVELYN TORRES HERAZO',0,0,'C',true);
        $pdf->Cell(3.8,0.3,'DIRECTOR DE GRUPO',0,1,'C',true);
        
	$pdf->SetFont('Arial','',7); 
      	$pdf->Cell(9.1,0.5,'PLATAFORMA USUARIO: '.strtoupper($rs_sest[2]).'  CLAVE: '.$rs_sest[3],0,0,'L');
	$pdf->SetFont('Arial','b',6); 
	    $pdf->Image('../img/firma_rector.jpg',10.5,4.5,0);
        $pdf->Cell(3.8,0.3,'RECTOR',0,0,'C',true);
        $pdf->Image('../img/firma_secretaria.jpg',13.7,4.5,0);
        $pdf->Cell(3.8,0.3,'SECRETARIA ACADEMICA',0,0,'C',true);
        $pdf->Cell(3.8,0.3,' ',0,1,'C',true);

	$pdf->Image('../img/escudo.jpg',0.5,1.8,3);
        $pdf->Ln(0.1);

	$res_seleccion_pen=mysql_query($seleccion_pen);
	$num_filas_pen = mysql_num_rows($res_seleccion_pen);	

	if($num_filas_pen>0){
//	$pdf->Ln(2);	
$color=242;$cont=1;

		while($rs_sel_pen=mysql_fetch_array($res_seleccion_pen)){
                                /**************************   FALTAS  *****************************/
				$sel_faltas="select * from asistencia a,asistencia_det b
						where b.asistencia_id=a.id
						and a.periodo=".$_POST['per1']."
						and a.pensum=".$rs_sel_pen[0]."
						and b.estudiante=".$rs_sest[0]."
						and asiste=0";
				$num_faltas=0;
		            	$res_sel_faltas=mysql_query($sel_faltas);
			    	$num_faltas = mysql_num_rows($res_sel_faltas);	
		 	
				/**************************  FIN FALTAS  *****************************/
			 	$select_curso_nota=" select  asignatura.nombre,planilla_consulta.pensum,
				            IFNULL(planilla_consulta.D,0),
								IFNULL(planilla_consulta.I,0),
								IFNULL(planilla_consulta.F,0),
								IFNULL(planilla_consulta.IP,0),
								IFNULL(planilla_consulta.FP,0),IFNULL(planilla_consulta.C1,0),
								IFNULL(planilla_consulta.C2,0),
								IFNULL(planilla_consulta.CG,0),pensum.intensidad
				            from estudiante,pensum,curso,planilla_consulta,asignatura 
				            where pensum.class_id=".$_POST['cur1']." 
				            and estudiante.estudiante_id=".$rs_sest[0]." 
				            and planilla_consulta.periodo=".$_POST['per1']." 
				            and pensum.class_id=curso.curso_id 
				            and estudiante.curso_id=pensum.class_id 
				            and pensum.estado='A' 
				            and pensum.subject_id=".$rs_sel_pen[0]."
				            and planilla_consulta.pensum=pensum.subject_id 
				            and planilla_consulta.estudiante=estudiante.estudiante_id 
				            and asignatura.subject_id=pensum.asignatura_id order by pensum.nombre";	

//echo $select_curso_nota."<br>";
				            
				            $res_select_curso_nota=mysql_query($select_curso_nota);
					    $num_filas_not = mysql_num_rows($res_select_curso_nota);	
					    
					    	if($num_filas_not>0){			
									$materia_pensum='';
									$diario=0;
									$inter=0;
									$final=0;
									$int_prof=0;
									$fin_prof=0;
									$credito1=0;
									$credito2=0;	
									$total_60_p=0;
									$cuarenta_intermedio_p=0;
									$sesenta_global_p=0;
									$cuarenta_global_p=0;
									while($rs_curso_nota=mysql_fetch_array($res_select_curso_nota)){
									$materia_pensum=utf8_decode($rs_curso_nota[0]);
									$diario+=$rs_curso_nota[2];
									$inter+=$rs_curso_nota[3];
									$final+=$rs_curso_nota[4];
									$int_prof+=$rs_curso_nota[5];
									$fin_prof+=$rs_curso_nota[6];
									$credito1+=$rs_curso_nota[7];
									$credito2+=$rs_curso_nota[8];
									$intensidad=$rs_curso_nota[10];

							
									
									
									}
									
											if($credito1>=0 && $credito1<=59)  {$bono1=0;}
											if($credito1>=60 && $credito1<=64) {$bono1=3;}
											if($credito1>=65 && $credito1<=69) {$bono1=5;}
											if($credito1>=70 && $credito1<=74) {$bono1=8;}
											if($credito1>=75 && $credito1<=79) {$bono1=10;}
											if($credito1>=80 && $credito1<=84) {$bono1=13;}
											if($credito1>=85 && $credito1<=89) {$bono1=15;}
											if($credito1>=90 && $credito1<=94) {$bono1=18;}
											if($credito1>=95 && $credito1<=100){$bono1=20;}
											
											if($credito2>=0 && $credito2<=59)  {$bono2=0;}
											if($credito2>=60 && $credito2<=64) {$bono2=3;}
											if($credito2>=65 && $credito2<=69) {$bono2=5;}
											if($credito2>=70 && $credito2<=74) {$bono2=8;}
											if($credito2>=75 && $credito2<=79) {$bono2=10;}
											if($credito2>=80 && $credito2<=84) {$bono2=13;}
											if($credito2>=85 && $credito2<=89) {$bono2=15;}
											if($credito2>=90 && $credito2<=94) {$bono2=18;}
											if($credito2>=95 && $credito2<=100){$bono2=20;}
									
									if($cont==1){$color=212;$cont=2;}
									elseif($cont==2){$color=242;$cont=1;}
									$cuarenta_intermedio=round(($int_prof+$inter)/2)*0.4;
									//$sesenta_global=round(($cuarenta_intermedio+round($diario*0.6))*0.6);
									$sesenta_global=round(($cuarenta_intermedio+round($diario*0.6)));
									if(round($sesenta_global+$bono2+$bono1)>100){$not=100;}else{$not=round($sesenta_global+$bono2+$bono1);}
									$pdf->SetFont('Arial','b',7);
									//$pdf->SetDrawColor(212,86,86);
									$pdf->SetFillColor($color,$color,$color);
									$pdf->Cell(9,0.5,"  ".strtoupper($materia_pensum),0,0,'L',true);
									$pdf->Cell(0.5,0.5," IH:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5,"".strtoupper($intensidad),1,0,'C',false);
									$pdf->Cell(0.5,0.5," F:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".$num_faltas,1,0,'C',false);
									$pdf->Cell(2.5,0.5," PROM. REGISTROS:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($diario),1,0,'C',false);
									$pdf->Cell(2,0.5," PROC-INTERM.:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($inter),1,0,'C',false);
									$pdf->Cell(1.5,0.5," REC/PROF:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($int_prof),1,0,'C',false);
									$pdf->Cell(1.5,0.5," NOTA:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".$not,1,1,'C',false);
									
								
								}
		
		}
	
	}
	
$sel_estudiante="select nombre,usuario,clave from estudiante where estudiante_id=".$rs_sest[0]." ";

//echo $sel_estudiante."<br>";
$res_sel_estudiante=mysql_query($sel_estudiante);
$estudiante=mysql_fetch_array($res_sel_estudiante);


}
$pdf->Output("Informe_Intermedio.pdf",'I');
}
if($_POST['val1']==2){
while($rs_sest=mysql_fetch_array($res_select_est))
{

$seleccion_pen=" select distinct pensum.subject_id
            from estudiante,pensum,curso,planilla_detalle,asignatura 
				             where pensum.class_id=".$_POST['cur1']." 
				            and estudiante.estudiante_id=".$rs_sest[0]." 
				            and planilla_detalle.planilla=".$_POST['per1']." 
				            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 pensum.nombre";

//echo $rs_sest[0]."<br>";
$pdf->AddPage();

$today_h = date('d-m-Y');	

$sel_estudiante="select estudiante_id,nombre,usuario,clave  from estudiante where curso_id=".$_POST['cur1']." 
and estudiante_id=".$rs_sest[0]."
and estado_est='A' ";
//echo $sel_estudiante;
$res_sel_estudiante=mysql_query($sel_estudiante);
$estudiante=mysql_fetch_array($res_sel_estudiante);

$sel_curso="select codigo,nombre from curso where curso_id=".$_POST['cur1']." ";
$res_sel_curso=mysql_query($sel_curso);
$curso=mysql_fetch_array($res_sel_curso);

$sel_planilla="select anno,periodo from planilla where id=".$_POST['per1']." ";
$res_sel_planilla=mysql_query($sel_planilla);
$planilla=mysql_fetch_array($res_sel_planilla);

      
	$pdf->Ln(0.2);
	$pdf->SetFillColor(212,212,212);
	$pdf->SetFont('Arial','B',16); 
        $pdf->Cell(9,1,' COLEGIO DE LA ESPERANZA',0,0,'L',TRUE); 
        $pdf->Cell(0.1,1,' ',0,0,'C');
        $pdf->Cell(11.4,1,' INFORME INTERMEDIO',0,1,'C',TRUE);

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(11.4,0.5,'NOMBRE DEL ALUMNO',0,1,'C',TRUE);

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','',8); 
        $pdf->Cell(11.4,0.5,''.utf8_decode($rs_sest[1]),0,1,'C',false);

	$pdf->Ln(0.1);
	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(2,0.5,'CODIGO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'CURSO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'FECHA',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,'PERIODO',0,0,'C',true);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(3,0.5,'AÑO ESCOLAR',0,1,'C',true);        

	$pdf->Cell(9.1,1,' ',0,0,'C');
	$pdf->SetFont('Arial','',8); 
        $pdf->Cell(2,0.5,''.$rs_sest[0],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$curso[0].' - '.$curso[1],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$today_h,0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(2,0.5,''.$planilla[1],0,0,'C',false);
        $pdf->Cell(0.1,1,' ',0,0,'C');        
        $pdf->Cell(3,0.5,''.$planilla[0],0,1,'C',false);        

	$pdf->Ln(0.1);
	$pdf->SetFillColor(255,255,255);
	$pdf->Cell(9.1,0.7,' ',0,0,'C');
	$pdf->SetFont('Arial','b',8); 
        $pdf->Cell(3.8,0.5,' ',0,0,'C',true);
        $pdf->Cell(3.8,0.5,' ',0,0,'C',true);
        $pdf->Cell(3.8,0.5,'_______________________',0,1,'C',true);

	$pdf->Cell(9.1,0.5,' ',0,0,'C');
	$pdf->SetFont('Arial','b',6); 
        $pdf->Cell(3.8,0.5,'JORGE ALFONSO PEREZ VASQUEZ',0,0,'C',true);
        $pdf->Cell(3.8,0.5,'EVELYN TORRES HERAZO',0,0,'C',true);
        $pdf->Cell(3.8,0.5,'DIRECTOR DE GRUPO',0,1,'C',true);
        
	$pdf->SetFont('Arial','',6); 
      	$pdf->Cell(9.1,0.5,'PLATAFORMA USUARIO: '.strtoupper($rs_sest[2]).'  CLAVE: '.$rs_sest[3],0,0,'L');
	$pdf->SetFont('Arial','b',7);
	    $pdf->Image('../img/firma_rector.jpg',10.5,3.3,0);
        $pdf->Cell(3.8,0.5,'RECTOR',0,0,'C',true);
        $pdf->Image('../img/firma_secretaria.jpg',13.7,3.3,0);
        $pdf->Cell(3.8,0.5,'SECRETARIA ACADEMICA',0,0,'C',true);
        $pdf->Cell(3.8,0.5,' ',0,1,'C',true);

	$pdf->Image('../img/escudo.jpg',0.5,1.8,3);
        $pdf->Ln(0.1);

	$res_seleccion_pen=mysql_query($seleccion_pen);
	$num_filas_pen = mysql_num_rows($res_seleccion_pen);	

	if($num_filas_pen>0){
//	$pdf->Ln(2);	
$color=242;$cont=1;

		while($rs_sel_pen=mysql_fetch_array($res_seleccion_pen)){
                                /**************************   FALTAS  *****************************/
				$sel_faltas="select * from asistencia a,asistencia_det b
						where b.asistencia_id=a.id
						and a.periodo=".$_POST['per1']."
						and a.pensum=".$rs_sel_pen[0]."
						and b.estudiante=".$rs_sest[0]."
						and asiste=0";
				$num_faltas=0;
		            	$res_sel_faltas=mysql_query($sel_faltas);
			    	$num_faltas = mysql_num_rows($res_sel_faltas);	
		 	
				/**************************  FIN FALTAS  *****************************/

			 	$select_curso_nota=" select  asignatura.nombre,planilla_consulta.pensum,
				            IFNULL(planilla_consulta.D,0),
								IFNULL(planilla_consulta.I,0),
								IFNULL(planilla_consulta.F,0),
								IFNULL(planilla_consulta.IP,0),
								IFNULL(planilla_consulta.FP,0),
                                                                IFNULL(planilla_consulta.C1,0),
								IFNULL(planilla_consulta.C2,0),
								IFNULL(planilla_consulta.CG,0),
                                                                pensum.intensidad
				            from estudiante,pensum,curso,planilla_consulta,asignatura 
				            where pensum.class_id=".$_POST['cur1']." 
				            and estudiante.estudiante_id=".$rs_sest[0]." 
				            and planilla_consulta.periodo=".$_POST['per1']." 
				            and pensum.class_id=curso.curso_id 
				            and estudiante.curso_id=pensum.class_id 
				            and pensum.estado='A' 
				            and pensum.subject_id=".$rs_sel_pen[0]."
				            and planilla_consulta.pensum=pensum.subject_id 
				            and planilla_consulta.estudiante=estudiante.estudiante_id 
				            and asignatura.subject_id=pensum.asignatura_id order by pensum.nombre";	

//echo $select_curso_nota."<br>";
				            
				            $res_select_curso_nota=mysql_query($select_curso_nota);
					    $num_filas_not = mysql_num_rows($res_select_curso_nota);	
					    
					    	if($num_filas_not>0){			
												
												
									$materia_pensum='';
									$diario=0;
									$inter=0;
									$final=0;
									$int_prof=0;
									$fin_prof=0;
									$credito1=0;
									$credito2=0;	
									$total_60_p=0;
									$cuarenta_intermedio_p=0;
									$sesenta_global_p=0;
									$cuarenta_global_p=0;
									while($rs_curso_nota=mysql_fetch_array($res_select_curso_nota)){
									$materia_pensum=utf8_decode($rs_curso_nota[0]);
									$diario+=$rs_curso_nota[2];
									$inter+=$rs_curso_nota[3];
									$final+=$rs_curso_nota[4];
									$int_prof+=$rs_curso_nota[5];
									$fin_prof+=$rs_curso_nota[6];
									$credito1+=$rs_curso_nota[7];
									$credito2+=$rs_curso_nota[8];
									$intensidad=$rs_curso_nota[10];

							
									
									
									}
									
											if($credito1>=0 && $credito1<=59)  {$bono1=0;}
											if($credito1>=60 && $credito1<=64) {$bono1=3;}
											if($credito1>=65 && $credito1<=69) {$bono1=5;}
											if($credito1>=70 && $credito1<=74) {$bono1=8;}
											if($credito1>=75 && $credito1<=79) {$bono1=10;}
											if($credito1>=80 && $credito1<=84) {$bono1=13;}
											if($credito1>=85 && $credito1<=89) {$bono1=15;}
											if($credito1>=90 && $credito1<=94) {$bono1=18;}
											if($credito1>=95 && $credito1<=100){$bono1=20;}
											
											if($credito2>=0 && $credito2<=59)  {$bono2=0;}
											if($credito2>=60 && $credito2<=64) {$bono2=3;}
											if($credito2>=65 && $credito2<=69) {$bono2=5;}
											if($credito2>=70 && $credito2<=74) {$bono2=8;}
											if($credito2>=75 && $credito2<=79) {$bono2=10;}
											if($credito2>=80 && $credito2<=84) {$bono2=13;}
											if($credito2>=85 && $credito2<=89) {$bono2=15;}
											if($credito2>=90 && $credito2<=94) {$bono2=18;}
											if($credito2>=95 && $credito2<=100){$bono2=20;}
									
									if($cont==1){$color=212;$cont=2;}
									elseif($cont==2){$color=242;$cont=1;}
									$cuarenta_intermedio=round(($int_prof+$inter)/2)*0.4;
									//$sesenta_global=round(($cuarenta_intermedio+round($diario*0.6))*0.6);
									$sesenta_global=round(($cuarenta_intermedio+round($diario*0.6)));
                                    if(round($sesenta_global+$bono2+$bono1)>100){$not=100;}else{$not=round($sesenta_global+$bono2+$bono1);}
									$pdf->SetFont('Arial','b',7);
									//$pdf->SetDrawColor(212,86,86);
									$pdf->SetFillColor($color,$color,$color);
									$pdf->Cell(9,0.5,"  ".strtoupper($materia_pensum),0,0,'L',true);
									$pdf->Cell(0.5,0.5," IH:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5,"".strtoupper($intensidad),1,0,'C',false);
									$pdf->Cell(0.5,0.5," F:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".$num_faltas,1,0,'C',false);
									$pdf->Cell(2.5,0.5," PROM. REGISTROS:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($diario),1,0,'C',false);
									$pdf->Cell(2,0.5," PROC-INTERM.:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($inter),1,0,'C',false);
									$pdf->Cell(1.5,0.5," REC/PROF:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".round($int_prof),1,0,'C',false);
									$pdf->Cell(1.5,0.5," NOTA:",0,0,'C',true);									
									$pdf->Cell(0.5,0.5," ".$not,1,1,'C',false);
									
									$select_logro="
									select logros.descripcion 
									from logros,logros_estudiante 
									where logros.id=logros_estudiante.id_logro
									and logros_estudiante.id_estudiante=".$rs_sest[0]." 
									and logros.planilla=".$_POST['per1']." 
									and logros.pensum=".$rs_sel_pen[0]."
									order by logros.descripcion ";
									$res_select_logro=mysql_query($select_logro);
									$num_filas_log = mysql_num_rows($res_select_logro);	
									if($num_filas_log>0){	
										$pdf->Cell(9,0.5,"  LOGROS:",0,1,'L',false);
										while($rs_logro=mysql_fetch_array($res_select_logro)){
										
										$pdf->Cell(9,0.5,"  *  ".strtoupper(utf8_decode($rs_logro[0])),0,1,'L',false);
										
										}
									}
									
									$select_rec="select id,descripcion 
											from recomendacion 
											where pensum=".$rs_sel_pen[0]." 
											and id_estudiante='".$rs_sest[0]."' 
											and planilla='".$_POST['per1']."' ";
											
									$res_select_rec=mysql_query($select_rec);
									$filas=mysql_num_rows($res_select_rec);
									
									if($filas>0){
									$res=mysql_fetch_array($res_select_rec);
									$pdf->SetFillColor(255,255,255);
								        $pdf->Ln(0.1);
									$pdf->Cell(3,0.5,"  RECOMENDACIONES:  ",0,0,'L',false);
									$pdf->MultiCell(17.5,0.5," ".strtoupper(utf8_decode($res[1])),1,1,'L',false);	
									
									
									
									}
									
									
								
								}
		
		}
	
	}
	
$sel_estudiante="select nombre,usuario,clave from estudiante where estudiante_id=".$rs_sest[0]." ";

//echo $sel_estudiante."<br>";
$res_sel_estudiante=mysql_query($sel_estudiante);
$estudiante=mysql_fetch_array($res_sel_estudiante);


}
$pdf->Output("Informe_Intermedio_Logros.pdf",'I');
}




	?>