Răsfoiți Sursa

Added support for searching by location internal ID.

Alan Lam 8 ani în urmă
părinte
comite
05a1ee23ab
2 a modificat fișierele cu 70 adăugiri și 43 ștergeri
  1. 8 1
      controllers/tests.php
  2. 62 42
      views/test_list.php

+ 8 - 1
controllers/tests.php

@@ -21,11 +21,18 @@ if($user->level >= User::LEVEL_ADMIN) {
 	$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");
 
 	$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;
 
 	$filter_count = count($nvp);
@@ -77,7 +84,7 @@ if($user->level >= User::LEVEL_ADMIN) {
 	];
 
 	View::includeOnce("header", compact("page_title"));
-	View::include("test_list", compact("tests", "test_count", "sort", "sorts", "pagination_string", "projects", "project_id", "location_id", "test_id", "filter_count", "status"));
+	View::include("test_list", compact("tests", "test_count", "sort", "sorts", "pagination_string", "projects", "project_id", "location_id", "location_internal_id", "test_id", "filter_count", "status"));
 }
 
 // HQ / Venue (view completed tests)

+ 62 - 42
views/test_list.php

@@ -47,54 +47,65 @@ $query["sort"] = "SORT";
 					Filters
 				</div>
 				<div class="card-body">
+
 					<div class="row">
-						<div class="col-3">
-							<div class="form-group">
-								<label for="status">Status</label>
-								<select class="form-control" name="status" id="status">
-									<option value="">Any</option>
-									<?php
-									foreach(Test::STATUSES as $value => $display) {
-										$selected = ($value === $status) ? "selected" : "";
-										?>
-										<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+						<div class="col-xl-6 col-lg-8 offset-xl-3 offset-lg-2">
+							<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</option>
 										<?php
-									}
-									?>
-								</select>
-							</div>
-						</div>
-						<div class="col-3">
-							<div class="form-group">
-								<label for="project-id">Project</label>
-								<select class="form-control" name="project_id" id="project-id">
-									<option value="">Select project</option>
-									<?php
-									foreach($projects as $project) {
-										$selected = ($project->id == $project_id) ? "selected" : "";
+										foreach(Test::STATUSES as $value => $display) {
+											$selected = ($value === $status) ? "selected" : "";
+											?>
+											<option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
+											<?php
+										}
 										?>
-										<option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
+									</select>
+								</div>
+							</div>
+							<div class="row mb-1">
+								<label class="col-form-label col-sm-4" for="project-id">Project</label>
+								<div class="col-sm">
+									<select class="form-control" name="project_id" id="project-id">
+										<option value="">Select project</option>
 										<?php
-									}
-									?>
-								</select>
+										foreach($projects as $project) {
+											$selected = ($project->id == $project_id) ? "selected" : "";
+											?>
+											<option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
+											<?php
+										}
+										?>
+									</select>
+								</div>
 							</div>
-						</div>
-						<div class="col-3">
-							<div class="form-group">
-								<label for="location-id">Location ID</label>
-								<input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
+								<div class="col-sm">
+									<input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
+								</div>
 							</div>
-						</div>
-						<div class="col-3">
-							<div class="form-group">
-								<label for="test-id">Test ID</label>
-								<input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="location-internal-id">Location Internal ID</label>
+								<div class="col-sm">
+									<input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
+								</div>
 							</div>
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
+								<div class="col-sm">
+									<input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
+								</div>
+							</div>
+							<br />
+							<button class="btn btn-primary" type="submit">Filter</button>
+							<a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
 						</div>
 					</div>
-					<button class="btn btn-primary" type="submit">Filter</button>
-					<a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
+
 				</div>
 			</div>
 			<input type="hidden" name="sort" value="<?=$sort?>" />
@@ -129,7 +140,7 @@ $query["sort"] = "SORT";
 
 			<table class="table table-sm table-hover" style="min-width: 1024px;">
 				<thead>
-					<th class="pr-3">ID</th>
+					<th>ID</th>
 					<th>Location</th>
 					<th>Project</th>
 					<th>Tester</th>
@@ -152,11 +163,20 @@ $query["sort"] = "SORT";
 					?>
 
 					<tr>
-						<td class="text-right pr-3">
+						<td>
 							<?=$test->id?>
 						</td>
 						<td class="align-middle">
-							<a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
+							<a href="/account/locations/<?=$location->id?>">
+								<?=htmlspecialchars($location->name)?>
+								<?php
+								if($location->internal_id) {
+									?>
+									<small>(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
+									<?php
+								}
+								?>
+							</a><br />
 							<small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
 						</td>
 						<td class="align-middle">