Selaa lähdekoodia

Add nighttime badge

Alan Lam 8 vuotta sitten
vanhempi
commit
74c695ea17
2 muutettua tiedostoa jossa 22 lisäystä ja 3 poistoa
  1. 2 0
      controllers/tests_available.php
  2. 20 3
      views/tests_available.php

+ 2 - 0
controllers/tests_available.php

@@ -28,6 +28,8 @@ $tests = Test::query([
 ]);
 
 $locations = Location::load(array_column($tests, "location_id"));
+$projects = Project::load($project_ids);
+$templates = Template::load(array_column($projects, "template_id"));
 
 $addresses = $user->getAddresses();
 if(!$addresses) {

+ 20 - 3
views/tests_available.php

@@ -25,13 +25,30 @@
 				$location = $test->getLocation();
 				$distance = Geolocation::getDistance($location->getGeolocation(), $address->getGeolocation());
 				$distance_formatted = number_format($distance, 1);
+				$project = $test->getProject();
+				$template = $project->getTemplate();
 				?>
 				<div class="list-group-item">
 					<div class="d-flex justify-content-between">
 						<div>
-							<?=htmlspecialchars($location->name)?><br />
-							<small><?=htmlspecialchars($location->getDisplayAddress())?></small><br />
-							<small><?=htmlspecialchars($distance_formatted)?> mi from your <?=htmlspecialchars($address->name)?> address.</small>
+							<div><?=htmlspecialchars($location->name)?></div>
+							<div><small><?=htmlspecialchars($location->getDisplayAddress())?></small></div>
+							<div>
+								<small><strong>Type:</strong> <?=htmlspecialchars($template->name)?></small>
+								<?php
+								if($project->isNighttime()) {
+									?>
+									<span class="badge badge-dark">
+										<i class="fas fa-fw fa-moon"></i>
+										Nighttime
+									</span>
+									<?php
+								}
+								?>
+							</div>
+							<div>
+								<small><strong><?=htmlspecialchars($distance_formatted)?> mi</strong> from your <?=htmlspecialchars($address->name)?> address.</small>
+							</div>
 						</div>
 						<button class="btn btn-primary align-self-start" data-test-id="<?=$test->id?>">Select</button>
 					</div>