Fixed delete and update error.
This commit is contained in:
parent
7787cb2956
commit
c306a59fec
@ -57,23 +57,57 @@ class EventController {
|
|||||||
$this->view->setVars(['event' => $event]);
|
$this->view->setVars(['event' => $event]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateEvent($id, $data) {
|
public function updateEvent() {
|
||||||
$id = $_POST['ausstellungid'];
|
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
||||||
|
header('Location: index.php?controller=Event&do=showEvents');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$id = $_POST['id'] ?? null;
|
||||||
$data = [
|
$data = [
|
||||||
'standortid' => $_POST['standortid'] ?? null,
|
'name' => $_POST['name'] ?? '',
|
||||||
'datum_von' => $_POST['datum_von'] ?? null,
|
'start_date' => $_POST['start_date'] ?? '',
|
||||||
'datum_bis' => $_POST['datum_bis'] ?? null,
|
'end_date' => $_POST['end_date'] ?? '',
|
||||||
'name' => $_POST['name'] ?? null,
|
'location_id' => $_POST['location_id'] ?? '',
|
||||||
'beschreibung' => $_POST['beschreibung'] ?? null,
|
'description' => $_POST['description'] ?? '',
|
||||||
'max_tickets' => $_POST['max_tickets'] ?? null,
|
'max_tickets' => $_POST['max_tickets'] ?? '',
|
||||||
'preis' => $_POST['preis'] ?? null
|
'ticket_price' => $_POST['ticket_price'] ?? ''
|
||||||
];
|
];
|
||||||
|
$errors = [];
|
||||||
|
if (empty($data['name']) || empty($data['start_date']) || empty($data['end_date']) || empty($data['location_id']) || empty($data['description']) || empty($data['max_tickets']) || empty($data['ticket_price'])) {
|
||||||
|
$errors['event'] = 'Bitte alle Felder ausfüllen.';
|
||||||
|
}
|
||||||
|
if (!empty($errors)) {
|
||||||
|
$standortModel = new StandortModel();
|
||||||
|
$location = $standortModel->getStandort($data['location_id']);
|
||||||
|
$eventView = [
|
||||||
|
'id' => $id,
|
||||||
|
'name' => $data['name'],
|
||||||
|
'start_date' => $data['start_date'],
|
||||||
|
'end_date' => $data['end_date'],
|
||||||
|
'location_id' => $data['location_id'],
|
||||||
|
'location_name' => $location['city'] ?? '',
|
||||||
|
'description' => $data['description'],
|
||||||
|
'max_tickets' => $data['max_tickets'],
|
||||||
|
'ticket_price' => $data['ticket_price'],
|
||||||
|
];
|
||||||
|
$this->view->setVars(['event' => $eventView, 'errors' => $errors]);
|
||||||
|
$this->view->setDoMethodName('showUpdateEvent');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->model->updateEvent($id, $data);
|
$this->model->updateEvent($id, $data);
|
||||||
|
$this->view->setDoMethodName('showUpdateForwarding');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteEvent($id) {
|
public function deleteEvent() {
|
||||||
$this->model->deleteEvent($id);
|
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
|
||||||
$this->view->setVars(['id' => $id]);
|
header('Location: index.php?controller=Event&do=showEvents');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$id = $_GET['event_id'] ?? null;
|
||||||
|
if ($id) {
|
||||||
|
$this->model->deleteEvent($id);
|
||||||
|
}
|
||||||
|
$this->view->setDoMethodName('deleteEvent');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showUpdateEvent() {
|
public function showUpdateEvent() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user