getProject(); $template = $project->getTemplate(); $template->setOverrides($project->getTemplateOverrides()); $template_parts = json_decode($template->json); $fields = array_merge($template_parts->beforeTest, $template_parts->duringTest); $field_name_label_map = []; foreach($fields as $field) { if(empty($field->name)) continue; $field = $template->applyOverridesToField($field); $field_name_label_map[$field->name] = $field->label; } if(!isset($output)) $output = true; $location = $test->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); $values = array_filter($values, function($value) { return strlen($value) !== 0; }); $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 . " UTC"); $dt_start->setTimezone(new DateTimeZone(TIMEZONE)); $dt_end = new DateTime($test->dts_end . " UTC"); $dt_end->setTimezone(new DateTimeZone(TIMEZONE)); $time_start = $dt_start->format("H:i:s"); $time_end = $dt_end->format("H:i:s"); $diff = $dt_start->diff($dt_end, true); $date_start = date("d/m/Y", strtotime($test->dts_start . " UTC")); $location_text = " $location->name"; if($location->internal_id) { $location_text .= " (ID: $location->internal_id)"; } $template_processing_file_path = $template->getProcessingFilePath("test_pdf.php"); // A4 size: 210x297mm // Start PDF Building $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 $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); require $template_processing_file_path; // Output if($output) { $pdf->Output(); } ?>