<?php
require('classes/fpdf.php');
require('classes/db.class.php');

$db = new db();

$pdf = new FPDF();

$pdf->AliasNbPages();

$bins_res = $db->exec_query('bins', ['*'],'','','','','',"record_id = {$_GET['record_id']}");
$bins = $bins_res->fetch_assoc();

$variety_res = $db->exec_query('variety', ['*'], '', '', '', '', "record_id = {$bins['variety_id']}");
$variety = $variety_res->fetch_assoc();

$drying_bin_res = $db->exec_query('drying_bins', ['*'], '', '', '', '', "record_id = {$bins['drying_bin_id']}");
$drying_bin = $drying_bin_res->fetch_assoc();

$pdf->AddPage('P');

$table_top = [50, 28, 16, 65, 35, 55, 30, 40, 25, 20, 20, 20];

$pdf->SetFont('Arial', 'B', 20);
$pdf->Cell(200, 15, "DRYING BINS REPORT ", 0, 1, 'C');
$pdf->Cell(10, 5, '', 0, 1, 'L');
$pdf->SetFont('Arial', '', 10);

$pdf->Cell(-2);

$pdf->SetFont('Arial', 'B', 20); 
$pdf->Cell($table_top[0], 10, 'BATCH NO: BA ' . $_GET['record_id'], 0, 1, 'L');

$pdf->SetFont('Arial', 'B', 20);
$pdf->Cell(60, 15, '', 0, 1, 'C');

$pdf->Cell(100, 15, 'WEIGHT:', "R" , 0, 'L');
$pdf->Cell(100, 15, $bins['weight'], "", 1, 'L');

$pdf->Cell(100, 15, 'VARIETY:', "R" , 0, 'L');
$pdf->Cell(100, 15, $variety['name'], "", 1, 'L');

$pdf->Cell(100, 15, 'DATE:', "R" , 0, 'L');
$pdf->Cell(100, 15, $bins['date'], "", 1, 'L');

$pdf->Cell(100, 15, 'DRYING_BIN:', "R" , 0, 'L');
$pdf->Cell(100, 15, $drying_bin['name'], "", 1, 'L');



$pdf->Output("I");
