Standardmethoden für Standort und News.Events erweitert
This commit is contained in:
parent
6e3e3708b2
commit
1964cadd8c
@ -14,6 +14,21 @@ class EventController {
|
|||||||
$this->view = $view;
|
$this->view = $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showEvents() {
|
||||||
|
$events = $this->eventModel->getEvents();
|
||||||
|
$this->view->setVars([
|
||||||
|
"events" => $events
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEvent() {
|
||||||
|
$ausstellungid = $_GET['ausstellungid'];
|
||||||
|
$event = $this->eventModel->getEvent($ausstellungid);
|
||||||
|
$this->view->setVars([
|
||||||
|
"event" => $event
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateEvent() {
|
public function updateEvent() {
|
||||||
$event = array(
|
$event = array(
|
||||||
"ausstellungid" => $_POST['ausstellungid'],
|
"ausstellungid" => $_POST['ausstellungid'],
|
||||||
|
43
Controller/NewsController.php
Normal file
43
Controller/NewsController.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Controller;
|
||||||
|
|
||||||
|
use Blog\Model\NewsModel;
|
||||||
|
|
||||||
|
class NewsController {
|
||||||
|
|
||||||
|
protected $view;
|
||||||
|
protected $newsModel;
|
||||||
|
|
||||||
|
public function __construct($view) {
|
||||||
|
$this->newsModel = new NewsModel();
|
||||||
|
$this->view = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showNews() {
|
||||||
|
$news = $this->newsModel->getNews();
|
||||||
|
$this->view->setVars([
|
||||||
|
"news" => $news
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createNews() {
|
||||||
|
$news = [
|
||||||
|
"name" => $_POST['name'],
|
||||||
|
"beschreibung" => $_POST['beschreibung'],
|
||||||
|
"datum" => $_POST['datum']
|
||||||
|
];
|
||||||
|
$this->newsModel->createNews($news);
|
||||||
|
$this->view->setVars([
|
||||||
|
"name" => $_POST['name']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteNews() {
|
||||||
|
$newsId = $_POST['newsid'];
|
||||||
|
$this->newsModel->deleteNews($newsId);
|
||||||
|
$this->view->setVars([
|
||||||
|
"deleted" => $newsId
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
24
Controller/StandortController.php
Normal file
24
Controller/StandortController.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Controller;
|
||||||
|
|
||||||
|
use Blog\Model\StandortModel;
|
||||||
|
|
||||||
|
class StandortController {
|
||||||
|
|
||||||
|
protected $view;
|
||||||
|
protected $standortModel;
|
||||||
|
|
||||||
|
public function __construct($view) {
|
||||||
|
$this->standortModel = new StandortModel();
|
||||||
|
$this->view = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showStandorte() {
|
||||||
|
$this -> standortModel -> getStandorte();
|
||||||
|
$this->view->setVars([
|
||||||
|
"standorte" => $this->standortModel->getStandorte()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,8 +6,19 @@ use PDOException;
|
|||||||
|
|
||||||
class EventModel extends Database {
|
class EventModel extends Database {
|
||||||
|
|
||||||
public function showEvents() {
|
public function getEvents() {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT * from ausstellung ORDER BY datum_von DESC;";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
$erg = $sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
return $erg;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Lesen der Daten.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateEvent($event) {
|
public function updateEvent($event) {
|
||||||
@ -77,7 +88,7 @@ class EventModel extends Database {
|
|||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute($params);
|
$sth->execute($params);
|
||||||
$erg = $sth->fetchAll(\PDO::FETCH_ASSOC);
|
$erg = $sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
return $erg[0];
|
return $erg;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der Daten.", $e);
|
||||||
die;
|
die;
|
||||||
|
53
Model/NewsModel.php
Normal file
53
Model/NewsModel.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Model;
|
||||||
|
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
|
class NewsModel extends Database {
|
||||||
|
|
||||||
|
public function getNews() {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT * FROM news ORDER BY datum DESC;";
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
$erg = $sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
return $erg;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Lesen der News.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createNews($news) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "INSERT INTO news (`name`, `beschreibung`, `datum`) VALUES (:titel, :inhalt, :datum);";
|
||||||
|
$params = [
|
||||||
|
":name" => $news['name'],
|
||||||
|
":beschreibung" => $news['beschreibung'],
|
||||||
|
":datum" => $news['datum']
|
||||||
|
];
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute($params);
|
||||||
|
return $sth;
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der News.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteNews($newsId) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "DELETE FROM news WHERE newsid = :newsid;";
|
||||||
|
$params = [":newsid" => $newsId];
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute($params);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Löschen der News.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
Model/StandortModel.php
Normal file
22
Model/StandortModel.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Model;
|
||||||
|
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
|
class StandortModel extends Database {
|
||||||
|
|
||||||
|
public function getStandorte() {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT * from standort ORDER BY ort;";
|
||||||
|
|
||||||
|
try {
|
||||||
|
$sth = $pdo->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
return $sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
new \Blog\Library\ErrorMsg("Fehler beim Lesen der Daten.", $e);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
Views/Event/showEvents.phtml
Normal file
32
Views/Event/showEvents.phtml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php include dirname(__DIR__) . '/header.phtml'; ?>
|
||||||
|
|
||||||
|
<h2>Alle Ausstellungen</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($events)): ?>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Beschreibung</th>
|
||||||
|
<th>Von</th>
|
||||||
|
<th>Bis</th>
|
||||||
|
<th>Max. Tickets</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($events as $event): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($event['name']); ?></td>
|
||||||
|
<td><?php echo nl2br(htmlspecialchars($event['beschreibung'])); ?></td>
|
||||||
|
<td><?php echo date('d.m.Y', strtotime($event['datum_von'])); ?></td>
|
||||||
|
<td><?php echo date('d.m.Y', strtotime($event['datum_bis'])); ?></td>
|
||||||
|
<td><?php echo (int) $event['max_tickets']; ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Derzeit sind keine Ausstellungen verfügbar.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
|
28
Views/News/showNews.phtml
Normal file
28
Views/News/showNews.phtml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php include dirname(__DIR__) . '/header.phtml'; ?>
|
||||||
|
|
||||||
|
<h2>Alle News</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($news)): ?>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Beschreibung</th>
|
||||||
|
<th>Datum</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($news as $item): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($item['name']); ?></td>
|
||||||
|
<td><?php echo nl2br(htmlspecialchars($item['beschreibung'])); ?></td>
|
||||||
|
<td><?php echo date('d.m.Y', strtotime($item['datum'])); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Derzeit sind keine News verfügbar.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
|
36
Views/Standort/showStandorte.phtml
Normal file
36
Views/Standort/showStandorte.phtml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php include dirname(__DIR__) . '/header.phtml'; ?>
|
||||||
|
|
||||||
|
<h2>Unsere Standorte</h2>
|
||||||
|
|
||||||
|
<?php if (!empty($standorte)): ?>
|
||||||
|
<table border="1" cellpadding="8" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Straße</th>
|
||||||
|
<th>Hausnr.</th>
|
||||||
|
<th>PLZ</th>
|
||||||
|
<th>Ort</th>
|
||||||
|
<th>Land</th>
|
||||||
|
<th>Telefon</th>
|
||||||
|
<th>Email</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($standorte as $standort): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($standort['straße']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['hausnr']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['postleitzahl']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['ort']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['land']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['tel']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($standort['email']); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Keine Standorte gefunden.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php include dirname(__DIR__) . '/footer.phtml'; ?>
|
11
Views/Ticket/hasTicket.phtml
Normal file
11
Views/Ticket/hasTicket.phtml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
include dirname(__DIR__).'/header.phtml';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="msg">
|
||||||
|
<p>TEST</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<?php include dirname(__DIR__).'/footer.phtml'; ?>
|
Loading…
x
Reference in New Issue
Block a user