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

Implemented tests table for location page.

Alan Lam 8 лет назад
Родитель
Сommit
b41538446f
3 измененных файлов с 64 добавлено и 20 удалено
  1. 13 12
      controllers/location_view.php
  2. 2 0
      controllers/tests.php
  3. 49 8
      views/location.php

+ 13 - 12
controllers/location_view.php

@@ -11,26 +11,27 @@ Core::addBreadcrumb("/account/locations", "Locations");
 Core::addBreadcrumb("/account/locations/$location->id", $page_title);
 
 $status_constraint = new Constraint("BETWEEN");
-$status_constraint->setValues(Test::STATUS_ASSIGNED, Test::STATUS_PENDING_VERIFICATION);
 
-$pending_tests = Test::query([
+if(Core::$user->level >= User::LEVEL_ADMIN) {
+	$status_constraint->setValues(Test::STATUS_UNASSIGNED, Test::STATUS_COMPLETED);
+}
+else {
+	$status_constraint->setValues(Test::STATUS_COMPLETED, Test::STATUS_COMPLETED);
+}
+
+$tests = Test::query([
 	"location_id" => $location->id,
 	"status" => $status_constraint,
 ], [
-	"sort" => "id",
-	"order" => "desc",
+	"sort" => "status",
+	"order" => "asc",
 ]);
 
-$completed_tests = Test::query([
-	"location_id" => $location->id,
-	"status" => Test::STATUS_COMPLETED,
-], [
-	"sort" => "dts_end",
-	"order" => "desc",
-]);
+$projects = Project::load(array_column($tests, "project_id"));
+
 
 View::includeOnce("header", compact("page_title"));
-View::include("location", compact("location"));
+View::include("location", compact("location", "tests"));
 View::includeOnce("footer");
 
 ?>

+ 2 - 0
controllers/tests.php

@@ -20,6 +20,8 @@ if($user->level >= User::LEVEL_ADMIN) {
 
 	$tests = Test::query($nvp, ["sort" => "status"]);
 
+	$projects = Project::load(array_column($tests, "project_id"))
+
 	View::includeOnce("header", compact("page_title"));
 	View::include("test_list", compact("tests", "filter_count", "status"));
 	View::includeOnce("footer");

+ 49 - 8
views/location.php

@@ -10,11 +10,6 @@
 		</div>
 	</div>
 
-	<div class="mb-3" id="map" data-maps data-lat="<?=$location->latitude?>" data-lng="<?=$location->longitude?>" data-zoom="17" data-marker="true" style="height: 320px;">
-	</div>
-
-	<h3>Address</h3>
-
 	<p><?=htmlspecialchars($location->getDisplayAddress())?></p>
 
 	<h3>Tests</h3>
@@ -29,11 +24,57 @@
 	}
 	else {
 		?>
-		<div class="alert alert-warning">
-			Test list goes here.
-		</div>
+		<table class="table table-hover">
+			<thead>
+				<tr>
+					<th>ID</th>
+					<th>Project</th>
+					<th>Status</th>
+					<th></th>
+				</tr>
+			</thead>
+			<tbody>
+			<?php
+			foreach($tests as $test) {
+				$project = $test->getProject();
+				?>
+				<tr>
+					<td class="text-right align-middle">
+						<?=$test->id?>
+					</td>
+					<td class="align-middle">
+						<a href=""><?=htmlspecialchars($project->name)?></a>
+					</td>
+					<td class="align-middle">
+						<span class="badge badge-lg badge-<?=$test->getStatusClass()?>"><?=htmlspecialchars($test->getStatusText())?></span>
+					</td>
+					<td class="text-right">
+					<?php
+					if($test->status >= Test::STATUS_PENDING_VERIFICATION) {
+						?>
+						<a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View Results</a>
+						<?php
+					}
+					else {
+						?>
+						<a class="btn btn-outline-primary" href="/account/projects/<?=$test->project_id?>">View Project</a>
+						<?php
+					}
+					?>
+					</td>
+				</tr>
+				<?php
+			}
+			?>
+			</tbody>
+		</table>
 		<?php
 	}
 	?>
 
+	<h3>Map</h3>
+
+	<div class="mb-3" id="map" data-maps data-lat="<?=$location->latitude?>" data-lng="<?=$location->longitude?>" data-zoom="17" data-marker="true" style="height: 320px;">
+	</div>
+
 </div>