| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- Core::addScript("public/js/app-tests-tester-list.js");
- $tests = $user->getPendingTests();
- $locations = Location::load(array_column($tests, "location_id"));
- $bounds = new GeolocationBounds;
- foreach($tests as $test) {
- $location = $test->getLocation();
- $bounds->extend($location->latitude, $location->longitude);
- }
- $latitude = 51.3555177;
- $longitude = -1.1743197;
- if(HTTP::isAJAX()) {
- JSON::header();
- $action = http::value("action");
- switch($action) {
- case "get-tests":
- $output = [];
- foreach($tests as $test) {
- $location = $test->getLocation();
- $icon = null;
- switch($test->status) {
- case 2:
- $icon = "building-orange";
- break;
- case 3:
- $icon = "building-green";
- break;
- case 4:
- $icon = "building-pink";
- break;
- case 8:
- $icon = "building-grey";
- break;
- }
- $output[] = (object) [
- "id" => $test->id,
- "status" => $test->getStatusText(),
- "statusClass" => $test->getStatusClass(),
- "name" => $location->name,
- "address" => $location->getDisplayAddress(["address_1", "address_2", "city", "county", "postal_code", "state"]),
- "icon" => $icon,
- "geolocation" => $location->getGeolocation(),
- ];
- }
- JSON::success([
- "tests" => $output,
- "southWest" => $bounds->getSouthWest(),
- "northEast" => $bounds->getNorthEast(),
- ]);
- break;
- default:
- JSON::fail("Invalid action");
- }
- }
- View::includeOnce("header", compact("page_title"));
- View::include("test_list_assigned", compact("tests", "latitude", "longitude"));
|