getProject(); $customer = $project->getCustomer(); $template = $project->getTemplate(); $template->setKeys($project->getTemplateKeys()); $template->setOverrides($project->getTemplateOverrides()); $template_parts = json_decode($template->getJSON()); $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; }); 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")); $duration_text = 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); $location_text = " $location->name"; if($location->internal_id) { $location_text .= " ({$customer->internal_id_field_name}: {$location->internal_id})"; } $template_processing_file_path = $template->getProcessingFilePath("test_pdf.php"); // A4 size: 210x297mm // Start PDF Building $mpdf = new Mpdf([ "margin_top" => 26, "margin_bottom" => 15, "margin_left" => 15, "margin_right" => 15, ]); $mpdf->SetSubject("Test Result"); $mpdf->SetCreator(APP_NAME); $mpdf->SetAuthor(APP_NAME); $mpdf->SetTitle("{$location->name} Test Result @ {$date_start}"); $mpdf->useSubstitutions = true; ob_start() ?> WriteHTML($html); // Output if($output) { $mpdf->Output(); }