<?php
header('Content-Type: text/html; charset=UTF-8');
require('fpdf/fpdf.php');
require('alphapdf.php');
date_default_timezone_set("America/La_Paz");
include "core/autoload.php";
include "core/app/model/CertificateData.php";
include "core/app/model/UserData.php";
include "core/app/model/CategoryData.php";

class PDF extends FPDF
{
	function Header()
	{
		$dia = date('d');
		$anio = date('Y');
		$mes = date('m');
		//Logo
		$this->SetFillColor(0, 0, 0);
		$this->Image('encabezado.jpg', 0, 5, 200);
		$this->Ln(40);
	}
	function Footer()
	{
		//Posici�n: a 1,5 cm del final
		$this->SetY(-25);
		//Arial italic 8
		//$this->SetFont('Arial','I',8);
		//N�mero de p�gina
		//$this->Cell(0,10,'',0,0,'C');
		$this->Cell(0, 5, 'Lic. Gabriela Deheza Duran', 0, 1, 'C');
		$this->Cell(0, 5, utf8_decode('Panqaraña'), 0, 1, 'C');
	}
}

$o = array();
$o = CertificateData::getById($_GET["id"]);;
$sdate = $o->created_at;
$dia = date('d', strtotime($sdate));
$anio = date('Y', strtotime($sdate));
$mes = date('m', strtotime($sdate));
$user  = UserData::getByPhone($o->resp_id);
//$user_id = $o->user_id;

$pdf  = new PDF('P', 'mm', 'letter');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetAlpha(0.1);
//$pdf->Image('fondo.png', 16, 60, $fpdf->w, $fpdf->h);
$pdf->SetAlpha(1);

$pdf->SetFont('Arial', 'B', 16);
//$pdf->Cell(0, 5, 'CERTIFICADO ', 0, 1, 'C');
$pdf->Cell(189, 10, '', 0, 1); //end of line
//set font to arial, bold, 14pt
$pdf->SetFont('Arial', '', 12);

//$pdf->Cell(100 ,5,'Lugar y Fecha : La Paz, '.$fecha_l,0,1);//end of line
//$pdf->Cell(100 ,5,'Hora : '.date('H:i'),0,1);//end of line

$pdf->Cell(50, 5, 'Sres: ', 0, 1);
$pdf->Cell(50, 5, utf8_decode($o->destined), 0, 1);
$pdf->SetFont('Arial', 'U', 12);
$pdf->Cell(50, 5, 'Presente.-', 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(189, 10, '', 0, 1);
$pdf->Cell(189, 5, 'Ref. '.utf8_decode($o->title), 0, 1,'R');

//make a dummy empty cell as a vertical spacer
//end of line
$pdf->Cell(0, 5, '', 0, 1);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->description);
$pdf->MultiCell(180, 5, $txt, 0, 1);


$pdf->Cell(189, 10, '', 0, 1); //end of line
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(0, 5, 'Atentamente', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);


// $pdf->Cell(189, 10, '', 0, 1); //end of line
// //invoice contents
// $pdf->SetFont('Arial', 'B', 10);
// $pdf->Cell(0, 5, $user->name . ' ' . $user->lastname, 0, 1, 'C');
// $pdf->Cell(0, 5, '', 0, 1, 'C');

$pdf->Output();
