getConfiguration(); $field_names = [ "Internal ID", "Location Name", "Division", "Template Name", "Date", "Test ID", "Test Cost", "Bar Cost", "Test + Bar Cost", ]; fputcsv($handle, $field_names); foreach($tests as $test) { $location = $test->getLocation(); $project = $test->getProject(); $values = $test->getValues(true); $test_cost = $test->getCustomerFee(); $bar_cost = bcadd($values["bar_expenditure"] ?? "0.00", 0, 2); $test_and_bar_cost = bcadd($test_cost, $bar_cost, 2); $dt_start = $test->getDateTimeStart(); $output = []; $output[] = $location->internal_id; $output[] = $location->name; $output[] = $location->brand; $output[] = $template->name; $output[] = $dt_start ? $dt_start->format("d/m/Y") : ""; $output[] = $test->id; $output[] = $test_cost; $output[] = $bar_cost; $output[] = $test_and_bar_cost; fputcsv($handle, $output); }