diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccb8229 --- /dev/null +++ b/.gitignore @@ -0,0 +1,193 @@ +# Created by https://www.toptal.com/developers/gitignore/api/intellij,windows,macos,git +# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,windows,macos,git + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/encodings.xml +.idea/php.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/intellij,windows,macos,git \ No newline at end of file diff --git a/Controller/ContactController.php b/Controller/ContactController.php index 7a24662..de3862e 100644 --- a/Controller/ContactController.php +++ b/Controller/ContactController.php @@ -13,14 +13,12 @@ class ContactController private $labels = array("name" => "Name", "email" => "E-Mail-Adresse", "content" => "Nachricht"); - public function __construct($view) - { + public function __construct($view) { $this->db = new ContactModel(); $this->view = $view; } - public function showContactForm() - { + public function showContactForm() { $this->view->setVars([ 'labels' => $this->labels, 'validData' => $this->validData, @@ -28,12 +26,11 @@ class ContactController ]); } - public function showConfirmation() - { + public function showConfirmation() { } - public function validateForm(){ + public function validateForm() { foreach ($this->labels as $index => $value) { if (!isset($_POST[$index]) || empty($_POST[$index])) { $this->errors[$index] = "Bitte " . $value . " angeben"; diff --git a/Controller/EventController.php b/Controller/EventController.php new file mode 100644 index 0000000..fbe201d --- /dev/null +++ b/Controller/EventController.php @@ -0,0 +1,64 @@ +model = new EventModel(); + $this->view = $view; + } + + public function showEvents() { + $events = $this->model->getEvents(); + $this->view->setVars([ + 'events' => $events + ]); + } + + public function createEvent() { + $data = [ + 'name' => $_POST['name'] ?? null, + 'beschreibung' => $_POST['beschreibung'] ?? null, + 'standortid' => $_POST['standortid'] ?? null, + 'datum_von' => $_POST['datum_von'] ?? null, + 'datum_bis' => $_POST['datum_bis'] ?? null, + 'max_tickets' => $_POST['max_tickets'] ?? null, + 'preis' => $_POST['preis'] ?? null + ]; + + $this->model->createEvent($data); + $this->view->setVars(['event' => $data]); + exit; + } + + public function editEventForm() { + $id = $_GET['ausstellungid']; + $event = $this->model->getEvent($id); + $this->view->setVars(['event' => $event]); + } + + public function updateEvent($id, $data) { + $id = $_POST['ausstellungid']; + $data = [ + 'standortid' => $_POST['standortid'] ?? null, + 'datum_von' => $_POST['datum_von'] ?? null, + 'datum_bis' => $_POST['datum_bis'] ?? null, + 'name' => $_POST['name'] ?? null, + 'beschreibung' => $_POST['beschreibung'] ?? null, + 'max_tickets' => $_POST['max_tickets'] ?? null, + 'preis' => $_POST['preis'] ?? null + ]; + $this->model->updateEvent($id, $data); + } + + public function deleteEvent($id) { + $this->model->deleteEvent($id); + $this->view->setVars(['id' => $id]); + } +} \ No newline at end of file diff --git a/Controller/GutscheinController.php b/Controller/GutscheinController.php new file mode 100644 index 0000000..859a3d1 --- /dev/null +++ b/Controller/GutscheinController.php @@ -0,0 +1,57 @@ +model = new GutscheinModel(); + $this->view = $view; + } + + public function showGutscheine() { + $gutscheine = $this->model->getGutscheine(); + $this->view->setVars(['gutscheine' => $gutscheine]); + } + + public function createGutschein() { + $data = [ + 'code' => $_POST['code'] ?? null, + 'rabatt' => $_POST['rabatt'] ?? null, + 'eventid' => $_POST['eventid'] ?? null, + 'gültigkeit' => $_POST['gültigkeit'] ?? null + ]; + $erg = $this->model->createGutschein($data); + $this->view->setVars(['gutschein' => $erg]); + exit; + } + + public function editGutscheinForm() { + $id = $_GET['gutscheinid']; + if ($id) { + $gutschein = $this->model->getGutschein($id); + $this->view->setVars(['gutschein' => $gutschein]); + } + } + + public function updateGutschein() { + $id = $_POST['gutscheinid']; + $data = [ + 'code' => $_POST['code'] ?? null, + 'rabatt' => $_POST['rabatt'] ?? null, + 'eventid' => $_POST['eventid'] ?? null, + 'gültigkeit' => $_POST['gültigkeit'] ?? null + ]; + $this->model->updateGutschein($id, $data); + } + + public function deleteGutschein() { + $id = $_GET['gutscheinid'] ?? null; + $this->model->deleteGutschein($id); + } +} \ No newline at end of file diff --git a/Controller/NewsController.php b/Controller/NewsController.php new file mode 100644 index 0000000..a2c7620 --- /dev/null +++ b/Controller/NewsController.php @@ -0,0 +1,53 @@ +model = new NewsModel(); + $this->view = $view; + } + + public function showNews() { + $news = $this->model->getNews(); + $this->view->setVars(['news' => $news]); + } + + public function createNews() { + $data = [ + 'name' => $_POST['name'], + 'beschreibung' => $_POST['beschreibung'], + 'datum' => $_POST['datum'], + ]; + $erg = $this->model->createNews($data); + $this->view->setVars(['news' => $erg]); + exit; + } + + public function editNewsForm() { + $id = $_GET['newsid']; + $news = $this->model->getNewsById($id); + $this->view->setVars(['news' => $news]); + } + + public function updateNews() { + $id = $_POST['newsid'] ?? null; + $data = [ + 'name' => $_POST['name'], + 'beschreibung' => $_POST['beschreibung'], + 'datum' => $_POST['datum'], + ]; + $this->model->updateNews($id, $data); + } + + public function deleteNews() { + $id = $_GET['newsid'] ?? null; + $this->model->deleteNews($id); + } +} \ No newline at end of file diff --git a/Controller/StandortController.php b/Controller/StandortController.php new file mode 100644 index 0000000..9bbcaaa --- /dev/null +++ b/Controller/StandortController.php @@ -0,0 +1,61 @@ +model = new StandortModel(); + $this->view = $view; + } + + public function showStandorte() { + $standorte = $this->model->getStandorte(); + $this->view->setVars(['standorte' => $standorte]); + } + + public function createStandort() { + $data = [ + 'straße' => $_POST['straße'], + 'hausnr' => $_POST['hausnr'], + 'postleitzahl' => $_POST['postleitzahl'], + 'ort' => $_POST['ort'], + 'land' => $_POST['land'], + 'tel' => $_POST['tel'], + 'email' => $_POST['email'] + ]; + $erg = $this->model->createStandort($data); + $this->view->setVars(['standort' => $erg]); + } + + public function editStandortForm() { + $id = $_GET['standortid']; + $standort = $this->model->getStandort($id); + $this->view->setVars(['standort' => $standort]); + } + + public function updateStandort() { + $id = $_POST['standortid']; + $data = [ + 'straße' => $_POST['straße'], + 'hausnr' => $_POST['hausnr'], + 'postleitzahl' => $_POST['postleitzahl'], + 'ort' => $_POST['ort'], + 'land' => $_POST['land'], + 'tel' => $_POST['tel'], + 'email' => $_POST['email'] + ]; + $erg = $this->model->updateStandort($id, $data); + $this->view->setVars(['standort' => $erg]); + } + + public function deleteStandort() { + $id = $_GET['standortid'] ?? null; + $this->model->deleteStandort($id); + } +} \ No newline at end of file diff --git a/Controller/TicketController.php b/Controller/TicketController.php new file mode 100644 index 0000000..8ed3023 --- /dev/null +++ b/Controller/TicketController.php @@ -0,0 +1,39 @@ +ticketModel = new TicketModel(); + $this->view = $view; + } + + public function showTickets() { + $tickets = $this->ticketModel->getTickets(); + $this->view->setVars(['tickets' => $tickets]); + } + + public function buyTicket() { + $data = [ + 'userid' => $_POST['userid'], + 'eventid' => $_POST['eventid'], + 'kaufdatum' => date('Y-m-d'), + 'gültigkeitsdatum' => $_POST['gültigkeitsdatum'] + ]; + $erg = $this->ticketModel->buyTicket($data); + $this->view->setVars(['ticket' => $erg]); + } + + public function deleteTicket() { + $ticketid = $_GET['ticketid'] ?? null; + if ($ticketid) { + $this->ticketModel->deleteTicket($ticketid); + } + } +} \ No newline at end of file diff --git a/Model/EventModel.php b/Model/EventModel.php new file mode 100644 index 0000000..4e2ad48 --- /dev/null +++ b/Model/EventModel.php @@ -0,0 +1,90 @@ +linkDB(); + $sql = "SELECT * FROM ausstellung ORDER BY datum_von DESC;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute(); + return $sth->fetchAll(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen der Events.", $e); + die; + } + } + + public function getEvent($id) { + $pdo = $this->linkDB(); + $sql = "SELECT * FROM ausstellung WHERE ausstellungid = :id;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute([":id" => $id]); + return $sth->fetch(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen des Events.", $e); + die; + } + } + + public function updateEvent($id, $data) { + $pdo = $this->linkDB(); + $sql = "UPDATE ausstellung SET standortid = :standortid, datum_von = :datum_von, datum_bis = :datum_bis, name = :name, beschreibung = :beschreibung, max_tickets = :max_tickets, preis = :preis WHERE ausstellungid = :id;"; + $params = [ + ":standortid" => $data['standortid'], + ":datum_von" => $data['datum_von'], + ":datum_bis" => $data['datum_bis'], + ":name" => $data['name'], + ":beschreibung" => $data['beschreibung'], + ":max_tickets" => $data['max_tickets'], + ":preis" => $data['preis'], + ":id" => $id + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Events.", $e); + die; + } + } + + public function createEvent($data) { + $pdo = $this->linkDB(); + $sql = "INSERT INTO ausstellung (standortid, datum_von, datum_bis, name, beschreibung, max_tickets, preis) VALUES (:standortid, :datum_von, :datum_bis, :name, :beschreibung, :max_tickets, :preis);"; + $params = [ + ":standortid" => $data['standortid'], + ":datum_von" => $data['datum_von'], + ":datum_bis" => $data['datum_bis'], + ":name" => $data['name'], + ":beschreibung" => $data['beschreibung'], + ":max_tickets" => $data['max_tickets'], + ":preis" => $data['preis'] + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth; + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Erstellen des Events.", $e); + die; + } + } + + public function deleteEvent($id) { + $pdo = $this->linkDB(); + $sql = "DELETE FROM ausstellung WHERE ausstellungid = :id;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute([":id" => $id]); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Löschen des Events.", $e); + die; + } + } +} \ No newline at end of file diff --git a/Model/GutscheinModel.php b/Model/GutscheinModel.php new file mode 100644 index 0000000..e9ba8a5 --- /dev/null +++ b/Model/GutscheinModel.php @@ -0,0 +1,86 @@ +linkDB(); + $sql = "SELECT * FROM gutschein ORDER BY gültigkeit DESC;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute(); + return $sth->fetchAll(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen der Gutscheine.", $e); + die; + } + } + + public function getGutschein($id) { + $pdo = $this->linkDB(); + $sql = "SELECT * FROM gutschein WHERE gutscheinid = :id;"; + $params = [":id" => $id]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->fetch(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen des Gutscheins.", $e); + die; + } + } + + public function createGutschein($data) { + $pdo = $this->linkDB(); + $sql = "INSERT INTO gutschein (code, rabatt, eventid, gültigkeit) VALUES (:code, :rabatt, :eventid, :gültigkeit);"; + $params = [ + ":code" => $data['code'], + ":rabatt" => $data['rabatt'], + ":eventid" => $data['eventid'], + ":gültigkeit" => $data['gültigkeit'] + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth; + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Erstellen des Gutscheins.", $e); + die; + } + } + + public function updateGutschein($id, $data) { + $pdo = $this->linkDB(); + $sql = "UPDATE gutschein SET code = :code, rabatt = :rabatt, eventid = :eventid, gültigkeit = :gültigkeit WHERE gutscheinid = :id;"; + $params = [ + ":code" => $data['code'], + ":rabatt" => $data['rabatt'], + ":eventid" => $data['eventid'], + ":gültigkeit" => $data['gültigkeit'], + ":id" => $id + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Gutscheins.", $e); + die; + } + } + + public function deleteGutschein($id) { + $pdo = $this->linkDB(); + $sql = "DELETE FROM gutschein WHERE gutscheinid = :id;"; + $params = [":id" => $id]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Löschen des Gutscheins.", $e); + die; + } + } +} \ No newline at end of file diff --git a/Model/NewsModel.php b/Model/NewsModel.php new file mode 100644 index 0000000..5d5833d --- /dev/null +++ b/Model/NewsModel.php @@ -0,0 +1,85 @@ +linkDB(); + $sql = "SELECT * FROM news WHERE newsid = :newsid;"; + $params = [":newsid" => $newsId]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->fetch(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen der News.", $e); + die; + } + } + + public function updateNews($newsId, $news) { + $pdo = $this->linkDB(); + $sql = "UPDATE news SET name = :name, beschreibung = :beschreibung, datum = :datum WHERE newsid = :newsid;"; + $params = [ + ":name" => $news['titel'], + ":beschreibung" => $news['inhalt'], + ":datum" => $news['datum'], + ":newsid" => $newsId + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth; + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der News.", $e); + die; + } + } + + public function getNews() { + $pdo = $this->linkDB(); + $sql = "SELECT * FROM news ORDER BY datum DESC;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute(); + return $sth->fetchAll(\PDO::FETCH_ASSOC); + } 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 (:name, :beschreibung, :datum);"; + $params = [ + ":name" => $news['titel'], + ":beschreibung" => $news['inhalt'], + ":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; + } + } +} \ No newline at end of file diff --git a/Model/StandortModel.php b/Model/StandortModel.php new file mode 100644 index 0000000..8bbce96 --- /dev/null +++ b/Model/StandortModel.php @@ -0,0 +1,103 @@ +linkDB(); + $sql = "SELECT * FROM Standort ORDER BY standortid ASC;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute(); + return $sth->fetchAll(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen der Standorte.", $e); + die; + } + } + + public function getStandort($standortid) { + $pdo = $this->linkDB(); + $sql = "SELECT * FROM Standort WHERE standortid = :standortid;"; + $params = [":standortid" => $standortid]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->fetch(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen des Standorts.", $e); + die; + } + } + + public function createStandort($data) { + $pdo = $this->linkDB(); + $sql = "INSERT INTO Standort (straße, hausnr, postleitzahl, ort, land, tel, email) + VALUES (:straße, :hausnr, :postleitzahl, :ort, :land, :tel, :email);"; + $params = [ + ":straße" => $data['straße'], + ":hausnr" => $data['hausnr'], + ":postleitzahl" => $data['postleitzahl'], + ":ort" => $data['ort'], + ":land" => $data['land'], + ":tel" => $data['tel'], + ":email" => $data['email'] + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $pdo->lastInsertId(); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Anlegen des Standorts.", $e); + die; + } + } + + public function updateStandort($standortid, $data) { + $pdo = $this->linkDB(); + $sql = "UPDATE Standort SET + straße = :straße, + hausnr = :hausnr, + postleitzahl = :postleitzahl, + ort = :ort, + land = :land, + tel = :tel, + email = :email + WHERE standortid = :standortid;"; + $params = [ + ":straße" => $data['straße'], + ":hausnr" => $data['hausnr'], + ":postleitzahl" => $data['postleitzahl'], + ":ort" => $data['ort'], + ":land" => $data['land'], + ":tel" => $data['tel'], + ":email" => $data['email'], + ":standortid" => $standortid + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->rowCount(); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Standorts.", $e); + die; + } + } + + public function deleteStandort($standortid) { + $pdo = $this->linkDB(); + $sql = "DELETE FROM Standort WHERE standortid = :standortid;"; + $params = [":standortid" => $standortid]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->rowCount(); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Löschen des Standorts.", $e); + die; + } + } +} \ No newline at end of file diff --git a/Model/TicketModel.php b/Model/TicketModel.php new file mode 100644 index 0000000..1d6f23a --- /dev/null +++ b/Model/TicketModel.php @@ -0,0 +1,72 @@ +linkDB(); + $sql = "SELECT * FROM Ticket ORDER BY ticketid ASC;"; + try { + $sth = $pdo->prepare($sql); + $sth->execute(); + return $sth->fetchAll(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Lesen der Tickets.", $e); + die; + } + } + + public function buyTicket($data) { + $pdo = $this->linkDB(); + $sql = "INSERT INTO Ticket (userid, eventid, kaufdatum, gültigkeitsdatum) + VALUES (:userid, :eventid, :kaufdatum, :gültigkeitsdatum);"; + $params = [ + ":userid" => $data['userid'], + ":eventid" => $data['eventid'], + ":kaufdatum" => $data['kaufdatum'], + ":gültigkeitsdatum" => $data['gültigkeitsdatum'] + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $pdo->lastInsertId(); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Kauf des Tickets.", $e); + die; + } + } + + public function hasTicket($userid, $eventid) { + $pdo = $this->linkDB(); + $sql = "SELECT COUNT(*) as count FROM Ticket WHERE userid = :userid AND eventid = :eventid;"; + $params = [ + ":userid" => $userid, + ":eventid" => $eventid + ]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->fetch(\PDO::FETCH_ASSOC); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler bei der Ticketprüfung.", $e); + die; + } + } + + public function deleteTicket($ticketid) { + $pdo = $this->linkDB(); + $sql = "DELETE FROM Ticket WHERE ticketid = :ticketid;"; + $params = [":ticketid" => $ticketid]; + try { + $sth = $pdo->prepare($sql); + $sth->execute($params); + return $sth->rowCount(); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Löschen des Tickets.", $e); + die; + } + } +} \ No newline at end of file diff --git a/Views/Event/createEvent.phtml b/Views/Event/createEvent.phtml new file mode 100644 index 0000000..b0376d4 --- /dev/null +++ b/Views/Event/createEvent.phtml @@ -0,0 +1,12 @@ + + +
+

