<?php

require_once 'bs_con2.php';
require_once 'bs_info_col.php';
require_once('FPDF/fpdf.php');

class GenerarPdf extends FPDF
{
    function Header()
    {
        $ob=new InfoCol();
        $arr=$obj->proceso();
        
        $this->Ln(10);
        $this->Image("../../views/default/images/".$arr[1],20,12,20);
        $this->SetFont("Times","B",16);
        $this->Cell(34);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(248,248,255);
        $this->Cell(125,9,$arr[0],1,0,'C',false);
                
                
        $this->Ln(13);
        //$this->Image("",10,10,30);
        $this->SetFont("Times","B",12);
        $this->Cell(70);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(240,230,140);
        $this->Cell(50,6,"Logros",1,0,'C',true);
        $this->Ln(12);
        
    }
 
    

    function titTabla($cabeceraT){


       $this->SetFont("Helvetica","B",9);
       $this->Cell(20);
       $this->SetFillColor(189,183,107);
       for($i=0;$i<count($cabeceraT);$i++)
        {            
           if($i==1)
               {
           $this->Cell(93,5,($cabeceraT[$i]),1,0,'C',true);
               }else
                   {
           $this->Cell(24,5,($cabeceraT[$i]),1,0,'C',true);
               }
                
            }
        $this->ln(5);

    }


    function datos_Tbla($cabeceraT){
        
        $obj=new Con2();
        $arr=$obj->proceso($_REQUEST['grado'],$_REQUEST['curso'],$_REQUEST['asig']);
        $obj->disconnect();

        
        if($arr=='no')
         {
            //$this->SetFont("Helvetica","B",9);
            $this->Cell(65);
            $this->SetFillColor(248,248,255);
            $this->Cell(60,9,"No hay Logros Registrados",1,0,'C',true);
         }else{
       
        
        $this->Ln(5);
       $this->Cell(1);
       $this->SetFont("Times","B",12);
       $this->SetTextColor(0,0,0);
       $this->SetFillColor(248,248,255);
       $this->Cell(110,6,"Curso : ".$arr[0][2],1,0,'C',true);
       $this->Ln(10);
       $this->SetFont("Helvetica","B",7);
       $this->Cell(21);
        
        for($c=0;$c<count($arr);$c++)
       {

       if($c>0){

               if($arr[$c][4]==$arr[$c-1][4])
                 {      
                     

                $this->SetFont("Helvetica","I",7);
                $this->Cell(10);

                for($i=3;$i<7;$i++)
                   {
                        if($i==6)
                        {
                            $this->Cell(55,5,$arr[$c][$i],1,0,'C');
                        }else if($i==3){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');

                        }else if($i==5){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');
                        }

                   }

                   $this->ln(5);

                   }else    {
                       
                       
               $this->Ln(5);
               $this->Cell(1);
               $this->SetFont("Times","B",12);
               $this->SetTextColor(0,0,0);
               $this->SetFillColor(255,248,220);
               $this->Cell(10);
               $this->Cell(50,6,"Periodo : ".$arr[$c][4],1,0,'C',true);
               $this->Ln(10);
               $this->SetFont("Helvetica","B",7);
               
               $this->Cell(30);

                $this->SetFillColor(248,248,255);
               for($i=0;$i<count($cabeceraT);$i++)
                {
                   if($i==2)
                   {
                       $this->Cell(55,5,($cabeceraT[$i]),1,0,'C',true);
                   
                   }else{
                   $this->Cell(25,5,($cabeceraT[$i]),1,0,'C',true);}
                       

                 }
                $this->ln(5);


                $this->SetFont("Helvetica","I",7);
                $this->Cell(30);

                for($i=3;$i<7;$i++)
                   {
                        if($i==6)
                        {                            
                            $this->Cell(55,5,$arr[$c][$i],1,0,'C');
                        }else if($i==3){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');
                        
                        }else if($i==5){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');
                        }

                   }
                   
                   $this->ln(5);
                $this->Cell(20);  

        
                   
               }
           }else
               {
        
               $this->Ln(5);
               $this->Cell(1);
               $this->SetFont("Times","B",12);
               $this->SetTextColor(0,0,0);
               $this->SetFillColor(255,248,220);
               $this->Cell(10);
               $this->Cell(50,6,"Periodo : ".$arr[$c][4],1,0,'C',true);
               $this->Ln(10);
               $this->SetFont("Helvetica","B",7);
               
               $this->Cell(30);

                $this->SetFillColor(248,248,255);
               for($i=0;$i<count($cabeceraT);$i++)
                {
                   if($i==2)
                   {
                       $this->Cell(55,5,($cabeceraT[$i]),1,0,'C',true);
                   
                   }else{
                   $this->Cell(25,5,($cabeceraT[$i]),1,0,'C',true);}
                       

                 }
                $this->ln(5);


                $this->SetFont("Helvetica","I",7);
                $this->Cell(30);

                for($i=3;$i<7;$i++)
                   {
                        if($i==6)
                        {                            
                            $this->Cell(55,5,$arr[$c][$i],1,0,'C');
                        }else if($i==3){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');
                        
                        }else if($i==5){
                            $this->Cell(25,5,$arr[$c][$i],1,0,'C');
                        }

                   }
                   
                   $this->ln(5);
                $this->Cell(20);  

               }

           }
         }
        
       
        
    }





function Footer()
    {
        $this->SetY(-20);
        $this->Cell(20);
        $this->Cell(120,10,"Pagina No.".$this->PageNo()."",1,0);
        $this->Cell(200);
    }
}

$cabeceraT=array("Asignatura","Codigo","Descripcion");


$pdf=new GenerarPdf();
$pdf->AddPage();

$pdf->datos_Tbla($cabeceraT);
$pdf->Output();

?>
