Bläddra i källkod

Add location, company and customer to related items

Alan Lam 2 år sedan
förälder
incheckning
6d571255a3
1 ändrade filer med 27 tillägg och 5 borttagningar
  1. 27 5
      views/related_items_section.php

+ 27 - 5
views/related_items_section.php

@@ -2,6 +2,8 @@
 
 namespace App;
 
+use Exception;
+
 /**
  * @var Sale $sale
  * @var Document $document
@@ -14,6 +16,9 @@ if(isset($sale)) {
 	$is_current = $sale->is($current);
 	$url = $sale->getUrl();
 	$tickets = $sale->getTickets();
+
+	$location = $sale->getLocation();
+	$company = $sale->getCompany();
 }
 else if(isset($document)) {
 	$title = $document->getTitle();
@@ -21,11 +26,16 @@ else if(isset($document)) {
 	$is_current = $document->is($current);
 	$url = $document->getUrl();
 	$tickets = $document->getTickets();
+
+	$location = $document->getLocation();
+	$company = $document->getCompany();
 }
 else {
 	return;
 }
 
+$customer = $location->getCustomer();
+
 ?>
 
 <section class="mb-4">
@@ -35,8 +45,9 @@ else {
 	<?php
 	/**
 	 * @param Document[] $documents
+	 * @param Model $current
 	 * @return void
-	 * @throws \Exception
+	 * @throws Exception
 	 */
 	function renderDocumentList(array $documents, Model $current): void {
 		if(!$documents) {
@@ -87,11 +98,9 @@ else {
 				<a href="<?=htmlspecialchars($url)?>"><?=htmlspecialchars($title)?></a>
 				<?php
 			}
-			?>
-			<?php
+
 			renderDocumentList($child_documents, $current);
-			?>
-			<?php
+
 			foreach($tickets as $ticket) {
 				?>
 				<ul>
@@ -106,5 +115,18 @@ else {
 			?>
 		</li>
 
+		<li>
+			<a href="<?=htmlspecialchars($customer->getUrl())?>"><?=htmlspecialchars($customer->name)?></a>
+			<ul>
+				<li>
+					<a href="<?=htmlspecialchars($location->getUrl())?>"><?=htmlspecialchars($location->name)?></a>
+				</li>
+			</ul>
+		</li>
+
+		<li>
+			<a href="<?=htmlspecialchars($company->getUrl())?>"><?=htmlspecialchars($company->name)?></a>
+		</li>
+
 	</ul>
 </section>