diff --git a/README.md b/README.md
index bd96ba6..81d98c9 100755
--- a/README.md
+++ b/README.md
@@ -4,15 +4,18 @@
## TO DO:
*Make searchbar work*
- *Implement articles*
*Implement listing and following*
### Tasks
*search.php*
+ *implement tags*
+
*insert beer/brewery/article form - /admin.php*
*add beer to list/ add brewery to follow*
- *article/brewery/beer/list .php*
+ *brewery/beer/list .php*
+
+
diff --git a/article.php b/article.php
index fea8721..cea6254 100644
--- a/article.php
+++ b/article.php
@@ -4,6 +4,7 @@ require_once("model/db.php");
require_once("controller/getRecord.php");
require("view/header.php");
+require("view/sidebar.php");
$record = getRecord($pdo, "article", $_GET["id"] );
$title = $record["title"];
@@ -13,6 +14,4 @@ $date = $record["time"];
require("view/mainContent/mainContent.php");
-require("view/sidebar.php");
-
include("view/footer.php");
\ No newline at end of file
diff --git a/beer.php b/beer.php
index bcd5dad..85273cf 100644
--- a/beer.php
+++ b/beer.php
@@ -2,20 +2,33 @@
session_start();
require_once("model/db.php");
require_once("controller/getRecord.php");
+require_once("view/mainContent/userButtons.php");
require("view/header.php");
+require("view/sidebar.php");
+
$record = getRecord($pdo, "beer", $_GET["id"] );
$title = $record["name"];
+$description = $record["description"];
+$date = $record["time"];
$alc = $record["alc"];
$ibu = $record["ibu"];
-$description = $record["description"];
$brewery_id = $record["brewery_id"];
-$date = $record["time"];
-
require("view/mainContent/mainContent.php");
-require("view/sidebar.php");
+
+$brewery = getRecord($pdo, "brewery", $brewery_id )["name"];
+
+require("view/mainContent/beerExtraInfo.php");
+
+echo "Kappa";
+if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
+ if(isThisBound($pdo, "list", $_GET["id"], $_SESSION["id"])){
+ unfollowButton($pdo, "list", $_GET["id"], $_SESSION["id"]);
+ } else followButton($pdo, "list", $_GET["id"], $_SESSION["id"]);
+ showStars($pdo, $_GET["id"], $_SESSION["id"]);
+}
include("view/footer.php");
\ No newline at end of file
diff --git a/brewery.php b/brewery.php
index 7bcbcbe..30bba50 100644
--- a/brewery.php
+++ b/brewery.php
@@ -2,8 +2,10 @@
session_start();
require_once("model/db.php");
require_once("controller/getRecord.php");
+require_once("controller/listLatest.php");
require("view/header.php");
+require("view/sidebar.php");
$record = getRecord($pdo, "brewery", $_GET["id"] );
$title = $record["name"];
@@ -11,10 +13,24 @@ $description = $record["description"];
$date = $record["time"];
$region = $record["region"];
+$array = listBeersByBrewery($pdo, $_GET["id"]);
+
+
require("view/mainContent/mainContent.php");
+require("view/mainContent/breweryExtraInfo.php");
-require("view/sidebar.php");
+$title = "Beers from $title";
+$what = "beer";
+
+require("view/sidebar/sidebarLister.php");
+
+if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
+ if(isThisBound($pdo, "follow", $_GET["id"], $_SESSION["id"])){
+ unfollowButton($pdo, "follow", $_GET["id"], $_SESSION["id"]);
+
+ } else followButton($pdo, "follow", $_GET["id"], $_SESSION["id"]);
+}
include("view/footer.php");
\ No newline at end of file
diff --git a/controller/getRecord.php b/controller/getRecord.php
index 7291d07..084ad8d 100644
--- a/controller/getRecord.php
+++ b/controller/getRecord.php
@@ -12,4 +12,21 @@ function getRecord($pdo, $from, $where ){
echo "Error in $from: Not Found";
}
return $record;
+}
+
+function isThisBound($pdo, $where, $item_id, $user_id){
+ $conn = $pdo;
+ try {
+ if($where === "list"){
+ $item = "beer_id";
+ }else $item = "brewery_id";
+ $sql = "SELECT * FROM $where WHERE $item = $item_id AND user_id = $user_id";
+ $stmt = $conn->prepare($sql);
+ $stmt->execute();
+ $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ if($stmt->rowCount() == 1)return true;
+ else return false;
+ } catch (PDOException $e) {
+ echo "Error in $where: Not Found";
+ }
}
\ No newline at end of file
diff --git a/controller/listLatest.php b/controller/listLatest.php
index 154ebef..9d28da7 100644
--- a/controller/listLatest.php
+++ b/controller/listLatest.php
@@ -56,3 +56,17 @@ function listLatestArticle($pdo, $where){
return $arrayOfArticles;
}
+function listBeersByBrewery($pdo, $where){
+ $conn = $pdo;
+ try {
+
+ $stmt = $conn->prepare("SELECT * FROM beer WHERE brewery_id = $where");
+ $stmt->execute();
+ $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ $arrayBeers = $stmt->fetchAll();
+ } catch (PDOException $e) {
+ echo "Error in Beers: " . $e->getMessage();
+ }
+ return $arrayBeers;
+}
+
diff --git a/databaseDeploy/priloha5.sql b/databaseDeploy/priloha5.sql
index 607da54..197949d 100644
--- a/databaseDeploy/priloha5.sql
+++ b/databaseDeploy/priloha5.sql
@@ -12,7 +12,7 @@ insert into user ( nick, mail, password ) values ( 'aa', 'test@mail.cz', '$2y$10
insert into brewery (name, region, description) values ( 'Zichovec', 'Louny', 'Remeslny pivovar');
-insert into brewery (name, region, description) values ( 'Siberia', 'Praha 9-Vysočany', 'Remeslny pivovar');
+insert into brewery (name, region, description) values ( 'Siberia', 'Praha 9-Vysocany', 'Remeslny pivovar');
insert into brewery (name, region, description) values ( 'Matuska', 'Broumy', 'Remeslny pivovar');
insert into brewery (name, region, description) values ( 'Cestmir', 'Stara Boleslav', 'Remeslny pivovar');
insert into brewery (name, region, description) values ( 'Prazdroj', 'Plzen', 'Pilsner Urquell');
diff --git a/src/articles/article.md b/src/articles/article.md
deleted file mode 100644
index e69de29..0000000
diff --git a/src/style/style.css b/src/style/style.css
index 04ca1ab..97b1198 100755
--- a/src/style/style.css
+++ b/src/style/style.css
@@ -21,6 +21,33 @@ body {
background-color:white;
}
+/* Tagy */
+
+.taglist .tag{
+ margin-right:.4em;
+ padding:.5em;
+ background:#e8e6dc;
+ color:#000;
+ border-radius:5px;
+ border:1px solid #aaa;
+ font-size:.9rem;
+ display:inline-block;
+}
+
+.taglist .tag a{
+ color: #000;
+}
+
+.taglist .tag a:hover{
+ color:#fff;
+}
+
+.taglist {
+ display:flex;
+ align-items:center;
+ margin-bottom:.5em
+}
+
/* - Nadpisy - */
h1, h2, h3 {
font-family: 'Signika Negative', sans-serif;
@@ -75,7 +102,7 @@ nav > div.profile {
justify-content: space-between;
}
-nav ul, nav li {
+ul, li {
list-style: none;
text-align: justify;
}
@@ -127,6 +154,27 @@ aside ul, aside li {
text-align: left;
}
+/* Tables */
+
+table {
+ border-collapse: collapse;
+ margin: 25px 0;
+ font-size: 0.9em;
+ min-width: 400px;
+ border-radius: 5px 5px 0 0;
+ overflow: hidden;
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
+}
+
+table th,
+table td {
+ padding: 12px 15px;
+ border: 1px solid #575757;
+}
+
+table tbody tr {
+ border: 3px solid #575757;
+}
/* Formulář */
@@ -185,4 +233,4 @@ footer {
}
footer p {
margin: 0 0 0 0;
-}
+}
\ No newline at end of file
diff --git a/view/mainContent/beerExtraInfo.php b/view/mainContent/beerExtraInfo.php
new file mode 100644
index 0000000..bbb5d6b
--- /dev/null
+++ b/view/mainContent/beerExtraInfo.php
@@ -0,0 +1,14 @@
+
+
+
+ Alcohol Volume: |
+ IBU: |
+ From brewery: |
+
+
+ = $alc ?> |
+ = $ibu ?> |
+ = $brewery ?> |
+
+
+
diff --git a/view/mainContent/breweryExtraInfo.php b/view/mainContent/breweryExtraInfo.php
new file mode 100644
index 0000000..e82472a
--- /dev/null
+++ b/view/mainContent/breweryExtraInfo.php
@@ -0,0 +1,10 @@
+
+
+
+ From: |
+
+
+ = $region ?> |
+
+
+
\ No newline at end of file
diff --git a/view/mainContent/userButtons.php b/view/mainContent/userButtons.php
new file mode 100644
index 0000000..9cba92e
--- /dev/null
+++ b/view/mainContent/userButtons.php
@@ -0,0 +1,35 @@
+prepare($sql);
+ $stmt->execute();
+ $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ $record = $stmt->fetch();
+ } catch (PDOException $e) {
+ echo "Error in $from: Not Found";
+ }
+ return $record;
+}
+
+function followButton($pdo, $where, $item_id, $user_id){
+ print_r($pdo);
+ $conn = $pdo;
+ try {
+ $sql = "SELECT * FROM $from WHERE id = $where";
+ $stmt = $conn->prepare($sql);
+ $stmt->execute();
+ $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
+ $record = $stmt->fetch();
+ } catch (PDOException $e) {
+ echo "Error in $from: Not Found";
+ }
+ return $record;
+ }
+
+function showStars($pdo, $beer_id, $user_id){
+ print_r($pdo);
+}