getCustomers(); if(!$customers) throw new Exception(__("An unexpected error has occurred. Please try again later.")); $project = Project::get($project_id); if(!$project) throw new Exception(__("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 Exception(__("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, function($a, $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");