<?php
require('classes/fpdf.php');
require('classes/db.class.php');

$db = new db();

$pdf = new FPDF();

$pdf->AliasNbPages();

$batches_res = $db->exec_query('batches', ['*']);
$batches = $batches_res->fetch_assoc();

$variety_res = $db->exec_query('variety', ['*'], '', '', '', '', "record_id = {$batches['variety_id']}");
$variety = $variety_res->fetch_assoc();

$clients_res = $db->exec_query('clients', ['*'], '', '', '', '', "record_id = {$batches['client_id']}");
$clients = $clients_res->fetch_assoc();

$pdf->AddPage('P');

$pdf->Image('images/logo_1.png', 170, 5, 40);
// Arial bold 15
$pdf->SetFont('Arial', 'B', 8);
// Move to the right
$pdf->Cell(20);
$pdf->Cell(60, -4, '', 0, 1, 'C');
$pdf->Cell(-3);

$table_top = [20, 20, 40, 50, 35, 70, 20, 25, 50, 20, 70];
// Title
$pdf->SetFont('Arial', 'B', 22);

$pdf->Cell($table_top[0], 20, 'RECIEVED REPORT', 0, 1, 'L');
$pdf->SetFont('Arial', 'B', 8);

$pdf->Cell(-2);

$pdf->SetFont('Arial', 'B', 15); 
$pdf->Cell($table_top[0], 5, 'RECIEVED REPORT', 0, 1, 'L');

$pdf->Cell(-2);

$pdf->SetFont('Arial', 'B', 15); 
$pdf->Cell($table_top[0], 10, 'BATCH NO: BA ' . $batches['record_id'], 0, 1, 'L');

$pdf->SetFont('Arial', 'B', 12);
$pdf->Cell(60, 15, '', 0, 1, 'C');

$pdf->Cell(130, 20, 'PV:', 0, 0);
$pdf->Cell(130, 20, $batches['pv'], 0, 1);

$pdf->Cell(130, 20, 'FFA:', 0, 0);
$pdf->Cell(130, 20, $batches['ffa'], 0, 1);

$pdf->Cell(130, 20, 'VARIETY:', 0, 0);
$pdf->Cell(130, 20, $variety['name'], 0, 1);

$pdf->Cell(130, 20, 'WEIGHT:', 0, 0);
$pdf->Cell(130, 20, $batches['weight'], 0, 1);

$pdf->Cell(130, 20, 'SIZE:', 0, 0);
$pdf->Cell(130, 20, $batches['size'], 0, 1);

$pdf->Cell(130, 20, 'SOUND NOT SOUND:', 0, 0);
$pdf->Cell(130, 20, $batches['sound_not_sound'], 0, 1);

$pdf->Cell(130, 20, 'MOLD:', 0, 0);
$pdf->Cell(130, 20, $batches['mold'], 0, 1);

$pdf->Cell(130, 20, 'MOISTURE:', 0, 0);
$pdf->Cell(130, 20, $batches['moisture'], 0, 1);

$pdf->Cell(130, 20, 'CLIENT NAME:', 0, 0);
$pdf->Cell(130, 20, $clients['client_name'], 0, 1);

$pdf->Cell(130, 20, 'SHELL:', 0, 0);
$pdf->Cell(130, 20, $batches['shell'], 0, 1);

$pdf->Cell(130, 20, 'DATE:', 0, 0);
$pdf->Cell(130, 20, $batches['date'], 0, 1);

$pdf->Output("I");