test_results_project_list.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var int $customer_id
  4. */
  5. $customers = Core::$user->getCustomers();
  6. if(!$customers) {
  7. throw new RuntimeException(__("An unexpected error has occurred. Please try again later."));
  8. }
  9. $customer_ids = array_column($customers, "id");
  10. if(!in_array($customer_id, $customer_ids)) {
  11. throw new RuntimeException(__("You do not have permission to access this page."));
  12. }
  13. $customer = Customer::get($customer_id);
  14. $projects = $customer->getProjects();
  15. $projects = array_filter($projects, static function(Project $project) {
  16. return $project->isFinished();
  17. });
  18. $test_results_url = $customer->getTestResultsUrl();
  19. $page_title = $customer->name;
  20. Core::addBreadcrumb("/account", __("Account"));
  21. Core::addBreadcrumb("/account/test-results", __("Test Results"));
  22. Core::addBreadcrumb($test_results_url, $customer->name);
  23. Core::addScript("public/js/app-test-results-project-list.js");
  24. View::includeOnce("header", compact("page_title"));
  25. View::include("test_results_project_list", compact("projects"));
  26. View::includeOnce("footer");