commit ee62b2c57fbbbb7d214e48383d2115c5eff4d7c0
Author: Filip Jani <jsem@filek.cz>
Date:   Sun Mar 24 16:32:50 2019 +0100

    Re #7178 vytvoření repository pro práci s tabulkama

diff --git a/.gitignore b/.gitignore
index 4c36e38..3b0fa90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 .idea/
 vendor/
+app/config/config.local.neon
\ No newline at end of file
diff --git a/app/bootstrap.php b/app/bootstrap.php
index 16d93ac..5388b7b 100644
--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -16,6 +16,7 @@ $configurator->createRobotLoader()
 
 $configurator->addConfig(__DIR__ . '/config/config.neon');
 $configurator->addConfig(__DIR__ . '/config/config.local.neon');
+$configurator->addConfig(__DIR__ . '/config/model.neon');
 
 $container = $configurator->createContainer();
 
diff --git a/app/config/config.local.example.neon b/app/config/config.local.example.neon
new file mode 100644
index 0000000..44393b4
--- /dev/null
+++ b/app/config/config.local.example.neon
@@ -0,0 +1,7 @@
+parameters:
+
+
+database:
+	dsn: 'mysql:host=127.0.0.1;dbname=test'
+	user:
+	password:
diff --git a/app/config/model.neon b/app/config/model.neon
new file mode 100644
index 0000000..c89e62e
--- /dev/null
+++ b/app/config/model.neon
@@ -0,0 +1,16 @@
+services:
+    - Model\Repository\Repository
+    - Model\Repository\BookRepository
+    - Model\Repository\BookTypeRepository
+    - Model\Repository\LineRepository
+    - Model\Repository\LitReferenceRepository
+    - Model\Repository\MuseumRepository
+    - Model\Repository\ObjectTypeRepository
+    - Model\Repository\OriginRepository
+    - Model\Repository\RevHistoryRepository
+    - Model\Repository\SurfaceRepository
+    - Model\Repository\SurfaceTypeRepository
+    - Model\Repository\TransliterationRepository
+    - Model\Repository\UserLogRepository
+    - Model\Repository\UserRepository
+    - Model\Repository\UserRoleRepository
\ No newline at end of file
diff --git a/app/model/repository/BookRepository.php b/app/model/repository/BookRepository.php
new file mode 100644
index 0000000..43b266e
--- /dev/null
+++ b/app/model/repository/BookRepository.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `book`
+ *
+ * @package Model
+ */
+class BookRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'book';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_book';
+    const COLUMN_BOOK_ABREV = 'book_abrev';
+    const COLUMN_BOOK_AUTHOR = 'book_autor';
+    const COLUMN_BOOK_DESCRIPTION = 'book_description';
+    const COLUMN_BOOK_NAME = 'book_name';
+    const COLUMN_BOOK_SUBTITLE = 'book_subtitle';
+    const COLUMN_PLACE_OF_PUB = 'place_of_pub';
+    const COLUMN_DATE_OF_PUB = 'date_of_pub';
+    const COLUMN_PAGES = 'pages';
+    const COLUMN_VOLUME = 'volume';
+    const COLUMN_VOLUME_NO = 'volume_no';
+    const COLUMN_REVISION_HISTORY = 'revision_history';
+}
\ No newline at end of file
diff --git a/app/model/repository/BookTypeRepository.php b/app/model/repository/BookTypeRepository.php
new file mode 100644
index 0000000..1dbc886
--- /dev/null
+++ b/app/model/repository/BookTypeRepository.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `book_type`
+ *
+ * @package model\repository
+ */
+class BookTypeRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'book_type';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_book_type';
+    const COLUMN_BOOK_TYPE = 'book_type';
+}
\ No newline at end of file
diff --git a/app/model/repository/LineRepository.php b/app/model/repository/LineRepository.php
new file mode 100644
index 0000000..832c68f
--- /dev/null
+++ b/app/model/repository/LineRepository.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `line`
+ *
+ * @package model\repository
+ */
+class LineRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'line';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_line';
+    const COLUMN_TRANSLITERATION = 'transliteration';
+    const COLUMN_SURFACE_ID = 'id_surface';
+    const COLUMN_BROKEN = 'broken';
+    const COLUMN_OLD_BOOKANDCHAPTER = 'old_bookandchapter';
+    const COLUMN_LINE_NUMBER = 'line_number';
+}
\ No newline at end of file
diff --git a/app/model/repository/LitReferenceRepository.php b/app/model/repository/LitReferenceRepository.php
new file mode 100644
index 0000000..cdcdc0a
--- /dev/null
+++ b/app/model/repository/LitReferenceRepository.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `lit_reference`
+ *
+ * @package Model\Repository
+ */
+class LitReferenceRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'lit_reference';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_lit_reference';
+    const COLUMN_SERIES = 'series';
+    const COLUMN_NUMBER = 'number';
+    const COLUMN_PLATE = 'plate';
+    const COLUMN_TRANSLITERATION_ID = 'id_transliteration';
+}
\ No newline at end of file
diff --git a/app/model/repository/MuseumRepository.php b/app/model/repository/MuseumRepository.php
new file mode 100644
index 0000000..c4aa0ca
--- /dev/null
+++ b/app/model/repository/MuseumRepository.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `museum`
+ *
+ * @package Model\Repository
+ */
+class MuseumRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'museum';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_museum';
+    const COLUMN_TITLE = 'museum';
+    const COLUMN_PLACE = 'place';
+}
\ No newline at end of file
diff --git a/app/model/repository/ObjectTypeRepository.php b/app/model/repository/ObjectTypeRepository.php
new file mode 100644
index 0000000..9411380
--- /dev/null
+++ b/app/model/repository/ObjectTypeRepository.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `object_type`
+ *
+ * @package model\repository
+ */
+class ObjectTypeRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'object_type';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_object_type';
+    const COLUMN_OBJECT_TYPE = 'object_type';
+}
\ No newline at end of file
diff --git a/app/model/repository/OriginRepository.php b/app/model/repository/OriginRepository.php
new file mode 100644
index 0000000..3c1597c
--- /dev/null
+++ b/app/model/repository/OriginRepository.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `origin`
+ *
+ * @package model\repository
+ */
+class OriginRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'origin';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_origin';
+    const COLUMN_ORIGIN = 'origin';
+    const COLUMN_OLD_NAME = 'old_name';
+}
\ No newline at end of file
diff --git a/app/model/repository/Repository.php b/app/model/repository/Repository.php
new file mode 100644
index 0000000..3b828f9
--- /dev/null
+++ b/app/model/repository/Repository.php
@@ -0,0 +1,135 @@
+<?php
+
+namespace Model\Repository;
+
+use Nette;
+
+/**
+ * Základní repository s operacemi pro práci s tabulkou
+ *
+ * @package Model
+ */
+class Repository
+{
+    use Nette\SmartObject;
+
+    /** @var string Název tabulky */
+    protected $tableName;
+
+    /** @var \Nette\Database\Context */
+    protected $context;
+
+    public function __construct(Nette\Database\Context $context)
+    {
+        $this->context = $context;
+    }
+
+    /**
+     * Vrací název tabulky
+     *  - pokud není definovaný odvodí se název tabulky podle názvu třídy
+     *
+     * @return string
+     */
+    public function getTableName(): string
+    {
+        if (empty($this->tableName))
+        {
+            preg_match('#(\w+)Repository$#', get_class($this), $m);
+            $this->tableName = strtolower($m[1]);
+        }
+
+        return $this->tableName;
+    }
+
+    /**
+     * Vrací Selection reprezentující danou tabulku
+     *
+     * @return Nette\Database\Table\Selection
+     */
+    public function getTable(): Nette\Database\Table\Selection
+    {
+        if (empty($this->tableName))
+        {
+            $this->getTableName();
+        }
+
+        return $this->context->table($this->tableName);
+    }
+
+    /**
+     * Vrací všechny řádky z tabulky
+     *
+     * @return Nette\Database\Table\Selection
+     */
+    public function findAll(): Nette\Database\Table\Selection
+    {
+        return $this->getTable();
+    }
+
+    /**
+     * Vrací řádky podle filtru
+     *
+     * @param array $by : associativní pole s filtry, např. array('id' => 5)
+     * @return Nette\Database\Table\Selection
+     */
+    public function findBy(array $by): Nette\Database\Table\Selection
+    {
+        return $this->getTable()->where($by);
+    }
+
+    /**
+     * Vrací záznam z tabulky podle primárního klíče
+     *
+     * @param int $id
+     * @return Nette\Database\Table\ActiveRow
+     */
+    public function findRow(int $id): Nette\Database\Table\ActiveRow
+    {
+        return $this->getTable()->get($id);
+    }
+
+    /**
+     * Vložení dat do tabulky
+     *
+     * @param array $data
+     * @return bool|int|Nette\Database\Table\ActiveRow
+     */
+    public function insert(array $data)
+    {
+        return $this->getTable()->insert($data);
+    }
+
+    /**
+     * Smaže záznam podle primárního klíče
+     *
+     * @param int $id
+     * @return int
+     */
+    public function delete(int $id): int
+    {
+        return $this->findRow($id)->delete();
+    }
+
+    /**
+     * Uloží nebo updatuje záznam v tabulce
+     *  - pokud je $id NULL -> vloží nový záznam
+     *  - pokud $id není NULL -> aktualizace existujícího záznamu
+     *
+     * @param array $data
+     * @param int|NULL $id
+     * @return Nette\Database\Table\ActiveRow
+     */
+    public function save(array $data, int $id = NULL): Nette\Database\Table\ActiveRow
+    {
+        if ($id == NULL)
+        {
+            $record = $this->insert($data);
+        } else
+        {
+            $record = $this->findRow($id);
+            $record->update($data);
+        }
+
+        return $record;
+    }
+}
\ No newline at end of file
diff --git a/app/model/repository/RevHistoryRepository.php b/app/model/repository/RevHistoryRepository.php
new file mode 100644
index 0000000..d6d121c
--- /dev/null
+++ b/app/model/repository/RevHistoryRepository.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `rev_hisotry`
+ *
+ * @package Model\Repository
+ */
+class RevHistoryRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'rev_history';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_rev_history';
+    const COLUMN_TRANSLITERATION_ID = 'id_transliteration';
+    const COLUMN_DATE = 'date';
+    const COLUMN_NAME = 'name';
+    const COLUMN_DESCRIPTION = 'description';
+}
\ No newline at end of file
diff --git a/app/model/repository/SurfaceRepository.php b/app/model/repository/SurfaceRepository.php
new file mode 100644
index 0000000..d070885
--- /dev/null
+++ b/app/model/repository/SurfaceRepository.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `surface`
+ *
+ * @package model\repository
+ */
+class SurfaceRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'surface';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_surface';
+    const COLUMN_COLUMN_NUMBER = 'column_number';
+    const COLUMN_TRANSLITERATION_ID = 'id_transliteration';
+    const COLUMN_OBJECT_TYPE_ID = 'id_object_type';
+    const COLUMN_SURFACE_TYPE_ID = 'id_surface_type';
+}
\ No newline at end of file
diff --git a/app/model/repository/SurfaceTypeRepository.php b/app/model/repository/SurfaceTypeRepository.php
new file mode 100644
index 0000000..98f6889
--- /dev/null
+++ b/app/model/repository/SurfaceTypeRepository.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `surface_type`
+ *
+ * @package model\repository
+ */
+class SurfaceTypeRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'surface_type';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_surface_type';
+    const COLUMN_SURFACE_TYPE = 'surface_type';
+    const COLUMN_SORTER = 'sorter';
+}
\ No newline at end of file
diff --git a/app/model/repository/TransliterationRepository.php b/app/model/repository/TransliterationRepository.php
new file mode 100644
index 0000000..f1b2571
--- /dev/null
+++ b/app/model/repository/TransliterationRepository.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `transliteration`
+ *
+ * @package Model\Repository
+ */
+class TransliterationRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'transliteration';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id_transliteration';
+    const COLUMN_CHAPTER = 'chapter';
+    const COLUMN_BOOK_ID = 'id_book';
+    const COLUMN_MUSEUM_NO = 'museum_no';
+    const COLUMN_MUSEUM_ID = 'id_museum';
+    const COLUMN_ORIGIN_ID = 'id_origin';
+    const COLUMN_OLD_BOOKANDCHAPTER = 'old_bookandchapter';
+    const COLUMN_BOOK_TYPE_ID = 'id_book_type';
+    const COLUMN_REG_NO = 'reg_no';
+    const COLUMN_DATE = 'date';
+    const COLUMN_NOTE = 'note';
+}
\ No newline at end of file
diff --git a/app/model/repository/UserLogRepository.php b/app/model/repository/UserLogRepository.php
new file mode 100644
index 0000000..10d7fa3
--- /dev/null
+++ b/app/model/repository/UserLogRepository.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `user_log`
+ *
+ * @package model\repository
+ */
+class UserLogRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'user_log';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id';
+    const COLUMN_LOGGED_DATE = 'logged';
+    const COLUMN_IP = 'ip';
+    const COLUMN_CLIENT = 'client';
+    const COLUMN_USER_ID = 'user_id';
+}
\ No newline at end of file
diff --git a/app/model/repository/UserRepository.php b/app/model/repository/UserRepository.php
new file mode 100644
index 0000000..83e395e
--- /dev/null
+++ b/app/model/repository/UserRepository.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `user`
+ *
+ * @package model\repository
+ */
+class UserRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'user';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_ID = 'id';
+    const COLUMN_USERNAME = 'username';
+    const COLUMN_LOGIN = 'login';
+    const COLUMN_PASSWORD = 'password';
+    const COLUMN_EMAIL = 'email';
+    const COLUMN_CREATED = 'created';
+    const COLUMN_UPDATED = 'updated';
+}
\ No newline at end of file
diff --git a/app/model/repository/UserRoleRepository.php b/app/model/repository/UserRoleRepository.php
new file mode 100644
index 0000000..d638165
--- /dev/null
+++ b/app/model/repository/UserRoleRepository.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Model\Repository;
+
+/**
+ * Repository pro práci s tabulkou `user_role`
+ *
+ * @package model\repository
+ */
+class UserRoleRepository extends Repository
+{
+    /** @var string Název tabulky */
+    const TABLE_NAME = 'user_role';
+    protected $tableName = self::TABLE_NAME;
+
+    /** Sloupečky tabulky */
+    const COLUMN_USER_ID = 'user_id';
+    const COLUMN_ROLE_ID = 'role_id';
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 364e4e5..3a1af1e 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,7 @@
 	"type": "project",
 	"license": ["MIT", "BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
 	"require": {
-		"php": ">= 5.6",
+		"php": ">= 7.0",
 		"nette/application": "^2.4",
 		"nette/bootstrap": "^2.4.2",
 		"nette/caching": "^2.5",
@@ -27,7 +27,7 @@
 	"minimum-stability": "stable",
 	"config": {
 		"platform": {
-			"php": "7"
+			"php": "7.0"
 		}
 	}
 }
diff --git a/composer.lock b/composer.lock
index ba3fb6d..7df0651 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "b0c293d4de647886af79ecc8786cc114",
+    "content-hash": "29742b99e1ba0714587bf91cdbaecb4d",
     "packages": [
         {
             "name": "latte/latte",
@@ -1182,16 +1182,16 @@
         },
         {
             "name": "tracy/tracy",
-            "version": "v2.5.7",
+            "version": "v2.5.8",
             "source": {
                 "type": "git",
                 "url": "https://github.com/nette/tracy.git",
-                "reference": "36191fd045a0b9cb31a6f1ae658a921b90110454"
+                "reference": "3c874946fc403f728af9118cd602cac56bd493d3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/nette/tracy/zipball/36191fd045a0b9cb31a6f1ae658a921b90110454",
-                "reference": "36191fd045a0b9cb31a6f1ae658a921b90110454",
+                "url": "https://api.github.com/repos/nette/tracy/zipball/3c874946fc403f728af9118cd602cac56bd493d3",
+                "reference": "3c874946fc403f728af9118cd602cac56bd493d3",
                 "shasum": ""
             },
             "require": {
@@ -1235,7 +1235,7 @@
                     "homepage": "https://nette.org/contributors"
                 }
             ],
-            "description": "😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.",
+            "description": "? Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.",
             "homepage": "https://tracy.nette.org",
             "keywords": [
                 "Xdebug",
@@ -1244,7 +1244,7 @@
                 "nette",
                 "profiler"
             ],
-            "time": "2019-03-13T19:52:49+00:00"
+            "time": "2019-03-21T15:06:29+00:00"
         }
     ],
     "packages-dev": [
@@ -1317,10 +1317,10 @@
     "prefer-stable": false,
     "prefer-lowest": false,
     "platform": {
-        "php": ">= 5.6"
+        "php": ">= 7.0"
     },
     "platform-dev": [],
     "platform-overrides": {
-        "php": "7"
+        "php": "7.0"
     }
 }
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index f418f19..ac3626e 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,6 +1,6 @@
 version: '2'
 services:
-  server:
+  klinopis:
     container_name: klinopis.local
     ports:
       - '80:80'
diff --git a/docker/dockerfile b/docker/dockerfile
index 6c92e54..3c1a1f1 100644
--- a/docker/dockerfile
+++ b/docker/dockerfile
@@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND=nointeractive
 RUN sed -i "s/^exit 101$/exit 0/" /usr/sbin/policy-rc.d
 
 RUN apt-get update && \
-    apt-get install -y apache2 php7.0 php7.0-zip php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml curl git unzip
+    apt-get install -y apache2 php7.0 php7.0-zip php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql curl git unzip
 
 COPY ./conf.d/apache/apache2.conf /etc/apache2
 COPY ./conf.d/apache/000-default.conf /etc/apache2/sites-enabled
