<?php
$media=sprintf("%01.2f", $_GET['media']);
$minima=sprintf("%01.2f", $_GET['minima']);
$maxima=sprintf("%01.2f", $_GET['maxima']);
$Umedia=sprintf("%01.2f", $_GET['Umedia']);
$Uminima=sprintf("%01.2f", $_GET['Uminima']);
$Umaxima=sprintf("%01.2f", $_GET['Umaxima']);
$lim=$_GET['limite'];
$rt[1]='Giovana Albernaz Trevisan';
$crf[1]='CRF35063';
require('fpdf.php');
class PDF extends FPDF
{

function LoadData($file)
{
    $lines = file($file);
    $data = array();
    foreach($lines as $line)
        $data[] = explode(';',trim($line));
    return $data;
}
function FancyTable($data,$med,$min,$max,$rt1,$crf1,$Umed,$Umin,$Umax,$lim)
{
    $armazem[1]='A1 - MOV';
    $armazem[2]='A1 - ARM';
    $armazem[3]='A2 - ARM';
    $armazem[4]='A3 - ARM';
    $armazem[5]='ARM01';
    $armazem[6]='ARM02';
    $armazem[7]='HUB';
    $armazem[8]='TW-OSA';
    $this->SetFillColor(255,255,255);
    $this->SetDrawColor(0);
    $this->SetLineWidth(.2);
    $this->SetTextColor(0);
    $this->SetFont('Arial','B',13);
    $this->Cell(40,24,'',1,0,'C',true);
        $this->Cell(115,24,utf8_decode('RELATÓRIO TÉRMICO DOS ARMAZÉNS'),1,0,'C',true);
    $this->SetFont('Arial','B',8);
        $this->Cell(13,6,utf8_decode('Código:'),'TB',0,'L',false);
    $this->SetFont('Arial','','8');
        $this->Cell(27,6,'FO.06.02.RTA','TBR',0,'L',false);
    $this->Ln(6);
    $this->Cell(155);
    $this->SetFont('Arial','B','8');
        $this->Cell(13,6,utf8_decode('Revisão:'),'B',0,'L',false);
    $this->SetFont('Arial','','8');
    if($lim=='novo'){$this->Cell(27,6,'01','BR',0,'BR',false);}else{$this->Cell(27,6,'00','BR',0,'BR',false);}
        //$this->Cell(27,6,'01','BR',0,'BR',false);
    $this->Ln(6);
    $this->Cell(155);
    $this->SetFont('Arial','B','8');
        $this->Cell(20,6,utf8_decode('Efetivado em:'),'B',0,'L',false);
    $this->SetFont('Arial','','8');
    if($lim=='novo'){$this->Cell(20,6,'31/03/23','BR',0,'L',false);}else{$this->Cell(20,6,'21/12/21','BR',0,'L',false);}
       // $this->Cell(20,6,'31/03/23','BR',0,'L',false);
    $this->Ln(6);
    $this->Cell(155);
    $this->SetFont('Arial','B','8');
        $this->Cell(16,6,utf8_decode('Válido até:'),'B',0,'L',false);
    $this->SetFont('Arial','','8');
    if($lim=='novo'){$this->Cell(24,6,'31/03/26','BR',0,'L',false);}else{$this->Cell(24,6,'21/12/24','BR',0,'L',false);}
        //$this->Cell(24,6,'31/03/26','BR',0,'L',false);
    $this->Image('images/logo.png',13,17,36);
    $this->Ln(9);
    $this->SetFillColor(164,164,164);
    $this->SetTextColor(0);
    $this->SetDrawColor(0);
    $this->SetDrawColor(0);
    $this->SetLineWidth(.2);
    $this->SetFont('Arial','B','16');
    $this->Cell(195,10,utf8_decode('ARMAZÉM: ').$armazem[$data[3][2]],'TLR',0,'C',true);
$this->Ln();
    $this->Cell(195,0,'','T');
    $this->Ln(2);
    $this->SetFillColor(255,255,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(0);
    $this->SetLineWidth(.8);
    $this->SetFont('Arial','B','10');
        $this->Cell(25,7,utf8_decode('INÍCIO:'),'R',0,'L',true);
    $this->Cell(43,7,$data[1][0],1,0,'C',true);
        $this->Cell(83,7,'FIM:','LR',0,'R',true);
    $this->Cell(43,7,$data[1][1],1,0,'C',true);
    $this->Ln(9);
        $this->Cell(45,7,utf8_decode('TEMPERATURA MÍNIMA:'),'R',0,'L',true);
    $this->Cell(23,7,$data[3][0],1,0,'C',true);
        $this->Cell(103,7,utf8_decode('TEMPERATURA MÁXIMA:'),'LR',0,'R',true);
    $this->Cell(23,7,$data[3][1],1,0,'C',true);
    $this->Ln(2);
    $this->SetLineWidth(.2);
    $this->SetDrawColor(0);
        $this->SetFont('Arial','',10);
    $this->Ln(7);
        $this->Cell(195,112,'',1,0,'L',true);
        $this->Image('images/grafico.png',14,68,190);
        $this->Image('images/grafico2.png',11,123,190);
    $this->Ln(113);
    $this->Cell(30,5,utf8_decode('Umidade Mínima:'),'R',0,'R',true);
    $this->Cell(20,5,$Umin.utf8_decode(' %'),1,0,'C',true);
        $this->Cell(105);
        $this->Cell(20,5,utf8_decode('Temperatura Mínima:'),'R',0,'R',true);
    $this->Cell(20,5,$min.utf8_decode(' ºC'),1,0,'C',true);
    $this->Ln(6);
    $this->Cell(30,5,utf8_decode('Umidade Máxima:'),'R',0,'R',true);
    $this->Cell(20,5,$Umax.utf8_decode(' %'),1,0,'C',true);
        $this->Cell(105);
        $this->Cell(20,5,utf8_decode('Temperatura Máxima:'),'R',0,'R',true);
    $this->Cell(20,5,$max.utf8_decode(' ºC'),1,0,'C',true);
    $this->Ln(6);
    $this->Cell(30,5,utf8_decode('Média:'),'R',0,'R',true);
    $this->Cell(20,5,$Umed.utf8_decode(' %'),1,0,'C',true);
        $this->Cell(105);
        $this->Cell(20,5,utf8_decode('Média:'),'R',0,'R',true);
    $this->Cell(20,5,$med.utf8_decode(' ºC'),1,0,'C',true);
    $this->Ln(15);
        $this->Cell(50);
        $this->SetFont('Arial','B',10);
        $this->Cell(95,7,$rt1,'T',0,'C',true);
    $this->Image('images/gigi.png',90,185,36);
    $this->Ln(5);
        $this->Cell(50);
        $this->SetFont('Arial','',10);
        $this->Cell(95,7,'Gestora da Qualidade/RT - '.$crf1,'',0,'C',true);
    $this->Ln(15);
        $this->Cell(50);
        $this->Cell(95,7,'','B',0,'C',true);
    $this->Ln(5);
        $this->Cell(50);
        $this->SetFont('Arial','B',10);
        $this->Cell(95,7,'Edna Silva Lopes','T',0,'C',true);
    $this->Image('images/edna.png',90,222,36);
    $this->Ln(5);
        $this->Cell(50);
        $this->SetFont('Arial','',10);
        $this->Cell(95,7,'Garantia da Qualidade','',0,'C',true);
    if($lim=='novo'){    
        $this->Ln(10);
        $this->SetFillColor(164,164,164);
        $this->SetTextColor(0);
        $this->SetDrawColor(0);
        $this->SetLineWidth(.2);
        $this->SetFillColor(8,75,138);
        $this->SetFont('Arial','I',8);
        $this->SetTextColor(255);
        $this->Ln(6);
        $this->Cell(65,4,utf8_decode('ELABORADO POR:'),1,0,'C',true);
        $this->Cell(65,4,utf8_decode('APROVADO POR:'),1,0,'C',true);
        $this->Cell(65,4,utf8_decode('VALIDADO POR:'),1,0,'C',true);
        $this->Ln(4);
        $this->SetTextColor(0);
        $this->Cell(65,4,utf8_decode('Edna Lopes'),'LR',0,'L',false);
        $this->Cell(65,4,utf8_decode('Cristiano Lopes'),'LR',0,'L',false);
        $this->Cell(65,4,utf8_decode('Giovana Trevisan'),'LR',0,'L',false);
        $this->Ln(4);
        $this->Cell(65,8,'','LR',0,0,false);
        $this->Cell(65,8,'','LR',0,0,false);
        $this->Cell(65,8,'','LR',0,0,false);
        $this->Ln(8);
        $this->SetTextColor(255);
        $this->Cell(65,4,utf8_decode('DATA: 21/02/23'),1,0,'C',true);
        $this->Cell(65,4,utf8_decode('DATA: 22/02/23'),1,0,'C',true);
        $this->Cell(65,4,utf8_decode('DATA: 28/02/23'),1,0,'C',true);
        $this->Ln(5);
        $this->SetTextColor(0);
        $this->SetY(-15);
        $this->Image('images/edna.png',30,258,20);
        $this->Image('images/cristiano.png',95,258,25);
        $this->Image('images/Giovana.png',160,255,20);
    }
 }
}
$pdf = new PDF();
$data = $pdf->LoadData('quali3.txt');
$pdf->SetFont('Arial','','12');
$pdf->AddPage();
$pdf->FancyTable($data,$media,$minima,$maxima,$rt[1],$crf[1],$Umedia,$Uminima,$Umaxima,$lim);
$pdf->Output();
?> 