Explorar o código

Add assigned date column to "Tests" tab on the user page

Alan Lam hai 1 ano
pai
achega
8cb72146c2
Modificáronse 2 ficheiros con 43 adicións e 16 borrados
  1. 4 0
      engine/test.php
  2. 39 16
      views/user.php

+ 4 - 0
engine/test.php

@@ -979,6 +979,10 @@ class Test extends Model {
 		return Util::getDateTimeFromUtcString($this->dts_end);
 	}
 
+	public function getDateTimeAssigned(): ?CarbonImmutable {
+		return Util::getDateTimeFromUtcString($this->dts_assigned);
+	}
+
 	public function getVerifierNotesHtml(): string {
 		return nl2br(htmlspecialchars($this->verifier_notes));
 	}

+ 39 - 16
views/user.php

@@ -236,16 +236,18 @@ const userId = <?=$user->id?>;
 
 					<table class="table table-sm table-hover">
 						<col style="width: 10%;" />
-						<col style="width: 40%;" />
+						<col style="width: 30%;" />
 						<col style="width: 20%;" />
 						<col style="width: 10%;" />
 						<col style="width: 10%;" />
+						<col style="width: 10%;" />
 						<thead>
 						<tr>
 							<th>ID</th>
 							<th>Location</th>
 							<th>Project</th>
-							<th>Date Due</th>
+							<th>Assigned</th>
+							<th>Due</th>
 							<th></th>
 						</tr>
 						</thead>
@@ -254,16 +256,18 @@ const userId = <?=$user->id?>;
 							$project = $test->getProject();
 							$location = $test->getLocation();
 
-							if($test->dts_due !== null) {
-								$date = explode(" ", $test->dts_due)[0];
-							}
-							else {
-								$date = explode(" ", $project->dts_deadline)[0];
-							}
+							$date_due = "";
+							$date_assigned = "";
 
-							$unix_date = strtotime($date);
+							$dt_due = $test->getDateTimeDue();
+							if($dt_due) {
+								$date_due = $dt_due->setTimezone(TIMEZONE)->format("d/m/Y");
+							}
 
-							$date = date("d/m/Y", $unix_date);
+							$dt_assigned = $test->getDateTimeAssigned();
+							if($dt_assigned) {
+								$date_assigned = $dt_assigned->setTimezone(TIMEZONE)->format("d/m/Y");
+							}
 
 							?>
 							<tr>
@@ -276,7 +280,10 @@ const userId = <?=$user->id?>;
 									<a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
 								</td>
 								<td class="align-middle">
-									<?=$date?>
+									<?=$date_assigned?>
+								</td>
+								<td class="align-middle">
+									<?=$date_due?>
 								</td>
 								<td class="align-middle text-right">
 								</td>
@@ -366,16 +373,18 @@ const userId = <?=$user->id?>;
 
 					<table class="table table-sm table-hover">
 						<col style="width: 10%;" />
-						<col style="width: 40%;" />
+						<col style="width: 30%;" />
 						<col style="width: 20%;" />
 						<col style="width: 10%;" />
 						<col style="width: 10%;" />
+						<col style="width: 10%;" />
 						<thead>
 						<tr>
 							<th>ID</th>
 							<th>Location</th>
 							<th>Project</th>
-							<th>Date</th>
+							<th>Assigned</th>
+							<th>Completed</th>
 							<th></th>
 						</tr>
 						</thead>
@@ -383,8 +392,19 @@ const userId = <?=$user->id?>;
 						foreach($completed_tests as $test) {
 							$project = $test->getProject();
 							$location = $test->getLocation();
-							$date = explode(" ", $test->dts_start)[0];
-							$date = date("d/m/Y", strtotime($date));
+
+							$test_date = "";
+							$assigned_date = "";
+
+							$dt_test = $test->getDateTimeStart();
+							if($dt_test) {
+								$test_date = $dt_test->setTimezone(TIMEZONE)->format("d/m/Y");
+							}
+
+							$dt_assigned = $test->getDateTimeAssigned();
+							if($dt_assigned) {
+								$assigned_date = $dt_assigned->setTimezone(TIMEZONE)->format("d/m/Y");
+							}
 							?>
 							<tr>
 								<td><?=$test->id?></td>
@@ -396,7 +416,10 @@ const userId = <?=$user->id?>;
 									<a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
 								</td>
 								<td class="align-middle">
-									<?=$date?>
+									<?=$assigned_date?>
+								</td>
+								<td class="align-middle">
+									<?=$test_date?>
 								</td>
 								<td class="align-middle text-right">
 									<a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>