<?php
header('Content-Type: text/html;');
require('fpdf/fpdf.php');
date_default_timezone_set("America/La_Paz");
include "core/autoload.php";
include "core/app/model/OperationData.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_labogen.jpg',15,10,15);
		//Arial bold 15
		$this->SetFont('Arial', 'B', 8);
		//Movernos a la derecha
		$this->Cell(30);
		//T�tulo

		$this->SetFont('Arial', 'B', 9);
		$this->Cell(100, 5, 'REGISTRO', 1, 0, 'C');
		$this->Cell(50, 5, 'LAB-REG-ALM-008', 1, 1, 'C');
		$this->Cell(30);
		$this->Cell(100, 5, 'PLANILLA DE SEGUIMIENTO A DESPACHOS', 1, 0, 'C');
		$this->Cell(50, 5, 'REVISION 1', 1, 1, 'C');

		//Salto de l�nea
		$this->Ln(5);

		$this->SetAlpha(0.1);
		//$this->Image('fondo2.png', 22, 80,150, 30);
		$this->SetAlpha(1);
	}
	function Footer()
	{
		//Posici�n: a 1,5 cm del final
		$this->SetY(-15);
		//Arial italic 8
		//$this->SetFont('Arial','I',8);
		//N�mero de p�gina
		//$this->Cell(0,10,'',0,0,'C');

		$this->Cell(70, 5, 'Generado por', 0, 0, 'C');
		$this->Cell(70, 5, '', 0, 0, 'C');
		$this->Cell(70, 5, 'V.B.', 0, 0, 'C');
	}
}


$operations = array();
$operations = OperationData::getAllId($_GET["id"]);

$sdate = date("");
$hora = date('h:m:s', strtotime($sdate));
$dia = date('d', strtotime($sdate));
$anio = date('Y', strtotime($sdate));
$mes = date('m', strtotime($sdate));
//$operations = OperationData::getAllProductsBySellId($sell->id);
//$total = 0;

if ($mes == '01')
	$letra = 'Enero';
if ($mes == '02')
	$letra = 'Febrero';
if ($mes == '03')
	$letra = 'Marzo';
if ($mes == '04')
	$letra = 'Abril';
if ($mes == '05')
	$letra = 'Mayo';
if ($mes == '06')
	$letra = 'Junio';
if ($mes == '07')
	$letra = 'Julio';
if ($mes == '08')
	$letra = 'Agosto';
if ($mes == '09')
	$letra = 'Septiembre';
if ($mes == '10')
	$letra = 'Octubre';
if ($mes == '11')
	$letra = 'Noviembre';
if ($mes == '12')
	$letra = 'Diciembre';

$pdf  = new PDF('P', 'mm', 'letter');
$pdf->AliasNbPages();
$pdf->AddPage();


// $pdf->Cell(189, 10, '', 0, 1); //end of line

// $pdf->Cell(189, 5, '', 0, 1); //end of line

//Numbers are right-aligned so we give 'R' after new line parameter
//display the items
//$i = 11;
//$c = count($operations);

$pdf->SetFont('Arial', 'B', 8);

$pdf->Cell(70, 5, "ID de Usuario: ".$_GET["id"], 1, 0);
$pdf->Cell(70, 5, 'Evento', 1, 0);
$pdf->Cell(30, 5, 'Fecha', 1, 1); //end of line

$pdf->SetFont('Arial', '', 8);

foreach ($operations as $o) {
	$pdf->Cell(7, 5, $o->ID, 1, 0);
	$pdf->Cell(70, 5, $o->Voltaje." - ID: ".$o->ID, 1, 0);
	$pdf->Cell(30, 5, $o->Corriente, 1, 1);
}


//$pdf->Output('seguimiento_despacho.pdf','D');
$pdf->Output();
