<?php
//ini_set("error_reporting",E_ALL);
require('../fpdf.php');

class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;


function WriteHTML($html)
{
        //HTML parser
        $html=str_replace("\n",' ',$html);
        $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
        foreach($a as $i=>$e)
        {
                if($i%2==0)
                {
                        //Text
                        if($this->HREF)
                                $this->PutLink($this->HREF,$e);
                        else
                                $this->Write(5,$e);
//                              $this->Cell(180,5,$e,1,2,'J');
                }
                else
                {
                        //Tag
                        if($e{0}=='/')
                                $this->CloseTag(strtoupper(substr($e,1)));
                        else
                        {
                                //Extract attributes
                                $a2=explode(' ',$e);
                                $tag=strtoupper(array_shift($a2));
                                $attr=array();
                                foreach($a2 as $v)
                                        if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
                                                $attr[strtoupper($a3[1])]=$a3[2];
                                $this->OpenTag($tag,$attr);
                        }
                }
        }
}

function OpenTag($tag,$attr)
{
        //Opening tag
        if($tag=='B' or $tag=='I' or $tag=='U')
                $this->SetStyle($tag,true);
        if($tag=='A')
                $this->HREF=$attr['HREF'];
        if($tag=='BR')
                $this->Ln(5);
}

function CloseTag($tag)
{
        //Closing tag
        if($tag=='B' or $tag=='I' or $tag=='U')
                $this->SetStyle($tag,false);
        if($tag=='A')
                $this->HREF='';
}

function SetStyle($tag,$enable)
{
        //Modify style and select corresponding font
        $this->$tag+=($enable ? 1 : -1);
        $style='';
        foreach(array('B','I','U') as $s)
                if($this->$s>0)
                        $style.=$s;
        $this->SetFont('',$style);
}

function PutLink($URL,$txt)
{
        //Put a hyperlink
        $this->SetTextColor(0,0,255);
        $this->SetStyle('U',true);
        $this->Write(5,$txt,$URL);
        $this->SetStyle('U',false);
        $this->SetTextColor(0);
}
//Page header
function Header2($texto)
{
        //Logo
        $this->Image('../logo_colegio.png',10,8,20);
        $this->Image('../logo_colegio2.png',180,8,18);
        //Arial bold 15
        $this->SetFont('Arial','B',15);
        //Move to the right
        $this->Cell(80);
        //Title
        $this->Cell(30,10,$texto,0,0,'C');
        //Line break
        $this->Ln(20);
}

//Page footer
function Footer()
{
        //Position at 1.5 cm from bottom
        $this->SetY(-20);
        //Arial italic 8
        $this->SetFont('Arial','I',8);
        $this->Cell(90,5,date("d-m-Y"),0,0,"L");
        $this->Cell(60,5,date("H:i:s"),0,0,"R");
        //Page number
//        $this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'C');
}

function Encabezado2($institucion='', $titulo_reporte='')
{
        //Logo
        $this->Image('../logo_colegio.png',30,10,30);
//        $this->Image('../logo_colegio2.png',180,8,18);
        $this->SetFont('Arial','B',15);
                $this->Ln(-20);
        $this->Cell(0,7,$institucion,0,1,'C');
        $this->SetFont('Arial','B',13);
        $this->Cell(0,5,$titulo_reporte,0,1,'C');
//        $this->Ln(-11);
        $this->SetFont('Arial','',10);
//        $this->Cell(0,5,($this->Fecha())."              ",0,1,'R');
//        $this->Cell(0,5,($this->Hora())."              ",0,1,'R');
        //Line break
        $this->Ln(12);
}

}

include("../fnc.php");
$paper_width=Array();
$paper_width[0]=215.9;
$paper_width[1]=139.7;

$pdf=new PDF('P','mm',$paper_width);
$pdf->SetMargins(30,10,10);
$pdf->AddPage();
$pdf->Encabezado("$nombre_colegio","COORDINACION DE DISCIPLINA",false);
$pdf->SetFont("Arial","",11);

$q=mysql_query("select c.*, a.grado_estudio, a.nivel_estudio, a.year_estudio , a.jornada
                from conocimientos c inner join alumnos a ON a.carnet = c.alumno 
                where c.id = $id_con");

$info=mysql_fetch_array($q);
$pdf->Ln(10);
$pdf->SetFont("Arial","B","14");
$pdf->cell(160,5,"No. $id_con",0,1,"R");
$pdf->SetFont("Arial","","11");
//$pdf->cell(25,5,"Alumno:",0,0);
//$pdf->cell(90,5,$info[alumno],0,1);
//$pdf->Ln(-5);
//$pdf->cell(160,5,"Fecha: ".fecha($info[fecha]),0,1,"R");
$pdf->SetFont("Arial","B","13");
$pdf->setStyle("B",true);
$pdf->cell(25,5,"Alumno:",0,0);
$pdf->cell(90,5,galumno(enc($info[alumno]))." - ".$info[alumno],0,1);
$pdf->setStyle("B",false);
$pdf->SetFont("Arial","","11");
$pdf->cell(25,5,"Carrera:",0,0);
$pdf->cell(90,5,ggrado(enc($info[grado_estudio]))." ".gnivel(enc($info[nivel_estudio]))." ".gjornada(enc($info[jornada])),0,1);
$pdf->Ln(5);
$pdf->cell(170,5,"Fecha del conocimiento: ".fecha_letras($info[fecha]),0,1);
$pdf->cell(25,5,"Tipo de conocimiento: ".get_tipo_conocimiento(enc($info[tipo]))."                      Gravedad de la falta: ".get_nivel_conocimiento(enc($info[nivel])),0,1);

$pdf->Ln(3);
$pdf->SetStyle("B",true);
$pdf->cell(10,5,"Detalle del conocimiento:",0,1);
$pdf->SetStyle("B",false);
$pdf->Multicell(150,5,$info[detalle],0);
$pdf->Ln(3);
$pdf->SetStyle("B",true);
$pdf->Cell(0,5,"Reportado por: {$info[reportado_por]}");
$pdf->SetStyle("B",false);

$pdf->Ln(17);
$pdf->cell(60,0.1,"",1,0);
$pdf->cell(30,0.1,"",0,0);
$pdf->cell(60,0.1,"",1,1);
$pdf->cell(90,5,"(f) Alumno");
$pdf->cell(90,5,"(f) Encargado de Disciplina",0,1);
$pdf->Ln(11);
$pdf->cell(60,0.1,"",1,1);
$pdf->cell(90,5,"(f) Enterado Padre o Encargado");
$pdf->cell(90,5," Fecha: ___/____/_______",0,1);
$pdf->Output();
exit();
?>
