| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @var int $project_id
- */
- $customers = Core::$user->getCustomers();
- if(!$customers) {
- throw new RuntimeException(__("An unexpected error has occurred. Please try again later."));
- }
- $project = Project::get($project_id);
- if(!$project) {
- throw new RuntimeException(__("Project not found."));
- }
- $template = $project->getTemplate();
- $has_pass_fail = $template->hasPassFail();
- $customer_ids = array_column($customers, "id");
- if(!in_array($project->customer_id, $customer_ids)) {
- throw new RuntimeException(__("You do not have permission to access this page."));
- }
- $customer = $project->getCustomer();
- $tests = $project->getTests();
- $location_ids = array_column($tests, "location_id");
- Location::load($location_ids);
- usort($tests, static function(Test $a, Test $b) {
- $a_location = $a->getLocation();
- $b_location = $b->getLocation();
- return strnatcasecmp($a_location->name, $b_location->name);
- });
- $test_count = $project->getTestCount();
- $pass_count = $project->getPassCount();
- $fail_count = $project->getFailCount();
- $pass_percentage = 0;
- $fail_percentage = 0;
- $pass_fail_count = $pass_count + $fail_count;
- if($pass_fail_count > 0) {
- $pass_percentage = number_format($pass_count / $pass_fail_count, 4) * 100;
- $fail_percentage = 100 - $pass_percentage;
- }
- $project_list_url = $customer->getTestResultsUrl();
- $test_list_url = $project->getTestResultsUrl();
- $page_title = __("Test Results %s Test List", $project->name);
- Core::addBreadcrumb("/account", __("Account"));
- Core::addBreadcrumb("/account/test-results", __("Test Results"));
- Core::addBreadcrumb($project_list_url, $customer->name);
- Core::addBreadcrumb($test_list_url, $project->name);
- View::includeOnce("header", compact("page_title"));
- View::include("test_results_test_list", compact("project", "has_pass_fail", "tests", "test_count", "pass_count", "fail_count", "pass_percentage", "fail_percentage"));
- View::includeOnce("footer");
|