فهرست منبع

Improved layout of location page.

Alan Lam 8 سال پیش
والد
کامیت
44db6e78c8
2فایلهای تغییر یافته به همراه142 افزوده شده و 50 حذف شده
  1. 7 0
      engine/location.php
  2. 135 50
      views/location.php

+ 7 - 0
engine/location.php

@@ -34,6 +34,13 @@ class Location extends Model {
 		return [$this->latitude, $this->longitude];
 		return [$this->latitude, $this->longitude];
 	}
 	}
 
 
+	public function getPhotos() {
+		return LocationFile::query([
+			"location_id" => $this->id,
+			"type" => LocationFile::TYPE_PHOTO
+		]);
+	}
+
 }
 }
 
 
 ?>
 ?>

+ 135 - 50
views/location.php

@@ -1,4 +1,26 @@
-<div class="container pt-3 my-4">
+<?php
+$tabs = [
+	["details", "Details"],
+	["photos", "Photos"],
+	["tests", "Tests"],
+];
+
+$details = [
+	"Name" => htmlspecialchars($location->name),
+	"Address" => htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "county", "postal_code"])),
+];
+
+if($location->shop_left) $details["Shop Name (Left)"] = $location->shop_left;
+if($location->shop_right) $details["Shop Name (Right)"] = $location->shop_right;
+if($location->legal_entity_name) $details["Legal Entity Name"] = $location->legal_entity_name;
+if($location->region) $details["Region"] = $location->region;
+if($location->internal_id) $details["Internal ID"] = $location->internal_id;
+if($location->area_manager) $details["Area Manager"] = $location->area_manager;
+
+$photos = $location->getPhotos();
+
+?>
+<div class="container mt-3 py-4">
 	<div class="row">
 	<div class="row">
 		<div class="col">
 		<div class="col">
 			<h2>
 			<h2>
@@ -10,71 +32,134 @@
 		</div>
 		</div>
 	</div>
 	</div>
 
 
-	<p><?=htmlspecialchars($location->getDisplayAddress())?></p>
-
-	<h3>Tests</h3>
 
 
+	<ul class="nav nav-tabs mb-3" id="location-tabs" role="tablist">
 	<?php
 	<?php
-	if(empty($tests)) {
+	foreach($tabs as $index => $tab_options) {
+		list($id, $display) = $tab_options;
+		$active = ($index == 0) ? "active" : "";
 		?>
 		?>
-		<div class="alert alert-info">
-			This location has no tests.
-		</div>
+		<li class="nav-item">
+			<a class="nav-link <?=$active?>" id="<?=$id?>-tab" data-toggle="tab" href="#<?=$id?>" role="tab"><?=htmlspecialchars($display)?></a>
+		</li>
 		<?php
 		<?php
 	}
 	}
-	else {
+	?>
+	</ul>
+
+	<div class="tab-content mb-3" id="tab-content">
+		<div class="tab-pane fade show active" id="details" role="tabpanel" aria-labelledby="details-tab">
+			<div class="row">
+				<div class="col-lg-8 mb-3 mb-lg-0">
+					<div class="list-group">
+						<?php
+						foreach($details as $field => $value) {
+							?>
+							<div class="list-group-item">
+								<div class="row">
+									<div class="col-sm-4 text-muted"><?=$field?></div>
+									<div class="col-sm"><?=$value?></div>
+								</div>
+							</div>
+							<?php
+						}
+						?>
+					</div>
+				</div>
+				<div class="col-lg mb-3 mb-lg-0">
+					<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>
+			</div>
+		</div>
+		<div class="tab-pane fade" id="photos" role="tabpanel" aria-labelledby="photos-tab">
+		<?php
+		if(empty($photos)) {
+			?>
+			<div class="alert alert-info">
+				<i class="fal fa-fw fa-info-circle"></i> No photos are available for this location.
+			</div>
+			<?php
+		}
+		else {
+			?>
+			<div class="row">
+			<?php
+			foreach($photos as $photo) {
+				$uri = "/account/locations/$location->id/photos/$photo->id";
+				?>
+				<div class="col-md-4">
+					<a href="<?=$uri?>">
+						<img class="border img-fluid img-contain" src="/img/blank_4_3.png" style="background-image: url(<?=$uri?>)" />
+					</a>
+				</div>
+				<?php
+			}
+			?>
+			</div>
+			<?php
+		}
 		?>
 		?>
-		<table class="table table-hover">
-			<thead>
-				<tr>
-					<th>ID</th>
-					<th>Project</th>
-					<th>Status</th>
-					<th></th>
-				</tr>
-			</thead>
-			<tbody>
+		</div>
+		<div class="tab-pane fade" id="tests" role="tabpanel" aria-labelledby="tests-tab">
 			<?php
 			<?php
-			foreach($tests as $test) {
-				$project = $test->getProject();
+			if(empty($tests)) {
 				?>
 				?>
-				<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">
+				<div class="alert alert-info">
+					This location has no tests.
+				</div>
+				<?php
+			}
+			else {
+				?>
+				<table class="table table-hover">
+					<thead>
+						<tr>
+							<th>ID</th>
+							<th>Project</th>
+							<th>Status</th>
+							<th></th>
+						</tr>
+					</thead>
+					<tbody>
 					<?php
 					<?php
-					if($test->status >= Test::STATUS_PENDING_VERIFICATION) {
+					foreach($tests as $test) {
+						$project = $test->getProject();
 						?>
 						?>
-						<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>
+						<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
 						<?php
 					}
 					}
 					?>
 					?>
-					</td>
-				</tr>
+					</tbody>
+				</table>
 				<?php
 				<?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>
 	</div>
 
 
 </div>
 </div>