1
0

location_view.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. $customer = $location->getCustomer();
  6. $page_title = $location->name;
  7. Core::addBreadcrumb("/account", "Account");
  8. Core::addBreadcrumb("/account/locations", "Locations");
  9. Core::addBreadcrumb("/account/locations?customer_id=$customer->id", "$customer->name Locations");
  10. Core::addBreadcrumb("/account/locations/$location->id", $page_title);
  11. $status_constraint = new Constraint("BETWEEN");
  12. if(Core::$user->level >= User::LEVEL_ADMIN) {
  13. $status_constraint->setValues(Test::STATUS_UNASSIGNED, Test::STATUS_COMPLETED);
  14. }
  15. else {
  16. $status_constraint->setValues(Test::STATUS_COMPLETED, Test::STATUS_COMPLETED);
  17. }
  18. $tests = Test::query([
  19. "location_id" => $location->id,
  20. "status" => $status_constraint,
  21. ], [
  22. "sort" => "status",
  23. "order" => "asc",
  24. ]);
  25. $projects = Project::load(array_column($tests, "project_id"));
  26. View::includeOnce("header", compact("page_title"));
  27. View::include("location", compact("location", "tests"));
  28. View::includeOnce("footer");
  29. ?>