tests.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. $page_title = "Tests";
  3. Core::addBreadcrumb("/account", "Account");
  4. Core::addBreadcrumb("/account/tests", $page_title);
  5. $user = Core::$user;
  6. // Admin / Super Admin
  7. if($user->level >= User::LEVEL_ADMIN) {
  8. $status = http::value("status", "int");
  9. $project_id = http::value("project_id", "int");
  10. $location_id = http::value("location_id", "int");
  11. $test_id = http::value("test_id", "int");
  12. $nvp = [];
  13. if($status) $nvp["status"] = $status;
  14. if($project_id) $nvp["project_id"] = $project_id;
  15. if($location_id) $nvp["location_id"] = $location_id;
  16. if($test_id) $nvp["id"] = $test_id;
  17. $filter_count = count($nvp);
  18. if(!$filter_count) $filter_count = "";
  19. $tests = Test::query($nvp, ["sort" => "status"]);
  20. $testers = User::load(array_column($tests, "tester_id"));
  21. $projects = Project::load(array_column($tests, "project_id"));
  22. usort($projects, function($a, $b) {
  23. return $a->name <=> $b->name;
  24. });
  25. View::includeOnce("header", compact("page_title"));
  26. View::include("test_list", compact("tests", "projects", "project_id", "location_id", "test_id", "filter_count", "status"));
  27. View::includeOnce("footer");
  28. }
  29. // HQ / Venue (view completed tests)
  30. else if($user->level >= User::LEVEL_VENUE) {
  31. //$testers = User::load(array_column($tests, "tester_id"));
  32. View::includeOnce("header", compact("page_title"));
  33. View::include("test_list_completed", compact("tests"));
  34. View::includeOnce("footer");
  35. }
  36. // Tester
  37. else if($user->level == User::LEVEL_TESTER) {
  38. $tests = $user->getPendingTests();
  39. $testers = User::load(array_column($tests, "tester_id"));
  40. View::includeOnce("header", compact("page_title"));
  41. View::include("test_list_assigned", compact("tests"));
  42. View::includeOnce("footer");
  43. }
  44. ?>