<?php
require('classes/fpdf.php');
require('classes/db.class.php');

$db = new db();

$pdf = new FPDF();

$pdf->AliasNbPages();

$batches_res = $db->exec_query('batches', ['*'],'','','','','',"record_id = {$_GET['batch_record_id']}");
$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');

// 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], 30, 'RECIEVED REPORT', 0, 1, 'L');
$pdf->SetFont('Arial', 'B', 8);

$pdf->Cell(-2);

$pdf->SetFont('Arial', 'B', 20); 
$pdf->Cell($table_top[0], 5, 'RECIEVED REPORT', 0, 1, 'L');

$pdf->Cell(-2);

$pdf->SetFont('Arial', 'B', 20); 
$pdf->Cell($table_top[0], 10, 'BATCH NO: BA ' . $_GET['batch_record_id'], 0, 1, 'L');

$pdf->SetFont('Arial', 'B', 20);
$pdf->Cell(60, 15, '', 0, 1, 'C');

$pdf->Cell(100, 15, 'PV:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['pv'], "", 1, 'L');

$pdf->Cell(100, 15, 'FFA:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['ffa'], "", 1, 'L');

$pdf->Cell(100, 15, 'VARIETY:', "R" , 0, 'L');
$pdf->Cell(100, 15, $variety['name'], "", 1, 'L');

$pdf->Cell(100, 15, 'WEIGHT:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['weight'], "", 1, 'L');

$pdf->Cell(100, 15, 'SIZE:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['size'], "", 1, 'L');

$pdf->Cell(100, 15, 'SOUND NOT SOUND:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['sound_not_sound'], "", 1, 'L');

$pdf->Cell(100, 15, 'MOLD:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['mold'], "", 1, 'L');

$pdf->Cell(100, 15, 'MOISTURE:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['moisture'], "", 1, 'L');

$pdf->Cell(100, 15, 'CLIENT NAME:', "R" , 0, 'L');
$pdf->Cell(100, 15, $clients['client_name'], "", 1, 'L');

$pdf->Cell(100, 15, 'SHELL:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['shell'], "", 1, 'L');

$pdf->Cell(100, 15, 'DATE:', "R" , 0, 'L');
$pdf->Cell(100, 15, $batches['date'], "", 1, 'L');

$pdf->Output("I");