project_account_csv.php 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. ];
  19. fputcsv($handle, $field_names);
  20. foreach($tests as $test) {
  21. $location = $test->getLocation();
  22. $project = $test->getProject();
  23. $values = $test->getValues(true);
  24. $output = [];
  25. $output[] = $location->internal_id;
  26. $output[] = $location->name;
  27. $output[] = $template->name;
  28. $output[] = $test->getDateTimeStart()->format("d/m/Y");
  29. $output[] = $test->id;
  30. $output[] = $test->getCustomerFee();
  31. $output[] = bcadd($values["play_spent"] ?? "0.00", 0, 2);
  32. fputcsv($handle, $output);
  33. }