Das Event "" wurde erfolgreich erstellt!

+ Weiter +
+ + + + \ No newline at end of file diff --git a/Views/Event/deleteEvent.phtml b/Views/Event/deleteEvent.phtml new file mode 100644 index 0000000..4a7ce55 --- /dev/null +++ b/Views/Event/deleteEvent.phtml @@ -0,0 +1,12 @@ + + +
+

Das Event mit der id"" wurde erfolgreich gelöscht!

+ Weiter +
+ + + + \ No newline at end of file diff --git a/Views/Event/showEvents.phtml b/Views/Event/showEvents.phtml new file mode 100644 index 0000000..55ab417 --- /dev/null +++ b/Views/Event/showEvents.phtml @@ -0,0 +1,32 @@ + + +

Alle Ausstellungen

+ + + + + + + + + + + + + + + + + + + + + + + +
NameBeschreibungVonBisMax. Tickets
+ +

Derzeit sind keine Ausstellungen verfügbar.

+ + + \ No newline at end of file diff --git a/Views/Event/updateEvent.phtml b/Views/Event/updateEvent.phtml new file mode 100644 index 0000000..32c1acf --- /dev/null +++ b/Views/Event/updateEvent.phtml @@ -0,0 +1,12 @@ + + +
+

Das Event mit der ID "" wurde erfolgreich bearbeitet!

