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


$db = new db_safeguard();
// $main_request_res = $db->query("maintenance_request","SELECT * FROM maintenance_request WHERE jobcard_id = '{$_GET['jobcard_id']}'");
// $request_data = $main_request_res->fetch_assoc();

// $main_allocation_res = $db->query("maintenance_allocation","SELECT * FROM maintenance_allocation WHERE jobcard_id = '{$_GET['jobcard_id']}'");
// $allocation_data = $main_allocation_res->fetch_assoc();

// $main_jobcard_res = $db->query("maintenance_jobcard","SELECT * FROM maintenance_jobcard WHERE jobcard_id = '{$_GET['jobcard_id']}'");
// $jobcard_data = $main_jobcard_res->fetch_assoc();

// $main_res = $db->query("maintenance","SELECT * FROM maintenance WHERE jobcard_id = '{$_GET['jobcard_id']}'");
// $main_data = $main_res->fetch_assoc();

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

$pdf->SetFont('Arial', 'B', 20);
$pdf->Cell(200, 15, "JOB DONE REPORT" , 0, 1, 'C');
$pdf->Cell(200, 15, "FOR {$_GET['jobcard_id']}" , 0, 1, 'C');
$pdf->Cell(10, 8, '', 0, 1, 'L');
$pdf->SetFont('Arial', '', 10);

$pdf->Cell(70, 8, "Jobcard Id : ", "", 0, 'L');
$pdf->Cell(70, 8, $_GET['jobcard_id'], "", 1, 'L');
$pdf->Cell(70, 8, "Date & Time of Request : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['date_requested'], "", 1, 'L');
$pdf->Cell(70, 8, "Requested By : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['requested_by '], "", 1, 'L');
$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->SetFont('Arial', 'B', 15);
$pdf->Cell(200, 15, "Equipment / Asset Details: " , 0, 1, 'C');
$pdf->Cell(10, 8, '', 0, 1, 'L');
$pdf->SetFont('Arial', '', 10);

$pdf->Cell(70, 8, "Product Name : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['product_name'], "", 1, 'L');
$pdf->Cell(70, 8, "Cultivar : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['cultivar'], "", 1, 'L');
$pdf->Cell(70, 8, "Supplier Name : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['supplier_name'], "", 1, 'L');
$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->SetFont('Arial', 'B', 15);
$pdf->Cell(200, 15, "Problem Descriptions" , 0, 1, 'C');
$pdf->Cell(10, 8, '', 0, 1, 'L');
$pdf->SetFont('Arial', '', 10);

$pdf->Cell(70, 8, "Contact Person : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_person'], "", 1, 'L');
$pdf->Cell(70, 8, "Contact Number : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->Cell(70, 8, "Lockout / Tagout (LOTO) Required: ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_person'], "", 1, 'L');
$pdf->Cell(70, 8, "Sanitation Requirements : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(70, 8, "Allergen or Contamination Risk : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->Cell(70, 8, "Technician(s) Assigned : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['technician_assigned'], "", 1, 'L');
$pdf->Cell(70, 8, "Work Performed : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(70, 8, "Parts Used : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(70, 8, "Chemicals / Lubricants used : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(70, 8, "Was food contact surfaces touched or worked on? : ", "", 0, 'L');
$pdf->Cell(70, 8, $request_data['contact_number'], "", 1, 'L');
$pdf->Cell(10, 5, '', 0, 1, 'L');

$pdf->Output('I');