| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- $project = Project::get($id);
- if(!$project) throw new Exception("Project not found.");
- if(!Core::$user->hasPermission($project)) throw new Exception("You do not have permission to access this page.");
- $page_title = $project->name;
- $customer = $project->getCustomer();
- Core::addBreadcrumb("/account", "Account");
- Core::addBreadcrumb("/account/projects", "Projects");
- Core::addBreadcrumb("/account/projects?customer_id=$customer->id", "$customer->name Projects");
- Core::addBreadcrumb("/account/projects/$project->id", $page_title);
- Core::addScript("public/js/app-project.js");
- Core::addScript("public/js/markerclusterer.js");
- $completed_percentage = $project->getCompletedPercentage();
- $locations = $customer->getLocations();
- $tests = $project->getTests();
- usort($tests, function($a, $b) {
- return $a->status <=> $b->status;
- });
- $created_test_count = count($tests);
- $pending_verification_tests = array_filter($tests, function($test) { return $test->status == Test::STATUS_PENDING_VERIFICATION; });
- $pending_verification_test_count = count($pending_verification_tests);
- $completed_tests = array_filter($tests, function($test) { return $test->status == Test::STATUS_COMPLETED; });
- $completed_test_count = count($completed_tests);
- $pass_count = count(array_filter($tests, function($test) { return $test->pass === 1; }));
- $fail_count = count(array_filter($tests, function($test) { return $test->pass === 0; }));
- $pass_fail_count = $pass_count + $fail_count;
- $pass_percentage = 0;
- $fail_percentage = 0;
- if($pass_fail_count) {
- $pass_percentage = number_format(($pass_count / $pass_fail_count) * 100, 1);
- $fail_percentage = 100 - $pass_percentage;
- }
- $min_lat = $min_lng = 180;
- $max_lat = $max_lng = -180;
- foreach($locations as $location) {
- if($location->latitude < $min_lat) $min_lat = $location->latitude;
- if($location->latitude > $max_lat) $max_lat = $location->latitude;
- if($location->longitude < $min_lng) $min_lng = $location->longitude;
- if($location->longitude > $max_lng) $max_lng = $location->longitude;
- }
- $latitude = ($min_lat + $max_lat) / 2;
- $longitude = ($min_lng + $max_lng) / 2;
- $latitude = 51.3555177;
- $longitude = -1.1743197;
- $deadline_date = explode(" ", $project->dts_deadline)[0];
- View::includeOnce("header", compact("page_title"));
- View::include("project", compact("project", "tests", "latitude", "longitude", "completed_percentage", "pass_count", "fail_count", "pass_fail_count", "pass_percentage", "fail_percentage", "customer", "locations", "deadline_date", "created_test_count", "completed_test_count"));
- View::include("modal_assign_tester");
- View::includeOnce("footer");
- ?>
|