<?php
require('../../fpdf.php');
include "../../root.class.php";

$db = new db_safeguard();

$pdf = new FPDF();
$pdf->AliasNbPages();
$pdf->AddPage('L');

$cracking_food_safety_res = $db->query("cracking_food_safety", "SELECT * FROM cracking_food_safety WHERE cracking_food_safety_id = '{$_GET['cracking_food_safety_id']}'");
$food_safety = $cracking_food_safety_res->fetch_assoc();

$pdf->SetFont('Arial', 'B', 20);
$pdf->Cell(280, 15, "FOOD SAFETY INSPECTION REPORT", 0, 1, 'C');
$pdf->Cell(10, 5, '', 0, 1, 'L');
$pdf->SetFont('Arial', '', 10);

$pdf->Cell(40, 8, "Criteria/ Points", 1, 0, 'L');
$pdf->Cell(20, 8, "Answer", 1, 1, 'L');
$pdf->Cell(20, 8, "Comment", 1, 1, 'L');

if ($cracking_equipment_res->num_rows == 0) {
    echo " NO JOBCARDS FOUND";
} else {
    while ($cracking_equipment_res = $cracking_equipment->fetch_assoc()) {

        $equipment_res = $db->query("equipment_list", "SELECT * FROM equipment_list WHERE record_id = '{$cracking_equipment['equipment_id']}'");
        $equipment = $equipment_res->fetch_assoc();

        $food_safety_comments = $db->query("cracking_food_safety_comments","SELECT * FROM cracking_food_safety_comments WHERE cracking_food_safety_id = '{$cracking_equipment['record_id']}'");
        $food_safety_comment = $food_safety_comments->fetch_assoc();

        $pdf->Cell(13, 8, $cracking_equipment['equipment_cleaned'], "LB", 0, 'L');
        $pdf->Cell(13, 8, $food_safety_comment['equipment_cleaned_comment'], "LB", 1, 'L');
        $pdf->Cell(40, 8, $cracking_equipment['magnet_1_cleaned'], "LBR", 0, 'L');
        $pdf->Cell(40, 8, $cracking_equipment['magnet_1_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['magnet_2_cleaned'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['magnet_2_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['oxyacid_concentration_verification'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['oxyacid_concentration_verification_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['cracking_equipment_checked'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['creaking_equipment_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['oil_rust_signs'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['oil_rust_signs_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['shell_sieves_clean'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['shell_sieves_clean_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['filter_dust_control_working'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['filter_dust_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['personal_hygiene'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['personal_hygiene_comment'], "LBR", 1, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['tools_sanitized_labelled'], "LBR", 0, 'L');
        $pdf->Cell(20, 8, $cracking_equipment['tools_sanitized_comment'], "LBR", 1, 'L');

    }
}

$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->Output("I");