Przeglądaj źródła

Add "Tests" page for customers

Alan Lam 1 rok temu
rodzic
commit
bcd0226f0c

+ 3 - 4
controllers/account.php

@@ -100,7 +100,7 @@ $tests_remaining = 0;
 
 $icons = [];
 
-if($user->isTesterManager()) {
+if($user->isTesterManagerOrHigher()) {
 	$icons[] = new AccountIcon(__("Stats"), "/account/overview", "tasks-alt");
 }
 
@@ -164,15 +164,14 @@ if($user->canAccessReports()) {
 
 if($user->canAccessTestResults()) {
 	$icons[] = new AccountIcon(__("Test Results"), "/account/test-results", "clipboard-list-check");
+	$icons[] = new AccountIcon(__("Tests"), "/account/tests", "clipboard-check");
 }
 
 if($user->canAccessTests()) {
 	$tests = $user->getPendingTests();
 	$tests_remaining = count($tests);
 
-
-
-	$tests_url = $user->isTesterManager() ? "/account/tests?custom=overdue_test" : "/account/tests";
+	$tests_url = $user->isTesterManagerOrHigher() ? "/account/tests?custom=overdue_test" : "/account/tests";
 
 	$tests_icon = new AccountIcon(__("Tests"), $tests_url, "clipboard-check");
 	$tests_icon->setCounter($tests_remaining);

+ 15 - 5
controllers/test_results_test_list.php

@@ -1,16 +1,26 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+
+/**
+ * @var int $project_id
+ */
 
 $customers = Core::$user->getCustomers();
-if(!$customers) throw new Exception(__("An unexpected error has occurred. Please try again later."));
+if(!$customers) {
+	throw new RuntimeException(__("An unexpected error has occurred. Please try again later."));
+}
 
 $project = Project::get($project_id);
-if(!$project) throw new Exception(__("Project not found."));
+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 Exception(__("You do not have permission to access this page."));
+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();
@@ -18,7 +28,7 @@ $tests = $project->getTests();
 $location_ids = array_column($tests, "location_id");
 Location::load($location_ids);
 
-usort($tests, function($a, $b) {
+usort($tests, static function(Test $a, Test $b) {
     $a_location = $a->getLocation();
     $b_location = $b->getLocation();
 

+ 4 - 9
controllers/tests.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 $page_title = __("Tests");
 
@@ -7,14 +7,9 @@ Core::addBreadcrumb("/account/tests", $page_title);
 
 $user = Core::$user;
 
-// Admin / Super Admin / Tester Manager
-if($user->canAccessAdminTestsList()) {
-	require "tests_admin_list.php";
-}
-
-// HQ / Venue (view completed tests)
-else if($user->canAccessTestResults()) {
-	require "tests_location_list.php";
+// Admin / Super Admin / Tester Manager / Customer
+if($user->canAccessTestsTable()) {
+	require "tests_table.php";
 }
 
 // Tester

+ 111 - 41
controllers/tests_admin_list.php → controllers/tests_table.php

@@ -4,9 +4,18 @@
  * @var string $page_title
  */
 
+$user = Core::$user;
+if(!$user) {
+	throw new RuntimeException(__("No permission to access this page."));
+}
+
+$is_customer = $user->isCustomer();
+$is_staff = $user->isTesterManagerOrHigher();
+
+
 // Batch Action
 $submit = http::value("submit");
-if($submit) {
+if($submit && $is_staff) {
 	try {
 		Core::validateCSRFToken($submit);
 
@@ -72,20 +81,9 @@ if($submit) {
 		Core::addAlert("danger", $e->getMessage());
 	}
 }
+
 // Batch Action End
 
-$status = http::value("status", "int");
-$status_tester_invoice = http::value("status_tester_invoice");
-$customer_id = http::value("customer_id", "int");
-$project_id = http::value("project_id", "int");
-$location_id = http::value("location_id", "int");
-$location_name = http::value("location_name", "trim");
-$test_id = http::value("test_id", "int");
-$tester_id = http::value("tester_id", "int");
-$location_internal_id = http::value("location_internal_id", "int");
-$pass = http::value("pass", "int");
-$retest = http::value("retest", "int");
-$void = http::value("void", "int");
 $min_days_overdue = http::value("min_days_overdue", "int");
 $custom = http::value("custom");
 
@@ -93,27 +91,78 @@ $filter_count_offset = 0;
 
 $nvp = [];
 
-// Status
-if(strlen($status) > 0) $nvp["status"] = $status;
+// Staff only filters
+if($is_staff) {
+	// Status
+	$status = http::value("status", "int");
+	if(strlen($status) > 0) {
+		$nvp["status"] = $status;
+	}
+	else {
+		$nvp["status"] = Constraint::notEquals(Test::STATUS_CANCELLED);
+		$filter_count_offset--;
+	}
+
+	// Status Tester Invoice
+	$status_tester_invoice = http::value("status_tester_invoice");
+	if(strlen($status_tester_invoice)) {
+		$status_tester_invoice = (int) $status_tester_invoice;
+		$nvp["status_tester_invoice"] = $status_tester_invoice;
+	}
+
+	// Tester ID
+	$tester_id = http::value("tester_id", "int");
+	if($tester_id) {
+		$nvp["tester_id"] = $tester_id;
+	}
+}
 else {
-	$nvp["status"] = Constraint::notEquals(Test::STATUS_CANCELLED);
-	$filter_count_offset--;
+	$status = null;
+	$status_tester_invoice = null;
+	$tester_id = null;
 }
 
-// Status Tester Invoice
-if(strlen($status_tester_invoice)) {
-	$status_tester_invoice = (int) $status_tester_invoice;
-	$nvp["status_tester_invoice"] = $status_tester_invoice;
+if($is_customer) {
+	$customers = $user->getCustomers();
+
+	$projects = Project::query([
+		"customer_id" => array_column($customers, "id"),
+		"dts_finished" => Constraint::isNotNull(),
+	]);
+
+	$valid_project_ids = array_column($projects, "id");
+}
+else {
+	$customers = Customer::query([], ["sort" => "name"]);
+	$valid_project_ids = [];
 }
 
 // Project
-if($project_id) $nvp["project_id"] = $project_id;
-else if($customer_id) {
-	$projects = Project::query(["customer_id" => $customer_id]);
-	$nvp["project_id"] = array_column($projects, "id");
+$project_id = http::value("project_id", "int");
+$customer_id = null;
+if($project_id) {
+	if($is_staff || in_array($project_id, $valid_project_ids)) {
+		$nvp["project_id"] = $project_id;
+	}
+	else {
+		$nvp["project_id"] = 0;
+	}
+}
+else if($is_staff) {
+	$customer_id = http::value("customer_id", "int");
+	if($customer_id) {
+		$projects = Project::query(["customer_id" => $customer_id]);
+		$nvp["project_id"] = array_column($projects, "id");
+	}
+}
+else {
+	$nvp["project_id"] = $valid_project_ids;
 }
 
 // Location
+$location_id = http::value("location_id", "int");
+$location_internal_id = http::value("location_internal_id", "int");
+$location_name = http::value("location_name", "trim");
 if($location_id) {
 	$nvp["location_id"] = $location_id;
 }
@@ -129,14 +178,19 @@ else if($location_name) {
 }
 
 // Test ID
-if($test_id) $nvp["id"] = $test_id;
-
-// Tester ID
-if($tester_id) $nvp["tester_id"] = $tester_id;
+$test_id = http::value("test_id", "int");
+if($test_id) {
+	$nvp["id"] = $test_id;
+}
 
 // Pass
-if(strlen($pass) > 0) $nvp["pass"] = $pass;
+$pass = http::value("pass", "int");
+if(strlen($pass) > 0) {
+	$nvp["pass"] = $pass;
+}
 
+// Retest
+$retest = http::value("retest", "int");
 if(isset($retest)) {
 	if($retest === 0) {
 		$nvp["retest"] = 0;
@@ -147,13 +201,20 @@ if(isset($retest)) {
 }
 
 // Void
+$void = http::value("void", "int");
 if(isset($void)) {
 	$nvp["void"] = (int) $void;
 }
 
 $filter_count = count($nvp);
 
-$sort = http::value("sort");
+if($is_staff) {
+	$sort = http::value("sort");
+}
+else {
+	$sort = "end";
+}
+
 switch($sort) {
 	case "updated":
 		$query_options = ["sort" => "dts_updated", "order" => "desc"];
@@ -171,7 +232,10 @@ switch($sort) {
 }
 
 $tests = Test::query($nvp, $query_options);
-$projects = Project::load(array_column($tests, "project_id"));
+
+if($is_staff) {
+	$projects = Project::load(array_column($tests, "project_id"));
+}
 
 switch($custom) {
 	case "declined":
@@ -274,26 +338,32 @@ switch($custom) {
 }
 
 $filter_count += $filter_count_offset;
-if(!$filter_count) $filter_count = "";
+if(!$filter_count) {
+	$filter_count = "";
+}
 
 $pagination_object = Util::getPaginationObject(count($tests));
 $tests = array_slice($tests, $pagination_object->offset, $pagination_object->pageSize);
 
 $testers = User::load(array_column($tests, "tester_id"));
-$customers = Customer::query([], ["sort" => "name"]);
 
 usort($projects, static function(Project $a, Project $b): int {
 	return $a->name <=> $b->name;
 });
 
-$sorts = [
-	"status" => "Status",
-	"updated" => "Recently updated",
-	"end" => "Test date",
-	"due" => "Test due date",
-];
+if($is_staff) {
+	$sorts = [
+		"status" => "Status",
+		"updated" => "Recently updated",
+		"end" => "Test date",
+		"due" => "Test due date",
+	];
+}
+else {
+	$sorts = [];
+}
 
 Core::addScript("public/js/app-test-list.js");
 
 View::includeOnce("header", compact("page_title"));
-View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "location_name", "pass", "retest", "void", "min_days_overdue", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice"));
+View::include("test_list", compact("tests", "pagination_object", "sort", "sorts", "projects", "customers", "customer_id", "project_id", "location_id", "location_internal_id", "location_name", "pass", "retest", "void", "min_days_overdue", "custom", "test_id", "tester_id", "filter_count", "status", "status_tester_invoice", "is_staff"));

+ 6 - 6
engine/user.php

@@ -403,8 +403,8 @@ class User extends Model {
 		}
 	}
 
-	public function isTesterManager(): bool {
-		return $this->level >= User::LEVEL_TESTER_MANAGER;
+	public function isTesterManagerOrHigher(): bool {
+		return $this->level >= self::LEVEL_TESTER_MANAGER;
 	}
 
 	public function isAdmin(): bool {
@@ -735,7 +735,7 @@ class User extends Model {
 	}
 
 	public function canAccessTests(): bool {
-		return $this->isTester() || $this->isTesterManager();
+		return $this->isTester() || $this->isTesterManagerOrHigher();
 	}
 
 	public function canAccessPractice(): bool {
@@ -762,8 +762,8 @@ class User extends Model {
 		return $this->level == User::LEVEL_DEACTIVATED;
 	}
 
-	public function canAccessAdminTestsList(): bool {
-		return $this->isTesterManager();
+	public function canAccessTestsTable(): bool {
+		return $this->isTesterManagerOrHigher() || $this->isCustomer();
 	}
 
 	public function canExportProjectCsv(): bool {
@@ -779,7 +779,7 @@ class User extends Model {
 	}
 
 	public function canEditUsers(): bool {
-		return $this->isTesterManager();
+		return $this->isTesterManagerOrHigher();
 	}
 
 	public function canSeeMissingData(): bool {

+ 302 - 213
views/test_list.php

@@ -21,6 +21,7 @@
  * @var int $min_days_overdue
  * @var int $custom
  * @var object $pagination_object
+ * @var bool $is_staff
  */
 
 $filters_collapse = $filter_count ? "collapse show" : "collapse";
@@ -80,44 +81,56 @@ foreach($projects as $project) {
 							Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
 						</a>
 					</div>
-					<div class="col">
-						<div class="input-group">
-							<div class="input-group-prepend">
-								<label for="sort-dropdown" class="input-group-text">
-									Sort
-								</label>
+					<?php
+					if($sorts) {
+						?>
+						<div class="col">
+							<div class="input-group">
+								<div class="input-group-prepend">
+									<label for="sort-dropdown" class="input-group-text">
+										Sort
+									</label>
+								</div>
+								<select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
+									<?php
+									HtmlHelper::renderOptions($sorts, $sort);
+									?>
+								</select>
 							</div>
-							<select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
-							<?php
-							HtmlHelper::renderOptions($sorts, $sort);
-							?>
-							</select>
 						</div>
-					</div>
+						<?php
+					}
+					?>
 				</div>
 			</div>
 		</div>
 
-		<div class="form-row my-3">
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-primary" href="/account/tests">Show All</a>
-			</div>
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_UNASSIGNED?>">Unassigned</a>
-			</div>
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-warning" href="/account/tests?status=<?=Test::STATUS_CONFIRMED?>">Confirmed</a>
-			</div>
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-success" href="/account/tests?status=<?=Test::STATUS_PENDING_VERIFICATION?>&amp;sort=end">Pending Verification</a>
-			</div>
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-danger" href="/account/tests?pass=0">Fails</a>
-			</div>
-			<div class="col-xl col-6 col-lg-4 mb-1">
-				<a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_CANCELLED?>">Cancelled / Rejected</a>
+		<?php
+		if($is_staff) {
+			?>
+			<div class="form-row my-3">
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-primary" href="/account/tests">Show All</a>
+				</div>
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_UNASSIGNED?>">Unassigned</a>
+				</div>
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-warning" href="/account/tests?status=<?=Test::STATUS_CONFIRMED?>">Confirmed</a>
+				</div>
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-success" href="/account/tests?status=<?=Test::STATUS_PENDING_VERIFICATION?>&amp;sort=end">Pending Verification</a>
+				</div>
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-danger" href="/account/tests?pass=0">Fails</a>
+				</div>
+				<div class="col-xl col-6 col-lg-4 mb-1">
+					<a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_CANCELLED?>">Cancelled / Rejected</a>
+				</div>
 			</div>
-		</div>
+			<?php
+		}
+		?>
 
 		<div class="<?=$filters_collapse?>" id="filters">
 			<form method="get">
@@ -127,50 +140,53 @@ foreach($projects as $project) {
 
 					<div class="row mb-1">
 						<div class="col-lg-6">
-							<div class="row mb-1">
-								<label class="col-form-label col-sm-4" for="status">Status</label>
-								<div class="col-sm">
-									<select class="form-control" name="status" id="status">
-										<option value="">Any not rejected</option>
-										<?php
-										foreach(Test::STATUSES as $value => $display) {
-											$selected = ($value === $status) ? "selected" : "";
-											?>
-											<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+							<?php
+							if($is_staff) {
+								?>
+								<div class="row mb-1">
+									<label class="col-form-label col-sm-4" for="status">Status</label>
+									<div class="col-sm">
+										<select class="form-control" name="status" id="status">
+											<option value="">Any not rejected</option>
 											<?php
-										}
-										?>
-									</select>
-								</div>
-							</div>
-							<div class="row mb-1">
-								<label class="col-form-label col-sm-4" for="status-tester-invoice">Tester Invoice Status</label>
-								<div class="col-sm">
-									<select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
-										<option value="">Any</option>
-										<?php
-										foreach(Test::STATUSES_TESTER_INVOICE as $value) {
-											$display = Test::getStatusTesterInvoiceText($value);
-											$selected = ($value === $status_tester_invoice) ? "selected" : "";
+											HtmlHelper::renderOptions(Test::STATUSES, $status);
 											?>
-											<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+										</select>
+									</div>
+								</div>
+
+								<div class="row mb-1">
+									<label class="col-form-label col-sm-4" for="status-tester-invoice">Tester Invoice Status</label>
+									<div class="col-sm">
+										<select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
+											<option value="">Any</option>
 											<?php
-										}
-										?>
-									</select>
+											foreach(Test::STATUSES_TESTER_INVOICE as $value) {
+												$display = Test::getStatusTesterInvoiceText($value);
+												$selected = ($value === $status_tester_invoice) ? "selected" : "";
+												?>
+												<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+												<?php
+											}
+											?>
+										</select>
+									</div>
 								</div>
-							</div>
-							<div class="row mb-1">
-								<label class="col-form-label col-sm-4" for="customer-id">Customer</label>
-								<div class="col-sm">
-									<select class="form-control" name="customer_id" id="customer-id">
-										<option value="">Select customer</option>
-										<?php
-										HtmlHelper::renderOptions($customer_options, $customer_id);
-										?>
-									</select>
+
+								<div class="row mb-1">
+									<label class="col-form-label col-sm-4" for="customer-id">Customer</label>
+									<div class="col-sm">
+										<select class="form-control" name="customer_id" id="customer-id">
+											<option value="">Select customer</option>
+											<?php
+											HtmlHelper::renderOptions($customer_options, $customer_id);
+											?>
+										</select>
+									</div>
 								</div>
-							</div>
+								<?php
+							}
+							?>
 							<div class="row mb-1">
 								<label class="col-form-label col-sm-4" for="project-id">Project</label>
 								<div class="col-sm">
@@ -221,12 +237,18 @@ foreach($projects as $project) {
 									<input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
 								</div>
 							</div>
-							<div class="row mb-1">
-								<label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
-								<div class="col-sm">
-									<input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
+							<?php
+							if($is_staff) {
+								?>
+								<div class="row mb-1">
+									<label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
+									<div class="col-sm">
+										<input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
+									</div>
 								</div>
-							</div>
+								<?php
+							}
+							?>
 							<div class="row mb-1">
 								<label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
 								<div class="col-sm">
@@ -245,25 +267,31 @@ foreach($projects as $project) {
 									<input class="form-control" type="text" name="location_name" id="location-name" placeholder="Enter location name" value="<?=htmlspecialchars($location_name)?>" />
 								</div>
 							</div>
-							<div class="row mb-1">
-								<label class="col-sm-4 col-form-label" for="min-days-overdue">
-									<?=htmlspecialchars(__("Min. Days Overdue"))?>
-								</label>
-								<div class="col-sm">
-									<input class="form-control" type="number" name="min_days_overdue" id="min-days-overdue" placeholder="<?=htmlspecialchars(__("Enter days"))?>" value="<?=$min_days_overdue?>" />
+							<?php
+							if($is_staff) {
+								?>
+								<div class="row mb-1">
+									<label class="col-sm-4 col-form-label" for="min-days-overdue">
+										<?=htmlspecialchars(__("Min. Days Overdue"))?>
+									</label>
+									<div class="col-sm">
+										<input class="form-control" type="number" name="min_days_overdue" id="min-days-overdue" placeholder="<?=htmlspecialchars(__("Enter days"))?>" value="<?=$min_days_overdue?>" />
+									</div>
 								</div>
-							</div>
-							<div class="row mb-1">
-								<label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
-								<div class="col-sm">
-									<select class="form-control" name="custom" id="custom">
-										<option value="">Select custom filter</option>
-										<?php
-										HtmlHelper::renderOptions($custom_filters, $custom);
-										?>
-									</select>
+								<div class="row mb-1">
+									<label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
+									<div class="col-sm">
+										<select class="form-control" name="custom" id="custom">
+											<option value="">Select custom filter</option>
+											<?php
+											HtmlHelper::renderOptions($custom_filters, $custom);
+											?>
+										</select>
+									</div>
 								</div>
-							</div>
+								<?php
+							}
+							?>
 						</div>
 					</div>
 
@@ -310,24 +338,48 @@ foreach($projects as $project) {
 					<table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
 						<thead>
 						<tr>
-							<th>
-								<label for="tests-table-select-all" class="sr-only">
-									<?=htmlspecialchars(__("Select All"))?>
-								</label>
-								<input type="checkbox" id="tests-table-select-all" />
-							</th>
+							<?php
+							if($is_staff) {
+								?>
+								<th>
+									<label for="tests-table-select-all" class="sr-only">
+										<?=htmlspecialchars(__("Select All"))?>
+									</label>
+									<input type="checkbox" id="tests-table-select-all" />
+								</th>
+								<?php
+							}
+							?>
 							<th>ID</th>
 							<th>Location</th>
 							<th>Project</th>
-							<th>Tester</th>
-							<th>Due Date</th>
+							<?php
+							if($is_staff) {
+								?>
+								<th>Tester</th>
+								<th>Due Date</th>
+								<?php
+							}
+							?>
 							<th>Test Date</th>
-							<th>T. Costs</th>
-							<th>P. Costs</th>
-							<th>Status</th>
+							<?php
+							if($is_staff) {
+								?>
+								<th>T. Costs</th>
+								<th>P. Costs</th>
+								<th>Status</th>
+								<?php
+							}
+							?>
 							<th>Result</th>
 							<th>Retest</th>
-							<th>Actions</th>
+							<?php
+							if($is_staff) {
+								?>
+								<th>Actions</th>
+								<?php
+							}
+							?>
 						</tr>
 						</thead>
 						<tbody>
@@ -346,78 +398,98 @@ foreach($projects as $project) {
 							?>
 
 							<tr>
-								<td>
-									<label for="test-checkbox-<?=$test->id?>" class="sr-only">
-										<?=htmlspecialchars(__("Select Test ID %d", $test->id))?>
-									</label>
-									<input type="checkbox" name="test_ids[]" id="test-checkbox-<?=$test->id?>" value="<?=$test->id?>" />
-								</td>
+								<?php
+								if($is_staff) {
+									?>
+									<td>
+										<label for="test-checkbox-<?=$test->id?>" class="sr-only">
+											<?=htmlspecialchars(__("Select Test ID %d", $test->id))?>
+										</label>
+										<input type="checkbox" name="test_ids[]" id="test-checkbox-<?=$test->id?>" value="<?=$test->id?>" />
+									</td>
+									<?php
+								}
+								?>
 								<td>
 									<?=$test->id?>
 								</td>
 								<td class="align-middle">
 									<a href="/account/locations/<?=$location->id?>">
 										<?=htmlspecialchars($location->name)?>
-										<?php
-										if($location->internal_id) {
-											?>
-											(Internal ID: <?=htmlspecialchars($location->internal_id)?>)
-											<?php
-										}
+									</a>
+									<?php
+									if($location->internal_id) {
 										?>
-									</a><br />
+										<small class="text-muted">Internal ID: <?=htmlspecialchars($location->internal_id)?></small>
+										<?php
+									}
+									?>
+									<br />
 									<?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?>
 								</td>
 								<td class="align-middle">
 									<a href="/account/projects/<?=$project->id?>?location_id=<?=$test->location_id?>">
 										<?=htmlspecialchars($project->name)?>
-									</a><br />
-									<strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?>
-								</td>
-								<td class="align-middle">
-								<?php
-								if($tester) {
-									?>
-									<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
+									</a>
 									<?php
-									if($test->status_tester_invoice > 0) {
-										$time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
-										$dts = Util::getDisplayDateTime($time);
+									if($is_staff) {
 										?>
 										<br />
-										<span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=Test::getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
+										<strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?>
 										<?php
 									}
-								}
-								else {
 									?>
-									<small class="text-muted">N/A</small>
-									<?php
-								}
-								?>
 								</td>
-								<td class="align-middle <?=$due_class?>">
-									<?php
-									if($dt_due) {
-										$days_overdue = $dt_due->diffInDays();
-										?>
-										<strong><?=$dt_due->format("d/m/Y")?></strong>
+								<?php
+								if($is_staff) {
+									?>
+									<td class="align-middle">
 										<?php
-										if($is_overdue && !$test->isDone()) {
-											?><br />
-											<small>
-												<?=htmlspecialchars(n__("%d day overdue", "%d days overdue", $days_overdue, $days_overdue))?>
-											</small>
+										if($tester) {
+											?>
+											<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
+											<?php
+											if($test->status_tester_invoice > 0) {
+												$time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
+												$dts = Util::getDisplayDateTime($time);
+												?>
+												<br />
+												<span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=Test::getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
+												<?php
+											}
+										}
+										else {
+											?>
+											<small class="text-muted">N/A</small>
 											<?php
 										}
-									}
-									else {
 										?>
-										<small class="text-muted">N/A</small>
+									</td>
+									<td class="align-middle <?=$due_class?>">
 										<?php
-									}
-									?>
-								</td>
+										if($dt_due) {
+											$days_overdue = $dt_due->diffInDays();
+											?>
+											<strong><?=$dt_due->format("d/m/Y")?></strong>
+											<?php
+											if($is_overdue && !$test->isDone()) {
+												?><br />
+												<small>
+													<?=htmlspecialchars(n__("%d day overdue", "%d days overdue", $days_overdue, $days_overdue))?>
+												</small>
+												<?php
+											}
+										}
+										else {
+											?>
+											<small class="text-muted">N/A</small>
+											<?php
+										}
+										?>
+									</td>
+									<?php
+								}
+								?>
 								<td>
 									<?php
 									if($dt_end) {
@@ -430,28 +502,34 @@ foreach($projects as $project) {
 									}
 									?>
 								</td>
-								<td class="text-right align-middle">
-									<?php
-									if($test->test_travel_cost > 0) {
-										?>
-										£<?=number_format($test->test_travel_cost, 2)?>
-										<?php
-									}
+								<?php
+								if($is_staff) {
 									?>
-								</td>
-								<td class="text-right align-middle">
-									<?php
-									$tester_invoice_costs = $test->getTesterInvoiceCosts();
-									if($tester_invoice_costs > 0) {
+									<td class="text-right align-middle">
+										<?php
+										if($test->test_travel_cost > 0) {
+											?>
+											£<?=number_format($test->test_travel_cost, 2)?>
+											<?php
+										}
 										?>
-										£<?=number_format($tester_invoice_costs, 2)?>
+									</td>
+									<td class="text-right align-middle">
 										<?php
-									}
-									?>
-								</td>
-								<td class="text-center align-middle">
-									<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
-								</td>
+										$tester_invoice_costs = $test->getTesterInvoiceCosts();
+										if($tester_invoice_costs > 0) {
+											?>
+											£<?=number_format($tester_invoice_costs, 2)?>
+											<?php
+										}
+										?>
+									</td>
+									<td class="text-center align-middle">
+										<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
+									</td>
+									<?php
+								}
+								?>
 								<td class="text-center align-middle text-<?=$test->getPassClass()?>">
 									<div title="<?=$test->getPassText()?>">
 										<i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
@@ -466,28 +544,34 @@ foreach($projects as $project) {
 									}
 									?>
 								</td>
-								<td class="text-right align-middle">
-									<div class="dropdown">
-										<button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-											Actions
-										</button>
-										<div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
-											<a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
-											<?php
-											if($test->hasTesterInvoicePDF()) {
-												?>
-												<a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
+								<?php
+								if($is_staff) {
+									?>
+									<td class="text-right align-middle">
+										<div class="dropdown">
+											<button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+												Actions
+											</button>
+											<div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
+												<a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
 												<?php
-											}
-											if($test->hasTravelCostsPhoto()) {
+												if($test->hasTesterInvoicePDF()) {
+													?>
+													<a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
+													<?php
+												}
+												if($test->hasTravelCostsPhoto()) {
+													?>
+													<a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/travel_costs">View Travel Costs Photo</a>
+													<?php
+												}
 												?>
-												<a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/travel_costs">View Travel Costs Photo</a>
-												<?php
-											}
-											?>
+											</div>
 										</div>
-									</div>
-								</td>
+									</td>
+									<?php
+								}
+								?>
 							</tr>
 							<?php
 						}
@@ -496,33 +580,38 @@ foreach($projects as $project) {
 					</table>
 				</div>
 
-				<div class="row">
-					<div class="col-md">
+				<?php
+				if($is_staff) {
+					?>
+					<div class="row">
+						<div class="col-md">
 
-					</div>
-					<div class="col-md-auto">
-						<div class="input-group">
-							<div class="input-group-prepend">
-								<label class="input-group-text" for="batch-action">
-									Batch Action
-								</label>
-							</div>
-							<select class="form-control" name="batch_action" id="batch-action" required>
-								<option value="">Select Action</option>
-								<option value="unassign">Unassign</option>
-								<option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
-								<option value="reject_tester_invoice">Reject Tester Invoices</option>
-								<option value="send_test_assigned_email">Send Test Assigned Email</option>
-							</select>
-							<div class="input-group-append">
-								<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
-									Submit
-								</button>
+						</div>
+						<div class="col-md-auto">
+							<div class="input-group">
+								<div class="input-group-prepend">
+									<label class="input-group-text" for="batch-action">
+										Batch Action
+									</label>
+								</div>
+								<select class="form-control" name="batch_action" id="batch-action" required>
+									<option value="">Select Action</option>
+									<option value="unassign">Unassign</option>
+									<option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
+									<option value="reject_tester_invoice">Reject Tester Invoices</option>
+									<option value="send_test_assigned_email">Send Test Assigned Email</option>
+								</select>
+								<div class="input-group-append">
+									<button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
+										Submit
+									</button>
+								</div>
 							</div>
 						</div>
 					</div>
-				</div>
-
+					<?php
+				}
+				?>
 			</form>
 
 			<div class="mt-3">

+ 8 - 2
views/test_results_test_list.php

@@ -1,7 +1,13 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 /**
  * @var Project $project
  * @var Test[] $tests
+ * @var int $test_count
+ * @var bool $has_pass_fail
+ * @var int $pass_count
+ * @var int $fail_count
+ * @var float $pass_percentage
+ * @var float $fail_percentage
  */
 ?>
 <div class="container mt-3 py-4">
@@ -51,7 +57,7 @@
                     <div class="card-body">
                         Pass Rate
                         <div class="stat mb-3">
-                            <?=number_format($pass_count)?> Pass / <?=number_format($fail_count)?> Fail (<?=intval($pass_percentage)?>% Pass)
+                            <?=number_format($pass_count)?> Pass / <?=number_format($fail_count)?> Fail (<?=(int) $pass_percentage ?>% Pass)
                         </div>
                         <div class="progress">
                             <div class="progress-bar bg-success" role="progressbar" style="width: <?=$pass_percentage?>%"></div>