| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @var Template $template
- * @var object[] $fields
- * @var resource $handle
- * @var Test[] $tests
- * @var Constraint $year_cycle_constraint
- */
- $config = $template->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);
- }
|