1
0

tests_tester_list.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. Core::addScript("public/js/app-tests-tester-list.js");
  3. $tests = $user->getPendingTests();
  4. $locations = Location::load(array_column($tests, "location_id"));
  5. $bounds = new GeolocationBounds;
  6. foreach($tests as $test) {
  7. $location = $test->getLocation();
  8. $bounds->extend($location->latitude, $location->longitude);
  9. }
  10. $latitude = 51.3555177;
  11. $longitude = -1.1743197;
  12. if(HTTP::isAJAX()) {
  13. JSON::header();
  14. $action = http::value("action");
  15. switch($action) {
  16. case "get-tests":
  17. $output = [];
  18. foreach($tests as $test) {
  19. $location = $test->getLocation();
  20. $icon = null;
  21. switch($test->status) {
  22. case 2:
  23. $icon = "building-orange";
  24. break;
  25. case 3:
  26. $icon = "building-green";
  27. break;
  28. case 4:
  29. $icon = "building-pink";
  30. break;
  31. case 8:
  32. $icon = "building-grey";
  33. break;
  34. }
  35. $output[] = (object) [
  36. "status" => $test->getStatusText(),
  37. "statusClass" => $test->getStatusClass(),
  38. "name" => $location->name,
  39. "address" => $location->getDisplayAddress(["address_1", "address_2", "city", "county", "postal_code", "state"]),
  40. "icon" => $icon,
  41. "geolocation" => $location->getGeolocation(),
  42. ];
  43. }
  44. JSON::success([
  45. "tests" => $output,
  46. "southWest" => $bounds->getSouthWest(),
  47. "northEast" => $bounds->getNorthEast(),
  48. ]);
  49. break;
  50. default:
  51. JSON::fail("Invalid action");
  52. }
  53. }
  54. View::includeOnce("header", compact("page_title"));
  55. View::include("test_list_assigned", compact("tests", "latitude", "longitude"));
  56. ?>