| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- $page_title = "Tests";
- Core::addBreadcrumb("/account", "Account");
- Core::addBreadcrumb("/account/tests", $page_title);
- $user = Core::$user;
- // Pagination
- $page_size = 25;
- $page = http::value("page", "int");
- if($page <= 1) $page = 1;
- Core::$page = $page;
- // Admin / Super Admin
- if($user->level >= User::LEVEL_ADMIN) {
- $status = http::value("status", "int");
- $project_id = http::value("project_id", "int");
- $location_id = http::value("location_id", "int");
- $test_id = http::value("test_id", "int");
- $location_internal_id = http::value("location_internal_id", "int");
- $pass = http::value("pass", "int");
- $nvp = [];
- if($status) $nvp["status"] = $status;
- if($project_id) $nvp["project_id"] = $project_id;
- if($location_id) $nvp["location_id"] = $location_id;
- else if($location_internal_id) {
- $locations = Location::query(["internal_id" => $location_internal_id]);
- if($locations) {
- $nvp["location_id"] = array_column($locations, "id");
- }
- }
- if($test_id) $nvp["id"] = $test_id;
- if(strlen($pass) > 0) $nvp["pass"] = $pass;
- $filter_count = count($nvp);
- if(!$filter_count) $filter_count = "";
- $sort = http::value("sort");
- switch($sort) {
- case "updated":
- $query_options = ["sort" => "dts_updated", "order" => "desc"];
- break;
- case "due":
- $query_options = ["sort" => "dts_due", "order" => "desc"];
- break;
- default:
- $sort = "status";
- $query_options = ["sort" => "status", "order" => "asc"];
- break;
- }
- $tests = Test::query($nvp, $query_options);
- $test_count = count($tests);
- $page_count = ceil($test_count / $page_size);
- if($page_count <= 1) $page_count = 1;
- Core::$page_count = $page_count;
- $offset = ($page - 1) * $page_size;
- $tests = array_slice($tests, $offset, $page_size);
- $testers = User::load(array_column($tests, "tester_id"));
- $projects = Project::load(array_column($tests, "project_id"));
- usort($projects, function($a, $b) {
- return $a->name <=> $b->name;
- });
- $item_number_first = $offset + 1;
- $item_number_last = $offset + $page_size;
- if($item_number_last > $test_count) $item_number_last = $test_count;
- $pagination_string = "Showing $item_number_first-$item_number_last of $test_count tests";
- $sorts = [
- "status" => "Status",
- "updated" => "Update",
- "due" => "Due",
- ];
- View::includeOnce("header", compact("page_title"));
- View::include("test_list", compact("tests", "test_count", "sort", "sorts", "pagination_string", "projects", "project_id", "location_id", "location_internal_id", "pass", "test_id", "filter_count", "status"));
- }
- // HQ / Venue (view completed tests)
- else if($user->level >= User::LEVEL_VENUE) {
- //$testers = User::load(array_column($tests, "tester_id"));
- View::includeOnce("header", compact("page_title"));
- View::include("test_list_venue", compact("tests"));
- }
- // Tester
- else if($user->level == User::LEVEL_TESTER) {
- $tests = $user->getPendingTests();
- $testers = User::load(array_column($tests, "tester_id"));
- View::includeOnce("header", compact("page_title"));
- View::include("test_list_assigned", compact("tests"));
- }
- View::includeOnce("modal_page_jump");
- View::includeOnce("footer");
- ?>
|