Alles auf Englisch umbenannt: exhibition → event, Variablen und Tabellen angepasst, Views auf neue Felder umgestellt, Controller/Model/SQL konsistent gemacht. Alte Variablennamen raus, jetzt ist alles einheitlich. Fehler aus dem Frontend gefixt.
This commit is contained in:
parent
d24d914c8c
commit
8a59ddde8e
@ -9,14 +9,12 @@ class AuthController
|
|||||||
private $model;
|
private $model;
|
||||||
private $view;
|
private $view;
|
||||||
|
|
||||||
public function __construct($view)
|
public function __construct($view) {
|
||||||
{
|
|
||||||
$this->model = new AuthModel();
|
$this->model = new AuthModel();
|
||||||
$this->view = $view;
|
$this->view = $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showAuthForm()
|
public function showLoginForm() {
|
||||||
{
|
|
||||||
$this->view->setVars([
|
$this->view->setVars([
|
||||||
'labels' => [
|
'labels' => [
|
||||||
"email" => "E-Mail-Adresse",
|
"email" => "E-Mail-Adresse",
|
||||||
@ -30,8 +28,7 @@ class AuthController
|
|||||||
unset($_SESSION['auth_errors'], $_SESSION['auth_validData']);
|
unset($_SESSION['auth_errors'], $_SESSION['auth_validData']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showRegistrationForm()
|
public function showRegistrationForm() {
|
||||||
{
|
|
||||||
$this->view->setVars([
|
$this->view->setVars([
|
||||||
'labels' => [
|
'labels' => [
|
||||||
"email" => "E-Mail-Adresse",
|
"email" => "E-Mail-Adresse",
|
||||||
@ -69,25 +66,25 @@ class AuthController
|
|||||||
|
|
||||||
public function register() {
|
public function register() {
|
||||||
$data = [
|
$data = [
|
||||||
'vorname' => $_POST['vorname'] ?? '',
|
'first_name' => $_POST['vorname'] ?? '',
|
||||||
'nachname' => $_POST['nachname'] ?? '',
|
'last_name' => $_POST['nachname'] ?? '',
|
||||||
'straße' => $_POST['strasse'] ?? '',
|
'street' => $_POST['strasse'] ?? '',
|
||||||
'hausnr' => $_POST['hausnr'] ?? '',
|
'house_number' => $_POST['hausnr'] ?? '',
|
||||||
'plz' => $_POST['plz'] ?? '',
|
'postal_code' => $_POST['plz'] ?? '',
|
||||||
'ort' => $_POST['ort'] ?? '',
|
'city' => $_POST['ort'] ?? '',
|
||||||
'land' => $_POST['land'] ?? '',
|
'country' => $_POST['land'] ?? '',
|
||||||
'tel' => $_POST['tel'] ?? '',
|
'phone' => $_POST['tel'] ?? '',
|
||||||
'email' => $_POST['email'] ?? '',
|
'email' => $_POST['email'] ?? '',
|
||||||
'password' => $_POST['password'] ?? '',
|
'password' => $_POST['password'] ?? '',
|
||||||
'password_repeat' => $_POST['password_repeat'] ?? '',
|
'password_repeat' => $_POST['password_repeat'] ?? '',
|
||||||
'isAdmin' => $_POST['isAdmin'] ?? false,
|
'is_admin' => $_POST['isAdmin'] ?? false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = $this->model->register($data);
|
$result = $this->model->register($data);
|
||||||
|
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
$this->view->setVars(['success' => 'Registrierung erfolgreich!']);
|
$this->view->setVars(['success' => 'Registrierung erfolgreich!']);
|
||||||
$this->view->render('Auth/showAuthForm');
|
$this->view->render('Auth/showLoginForm');
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
|
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";
|
||||||
|
@ -23,13 +23,13 @@ class EventController {
|
|||||||
|
|
||||||
public function createEvent() {
|
public function createEvent() {
|
||||||
$data = [
|
$data = [
|
||||||
|
'location_id' => $_POST['location_id'] ?? null,
|
||||||
|
'start_date' => $_POST['start_date'] ?? null,
|
||||||
|
'end_date' => $_POST['end_date'] ?? null,
|
||||||
'name' => $_POST['name'] ?? null,
|
'name' => $_POST['name'] ?? null,
|
||||||
'beschreibung' => $_POST['beschreibung'] ?? null,
|
'description' => $_POST['description'] ?? null,
|
||||||
'standortid' => $_POST['standortid'] ?? null,
|
|
||||||
'datum_von' => $_POST['datum_von'] ?? null,
|
|
||||||
'datum_bis' => $_POST['datum_bis'] ?? null,
|
|
||||||
'max_tickets' => $_POST['max_tickets'] ?? null,
|
'max_tickets' => $_POST['max_tickets'] ?? null,
|
||||||
'preis' => $_POST['preis'] ?? null
|
'ticket_price' => $_POST['ticket_price'] ?? null
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->model->createEvent($data);
|
$this->model->createEvent($data);
|
||||||
@ -38,21 +38,21 @@ class EventController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function editEventForm() {
|
public function editEventForm() {
|
||||||
$id = $_GET['ausstellungid'];
|
$id = $_GET['event_id'];
|
||||||
$event = $this->model->getEvent($id);
|
$event = $this->model->getEvent($id);
|
||||||
$this->view->setVars(['event' => $event]);
|
$this->view->setVars(['event' => $event]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateEvent($id, $data) {
|
public function updateEvent($id, $data) {
|
||||||
$id = $_POST['ausstellungid'];
|
$id = $_POST['event_id'];
|
||||||
$data = [
|
$data = [
|
||||||
'standortid' => $_POST['standortid'] ?? null,
|
'location_id' => $_POST['location_id'] ?? null,
|
||||||
'datum_von' => $_POST['datum_von'] ?? null,
|
'start_date' => $_POST['start_date'] ?? null,
|
||||||
'datum_bis' => $_POST['datum_bis'] ?? null,
|
'end_date' => $_POST['end_date'] ?? null,
|
||||||
'name' => $_POST['name'] ?? null,
|
'name' => $_POST['name'] ?? null,
|
||||||
'beschreibung' => $_POST['beschreibung'] ?? null,
|
'description' => $_POST['description'] ?? null,
|
||||||
'max_tickets' => $_POST['max_tickets'] ?? null,
|
'max_tickets' => $_POST['max_tickets'] ?? null,
|
||||||
'preis' => $_POST['preis'] ?? null
|
'ticket_price' => $_POST['ticket_price'] ?? null
|
||||||
];
|
];
|
||||||
$this->model->updateEvent($id, $data);
|
$this->model->updateEvent($id, $data);
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Blog\Controller;
|
|
||||||
|
|
||||||
use Blog\Model\GutscheinModel;
|
|
||||||
|
|
||||||
class GutscheinController {
|
|
||||||
|
|
||||||
private $model;
|
|
||||||
private $view;
|
|
||||||
|
|
||||||
public function __construct($view) {
|
|
||||||
$this->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,
|
|
||||||
'ausstellungid' => $_POST['ausstellungid'] ?? null,
|
|
||||||
'gueltigkeit' => $_POST['gueltigkeit'] ?? 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,
|
|
||||||
'ausstellungid' => $_POST['ausstellungid'] ?? null,
|
|
||||||
'gueltigkeit' => $_POST['gueltigkeit'] ?? null
|
|
||||||
];
|
|
||||||
$this->model->updateGutschein($id, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteGutschein() {
|
|
||||||
$id = $_GET['gutscheinid'] ?? null;
|
|
||||||
$this->model->deleteGutschein($id);
|
|
||||||
}
|
|
||||||
}
|
|
61
Controller/LocationController.php
Normal file
61
Controller/LocationController.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Controller;
|
||||||
|
|
||||||
|
use Blog\Model\LocationModel;
|
||||||
|
|
||||||
|
class LocationController {
|
||||||
|
|
||||||
|
private $model;
|
||||||
|
private $view;
|
||||||
|
|
||||||
|
public function __construct($view) {
|
||||||
|
$this->model = new LocationModel();
|
||||||
|
$this->view = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showLocations() {
|
||||||
|
$locations = $this->model->getLocations();
|
||||||
|
$this->view->setVars(['locations' => $locations]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createLocation() {
|
||||||
|
$data = [
|
||||||
|
'street' => $_POST['street'],
|
||||||
|
'house_number' => $_POST['house_number'],
|
||||||
|
'postal_code' => $_POST['postal_code'],
|
||||||
|
'city' => $_POST['city'],
|
||||||
|
'country' => $_POST['country'],
|
||||||
|
'phone' => $_POST['phone'],
|
||||||
|
'email' => $_POST['email']
|
||||||
|
];
|
||||||
|
$result = $this->model->createLocation($data);
|
||||||
|
$this->view->setVars(['location' => $result]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editLocationForm() {
|
||||||
|
$id = $_GET['location_id'];
|
||||||
|
$location = $this->model->getLocation($id);
|
||||||
|
$this->view->setVars(['location' => $location]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateLocation() {
|
||||||
|
$data = [
|
||||||
|
'street' => $_POST['street'],
|
||||||
|
'house_number' => $_POST['house_number'],
|
||||||
|
'postal_code' => $_POST['postal_code'],
|
||||||
|
'city' => $_POST['city'],
|
||||||
|
'country' => $_POST['country'],
|
||||||
|
'phone' => $_POST['phone'],
|
||||||
|
'email' => $_POST['email']
|
||||||
|
];
|
||||||
|
$location_id = $_POST['location_id'];
|
||||||
|
$result = $this->model->updateLocation($location_id, $data);
|
||||||
|
$this->view->setVars(['location' => $result]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteLocation() {
|
||||||
|
$id = $_GET['location_id'] ?? null;
|
||||||
|
$this->model->deleteLocation($id);
|
||||||
|
}
|
||||||
|
}
|
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Blog\Controller;
|
|
||||||
|
|
||||||
use Blog\Model\StandortModel;
|
|
||||||
|
|
||||||
class StandortController {
|
|
||||||
|
|
||||||
private $model;
|
|
||||||
private $view;
|
|
||||||
|
|
||||||
public function __construct($view) {
|
|
||||||
$this->model = new StandortModel();
|
|
||||||
$this->view = $view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showStandorte() {
|
|
||||||
$standorte = $this->model->getStandorte();
|
|
||||||
$this->view->setVars(['standorte' => $standorte]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createStandort() {
|
|
||||||
$data = [
|
|
||||||
'strasse' => $_POST['strasse'],
|
|
||||||
'hausnr' => $_POST['hausnr'],
|
|
||||||
'plz' => $_POST['plz'],
|
|
||||||
'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() {
|
|
||||||
$data = [
|
|
||||||
'strasse' => $_POST['strasse'],
|
|
||||||
'hausnr' => $_POST['hausnr'],
|
|
||||||
'plz' => $_POST['plz'],
|
|
||||||
'ort' => $_POST['ort'],
|
|
||||||
'land' => $_POST['land'],
|
|
||||||
'tel' => $_POST['tel'],
|
|
||||||
'email' => $_POST['email']
|
|
||||||
];
|
|
||||||
$standortid = $_POST['standortid'];
|
|
||||||
$erg = $this->model->updateStandort($standortid, $data);
|
|
||||||
$this->view->setVars(['standort' => $erg]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteStandort() {
|
|
||||||
$id = $_GET['standortid'] ?? null;
|
|
||||||
$this->model->deleteStandort($id);
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,13 +21,13 @@ class TicketController {
|
|||||||
|
|
||||||
public function buyTicket() {
|
public function buyTicket() {
|
||||||
$data = [
|
$data = [
|
||||||
'userid' => $_POST['userid'],
|
'user_id' => $_POST['user_id'] ?? null,
|
||||||
'ausstellungid' => $_POST['ausstellungid'],
|
'event_id' => $_POST['event_id'] ?? null,
|
||||||
'kaufdatum' => date('Y-m-d'),
|
'price' => $_POST['price'] ?? null
|
||||||
'gueltigkeit' => $_POST['gueltigkeit']
|
|
||||||
];
|
];
|
||||||
$erg = $this->ticketModel->buyTicket($data);
|
|
||||||
$this->view->setVars(['ticket' => $erg]);
|
$result = $this->ticketModel->createTicket($data);
|
||||||
|
$this->view->setVars(['ticket' => $result]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteTicket() {
|
public function deleteTicket() {
|
||||||
|
57
Controller/VoucherController.php
Normal file
57
Controller/VoucherController.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Controller;
|
||||||
|
|
||||||
|
use Blog\Model\VoucherModel;
|
||||||
|
|
||||||
|
class VoucherController {
|
||||||
|
|
||||||
|
private $model;
|
||||||
|
private $view;
|
||||||
|
|
||||||
|
public function __construct($view) {
|
||||||
|
$this->model = new VoucherModel();
|
||||||
|
$this->view = $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showVouchers() {
|
||||||
|
$vouchers = $this->model->getVouchers();
|
||||||
|
$this->view->setVars(['vouchers' => $vouchers]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createVoucher() {
|
||||||
|
$data = [
|
||||||
|
'code' => $_POST['code'] ?? null,
|
||||||
|
'discount' => $_POST['discount'] ?? null,
|
||||||
|
'event_id' => $_POST['event_id'] ?? null,
|
||||||
|
'valid_until' => $_POST['valid_until'] ?? null
|
||||||
|
];
|
||||||
|
$result = $this->model->createVoucher($data);
|
||||||
|
$this->view->setVars(['voucher' => $result]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editVoucherForm() {
|
||||||
|
$id = $_GET['voucher_id'];
|
||||||
|
if ($id) {
|
||||||
|
$voucher = $this->model->getVoucher($id);
|
||||||
|
$this->view->setVars(['voucher' => $voucher]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateVoucher() {
|
||||||
|
$id = $_POST['voucher_id'];
|
||||||
|
$data = [
|
||||||
|
'code' => $_POST['code'] ?? null,
|
||||||
|
'discount' => $_POST['discount'] ?? null,
|
||||||
|
'event_id' => $_POST['event_id'] ?? null,
|
||||||
|
'valid_until' => $_POST['valid_until'] ?? null
|
||||||
|
];
|
||||||
|
$this->model->updateVoucher($id, $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteVoucher() {
|
||||||
|
$id = $_GET['voucher_id'] ?? null;
|
||||||
|
$this->model->deleteVoucher($id);
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ class AuthModel extends Database
|
|||||||
public function login(string $email, string $password)
|
public function login(string $email, string $password)
|
||||||
{
|
{
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT email, password, validUntil FROM user WHERE email = :email";
|
$sql = "SELECT email, password, valid_until FROM user WHERE email = :email";
|
||||||
$params = [":email" => $email];
|
$params = [":email" => $email];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -33,7 +33,7 @@ class AuthModel extends Database
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
$validUntil = new DateTime($user['validUntil']);
|
$validUntil = new DateTime($user['valid_until']);
|
||||||
|
|
||||||
if ($now > $validUntil) {
|
if ($now > $validUntil) {
|
||||||
return "Ihr Passwort ist abgelaufen. Bitte setzen Sie ein neues über \"Passwort vergessen\".";
|
return "Ihr Passwort ist abgelaufen. Bitte setzen Sie ein neues über \"Passwort vergessen\".";
|
||||||
@ -52,8 +52,8 @@ class AuthModel extends Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
$requiredFields = [
|
$requiredFields = [
|
||||||
'email', 'password', 'straße', 'hausnr', 'ort', 'postleitzahl',
|
'email', 'password', 'street', 'house_number', 'city', 'postal_code',
|
||||||
'land', 'vorname', 'nachname', 'tel'
|
'country', 'first_name', 'last_name', 'phone'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($requiredFields as $field) {
|
foreach ($requiredFields as $field) {
|
||||||
@ -77,21 +77,21 @@ class AuthModel extends Database
|
|||||||
|
|
||||||
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$sql = "INSERT INTO user (email, password, straße, hausnr, ort, postleitzahl, land,vorname, nachname, tel, isAdmin)
|
$sql = "INSERT INTO user (email, password, street, house_number, city, postal_code, country, first_name, last_name, phone, is_admin)
|
||||||
VALUES (:email, :password, :straße, :hausnr, :ort, :postleitzahl, :land,:vorname, :nachname, :tel, :isAdmin)";
|
VALUES (:email, :password, :street, :house_number, :city, :postal_code, :country, :first_name, :last_name, :phone, :is_admin)";
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
':email' => $data['email'],
|
':email' => $data['email'],
|
||||||
':password' => $hashedPassword,
|
':password' => $hashedPassword,
|
||||||
':straße' => $data['straße'],
|
':street' => $data['street'],
|
||||||
':hausnr' => $data['hausnr'],
|
':house_number' => $data['house_number'],
|
||||||
':ort' => $data['ort'],
|
':city' => $data['city'],
|
||||||
':postleitzahl'=> $data['postleitzahl'],
|
':postal_code'=> $data['postal_code'],
|
||||||
':land'=> $data['land'],
|
':country'=> $data['country'],
|
||||||
':vorname' => $data['vorname'],
|
':first_name' => $data['first_name'],
|
||||||
':nachname'=> $data['nachname'],
|
':last_name'=> $data['last_name'],
|
||||||
':tel' => $data['tel'],
|
':phone' => $data['phone'],
|
||||||
':isAdmin' => $data['isAdmin'] ? 1 : 0,
|
':is_admin' => $data['is_admin'] ? 1 : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -109,7 +109,7 @@ class AuthModel extends Database
|
|||||||
try {
|
try {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
|
|
||||||
$sql = "SELECT userid FROM user WHERE email = :email";
|
$sql = "SELECT user_id FROM user WHERE email = :email";
|
||||||
$params = [':email' => $email];
|
$params = [':email' => $email];
|
||||||
|
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
@ -163,15 +163,16 @@ class AuthModel extends Database
|
|||||||
|
|
||||||
|
|
||||||
$sql = "UPDATE user
|
$sql = "UPDATE user
|
||||||
SET password = :password, validUntil = :validUntil
|
SET password = :password, valid_until = :valid_until
|
||||||
WHERE email = :email";
|
WHERE email = :email";
|
||||||
|
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
return $stmt->execute([
|
$params = [
|
||||||
':email' => $email,
|
':email' => $email,
|
||||||
':password' => $hashedPassword,
|
':password' => $hashedPassword,
|
||||||
':validUntil' => $validUntil
|
':valid_until' => $validUntil
|
||||||
]);
|
];
|
||||||
|
return $stmt->execute($params);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der Daten.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der Daten.", $e);
|
||||||
die;
|
die;
|
||||||
@ -192,16 +193,16 @@ class AuthModel extends Database
|
|||||||
}
|
}
|
||||||
$hashedPassword = password_hash($newpw, PASSWORD_DEFAULT);
|
$hashedPassword = password_hash($newpw, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$sql = "INSERT INTO user (email, password)
|
$sql = "UPDATE user SET password = :password WHERE email = :email";
|
||||||
VALUES (:email, :password)";
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
return $stmt->execute([
|
$params = [
|
||||||
':email' => $email,
|
':email' => $email,
|
||||||
':password' => $hashedPassword,
|
':password' => $hashedPassword,
|
||||||
]);
|
];
|
||||||
|
return $stmt->execute($params);
|
||||||
} 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;
|
||||||
|
@ -8,11 +8,11 @@ class EventModel extends Database {
|
|||||||
|
|
||||||
public function getEvents() {
|
public function getEvents() {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM ausstellung ORDER BY datum_von DESC;";
|
$sql = "SELECT * FROM event ORDER BY start_date ASC;";
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$sth->execute();
|
$stmt->execute();
|
||||||
return $sth->fetchAll(\PDO::FETCH_ASSOC);
|
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Lesen der Events.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Lesen der Events.", $e);
|
||||||
die;
|
die;
|
||||||
@ -21,11 +21,12 @@ class EventModel extends Database {
|
|||||||
|
|
||||||
public function getEvent($id) {
|
public function getEvent($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM ausstellung WHERE ausstellungid = :id;";
|
$sql = "SELECT * FROM event WHERE event_id = :event_id;";
|
||||||
|
$params = [":event_id" => $id];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$sth->execute([":id" => $id]);
|
$stmt->execute($params);
|
||||||
return $sth->fetch(\PDO::FETCH_ASSOC);
|
return $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Lesen des Events.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Lesen des Events.", $e);
|
||||||
die;
|
die;
|
||||||
@ -34,20 +35,29 @@ class EventModel extends Database {
|
|||||||
|
|
||||||
public function updateEvent($id, $data) {
|
public function updateEvent($id, $data) {
|
||||||
$pdo = $this->linkDB();
|
$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;";
|
$sql = "UPDATE event SET
|
||||||
|
name = :name,
|
||||||
|
description = :description,
|
||||||
|
location_id = :location_id,
|
||||||
|
start_date = :start_date,
|
||||||
|
end_date = :end_date,
|
||||||
|
max_tickets = :max_tickets,
|
||||||
|
ticket_price = :ticket_price
|
||||||
|
WHERE event_id = :event_id;";
|
||||||
$params = [
|
$params = [
|
||||||
":standortid" => $data['standortid'],
|
|
||||||
":datum_von" => $data['datum_von'],
|
|
||||||
":datum_bis" => $data['datum_bis'],
|
|
||||||
":name" => $data['name'],
|
":name" => $data['name'],
|
||||||
":beschreibung" => $data['beschreibung'],
|
":description" => $data['description'],
|
||||||
|
":location_id" => $data['location_id'],
|
||||||
|
":start_date" => $data['start_date'],
|
||||||
|
":end_date" => $data['end_date'],
|
||||||
":max_tickets" => $data['max_tickets'],
|
":max_tickets" => $data['max_tickets'],
|
||||||
":preis" => $data['preis'],
|
":ticket_price" => $data['ticket_price'],
|
||||||
":id" => $id
|
":event_id" => $id
|
||||||
];
|
];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute($params);
|
$sth->execute($params);
|
||||||
|
return $sth;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Events.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Events.", $e);
|
||||||
die;
|
die;
|
||||||
@ -56,32 +66,35 @@ class EventModel extends Database {
|
|||||||
|
|
||||||
public function createEvent($data) {
|
public function createEvent($data) {
|
||||||
$pdo = $this->linkDB();
|
$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);";
|
$sql = "INSERT INTO event (name, description, location_id, start_date, end_date, max_tickets, ticket_price)
|
||||||
|
VALUES (:name, :description, :location_id, :start_date, :end_date, :max_tickets, :ticket_price);";
|
||||||
$params = [
|
$params = [
|
||||||
":standortid" => $data['standortid'],
|
|
||||||
":datum_von" => $data['datum_von'],
|
|
||||||
":datum_bis" => $data['datum_bis'],
|
|
||||||
":name" => $data['name'],
|
":name" => $data['name'],
|
||||||
":beschreibung" => $data['beschreibung'],
|
":description" => $data['description'],
|
||||||
|
":location_id" => $data['location_id'],
|
||||||
|
":start_date" => $data['start_date'],
|
||||||
|
":end_date" => $data['end_date'],
|
||||||
":max_tickets" => $data['max_tickets'],
|
":max_tickets" => $data['max_tickets'],
|
||||||
":preis" => $data['preis']
|
":ticket_price" => $data['ticket_price']
|
||||||
];
|
];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute($params);
|
$sth->execute($params);
|
||||||
return $sth;
|
return $sth;
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Erstellen des Events.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Schreiben des Events.", $e);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteEvent($id) {
|
public function deleteEvent($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "DELETE FROM ausstellung WHERE ausstellungid = :id;";
|
$sql = "DELETE FROM event WHERE event_id = :event_id;";
|
||||||
|
$params = [":event_id" => $id];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$sth->execute([":id" => $id]);
|
$stmt->execute($params);
|
||||||
|
return $stmt->rowCount();
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Löschen des Events.", $e);
|
new \Blog\Library\ErrorMsg("Fehler beim Löschen des Events.", $e);
|
||||||
die;
|
die;
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Blog\Model;
|
|
||||||
|
|
||||||
use PDOException;
|
|
||||||
|
|
||||||
class GutscheinModel extends Database {
|
|
||||||
|
|
||||||
public function getGutscheine() {
|
|
||||||
$pdo = $this->linkDB();
|
|
||||||
$sql = "SELECT * FROM gutschein ORDER BY gueltigkeit 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, ausstellungid, gueltigkeit) VALUES (:code, :rabatt, :ausstellungid, :gueltigkeit);";
|
|
||||||
$params = [
|
|
||||||
":code" => $data['code'],
|
|
||||||
":rabatt" => $data['rabatt'],
|
|
||||||
":ausstellungid" => $data['ausstellungid'],
|
|
||||||
":gueltigkeit" => $data['gueltigkeit']
|
|
||||||
];
|
|
||||||
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, ausstellungid = :ausstellungid, gueltigkeit = :gueltigkeit WHERE gutscheinid = :id;";
|
|
||||||
$params = [
|
|
||||||
":code" => $data['code'],
|
|
||||||
":rabatt" => $data['rabatt'],
|
|
||||||
":ausstellungid" => $data['ausstellungid'],
|
|
||||||
":gueltigkeit" => $data['gueltigkeit'],
|
|
||||||
":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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
namespace Blog\Model;
|
namespace Blog\Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
|
||||||
class StandortModel extends Database {
|
class LocationModel extends Database {
|
||||||
|
|
||||||
public function getStandorte() {
|
public function getLocations() {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM Standort ORDER BY standortid ASC;";
|
$sql = "SELECT * FROM location ORDER BY location_id ASC;";
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
@ -19,10 +20,10 @@ class StandortModel extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStandort($standortid) {
|
public function getLocation($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM Standort WHERE standortid = :standortid;";
|
$sql = "SELECT * FROM location WHERE location_id = :location_id;";
|
||||||
$params = [":standortid" => $standortid];
|
$params = [":location_id" => $id];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute($params);
|
$sth->execute($params);
|
||||||
@ -33,17 +34,17 @@ class StandortModel extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createStandort($data) {
|
public function createLocation($data) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "INSERT INTO Standort (strasse, hausnr, plz, ort, land, tel, email)
|
$sql = "INSERT INTO location (street, house_number, postal_code, city, country, phone, email)
|
||||||
VALUES (:strasse, :hausnr, :plz, :ort, :land, :tel, :email);";
|
VALUES (:street, :house_number, :postal_code, :city, :country, :phone, :email);";
|
||||||
$params = [
|
$params = [
|
||||||
":strasse" => $data['strasse'],
|
":street" => $data['street'],
|
||||||
":hausnr" => $data['hausnr'],
|
":house_number" => $data['house_number'],
|
||||||
":plz" => $data['plz'],
|
":postal_code" => $data['postal_code'],
|
||||||
":ort" => $data['ort'],
|
":city" => $data['city'],
|
||||||
":land" => $data['land'],
|
":country" => $data['country'],
|
||||||
":tel" => $data['tel'],
|
":phone" => $data['phone'],
|
||||||
":email" => $data['email']
|
":email" => $data['email']
|
||||||
];
|
];
|
||||||
try {
|
try {
|
||||||
@ -56,26 +57,26 @@ class StandortModel extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateStandort($standortid, $data) {
|
public function updateLocation($id, $data) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "UPDATE Standort SET
|
$sql = "UPDATE location SET
|
||||||
strasse = :strasse,
|
street = :street,
|
||||||
hausnr = :hausnr,
|
house_number = :house_number,
|
||||||
plz = :plz,
|
postal_code = :postal_code,
|
||||||
ort = :ort,
|
city = :city,
|
||||||
land = :land,
|
country = :country,
|
||||||
tel = :tel,
|
phone = :phone,
|
||||||
email = :email
|
email = :email
|
||||||
WHERE standortid = :standortid;";
|
WHERE location_id = :location_id;";
|
||||||
$params = [
|
$params = [
|
||||||
":strasse" => $data['strasse'],
|
":street" => $data['street'],
|
||||||
":hausnr" => $data['hausnr'],
|
":house_number" => $data['house_number'],
|
||||||
":plz" => $data['plz'],
|
":postal_code" => $data['postal_code'],
|
||||||
":ort" => $data['ort'],
|
":city" => $data['city'],
|
||||||
":land" => $data['land'],
|
":country" => $data['country'],
|
||||||
":tel" => $data['tel'],
|
":phone" => $data['phone'],
|
||||||
":email" => $data['email'],
|
":email" => $data['email'],
|
||||||
":standortid" => $standortid
|
":location_id" => $id
|
||||||
];
|
];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
@ -87,10 +88,10 @@ class StandortModel extends Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteStandort($standortid) {
|
public function deleteLocation($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "DELETE FROM Standort WHERE standortid = :standortid;";
|
$sql = "DELETE FROM location WHERE location_id = :location_id;";
|
||||||
$params = [":standortid" => $standortid];
|
$params = [":location_id" => $id];
|
||||||
try {
|
try {
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute($params);
|
$sth->execute($params);
|
@ -3,83 +3,58 @@
|
|||||||
namespace Blog\Model;
|
namespace Blog\Model;
|
||||||
|
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
class NewsModel extends Database {
|
class NewsModel extends Database {
|
||||||
|
|
||||||
public function getNewsById($newsId) {
|
public function getNewsById($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM news WHERE newsid = :newsid;";
|
$sql = "SELECT * FROM news WHERE news_id = :news_id;";
|
||||||
$params = [":newsid" => $newsId];
|
$stmt = $pdo->prepare($sql);
|
||||||
try {
|
$params = [':news_id' => $id];
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt->execute($params);
|
||||||
$sth->execute($params);
|
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
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) {
|
public function updateNews($id, $data) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "UPDATE news SET name = :name, beschreibung = :beschreibung, datum = :datum WHERE newsid = :newsid;";
|
$sql = "UPDATE news SET name = :name, description = :description, date = :date WHERE news_id = :news_id;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
$params = [
|
$params = [
|
||||||
":name" => $news['titel'],
|
':name' => $data['name'],
|
||||||
":beschreibung" => $news['inhalt'],
|
':description' => $data['description'],
|
||||||
":datum" => $news['datum'],
|
':date' => $data['date'],
|
||||||
":newsid" => $newsId
|
':news_id' => $id
|
||||||
];
|
];
|
||||||
try {
|
return $stmt->execute($params);
|
||||||
$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() {
|
public function getNews() {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM news ORDER BY datum DESC;";
|
$sql = "SELECT * FROM news ORDER BY date DESC;";
|
||||||
try {
|
$stmt = $pdo->prepare($sql);
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt->execute();
|
||||||
$sth->execute();
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
return $sth->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Lesen der News.", $e);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createNews($news) {
|
public function createNews($data) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "INSERT INTO news (name, beschreibung, datum) VALUES (:name, :beschreibung, :datum);";
|
$sql = "INSERT INTO news (name, description, date) VALUES (:name, :description, :date);";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
$params = [
|
$params = [
|
||||||
":name" => $news['titel'],
|
':name' => $data['name'],
|
||||||
":beschreibung" => $news['inhalt'],
|
':description' => $data['description'],
|
||||||
":datum" => $news['datum']
|
':date' => $data['date']
|
||||||
];
|
];
|
||||||
try {
|
$stmt->execute($params);
|
||||||
$sth = $pdo->prepare($sql);
|
return $pdo->lastInsertId();
|
||||||
$sth->execute($params);
|
|
||||||
return $sth;
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Schreiben der News.", $e);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteNews($newsId) {
|
public function deleteNews($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "DELETE FROM news WHERE newsid = :newsid;";
|
$sql = "DELETE FROM news WHERE news_id = :news_id;";
|
||||||
$params = [":newsid" => $newsId];
|
$stmt = $pdo->prepare($sql);
|
||||||
try {
|
$params = [':news_id' => $id];
|
||||||
$sth = $pdo->prepare($sql);
|
return $stmt->execute($params);
|
||||||
$sth->execute($params);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Löschen der News.", $e);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,70 +3,72 @@
|
|||||||
namespace Blog\Model;
|
namespace Blog\Model;
|
||||||
|
|
||||||
use PDOException;
|
use PDOException;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
class TicketModel extends Database {
|
class TicketModel extends Database {
|
||||||
|
|
||||||
public function getTickets() {
|
public function getTickets() {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT * FROM Ticket ORDER BY ticketid ASC;";
|
$sql = "SELECT * FROM ticket ORDER BY ticket_id ASC;";
|
||||||
try {
|
$stmt = $pdo->prepare($sql);
|
||||||
$sth = $pdo->prepare($sql);
|
$stmt->execute();
|
||||||
$sth->execute();
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
return $sth->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Lesen der Tickets.", $e);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buyTicket($data) {
|
public function buyTicket($data) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "INSERT INTO Ticket (userid, ausstellungid, kaufdatum, gueltigkeit)
|
$sql = "INSERT INTO ticket (user_id, event_id, purchase_date, valid_until)
|
||||||
VALUES (:userid, :ausstellungid, :kaufdatum, :gueltigkeit);";
|
VALUES (:user_id, :event_id, :purchase_date, :valid_until)";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
$params = [
|
$params = [
|
||||||
":userid" => $data['userid'],
|
':user_id' => $data['user_id'],
|
||||||
":ausstellungid" => $data['ausstellungid'],
|
':event_id' => $data['event_id'],
|
||||||
":kaufdatum" => $data['kaufdatum'],
|
':purchase_date' => $data['purchase_date'],
|
||||||
":gueltigkeit" => $data['gueltigkeit']
|
':valid_until' => $data['valid_until']
|
||||||
];
|
];
|
||||||
try {
|
$stmt->execute($params);
|
||||||
$sth = $pdo->prepare($sql);
|
return $pdo->lastInsertId();
|
||||||
$sth->execute($params);
|
|
||||||
return $pdo->lastInsertId();
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Kauf des Tickets.", $e);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasTicket($userid, $ausstellungid) {
|
public function checkTicketExists($userid, $ausstellungid) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "SELECT COUNT(*) as count FROM Ticket WHERE userid = :userid AND ausstellungid = :ausstellungid;";
|
$sql = "SELECT COUNT(*) as count FROM ticket WHERE user_id = :user_id AND event_id = :event_id;";
|
||||||
$params = [
|
$stmt = $pdo->prepare($sql);
|
||||||
":userid" => $userid,
|
$params = [':user_id' => $userid, ':event_id' => $ausstellungid];
|
||||||
":ausstellungid" => $ausstellungid
|
$stmt->execute($params);
|
||||||
];
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
try {
|
return $result['count'] > 0;
|
||||||
$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) {
|
public function deleteTicket($id) {
|
||||||
$pdo = $this->linkDB();
|
$pdo = $this->linkDB();
|
||||||
$sql = "DELETE FROM Ticket WHERE ticketid = :ticketid;";
|
$sql = "DELETE FROM ticket WHERE ticket_id = :ticket_id;";
|
||||||
$params = [":ticketid" => $ticketid];
|
$stmt = $pdo->prepare($sql);
|
||||||
try {
|
$params = [':ticket_id' => $id];
|
||||||
$sth = $pdo->prepare($sql);
|
return $stmt->execute($params);
|
||||||
$sth->execute($params);
|
}
|
||||||
return $sth->rowCount();
|
|
||||||
} catch (PDOException $e) {
|
public function createTicket($data) {
|
||||||
new \Blog\Library\ErrorMsg("Fehler beim Löschen des Tickets.", $e);
|
$pdo = $this->linkDB();
|
||||||
die;
|
$sql = "INSERT INTO ticket (event_id, user_id, price) VALUES (:event_id, :user_id, :price);";
|
||||||
}
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [
|
||||||
|
':event_id' => $data['event_id'],
|
||||||
|
':user_id' => $data['user_id'],
|
||||||
|
':price' => $data['price']
|
||||||
|
];
|
||||||
|
return $stmt->execute($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTicketsByUser($userId) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT t.*, e.name as event_name, e.start_date, e.end_date
|
||||||
|
FROM ticket t
|
||||||
|
JOIN event e ON t.event_id = e.event_id
|
||||||
|
WHERE t.user_id = :user_id;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [':user_id' => $userId];
|
||||||
|
$stmt->execute($params);
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
}
|
}
|
62
Model/VoucherModel.php
Normal file
62
Model/VoucherModel.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Blog\Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
|
class VoucherModel extends Database {
|
||||||
|
|
||||||
|
public function getVouchers() {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT * FROM voucher ORDER BY valid_until DESC;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVoucher($id) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "SELECT * FROM voucher WHERE voucher_id = :id;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [':id' => $id];
|
||||||
|
$stmt->execute($params);
|
||||||
|
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createVoucher($data) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "INSERT INTO voucher (code, discount, event_id, valid_until) VALUES (:code, :discount, :event_id, :valid_until);";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [
|
||||||
|
':code' => $data['code'],
|
||||||
|
':discount' => $data['discount'],
|
||||||
|
':event_id' => $data['event_id'],
|
||||||
|
':valid_until' => $data['valid_until']
|
||||||
|
];
|
||||||
|
$stmt->execute($params);
|
||||||
|
return $pdo->lastInsertId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateVoucher($id, $data) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "UPDATE voucher SET code = :code, discount = :discount, event_id = :event_id, valid_until = :valid_until WHERE voucher_id = :id;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [
|
||||||
|
':code' => $data['code'],
|
||||||
|
':discount' => $data['discount'],
|
||||||
|
':event_id' => $data['event_id'],
|
||||||
|
':valid_until' => $data['valid_until'],
|
||||||
|
':id' => $id
|
||||||
|
];
|
||||||
|
return $stmt->execute($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteVoucher($id) {
|
||||||
|
$pdo = $this->linkDB();
|
||||||
|
$sql = "DELETE FROM voucher WHERE voucher_id = :id;";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$params = [':id' => $id];
|
||||||
|
return $stmt->execute($params);
|
||||||
|
}
|
||||||
|
}
|
@ -44,7 +44,7 @@ include dirname(__DIR__) . '/header.phtml';
|
|||||||
<button class="button-register" type="submit">Registrieren</button>
|
<button class="button-register" type="submit">Registrieren</button>
|
||||||
</form>
|
</form>
|
||||||
<div style="text-align:center; margin-top: 1.5em;">
|
<div style="text-align:center; margin-top: 1.5em;">
|
||||||
<a href="?controller=Auth&do=showAuthForm" class="login-link">Bereits registriert? Hier einloggen</a>
|
<a href="?controller=Auth&do=showLoginForm" class="login-link">Bereits registriert? Hier einloggen</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,7 +3,7 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="msg">
|
<div class="msg">
|
||||||
<p>Das Event "<?php echo $name?>" wurde erfolgreich erstellt!</p>
|
<p>Das Event "<?php echo $event['name']?>" wurde erfolgreich erstellt!</p>
|
||||||
<a href="?controller=Event&do=showEvents">Weiter</a>
|
<a href="?controller=Event&do=showEvents">Weiter</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
include dirname(__DIR__).'/header.phtml';
|
include dirname(__DIR__).'/header.phtml';
|
||||||
?>
|
?>
|
||||||
<h2>Alle Ausstellungen</h2>
|
<h2>Alle Events</h2>
|
||||||
<?php if (!empty($events)): ?>
|
<?php if (!empty($events)): ?>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@ -17,16 +17,16 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
<?php foreach ($events as $event): ?>
|
<?php foreach ($events as $event): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo htmlspecialchars($event['name']); ?></td>
|
<td><?php echo htmlspecialchars($event['name']); ?></td>
|
||||||
<td><?php echo nl2br(htmlspecialchars($event['beschreibung'])); ?></td>
|
<td><?php echo nl2br(htmlspecialchars($event['description'])); ?></td>
|
||||||
<td><?php echo date('d.m.Y', strtotime($event['datum_von'])); ?></td>
|
<td><?php echo date('d.m.Y', strtotime($event['start_date'])); ?></td>
|
||||||
<td><?php echo date('d.m.Y', strtotime($event['datum_bis'])); ?></td>
|
<td><?php echo date('d.m.Y', strtotime($event['end_date'])); ?></td>
|
||||||
<td><?php echo (int) $event['max_tickets']; ?></td>
|
<td><?php echo (int) $event['max_tickets']; ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p>Derzeit sind keine Ausstellungen verfügbar.</p>
|
<p>Derzeit sind keine Events verfügbar.</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
include dirname(__DIR__).'/footer.phtml';
|
include dirname(__DIR__).'/footer.phtml';
|
||||||
|
@ -3,7 +3,7 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="msg">
|
<div class="msg">
|
||||||
<p>Das Event mit der ID "<?php echo $ausstellungid?>" wurde erfolgreich bearbeitet!</p>
|
<p>Das Event mit der ID "<?php echo $event_id?>" wurde erfolgreich bearbeitet!</p>
|
||||||
<a href="?controller=Event&do=showEvents">Weiter</a>
|
<a href="?controller=Event&do=showEvents">Weiter</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
include dirname(__DIR__).'/header.phtml';
|
|
||||||
?>
|
|
||||||
<h2>Alle Gutscheine</h2>
|
|
||||||
<a href="?controller=Gutschein&do=createGutscheinForm">Neuen Gutschein anlegen</a>
|
|
||||||
<?php if (!empty($gutscheine)): ?>
|
|
||||||
<table border="1" cellpadding="8" cellspacing="0">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Code</th>
|
|
||||||
<th>Rabatt (%)</th>
|
|
||||||
<th>Event-ID</th>
|
|
||||||
<th>Gültig bis</th>
|
|
||||||
<th>Aktionen</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($gutscheine as $g): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo htmlspecialchars($g['code']); ?></td>
|
|
||||||
<td><?php echo (int)$g['rabatt']; ?></td>
|
|
||||||
<td><?php echo (int)$g['ausstellungid']; ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($g['gueltigkeit']); ?></td>
|
|
||||||
<td>
|
|
||||||
<a href="?controller=Gutschein&action=editGutscheinForm&id=<?php echo $g['gutscheinid']; ?>">Bearbeiten</a> |
|
|
||||||
<a href="?controller=Gutschein&action=deleteGutschein&id=<?php echo $g['gutscheinid']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<?php else: ?>
|
|
||||||
<p>Keine Gutscheine vorhanden.</p>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php
|
|
||||||
include dirname(__DIR__).'/footer.phtml';
|
|
||||||
?>
|
|
@ -6,7 +6,7 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Titel</th>
|
||||||
<th>Beschreibung</th>
|
<th>Beschreibung</th>
|
||||||
<th>Datum</th>
|
<th>Datum</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -15,8 +15,8 @@ include dirname(__DIR__).'/header.phtml';
|
|||||||
<?php foreach ($news as $item): ?>
|
<?php foreach ($news as $item): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo htmlspecialchars($item['name']); ?></td>
|
<td><?php echo htmlspecialchars($item['name']); ?></td>
|
||||||
<td><?php echo nl2br(htmlspecialchars($item['beschreibung'])); ?></td>
|
<td><?php echo nl2br(htmlspecialchars($item['description'])); ?></td>
|
||||||
<td><?php echo date('d.m.Y', strtotime($item['datum'])); ?></td>
|
<td><?php echo date('d.m.Y', strtotime($item['date'])); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
37
Views/Voucher/showVouchers.phtml
Normal file
37
Views/Voucher/showVouchers.phtml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
include dirname(__DIR__).'/header.phtml';
|
||||||
|
?>
|
||||||
|
<h2>Alle Gutscheine</h2>
|
||||||
|
<a href="?controller=Voucher&do=createVoucherForm">Neuen Gutschein anlegen</a>
|
||||||
|
<?php if (!empty($vouchers)): ?>
|
||||||
|
<table border="1" cellpadding="8" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Code</th>
|
||||||
|
<th>Rabatt (%)</th>
|
||||||
|
<th>Event-ID</th>
|
||||||
|
<th>Gültig bis</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($vouchers as $v): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($v['code']); ?></td>
|
||||||
|
<td><?php echo (int)$v['discount']; ?></td>
|
||||||
|
<td><?php echo (int)$v['event_id']; ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($v['valid_until']); ?></td>
|
||||||
|
<td>
|
||||||
|
<a href="?controller=Voucher&do=editVoucherForm&id=<?php echo $v['voucher_id']; ?>">Bearbeiten</a> |
|
||||||
|
<a href="?controller=Voucher&do=deleteVoucher&id=<?php echo $v['voucher_id']; ?>" onclick="return confirm('Wirklich löschen?');">Löschen</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Keine Gutscheine vorhanden.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
include dirname(__DIR__).'/footer.phtml';
|
||||||
|
?>
|
109
bibarts.sql
109
bibarts.sql
@ -3,111 +3,110 @@ SET time_zone = "+00:00";
|
|||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
CREATE TABLE User (
|
CREATE TABLE user (
|
||||||
userid INT AUTO_INCREMENT PRIMARY KEY,
|
user_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
vorname VARCHAR(50),
|
first_name VARCHAR(50),
|
||||||
nachname VARCHAR(50),
|
last_name VARCHAR(50),
|
||||||
strasse VARCHAR(100),
|
street VARCHAR(100),
|
||||||
hausnr VARCHAR(10),
|
house_number VARCHAR(10),
|
||||||
plz VARCHAR(10),
|
postal_code VARCHAR(10),
|
||||||
ort VARCHAR(50),
|
city VARCHAR(50),
|
||||||
land VARCHAR(50),
|
country VARCHAR(50),
|
||||||
tel VARCHAR(20),
|
phone VARCHAR(20),
|
||||||
email VARCHAR(100) UNIQUE,
|
email VARCHAR(100) UNIQUE,
|
||||||
isAdmin BOOLEAN DEFAULT FALSE,
|
is_admin BOOLEAN DEFAULT FALSE,
|
||||||
validUntil DATETIME NOT NULL DEFAULT '3025-01-01 00:00:00',
|
valid_until DATETIME NOT NULL DEFAULT '3025-01-01 00:00:00',
|
||||||
password VARCHAR(255)
|
password VARCHAR(255)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE Standort (
|
CREATE TABLE location (
|
||||||
standortid INT AUTO_INCREMENT PRIMARY KEY,
|
location_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
strasse VARCHAR(100),
|
street VARCHAR(100),
|
||||||
hausnr VARCHAR(10),
|
house_number VARCHAR(10),
|
||||||
plz VARCHAR(10),
|
postal_code VARCHAR(10),
|
||||||
ort VARCHAR(50),
|
city VARCHAR(50),
|
||||||
land VARCHAR(50),
|
country VARCHAR(50),
|
||||||
tel VARCHAR(20),
|
phone VARCHAR(20),
|
||||||
email VARCHAR(100)
|
email VARCHAR(100)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE Ausstellung (
|
CREATE TABLE event (
|
||||||
austellungid INT AUTO_INCREMENT PRIMARY KEY,
|
event_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
standortid INT,
|
location_id INT,
|
||||||
datum_von DATE,
|
start_date DATE,
|
||||||
datum_bis DATE,
|
end_date DATE,
|
||||||
name VARCHAR(100),
|
name VARCHAR(100),
|
||||||
beschreibung TEXT,
|
description TEXT,
|
||||||
max_tickets INT,
|
max_tickets INT,
|
||||||
eintrittspreis DECIMAL(5,2),
|
ticket_price DECIMAL(5,2),
|
||||||
FOREIGN KEY (standortid) REFERENCES Standort(standortid)
|
FOREIGN KEY (location_id) REFERENCES location(location_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE Ticket (
|
CREATE TABLE ticket (
|
||||||
ticketid INT AUTO_INCREMENT PRIMARY KEY,
|
ticket_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
userid INT,
|
user_id INT,
|
||||||
ausstellungid INT,
|
event_id INT,
|
||||||
kaufdatum DATE,
|
purchase_date DATE,
|
||||||
gueltigkeit DATE,
|
valid_until DATE,
|
||||||
FOREIGN KEY (userid) REFERENCES User(userid),
|
FOREIGN KEY (user_id) REFERENCES user(user_id),
|
||||||
FOREIGN KEY (ausstellungid) REFERENCES Ausstellung(austellungid)
|
FOREIGN KEY (event_id) REFERENCES event(event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE Gutschein (
|
CREATE TABLE voucher (
|
||||||
gutscheinid INT AUTO_INCREMENT PRIMARY KEY,
|
voucher_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
code VARCHAR(50) UNIQUE,
|
code VARCHAR(50) UNIQUE,
|
||||||
rabatt INT CHECK (rabatt BETWEEN 0 AND 100),
|
discount INT CHECK (discount BETWEEN 0 AND 100),
|
||||||
ausstellungid INT,
|
event_id INT,
|
||||||
gueltigkeit DATE,
|
valid_until DATE,
|
||||||
FOREIGN KEY (ausstellungid) REFERENCES Ausstellung(austellungid)
|
FOREIGN KEY (event_id) REFERENCES event(event_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE News (
|
CREATE TABLE news (
|
||||||
newsid INT AUTO_INCREMENT PRIMARY KEY,
|
news_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
name VARCHAR(100),
|
name VARCHAR(100),
|
||||||
beschreibung TEXT,
|
description TEXT,
|
||||||
datum DATE
|
date DATE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- User-Daten (Passwort: passwort123)
|
-- User-Daten (Passwort: passwort123)
|
||||||
INSERT INTO User (vorname, nachname, strasse, hausnr, plz, ort, land, tel, email, isAdmin, password)
|
INSERT INTO user (first_name, last_name, street, house_number, postal_code, city, country, phone, email, is_admin, password)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
||||||
('Max', 'Muster', 'Musterstraße', '1', '12345', 'Musterstadt', 'Deutschland', '0123456789', 'max@muster.de', FALSE, '$2y$10$VAj.C0XHPUxV4oXS6b79aumlg5fBMPPx5FPqgkQSIQeBLh0WtYmKy'),
|
('Max', 'Muster', 'Musterstraße', '1', '12345', 'Musterstadt', 'Deutschland', '0123456789', 'max@muster.de', FALSE, '$2y$10$VAj.C0XHPUxV4oXS6b79aumlg5fBMPPx5FPqgkQSIQeBLh0WtYmKy'),
|
||||||
('Anna', 'Beispiel', 'Beispielweg', '5a', '54321', 'Beispielstadt', 'Deutschland', '0987654321', 'anna@beispiel.de', TRUE, '$2y$10$cnPBpkvLbdpDxzYvxlQg9uVp5y8ggr2SWL8NAMg9zk.3QnnEl.MGq');
|
('Anna', 'Beispiel', 'Beispielweg', '5a', '54321', 'Beispielstadt', 'Deutschland', '0987654321', 'anna@beispiel.de', TRUE, '$2y$10$cnPBpkvLbdpDxzYvxlQg9uVp5y8ggr2SWL8NAMg9zk.3QnnEl.MGq');
|
||||||
|
|
||||||
-- Standort-Daten
|
-- Standort-Daten
|
||||||
INSERT INTO Standort (strasse, hausnr, plz, ort, land, tel, email)
|
INSERT INTO location (street, house_number, postal_code, city, country, phone, email)
|
||||||
VALUES
|
VALUES
|
||||||
('Galeriestraße', '10', '10115', 'Berlin', 'Deutschland', '030123456', 'kontakt@galerie-berlin.de'),
|
('Galeriestraße', '10', '10115', 'Berlin', 'Deutschland', '030123456', 'kontakt@galerie-berlin.de'),
|
||||||
('Kunstallee', '22b', '50667', 'Köln', 'Deutschland', '0221123456', 'info@kunst-koeln.de');
|
('Kunstallee', '22b', '50667', 'Köln', 'Deutschland', '0221123456', 'info@kunst-koeln.de');
|
||||||
|
|
||||||
-- Ausstellung-Daten
|
-- Ausstellung-Daten
|
||||||
INSERT INTO Ausstellung (standortid, datum_von, datum_bis, name, beschreibung, max_tickets, eintrittspreis)
|
INSERT INTO event (location_id, start_date, end_date, name, description, max_tickets, ticket_price)
|
||||||
VALUES
|
VALUES
|
||||||
(1, '2025-07-01', '2025-08-31', 'Moderne Meisterwerke', 'Eine Sammlung moderner Kunstwerke aus Europa.', 200, 19.99),
|
(1, '2025-07-01', '2025-08-31', 'Moderne Meisterwerke', 'Eine Sammlung moderner Kunstwerke aus Europa.', 200, 19.99),
|
||||||
(2, '2025-09-10', '2025-10-20', 'Kunst der Antike', 'Ausstellung antiker Skulpturen und Gemälde.', 150, 39.99);
|
(2, '2025-09-10', '2025-10-20', 'Kunst der Antike', 'Ausstellung antiker Skulpturen und Gemälde.', 150, 39.99);
|
||||||
|
|
||||||
-- Gutschein-Daten (Spaltennamen korrigiert)
|
-- Gutschein-Daten
|
||||||
INSERT INTO Gutschein (code, rabatt, ausstellungid, gueltigkeit)
|
INSERT INTO voucher (code, discount, event_id, valid_until)
|
||||||
VALUES
|
VALUES
|
||||||
('SOMMER2025', 15, 1, '2025-08-31'),
|
('SOMMER2025', 15, 1, '2025-08-31'),
|
||||||
('HERBST25', 25, 2, '2025-10-15');
|
('HERBST25', 25, 2, '2025-10-15');
|
||||||
|
|
||||||
-- Ticket-Daten (Spaltennamen korrigiert)
|
-- Ticket-Daten
|
||||||
INSERT INTO Ticket (userid, ausstellungid, kaufdatum, gueltigkeit)
|
INSERT INTO ticket (user_id, event_id, purchase_date, valid_until)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, '2025-06-01', '2025-07-15'),
|
(1, 1, '2025-06-01', '2025-07-15'),
|
||||||
(2, 2, '2025-06-05', '2025-09-15');
|
(2, 2, '2025-06-05', '2025-09-15');
|
||||||
|
|
||||||
-- News-Daten
|
-- News-Daten
|
||||||
INSERT INTO News (name, beschreibung, datum)
|
INSERT INTO news (name, description, date)
|
||||||
VALUES
|
VALUES
|
||||||
('Neuer Standort eröffnet', 'Unsere Galerie in Köln ist jetzt geöffnet!', '2025-06-01'),
|
('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');
|
('Frühbucher-Rabatt', 'Sichern Sie sich jetzt 15% Rabatt auf unsere Sommerausstellung.', '2025-05-20');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user