<?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/PacientData.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('logo_panq.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. May Rivera', 0, 1, 'C');
	// 	$this->Cell(0, 5, 'Encargada Aula Integral', 0, 1, 'C');
	// }
}

$o = array();
$o = PacientData::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, 'ANAMNESIS ', 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(50, 5, 'Nombre: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, utf8_decode($o->name), 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(50, 5, 'Nombre de la Madre: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, utf8_decode($o->m_name), 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(50, 5, 'Nombre del Padre: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, utf8_decode($o->f_name), 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(50, 5, 'Fecha de Nacimiento: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $o->day_of_birth, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(50, 5, utf8_decode('Género: '), 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $o->gender, 0, 1);
$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(50, 5, 'Tipo de Parto: ', 0, 0);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(0, 5, $o->type, 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. .- Dificultades en el Parto', 0, 1);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->type_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, '2. Balbuceo.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$txt = iconv('utf-8', 'cp1252', $o->babbling);
$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, '3. Gateo.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->crawl);
$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, utf8_decode('4. Sostenía la cabeza.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->held);
$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, utf8_decode('5. Se sentó.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->sit);
$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, utf8_decode('6. Empezó a caminar.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->walk);
$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, '7. Primeras Palabras.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->words);
$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, '8. Vive con.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->lives);
$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, '9. Tiene hermanos.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->siblings);
$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, utf8_decode('10. Con quien pasa más tiempo.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->time);
$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, utf8_decode('11. Tipo de Alimentación.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->feed);
$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, '12. Grado de escolaridad.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->school);
$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, '13. Motivo de Consulta.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->consultation);
$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, '14. Antecedentes de Salud.- ', 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->health);
$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, utf8_decode('15. Formación de Hábitos.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->habit);
$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, utf8_decode('16. Antecedentes Familiares de Patologías.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->f_pathologies);
$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, utf8_decode('17. Internaciones Médicas.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->hospitalization);
$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, utf8_decode('18. Uso Farmacológico.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->pharmacological);
$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, utf8_decode('19. Cirugías.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->surgeries);
$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, utf8_decode('20. Diagnósticos de Consideración.- '), 0, 0);
$pdf->Cell(189, 5, '', 0, 1);
$pdf->SetFont('Arial', '', 12);
$pdf->Cell(189, 5, '', 0, 1);
$txt = iconv('utf-8', 'cp1252', $o->diagnostics);
$pdf->MultiCell(180, 5, $txt, 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();
