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:
2025-07-01 09:59:25 +02:00
parent d24d914c8c
commit 8a59ddde8e
25 changed files with 493 additions and 529 deletions

View File

@@ -9,14 +9,12 @@ class AuthController
private $model;
private $view;
public function __construct($view)
{
public function __construct($view) {
$this->model = new AuthModel();
$this->view = $view;
}
public function showAuthForm()
{
public function showLoginForm() {
$this->view->setVars([
'labels' => [
"email" => "E-Mail-Adresse",
@@ -30,8 +28,7 @@ class AuthController
unset($_SESSION['auth_errors'], $_SESSION['auth_validData']);
}
public function showRegistrationForm()
{
public function showRegistrationForm() {
$this->view->setVars([
'labels' => [
"email" => "E-Mail-Adresse",
@@ -69,25 +66,25 @@ class AuthController
public function register() {
$data = [
'vorname' => $_POST['vorname'] ?? '',
'nachname' => $_POST['nachname'] ?? '',
'straße' => $_POST['strasse'] ?? '',
'hausnr' => $_POST['hausnr'] ?? '',
'plz' => $_POST['plz'] ?? '',
'ort' => $_POST['ort'] ?? '',
'land' => $_POST['land'] ?? '',
'tel' => $_POST['tel'] ?? '',
'first_name' => $_POST['vorname'] ?? '',
'last_name' => $_POST['nachname'] ?? '',
'street' => $_POST['strasse'] ?? '',
'house_number' => $_POST['hausnr'] ?? '',
'postal_code' => $_POST['plz'] ?? '',
'city' => $_POST['ort'] ?? '',
'country' => $_POST['land'] ?? '',
'phone' => $_POST['tel'] ?? '',
'email' => $_POST['email'] ?? '',
'password' => $_POST['password'] ?? '',
'password_repeat' => $_POST['password_repeat'] ?? '',
'isAdmin' => $_POST['isAdmin'] ?? false,
'is_admin' => $_POST['isAdmin'] ?? false,
];
$result = $this->model->register($data);
if ($result === true) {
$this->view->setVars(['success' => 'Registrierung erfolgreich!']);
$this->view->render('Auth/showAuthForm');
$this->view->render('Auth/showLoginForm');
exit;
} else {
$errors['register'] = is_string($result) ? $result : "Registrierung fehlgeschlagen.";

View File

@@ -23,13 +23,13 @@ class EventController {
public function createEvent() {
$data = [
'location_id' => $_POST['location_id'] ?? null,
'start_date' => $_POST['start_date'] ?? null,
'end_date' => $_POST['end_date'] ?? null,
'name' => $_POST['name'] ?? null,
'beschreibung' => $_POST['beschreibung'] ?? null,
'standortid' => $_POST['standortid'] ?? null,
'datum_von' => $_POST['datum_von'] ?? null,
'datum_bis' => $_POST['datum_bis'] ?? null,
'description' => $_POST['description'] ?? null,
'max_tickets' => $_POST['max_tickets'] ?? null,
'preis' => $_POST['preis'] ?? null
'ticket_price' => $_POST['ticket_price'] ?? null
];
$this->model->createEvent($data);
@@ -38,21 +38,21 @@ class EventController {
}
public function editEventForm() {
$id = $_GET['ausstellungid'];
$id = $_GET['event_id'];
$event = $this->model->getEvent($id);
$this->view->setVars(['event' => $event]);
}
public function updateEvent($id, $data) {
$id = $_POST['ausstellungid'];
$id = $_POST['event_id'];
$data = [
'standortid' => $_POST['standortid'] ?? null,
'datum_von' => $_POST['datum_von'] ?? null,
'datum_bis' => $_POST['datum_bis'] ?? null,
'location_id' => $_POST['location_id'] ?? null,
'start_date' => $_POST['start_date'] ?? null,
'end_date' => $_POST['end_date'] ?? null,
'name' => $_POST['name'] ?? null,
'beschreibung' => $_POST['beschreibung'] ?? null,
'description' => $_POST['description'] ?? null,
'max_tickets' => $_POST['max_tickets'] ?? null,
'preis' => $_POST['preis'] ?? null
'ticket_price' => $_POST['ticket_price'] ?? null
];
$this->model->updateEvent($id, $data);
}

View File

@@ -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);
}
}

View 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);
}
}

View File

@@ -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);
}
}

View File

@@ -21,13 +21,13 @@ class TicketController {
public function buyTicket() {
$data = [
'userid' => $_POST['userid'],
'ausstellungid' => $_POST['ausstellungid'],
'kaufdatum' => date('Y-m-d'),
'gueltigkeit' => $_POST['gueltigkeit']
'user_id' => $_POST['user_id'] ?? null,
'event_id' => $_POST['event_id'] ?? null,
'price' => $_POST['price'] ?? null
];
$erg = $this->ticketModel->buyTicket($data);
$this->view->setVars(['ticket' => $erg]);
$result = $this->ticketModel->createTicket($data);
$this->view->setVars(['ticket' => $result]);
}
public function deleteTicket() {

View 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);
}
}