project.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. $project = Project::get($id);
  3. if(!$project) throw new Exception("Project not found.");
  4. if(!Core::$user->hasPermission($project)) throw new Exception("You do not have permission to access this page.");
  5. $page_title = $project->name;
  6. Core::addBreadcrumb("/account", "Account");
  7. Core::addBreadcrumb("/account/projects", "Projects");
  8. Core::addBreadcrumb("/account/projects/$project->id", $page_title);
  9. Core::addScript("public/js/app-project.js");
  10. $completed_percentage = $project->getCompletedPercentage();
  11. $customer = $project->getCustomer();
  12. $locations = $customer->getLocations();
  13. $tests = $project->getTests();
  14. usort($tests, function($a, $b) {
  15. return $a->status <=> $b->status;
  16. });
  17. $created_test_count = count($tests);
  18. $pending_verification_tests = array_filter($tests, function($test) { return $test->status == Test::STATUS_PENDING_VERIFICATION; });
  19. $pending_verification_test_count = count($pending_verification_tests);
  20. $completed_tests = array_filter($tests, function($test) { return $test->status == Test::STATUS_COMPLETED; });
  21. $completed_test_count = count($completed_tests);
  22. $min_lat = $min_lng = 180;
  23. $max_lat = $max_lng = -180;
  24. foreach($locations as $location) {
  25. if($location->latitude < $min_lat) $min_lat = $location->latitude;
  26. if($location->latitude > $max_lat) $max_lat = $location->latitude;
  27. if($location->longitude < $min_lng) $min_lng = $location->longitude;
  28. if($location->longitude > $max_lng) $max_lng = $location->longitude;
  29. }
  30. $latitude = ($min_lat + $max_lat) / 2;
  31. $longitude = ($min_lng + $max_lng) / 2;
  32. $deadline_date = explode(" ", $project->dts_deadline)[0];
  33. View::includeOnce("header", compact("page_title"));
  34. View::include("project", compact("project", "tests", "latitude", "longitude", "completed_percentage", "customer", "locations", "deadline_date", "created_test_count", "completed_test_count"));
  35. View::include("modal_assign_tester");
  36. View::includeOnce("footer");
  37. ?>