Просмотр исходного кода

Updated test list format for admins.

Alan Lam 8 лет назад
Родитель
Сommit
fd9a4bfdae
3 измененных файлов с 76 добавлено и 48 удалено
  1. 4 0
      controllers/tests.php
  2. 1 1
      engine/test.php
  3. 71 47
      views/test_list.php

+ 4 - 0
controllers/tests.php

@@ -20,6 +20,7 @@ if($user->level >= User::LEVEL_ADMIN) {
 
 	$tests = Test::query($nvp, ["sort" => "status"]);
 
+	$testers = User::load(array_column($tests, "tester_id"));
 	$projects = Project::load(array_column($tests, "project_id"));
 
 	View::includeOnce("header", compact("page_title"));
@@ -30,6 +31,8 @@ if($user->level >= User::LEVEL_ADMIN) {
 // 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_completed", compact("tests"));
 	View::includeOnce("footer");
@@ -38,6 +41,7 @@ else if($user->level >= User::LEVEL_VENUE) {
 // 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"));

+ 1 - 1
engine/test.php

@@ -4,7 +4,7 @@ class Test extends Model {
 
 	protected static $table = "test";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "test_fee", "test_time", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_start", "dts_end", "verifier_id", "verifier_notes", "pass", "dts_created", "dts_assigned", "dts_verified"];
+	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "test_fee", "test_time", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "verifier_id", "verifier_notes", "pass", "dts_created", "dts_assigned", "dts_verified"];
 
 	protected static $field_map = [
 	];

+ 71 - 47
views/test_list.php

@@ -72,53 +72,77 @@
 			Showing <?=number_format(count($tests))?> test(s).
 		</div>
 
-		<div class="list-group">
-		<?php
-
-		$testers = User::load(array_column($tests, "tester_id"));
-
-		foreach($tests as $test) {
-			$location = $test->getLocation();
-			$tester = $test->getTester();
-
-			$unix_start = strtotime($test->dts_start . " UTC");
-			$unix_end = strtotime($test->dts_end . " UTC");
-
-			?>
-			<div class="list-group-item">
-				<div class="row">
-					<div class="col">
-						<div class="row">
-							<div class="col">
-								<?=htmlspecialchars($location->name)?><br />
-								<small><?=htmlspecialchars($location->getDisplayAddress())?></small>
-
-								<?php
-								if($tester) {
-									?>
-									<br />
-									<small>
-										Tester: <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a> &mdash;
-										<?=Util::getDisplayDateTime($unix_start)?>
-									</small>
-									<?php
-								}
-								?>
-							</div>
-							<div class="col-auto align-self-center">
-								<span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
-							</div>
-						</div>
-					</div>
-
-					<div class="col-auto align-self-center">
-						<a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>" title="Edit Results" data-toggle="tooltip"><i class="fal fa-search"></i></a>
-					</div>
-				</div>
-			</div>
-			<?php
-		}
-		?>
+		<div class="table-responsive">
+
+			<table class="table table-hover">
+				<thead>
+					<th>ID</th>
+					<th>Location</th>
+					<th>Project</th>
+					<th>Tester</th>
+					<th>Due Date</th>
+					<th>Status</th>
+					<th></th>
+				</thead>
+				<tbody>
+				<?php
+
+				foreach($tests as $test) {
+					$location = $test->getLocation();
+					$project = $test->getProject();
+					$tester = $test->getTester();
+
+					$unix_start = strtotime($test->dts_start . " UTC");
+					$unix_end = strtotime($test->dts_end . " UTC");
+
+					?>
+
+					<tr>
+						<td class="text-right align-middle">
+							<?=$test->id?>
+						</td>
+						<td class="align-middle">
+							<a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
+							<small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
+						</td>
+						<td class="align-middle">
+							<a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
+						</td>
+						<td class="align-middle">
+						<?php
+						if($tester) {
+							?>
+							<a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
+							<?php
+						}
+						else {
+							?>
+							<small class="text-muted">N/A</small>
+							<?php
+						}
+						?>
+						</td>
+						<td class="text-center align-middle">
+						<?php
+						if(is_null($test->dts_due)) {
+							?>
+							<small class="text-muted">N/A</small>
+							<?php
+						}
+						?>
+						</td>
+						<td class="text-center align-middle">
+							<span class="badge badge-lg badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
+						</td>
+						<td class="text-right align-middle">
+							<a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
+						</td>
+					</tr>
+					<?php
+				}
+				?>
+				</tbody>
+			</table>
 		</div>
 		<?php
 	}