getLocation(); $tester = $test->getTester(); $test_values = $test->getValues(); $keys = array_column($test_values, "name"); $values = array_column($test_values, "value"); $values = array_combine($keys, $values); $tiny_font_size = 8; $small_font_size = 10; $normal_font_size = 10; $header_font_size = 14; $cell_height = 5; $cell_margin = 2; list($date_start, $time_start) = explode(" ", $test->dts_start); list($date_end, $time_end) = explode(" ", $test->dts_end); $dt_start = new DateTime($test->dts_start); $dt_end = new DateTime($test->dts_end); $diff = $dt_start->diff($dt_end, true); $date_start = date("d/m/Y", strtotime($test->dts_start)); // A4 size: 210x297mm $pdf = new TestPDF("P", "mm", "A4"); $pdf->SetSubject("Test Result"); $pdf->SetCreator(APP_NAME); $pdf->SetAuthor(APP_NAME); $pdf->SetTitle($location->name . " Test Result @ $date_start"); $pdf->AddPage(); $pdf->SetFont("Arial"); $pdf->SetDrawColor(240, 240, 240); $pdf->SetFillColor(226, 240, 217); $pdf->SetAutoPageBreak(false); // Logo $pdf->Image("public/img/logo.png", 11, 10, 60); // Right contact info $y = 10; $pdf->SetFont("Arial", "B", $tiny_font_size); $pdf->SetTextColor(255, 0, 0); $pdf->SetLeftMargin(120); $pdf->SetY(10); $pdf->Cell(80, 4, "Test / Location ID: $test->id / $location->id", 0, 1, "R"); $pdf->SetFont("Arial", ""); $pdf->SetTextColor(0, 0, 0); $pdf->Cell(80, 4, "Tel: 01579 342 104", 0, 1, "R", false, "tel:01579+342+104"); $pdf->SetFont("Arial", "U"); $pdf->SetTextColor(0, 128, 255); $pdf->Cell(80, 4, "check-policy.com", 0, 1, "R", false, "https://check-policy.com"); $pdf->Cell(80, 4, "info@check-policy.com", 0, 1, "R"); $pdf->SetLeftMargin(10); $pdf->SetXY(10, $pdf->GetY() + $cell_margin); // Header $pdf->SetTextColor(56, 87, 35); $pdf->SetFont("Arial", "B", $header_font_size); $pdf->Cell(190, 10, " Test Result", 0, 1, "L", true); // Pass/Fail $image_width = 130; if($test->pass) { $pdf->Image("public/img/pass.png", (210 - $image_width) / 2, $pdf->GetY() + 2, $image_width); } else { $pdf->Image("public/img/fail.png", (210 - $image_width) / 2, $pdf->GetY() + 2, $image_width); } $pdf->SetY($pdf->GetY() + 30); $pdf->SetTextColor(56, 87, 35); // Location / Tester Headers $pdf->SetFont("Arial", "B", $header_font_size); $tester_x = 150; $tester_y = $pdf->GetY(); $pdf->Cell(135, 10, " $location->name", 0, 1, "L", true); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial", "", $normal_font_size); $pdf->SetTextColor(0, 0, 0); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "ID:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $test->location_id, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Region / Manager:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, "$location->region / $location->area_manager", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Phone:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $location->phone, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Address:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->MultiCell(100, $cell_height, $location->getDisplayAddress(["address_1", "address_2", "city"], "\n"), 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Postcode:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $location->postal_code, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "County:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $location->county, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Shop Name - Left:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $test->shop_left, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Shop Name - Right:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(100, $cell_height, $test->shop_right, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY()); $test_details_y = $pdf->GetY(); // Tester Info $pdf->SetXY($tester_x, $tester_y); $pdf->SetLeftMargin(150); $pdf->SetTextColor(56, 87, 35); $pdf->SetFont("Arial", "B", $header_font_size); $pdf->Cell(50, 10, " Tester", 0, 1, "L", true); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial", "", $normal_font_size); $pdf->SetTextColor(0, 0, 0); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY()); $pdf->Cell(20, $cell_height, "Gender:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(20, $cell_height, $tester->getGenderText(), 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY()); $pdf->Cell(20, $cell_height, "Attire:", 0, 1); $pdf->SetX(150); $pdf->SetFont("Arial", "", $small_font_size); $pdf->MultiCell(50, 4, $test->attire, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY()); // Test Details $pdf->SetLeftMargin(10); $pdf->setXY(10, $test_details_y + 5 + 2); $pdf->SetTextColor(56, 87, 35); $pdf->SetFont("Arial", "B", $header_font_size); $pdf->Cell(190, 10, " Test Details", 0, 1, "L", true); $pdf->SetY($pdf->GetY() + 2); // Date / Time $id_requests_y = $pdf->GetY(); $pdf->SetFont("Arial", "B", $normal_font_size); $pdf->SetTextColor(0, 0, 0); $pdf->Cell(95, $cell_height, "Date & Time", 0, 1); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial"); $pdf->Cell(23, $cell_height, "Date"); $pdf->Cell(23, $cell_height, "Entry"); $pdf->Cell(23, $cell_height, "Exit"); $pdf->Cell(23, $cell_height, "Duration", 0, 1); $pdf->SetFont("Arial", "", $small_font_size); $pdf->Cell(23, $cell_height, $date_start); $pdf->Cell(23, $cell_height, $time_start); $pdf->Cell(23, $cell_height, $time_end); $pdf->Cell(23, $cell_height, str_pad($diff->h, 2, "0", STR_PAD_LEFT) . ":" . str_pad($diff->i, 2, "0", STR_PAD_LEFT) . ":" . str_pad($diff->s, 2, "0", STR_PAD_LEFT), 0, 1); $pdf->SetY($pdf->GetY() + 2); // Staff $pdf->SetFont("Arial", "B", $normal_font_size); $pdf->Cell(95, $cell_height, "Staff", 0, 1); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial"); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Name:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(57.5, $cell_height, $test->challenger_name, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Gender:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(57.5, $cell_height, $test->challenger_gender, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Description:", 0, 1); $pdf->SetFont("Arial", "", $small_font_size); $pdf->MultiCell(90, 4, $test->challenger_description, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial", "B", $normal_font_size); $pdf->Cell(95, $cell_height, "Tester's Notes", 0, 1); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial"); $pdf->SetFont("Arial", "", $small_font_size); $pdf->MultiCell(90, 4, $test->additional_notes, 0, 1); $pdf->SetY($pdf->GetY() + 2); // Challenge $pdf->SetLeftMargin(107.5); $pdf->SetY($id_requests_y); $pdf->SetFont("Arial", "B", $normal_font_size); $pdf->Cell(95, $cell_height, "ID Request", 0, 1); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial"); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(30, $cell_height, "ID Stage:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(60, $cell_height, $test->challenge_stage, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial", "", $small_font_size); $pdf->SetTextColor(0, 128, 0); $pdf->MultiCell(95, 4, "1: Challenge on entry 2: Challenge while browsing", 0, 1); $pdf->SetTextColor(255, 0, 0); $pdf->MultiCell(95, 4, "3: Challenge during play 4: Challenge on exit 5: No challenge", 0, 1); $pdf->SetFont("Arial", "", $normal_font_size); $pdf->SetTextColor(0, 0, 0); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial", "", $normal_font_size); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(30, $cell_height, "Eye Contact:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell(60, $cell_height, $test->challenger_eye_contact ? "Y" : "N", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell(95, $cell_height, "Description:", 0, 1); $pdf->SetFont("Arial", "", $small_font_size); $pdf->MultiCell(90, 4, $test->challenge_description, 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->SetY($pdf->GetY() + 2); // Details / Signage $pdf->SetFont("Arial", "B", $normal_font_size); $pdf->Cell(95, $cell_height, "Play Details & Signage", 0, 1); $pdf->SetY($pdf->GetY() + 2); $pdf->SetFont("Arial"); $field_width = 50; $value_width = 40; $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Machine Played:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["play_machine"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Jackpot Value:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["play_jackpot"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Stake Played:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["play_machine_stake"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Minutes Played:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["play_minutes"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Stake Spent:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["play_spent"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Think 21/25:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $values["think_21_25"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $value = $values["citizen_card_brochure_displayed"] ?? ""; if(strlen($value) > 0) $value = $value ? "Yes" : "No"; $pdf->Cell($field_width, $cell_height, "Citizen Card Brochure Displayed:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $value = $values["think_21_badge"] ?? ""; if(strlen($value) > 0) $value = $value ? "Yes" : "No"; $pdf->Cell($field_width, $cell_height, "Think 21 Badge Worn by Staff:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $value = $values["think_21_poster"] ?? ""; if(strlen($value) > 0) $value = $value ? "Yes" : "No"; $pdf->Cell($field_width, $cell_height, "Think 21 Posters Displayed:", 0, 0); $pdf->SetX($pdf->GetX() + 5); $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); $pdf->Cell($field_width, $cell_height, "Think 21 Poster Notes:", 0, 1); $pdf->SetFont("Arial", "", $small_font_size); $pdf->MultiCell(95, 4, $values["think_21_poster_notes"] ?? "N/A", 0, 1); $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY()); // Output $pdf->Output(); ?>