project_account_csv.php 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Template $template
  4. * @var object[] $fields
  5. * @var resource $handle
  6. * @var Test[] $tests
  7. * @var Constraint $year_cycle_constraint
  8. */
  9. $config = $template->getConfiguration();
  10. $field_names = [
  11. "Internal ID",
  12. "Location Name",
  13. "Template Name",
  14. "Date",
  15. "Test ID",
  16. "Test Cost",
  17. "Play Cost",
  18. "Bar Cost",
  19. ];
  20. fputcsv($handle, $field_names);
  21. foreach($tests as $test) {
  22. $location = $test->getLocation();
  23. $project = $test->getProject();
  24. $values = $test->getValues(true);
  25. $output = [];
  26. $output[] = $location->internal_id;
  27. $output[] = $location->name;
  28. $output[] = $template->name;
  29. $output[] = $test->getDateTimeStart()->format("d/m/Y");
  30. $output[] = $test->id;
  31. $output[] = $test->getCustomerFee();
  32. $output[] = bcadd($values["play_spent"] ?? "0.00", 0, 2);
  33. $output[] = bcadd($values["bar_expenditure"] ?? "0.00", 0, 2);
  34. fputcsv($handle, $output);
  35. }