+ Weiter +
+ + + + \ No newline at end of file diff --git a/Views/Gutschein/createGutschein.phtml b/Views/Gutschein/createGutschein.phtml new file mode 100644 index 0000000..6d85614 --- /dev/null +++ b/Views/Gutschein/createGutschein.phtml @@ -0,0 +1 @@ +echo "create gutschein" \ No newline at end of file diff --git a/Views/Gutschein/showGutscheine.phtml b/Views/Gutschein/showGutscheine.phtml new file mode 100644 index 0000000..6824976 --- /dev/null +++ b/Views/Gutschein/showGutscheine.phtml @@ -0,0 +1,35 @@ + + +

Alle Gutscheine

+ Neuen Gutschein anlegen + + + + + + + + + + + + + + + + + + + + + + +
CodeRabatt (%)Event-IDGültig bisAktionen
+ Bearbeiten | + Löschen +
+ +

Keine Gutscheine vorhanden.

+ + + \ No newline at end of file diff --git a/Views/News/showNews.phtml b/Views/News/showNews.phtml new file mode 100644 index 0000000..5f71b89 --- /dev/null +++ b/Views/News/showNews.phtml @@ -0,0 +1,28 @@ + + +

Alle News

+ + + + + + + + + + + + + + + + + + + +
NameBeschreibungDatum
+ +

