commit 8ef808c0b526b3b3e1e28a0f00f60d4738fae7f3
Author: Jan Šedivý <honza.seeda@gmail.com>
Date:   Sat Apr 20 00:17:37 2019 +0200

    Re #7327 Detail transliterace

diff --git a/app/FrontModule/presenters/TransliterationPresenter.php b/app/FrontModule/presenters/TransliterationPresenter.php
index 5bffd92..72c6697 100644
--- a/app/FrontModule/presenters/TransliterationPresenter.php
+++ b/app/FrontModule/presenters/TransliterationPresenter.php
@@ -5,9 +5,14 @@ namespace App\FrontModule\Presenters;
 
 
 use App\FrontModule\Components\ITransliterationSearchFormFactory;
+use App\Model\Repository\LineRepository;
+use App\Model\Repository\LitReferenceRepository;
+use App\Model\Repository\RevHistoryRepository;
 use App\Model\Repository\TransliterationRepository;
 use App\Model\TransliterationSearchModel;
 use Nette\Application\UI\Presenter;
+use Nette\SmartObject;
+use Tracy\Debugger;
 
 class TransliterationPresenter extends Presenter
 {
@@ -20,10 +25,22 @@ class TransliterationPresenter extends Presenter
     /** @var TransliterationSearchModel */
     private $transliterationSearchModel;
 
+    /** @var LitReferenceRepository */
+    private $litReferenceRepository;
+
+    /** @var RevHistoryRepository */
+    private $revHistoryRepository;
+
+    /** @var LineRepository */
+    private $lineRepository;
+
     public function __construct(
         ITransliterationSearchFormFactory $transliterationSearchFormFactory,
         TransliterationRepository $transliterationRepository,
-        TransliterationSearchModel $transliterationSearchModel
+        TransliterationSearchModel $transliterationSearchModel,
+        LitReferenceRepository $litReferenceRepository,
+        RevHistoryRepository $revHistoryRepository,
+        LineRepository $lineRepository
     )
     {
         parent::__construct();
@@ -31,6 +48,9 @@ class TransliterationPresenter extends Presenter
         $this->transliterationSearchFormFactory = $transliterationSearchFormFactory;
         $this->transliterationRepository = $transliterationRepository;
         $this->transliterationSearchModel = $transliterationSearchModel;
+        $this->litReferenceRepository = $litReferenceRepository;
+        $this->revHistoryRepository = $revHistoryRepository;
+        $this->lineRepository = $lineRepository;
     }
 
 
@@ -58,6 +78,27 @@ class TransliterationPresenter extends Presenter
         $this->template->resultRows = $resultRows;
     }
 
