Преглед изворни кода

Remove lists and add icons to customer page

Alan Lam пре 7 година
родитељ
комит
26e11e6616
2 измењених фајлова са 32 додато и 34 уклоњено
  1. 6 5
      controllers/customer_view.php
  2. 26 29
      views/customer.php

+ 6 - 5
controllers/customer_view.php

@@ -9,11 +9,12 @@ Core::addBreadcrumb("/account", "Account");
 Core::addBreadcrumb("/account/customers", "Customers");
 Core::addBreadcrumb("/account/customers/$id", $page_title);
 
-$projects = Project::query(["customer_id" => $id]);
-$locations = $customer->getLocations();
+$icons = [];
+$icons[] = new AccountIcon(__("Projects"), "/account/projects/{$id}", "list");
+$icons[] = new AccountIcon(__("Locations"), "/account/locations/{$id}", "map-marker");
+$icons[] = new AccountIcon(__("Reports"), "/account/reports/{$id}", "chart-pie");
+$icons[] = new AccountIcon(__("Templates"), "/account/templates/{$id}", "file-alt");
 
 View::includeOnce("header", compact("page_title"));
-View::include("customer", compact("customer", "projects", "locations"));
+View::include("customer", compact("customer", "icons"));
 View::includeOnce("footer");
-
-?>

+ 26 - 29
views/customer.php

@@ -10,36 +10,33 @@
 	</div>
 
 	<div class="row">
-		<div class="col-lg">
-			<div class="row">
-				<div class="col">
-					<h3>
-						Projects <span class="badge badge-pill badge-primary"><?=number_format(count($projects))?></span>
-					</h3>
-				</div>
-				<div class="col-auto">
-					<a class="btn btn-outline-primary" href="/account/projects/add?customer_id=<?=$customer->id?>">Add</a>
-				</div>
-			</div>
-			<?php
-			View::include("project_list", compact("projects", "customer"));
-			?>
-		</div>
-		<div class="col-lg">
-			<div class="row">
-				<div class="col">
-					<h3>
-						Locations <span class="badge badge-pill badge-primary"><?=number_format(count($locations))?></span>
-					</h3>
-				</div>
-				<div class="col-auto">
-					<a class="btn btn-outline-primary" href="/account/locations/add?customer_id=<?=$customer->id?>">Add</a>
-				</div>
-			</div>
-			<?php
-			View::include("location_list", compact("locations", "customer"));
-			?>
+	<?php
+	foreach($icons as $icon) {
+		?>
+		<div class="col-6 col-sm-3 text-center">
+			<a class="btn btn-light btn-block mb-3 p-2" href="<?=htmlspecialchars($icon->url)?>">
+				<?php
+				if($icon->counter) {
+					?>
+					<span class="fa-layers fa-fw fa-3x mb-2">
+						<i class="fal fa-<?=htmlspecialchars($icon->icon)?>"></i>
+						<span class="fa-layers-counter fa-layers-bottom-right"><?=number_format($icon->counter)?></span>
+					</span>
+					<?php
+				}
+				else {
+					?>
+					<i class="fal fa-3x fa-<?=htmlspecialchars($icon->icon)?> mb-2"></i>
+					<?php
+				}
+				?>
+				<br />
+				<?=htmlspecialchars($icon->name)?>
+			</a>
 		</div>
+		<?php
+	}
+	?>
 	</div>
 
 </div>