location_view.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. $location = Location::get($id);
  3. if(!$location) throw new Exception("Location not found.");
  4. if(!Core::$user->hasPermission($location)) throw new Exception("You do not have permission to access this page.");
  5. $page_title = $location->name;
  6. Core::addBreadcrumb("/account", "Account");
  7. Core::addBreadcrumb("/account/locations", "Locations");
  8. Core::addBreadcrumb("/account/locations/$location->id", $page_title);
  9. $status_constraint = new Constraint("BETWEEN");
  10. if(Core::$user->level >= User::LEVEL_ADMIN) {
  11. $status_constraint->setValues(Test::STATUS_UNASSIGNED, Test::STATUS_COMPLETED);
  12. }
  13. else {
  14. $status_constraint->setValues(Test::STATUS_COMPLETED, Test::STATUS_COMPLETED);
  15. }
  16. $tests = Test::query([
  17. "location_id" => $location->id,
  18. "status" => $status_constraint,
  19. ], [
  20. "sort" => "status",
  21. "order" => "asc",
  22. ]);
  23. $projects = Project::load(array_column($tests, "project_id"));
  24. View::includeOnce("header", compact("page_title"));
  25. View::include("location", compact("location", "tests"));
  26. View::includeOnce("footer");
  27. ?>