<?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/ReportData.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('ser.png', 0, 5, 50);
		$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, '', 0, 1, 'C');
		$this->Cell(0, 5, 'RESPONSABLE ', 0, 1, 'C');
	}
}

$o = array();
$o = ReportData::getById($_GET["id"]);;
$sdate = $o->created_at;
$dia = date('d-m-Y', strtotime($sdate));

//$user = UserData::getByPhone($o->resp_id);
//$n = $o->name;
//$e = $o->getCategory()->name;
$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, 'REPORTE ESPECIFICO ', 0, 1, 'C');
$pdf->Cell(189, 10, '', 0, 1); //end of line
//set font to arial, bold, 14pt
$pdf->SetFont('Arial', 'B', 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(27, 5, 'Nombre: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $o->name, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(27, 5, 'Edad: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->age);
$pdf->Cell(0, 5, $txt, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(27, 5, 'Fecha: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $dia, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(27, 5, 'Area: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $o->getCategory()->name, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
// $pdf->Cell(27, 5, 'Especialista: ', 0, 0);
// $pdf->SetFont('Arial', '', 12);
//$pdf->Cell(0, 5, $o->getPhone()->name.' '.$o->getPhone()->lastname, 0, 1);
//$pdf->Cell(0, 5, $o->name, 0, 1);
$pdf->SetFont('Arial', 'B', 12);

//make a dummy empty cell as a vertical spacer
$pdf->Cell(189, 10, '', 0, 1); //end of line
$pdf->Cell(0, 5, '1. .- DIAGNOSTICO PRELIMINAR', 0, 1);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->diagnosis);
$pdf->MultiCell(180, 5, $txt, 0, 1);
//$pdf->Cell(30);

// $pdf->SetWidths(array(150));
// $txt = iconv('utf-8', 'cp1252', $o->diagnosis);
// $pdf->Row(array($txt));


$pdf->Cell(189, 10, '', 0, 1); //end of line
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(0, 5, '2. MOTIVO DE LA EVALUACION.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->eval);
$pdf->MultiCell(180, 5, $txt, 0, 1);
//$pdf->Cell(30);
$pdf->Cell(189, 10, '', 0, 1); //end of line
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(0, 5, '3. OBSERVACIONES.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->description);
$pdf->MultiCell(180, 5, $txt, 0, 1);
//$pdf->Cell(30);
$pdf->Cell(189, 10, '', 0, 1); //end of line
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(0, 5, '4. RECOMENDACIONES.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);


$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->remark);
$pdf->MultiCell(180, 5, $txt, 0, 1);
//$pdf->Cell(30);
$pdf->Cell(189, 10, '', 0, 1); //end of line
//invoice contents
$pdf->SetFont('Arial', 'B', 10);


$pdf->Output();