Derzeit sind keine News verfügbar.

+ + + \ No newline at end of file diff --git a/Views/Standort/showStandorte.phtml b/Views/Standort/showStandorte.phtml new file mode 100644 index 0000000..3ac6cdb --- /dev/null +++ b/Views/Standort/showStandorte.phtml @@ -0,0 +1,36 @@ + + +

Unsere Standorte

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
StraßeHausnr.PLZOrtLandTelefonEmail
+ +

Keine Standorte gefunden.

+ + + \ No newline at end of file diff --git a/Views/Ticket/buyTicket.phtml b/Views/Ticket/buyTicket.phtml new file mode 100644 index 0000000..4cf930d --- /dev/null +++ b/Views/Ticket/buyTicket.phtml @@ -0,0 +1,12 @@ + + +
+

Ihr Ticket für das Event "" wurde erfolgreich gekauft!

+ Weiter +
+ + + + \ No newline at end of file diff --git a/bibarts.sql b/bibarts.sql new file mode 100644 index 0000000..ce10293 --- /dev/null +++ b/bibarts.sql @@ -0,0 +1,124 @@ +-- phpMyAdmin SQL Dump +-- version 4.5.1 +-- http://www.phpmyadmin.net +-- +-- Host: 127.0.0.1 +-- Erstellungszeit: 24. Nov 2017 um 17:01 +-- Server-Version: 10.1.16-MariaDB +-- PHP-Version: 7.0.9 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + +-- +-- Datenbank: `blog` +-- + +-- -------------------------------------------------------- + +CREATE TABLE User ( + userid INT AUTO_INCREMENT PRIMARY KEY, + vorname VARCHAR(50), + nachname VARCHAR(50), + strasse VARCHAR(100), + hausnr VARCHAR(10), + postleitzahl VARCHAR(10), + ort VARCHAR(50), + land VARCHAR(50), + tel VARCHAR(20), + email VARCHAR(100) UNIQUE, + isAdmin BOOLEAN DEFAULT FALSE, + password VARCHAR(255) +); + + +CREATE TABLE Standort ( + standortid INT AUTO_INCREMENT PRIMARY KEY, + strasse VARCHAR(100), + hausnr VARCHAR(10), + plz VARCHAR(10), + ort VARCHAR(50), + land VARCHAR(50), + tel VARCHAR(20), + email VARCHAR(100) +); + + +CREATE TABLE Ausstellung ( + austellungid INT AUTO_INCREMENT PRIMARY KEY, + standortid INT, + datum_von DATE, + datum_bis DATE, + name VARCHAR(100), + beschreibung TEXT, + max_tickets INT, + FOREIGN KEY (standortid) REFERENCES Standort(standortid) +); + + +CREATE TABLE Ticket ( + ticketid INT AUTO_INCREMENT PRIMARY KEY, + userid INT, + ausstellungid INT, + kaufdatum DATE, + gueltigkeit DATE, + preis DECIMAL(10,2), + FOREIGN KEY (userid) REFERENCES User(userid), + FOREIGN KEY (ausstellungid) REFERENCES Ausstellung(austellungid) +); + + +CREATE TABLE Gutschein ( + gutscheinid INT AUTO_INCREMENT PRIMARY KEY, + code VARCHAR(50) UNIQUE, + rabatt INT CHECK (rabatt BETWEEN 0 AND 100), + ausstellungid INT, + gueltigkeit DATE, + FOREIGN KEY (ausstellungid) REFERENCES Ausstellung(austellungid) +); + + +CREATE TABLE News ( + newsid INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(100), + beschreibung TEXT, + datum DATE +); + + + +-- User-Daten +INSERT INTO User (vorname, nachname, strasse, hausnr, postleitzahl, ort, land, tel, email, isAdmin, password) +VALUES + ('Max', 'Muster', 'Musterstraße', '1', '12345', 'Musterstadt', 'Deutschland', '0123456789', 'max@muster.de', FALSE, 'passwort123'), + ('Anna', 'Beispiel', 'Beispielweg', '5a', '54321', 'Beispielstadt', 'Deutschland', '0987654321', 'anna@beispiel.de', TRUE, 'adminpass'); + +-- Standort-Daten +INSERT INTO Standort (strasse, hausnr, plz, ort, land, tel, email) +VALUES + ('Galeriestraße', '10', '10115', 'Berlin', 'Deutschland', '030123456', 'kontakt@galerie-berlin.de'), + ('Kunstallee', '22b', '50667', 'Köln', 'Deutschland', '0221123456', 'info@kunst-koeln.de'); + +-- Ausstellung-Daten +INSERT INTO Ausstellung (standortid, datum_von, datum_bis, name, beschreibung, max_tickets) +VALUES + (1, '2025-07-01', '2025-08-31', 'Moderne Meisterwerke', 'Eine Sammlung moderner Kunstwerke aus Europa.', 200), + (2, '2025-09-10', '2025-10-20', 'Kunst der Antike', 'Ausstellung antiker Skulpturen und Gemälde.', 150); + +-- Gutschein-Daten (Spaltennamen korrigiert) +INSERT INTO Gutschein (code, rabatt, ausstellungid, gueltigkeit) +VALUES + ('SOMMER2025', 15, 1, '2025-08-31'), + ('HERBST25', 25, 2, '2025-10-15'); + +-- Ticket-Daten (Spaltennamen korrigiert) +INSERT INTO Ticket (userid, ausstellungid, kaufdatum, gueltigkeit, preis) +VALUES + (1, 1, '2025-06-01', '2025-07-15', 12.50), + (2, 2, '2025-06-05', '2025-09-15', 10.00); + +-- News-Daten +INSERT INTO News (name, beschreibung, datum) +VALUES + ('Neuer Standort eröffnet', 'Unsere Galerie in Köln ist jetzt geöffnet!', '2025-06-01'), + ('Frühbucher-Rabatt', 'Sichern Sie sich jetzt 15% Rabatt auf unsere Sommerausstellung.', '2025-05-20'); \ No newline at end of file diff --git a/contact.sql b/contact.sql deleted file mode 100644 index ff1ce98..0000000 --- a/contact.sql +++ /dev/null @@ -1,30 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.5.1 --- http://www.phpmyadmin.net --- --- Host: 127.0.0.1 --- Erstellungszeit: 24. Nov 2017 um 17:01 --- Server-Version: 10.1.16-MariaDB --- PHP-Version: 7.0.9 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - --- --- Datenbank: `blog` --- - --- -------------------------------------------------------- - -CREATE TABLE `contact` ( - `id` varchar(36) NOT NULL, - `topicCode` tinyint(2) NULL, - `name` varchar(200) NOT NULL, - `email` varchar(300) NOT NULL, - `phone` varchar(16) NULL, - `content` varchar(500) NOT NULL, - `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `contact` - ADD PRIMARY KEY (`id`)