<?php

require_once 'bs_con1.php';
require_once '../../../../app/model/bs_info_col.php';
require_once('../../../../app/model/FPDF/fpdf.php');

class GenerarPdf extends FPDF
{
    function Header()
    {
        $ob=new InfoCol();
        $arr=$obj->proceso();
        
        
        $this->Ln(7);
        $this->SetFont("Times","",13);
        $this->Cell(34);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(248,248,255);
        $this->Cell(125,7,$arr[2],0,0,'C',false);

        $this->Ln(6);
        $this->SetFont("Times","",13);
        $this->Cell(34);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(248,248,255);
        $this->Cell(125,7,$arr[3],0,0,'C',false);

        $this->Ln(6);
        $this->Image("../../../../fotografias/".$arr[1],19,20,21);

        $this->SetFont("Times","B",17);
        $this->Cell(34);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(248,248,255);
        $this->Cell(125,9,$arr[0],0,0,'C',false);

        $this->Ln(8);
        $this->SetFont("Times","",13);
        $this->Cell(34);
        $this->SetTextColor(0,0,0);
        $this->SetFillColor(248,248,255);
        $this->Cell(125,7,$arr[5],0,0,'C',false);
                
                
        $this->Ln(11);
        //$this->Image("",10,10,30);
        $this->SetFont("Times","",10);
        $this->Cell(70);
        $this->SetTextColor(0,0,0);
        $this->Cell(50,6,$arr[4],0,0,'C',false);
        $this->Ln(9);

        //$this->Image("",10,10,30);
        $this->SetFont("Times","",9);
        $this->Cell(112);
        $this->SetTextColor(0,0,0);
        $this->Cell(50,6,('C&oacute;digo DANE   ').$arr[8],0,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 datos_Tbla($cabeceraT){
        
        $obj=new Con2();
        $arr=$obj->proceso($_REQUEST['grado'],$_REQUEST['curso'],$_REQUEST['asig'],$_REQUEST['per']);
        $obj->disconnect();

        $orden='';
        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][1],1,0,'C',true);
            $this->Ln(10);
            $this->SetFont("Helvetica","B",7);
            $this->Cell(21);

            
           $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,"Asignatura : ".$arr[0][3],1,0,'C',true);
           $this->Ln(10);
           $this->SetFont("Helvetica","B",7);


           $this->Ln(5);
           $this->Cell(1);
           $this->SetFont("Times","B",12);
           $this->SetTextColor(0,0,0);
           $this->SetFillColor(255,248,220);
           $this->Cell(20);
           $this->Cell(50,6,"Periodo : ".$arr[0][5],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==1)
                   {
                           $this->Cell(105,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);
                
          
          $orden['y']=132;
          for($i=0;$i<count($arr);$i++)
                {      $this->Cell(30);
                      $this->Cell(25,5,$arr[$i][6],0,0,'C');
                      $orden=$this->VariasLineas(($arr[$i][7]),90,105,65,$orden['y'],$align="");
                      $this->Cell(30);
                      $this->Cell(130,0,'',1,0,'');
                      $this->ln(1);
                }


         }
        
       
        
    }

function VariasLineas($cadena, $cantidad,$largo,$x,$y,$align="")
{
$numLin=0;
while (!(strlen($cadena)==''))
{
    $numLin++;

    $subcadena = substr($cadena, 0, $cantidad);
    $this->SetXY($x,$y);
    $this->Cell($largo,5,$subcadena,'0',"",$align);
    $y+=5;
    $cadena= substr($cadena,$cantidad);

    $this->Ln();
}
$array['numLin']=$numLin;
$array['y']=$y;
    return $array;
}



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

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


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

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

?>
