|
|
@@ -0,0 +1,94 @@
|
|
|
+<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
|
+
|
|
|
+namespace App;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @var Sale $sale
|
|
|
+ * @var Document $document
|
|
|
+ * @var Model $current
|
|
|
+ */
|
|
|
+
|
|
|
+if(isset($sale)) {
|
|
|
+ $title = $sale->getTitle();
|
|
|
+ $child_documents = $sale->getChildDocuments();
|
|
|
+ $is_current = $sale->is($current);
|
|
|
+ $url = $sale->getUrl();
|
|
|
+}
|
|
|
+else if(isset($document)) {
|
|
|
+ $title = $document->getTitle();
|
|
|
+ $child_documents = $document->getChildDocuments();
|
|
|
+ $is_current = $document->is($current);
|
|
|
+ $url = $document->getUrl();
|
|
|
+}
|
|
|
+else {
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+?>
|
|
|
+
|
|
|
+<section class="mb-4">
|
|
|
+
|
|
|
+ <h4><?=htmlspecialchars(__("Related Items"))?></h4>
|
|
|
+
|
|
|
+ <?php
|
|
|
+ /**
|
|
|
+ * @param Document[] $documents
|
|
|
+ * @return void
|
|
|
+ * @throws \Exception
|
|
|
+ */
|
|
|
+ function renderDocumentList(array $documents, Model $current): void {
|
|
|
+ if(!$documents) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <ul>
|
|
|
+ <?php
|
|
|
+ foreach($documents as $document) {
|
|
|
+ ?>
|
|
|
+ <li>
|
|
|
+ <?php
|
|
|
+ if($document->is($current)) {
|
|
|
+ ?>
|
|
|
+ <?=htmlspecialchars($document->getTitle())?>
|
|
|
+ <span class="badge text-bg-primary"><?=htmlspecialchars(__("Current"))?></span>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ?>
|
|
|
+ <a href="<?=htmlspecialchars($document->getUrl())?>"><?=htmlspecialchars($document->getTitle())?></a>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <?php
|
|
|
+ renderDocumentList($document->getChildDocuments(), $current);
|
|
|
+ ?>
|
|
|
+ </li>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ </ul>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+
|
|
|
+ <ul>
|
|
|
+ <li>
|
|
|
+ <?php
|
|
|
+ if($is_current) {
|
|
|
+ ?>
|
|
|
+ <?=htmlspecialchars($title)?>
|
|
|
+ <span class="badge text-bg-primary"><?=htmlspecialchars(__("Current"))?></span>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ?>
|
|
|
+ <a href="<?=htmlspecialchars($url)?>"><?=htmlspecialchars($title)?></a>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <?php
|
|
|
+ renderDocumentList($child_documents, $current);
|
|
|
+ ?>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+</section>
|