+    public function actionView($id)
+    {
+        $transliteration = $this->transliterationRepository->getTransliterationDetail($id);
+        if(!$transliteration)
+        {
+            $this->presenter->flashMessage('Transliteration not found');
+            $this->redirect('Transliteration:search');
+        }
+        $lines = $this->lineRepository->getAllLinesForTransliteration($id);
+        $lineArray = [];
+        foreach ($lines as $line)
+        {
+            $lineArray[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
+        }
+
+        $this->template->transliteration = $transliteration;
+        $this->template->litReferences = $this->litReferenceRepository->findBy([LitReferenceRepository::COLUMN_TRANSLITERATION_ID => $id]);
+        $this->template->revisionHistory = $this->revHistoryRepository->findBy([RevHistoryRepository::COLUMN_TRANSLITERATION_ID => $id]);
+        $this->template->lineArray = $lineArray;
+    }
+
     public function createComponentTransliterationSearchForm()
     {
         return $this->transliterationSearchFormFactory->create();
diff --git a/app/FrontModule/templates/Transliteration/searchResult.latte b/app/FrontModule/templates/Transliteration/searchResult.latte
index 86884d5..bdd6e98 100644
--- a/app/FrontModule/templates/Transliteration/searchResult.latte
+++ b/app/FrontModule/templates/Transliteration/searchResult.latte
@@ -31,7 +31,7 @@
     {foreach $resultRows as $result}
         <hr>
 
-        <a href="transliteration-info.html">
+        <a n:href="Transliteration:view $result->id">
             {$result->book_abrev}, {$result->chapter}
         </a>
         <div>
diff --git a/app/FrontModule/templates/Transliteration/view.latte b/app/FrontModule/templates/Transliteration/view.latte
new file mode 100644
index 0000000..97c74e9
--- /dev/null
+++ b/app/FrontModule/templates/Transliteration/view.latte
@@ -0,0 +1,115 @@
+{block content}
+    <div class="display-5">Transliteration info</div>
+    <hr>
+
+    <div class="display-6">
+        <div class="text-muted">Catalogue information</div>
+    </div>
+    <div>
+
+        <div>
+            <a href="#">edit book</a> |
+            <a href="#">edit transliteration info</a>
+        </div>
+
+    </div>
+    <div class="container-fluid">
+        <dl class="row">
+
+            <dt class="col-sm-3">Book abrev.</dt>
+            <dd class="col-sm-9">{$transliteration->book_abrev}</dd>
+
+            <dt class="col-sm-3">Book name</dt>
+            <dd class="col-sm-9">{$transliteration->book_name}</dd>
+
+            <dt class="col-sm-3">Book subtitle</dt>
+            <dd class="col-sm-9">{$transliteration->book_subtitle}</dd>
+
+            <dt class="col-sm-3">Book author</dt>
+            <dd class="col-sm-9">{$transliteration->book_autor}</dd>
+
+            <dt class="col-sm-3">Place of publication</dt>
+            <dd class="col-sm-9">{$transliteration->place_of_pub}</dd>
+
+            <dt class="col-sm-3">Date of publication</dt>
+            <dd class="col-sm-9">{$transliteration->date_of_pub}</dd>
+
+            <dt class="col-sm-3">Pages</dt>
+            <dd class="col-sm-9">{$transliteration->pages}</dd>
+
+            <dt class="col-sm-3">Book description</dt>
+            <dd class="col-sm-9">{$transliteration->book_description}</dd>
+
+            <dt class="col-sm-3">Volume</dt>
+            <dd class="col-sm-9">{$transliteration->volume}</dd>
+
+            <dt class="col-sm-3">Volume number</dt>
+            <dd class="col-sm-9">{$transliteration->volume_no}</dd>
+
+            <dt class="col-sm-3">Book type</dt>
+            <dd class="col-sm-9">{$transliteration->book_type}</dd>
+
+            <dt class="col-sm-3">Chapter</dt>
+            <dd class="col-sm-9">{$transliteration->chapter}</dd>
+
+            <dt class="col-sm-3">Museum</dt>
+            <dd class="col-sm-9">{$transliteration->museum}{ifset $transliteration->place}, {$transliteration->place}{/ifset}</dd>
+
+            <dt class="col-sm-3">Museum no.</dt>
+            <dd class="col-sm-9">{$transliteration->museum_no}</dd>
+
+            <dt class="col-sm-3">Reg. (Excavation) no.</dt>
+            <dd class="col-sm-9">{$transliteration->reg_no}</dd>
+
+            <dt class="col-sm-3">Date</dt>
+            <dd class="col-sm-9">{$transliteration->date}</dd>
+
+            <dt class="col-sm-3">Origin (Ancient name / Modern name)</dt>
+            <dd class="col-sm-9">{$transliteration->old_name}/{$transliteration->origin}</dd>
+
+            <dt class="col-sm-3">Note</dt>
+            <dd class="col-sm-9">{$transliteration->note}</dd>
+
+            <dt class="col-sm-3">References (handcopy)</dt>
+            <dd class="col-sm-9">
+                {foreach $litReferences as $reference}
+                    {$reference->series} {$reference->number}, {$reference->plate}<br>
+                {/foreach}
+            </dd>
+
+        </dl>
+    </div>
+
+    <hr>
+    <div class="display-6">
+        <div class="text-muted">Transliteration data</div>
+    </div>
+
+
+    <a href="#">edit</a>
+
+    <div class="container-fluid">
+        {foreach $lineArray as $objectType => $surface}
+            <b>{$objectType}</b> <br>
+            {foreach $surface as $surfaceType => $lines}
+                <div class="noname" id="tablet-div">
+                    <hr>
+
+                    <i>{$surfaceType}</i> <br>
+                    {foreach $lines as $line}
+                        {$line['line_number']}. {$line['transliteration']} <br>
+                    {/foreach}
+                </div>
+            {/foreach}
+        {/foreach}
+    </div>
+    <hr>
+    <div class="display-6">
+        <div class="text-muted">Revision history</div>
+    </div>
+    <div class="container-fluid">
+        {foreach $revisionHistory as $revisionRecord}
+            {$revisionRecord->date|date:'Y-m-d'} {ifset $revisionRecord->name} - {$revisionRecord->name}{/ifset} - {$revisionRecord->description}<br>
+        {/foreach}
+    </div>
+{/block}
\ No newline at end of file
diff --git a/app/model/repository/LineRepository.php b/app/model/repository/LineRepository.php
index bdb04a0..20990bf 100644
--- a/app/model/repository/LineRepository.php
+++ b/app/model/repository/LineRepository.php
@@ -20,4 +20,23 @@ class LineRepository extends Repository
     const COLUMN_BROKEN = 'broken';
     const COLUMN_OLD_BOOKANDCHAPTER = 'old_bookandchapter';
     const COLUMN_LINE_NUMBER = 'line_number';
+
+    public function getAllLinesForTransliteration($transliterationId)
+    {
+        return $this->context->query(
+            "SELECT
+                         l.line_number,
+                         l.transliteration,
+                         st.surface_type,
+                         o.object_type
+                  FROM line l
+                         LEFT JOIN surface s on l.id_surface = s.id_surface
+                         LEFT JOIN surface_type st on s.id_surface_type = st.id_surface_type
+                         LEFT JOIN transliteration t on s.id_transliteration = t.id_transliteration
+                         LEFT JOIN object_type o on s.id_object_type = o.id_object_type
+                  WHERE t.id_transliteration = ?
+                  ORDER BY st.sorter ASC, line_number ASC",
+            $transliterationId
+        );
+    }
 }
\ No newline at end of file
diff --git a/app/model/repository/TransliterationRepository.php b/app/model/repository/TransliterationRepository.php
index f334af4..629fa0b 100644
--- a/app/model/repository/TransliterationRepository.php
+++ b/app/model/repository/TransliterationRepository.php
@@ -3,6 +3,7 @@
 namespace App\Model\Repository;
 
 use App\Enum\ELogicalConditions;
+use Tracy\Debugger;
 
 /**
  * Repository pro práci s tabulkou `transliteration`
@@ -63,7 +64,13 @@ class TransliterationRepository extends Repository
             $whereArgs[] = "%" . $queryParams['word3'] . "%";
         }
 
-        $query = "SELECT b.book_abrev, t.chapter, l.transliteration, l.line_number FROM transliteration t
+        $query = "SELECT 
+                    t.id_transliteration as id, 
+                    b.book_abrev, 
+                    t.chapter, 
+                    l.transliteration, 
+                    l.line_number 
+                  FROM transliteration t
                   LEFT JOIN surface s ON s.id_transliteration = t.id_transliteration
                   LEFT JOIN line l ON l.id_surface = s.id_surface
                   LEFT JOIN book b on t.id_book = b.id_book
@@ -71,4 +78,29 @@ class TransliterationRepository extends Repository
 
         return $this->context->queryArgs($query, $whereArgs);
     }
+
+    public function getTransliterationDetail($id)
+    {
+        return $this->context->query(
+            "SELECT 
+                    t.id_transliteration as id,
+                    t.chapter,
+                    t.museum_no,
+                    t.reg_no,
+                    t.date,
+                    t.note,
+                    b.*, 
+                    bt.book_type,
+                    m.museum,
+                    m.place,
+                    o.*
+                  FROM transliteration t
+                  LEFT JOIN surface s ON s.id_transliteration = t.id_transliteration
+                  LEFT JOIN book b on t.id_book = b.id_book
+                  LEFT JOIN book_type bt on t.id_book_type =bt.id_book_type
+                  LEFT JOIN museum m on t.id_museum = m.id_museum
+                  LEFT JOIN origin o on t.id_origin = o.id_origin
+                  WHERE t.id_transliteration = ?", $id
+        )->fetch();
+    }
 }
\ No newline at end of file
