diff --git a/config/config.php b/config/config.php index 991b5cc..93d0f78 100644 --- a/config/config.php +++ b/config/config.php @@ -1,5 +1,7 @@ '127.0.0.1', 'dbname' => 'vwl', @@ -7,7 +9,7 @@ return [ 'password' => '', 'charset' => 'utf8mb4' ]; -/* +*/ return [ 'host' => '148.251.96.181', 'dbname' => 'c1vwl', @@ -15,4 +17,3 @@ return [ 'password' => 'SommerNacht!2025', 'charset' => 'utf8mb4' ]; -*/ \ No newline at end of file diff --git a/src/controller/MainController.php b/src/controller/MainController.php index c7f89a2..90409de 100644 --- a/src/controller/MainController.php +++ b/src/controller/MainController.php @@ -22,4 +22,19 @@ class MainController { require '../src/view/hotel_edit.php'; require '../src/view/templates/footer.php'; } + + public function bestellungen() { + $pageTitle = "Bestellungen"; + require '../src/view/templates/header.php'; + require '../src/view/bestellungen.php'; + require '../src/view/templates/footer.php'; + } + + public function bestellung_edit() { + $pageTitle = "Bestellungen"; + require '../src/view/templates/header.php'; + require '../src/view/bestellung_edit.php'; + require '../src/view/templates/footer.php'; + } + } diff --git a/src/model/BestellungModel.php b/src/model/BestellungModel.php new file mode 100644 index 0000000..d8a68c3 --- /dev/null +++ b/src/model/BestellungModel.php @@ -0,0 +1,46 @@ +db = Database::connect(); + } + + public function getBestellungById($id) { + $stmt = $this->db->prepare("SELECT * FROM vwl_bestellung WHERE id = ?"); + $stmt->execute([$id]); + return $stmt->fetch(); + } + + public function updateBestellung($data) { + + $fieldsToUpdate = array_intersect_key($data, array_flip($this->allowedFields)); + if (empty($fieldsToUpdate)) { + return false; + } + + // Baue SQL-Statement + $setParts = []; + foreach ($fieldsToUpdate as $field => $value) { + $setParts[] = "`$field` = :$field"; + } + $sql = "UPDATE vwl_hotel SET " . implode(', ', $setParts) . " WHERE id = :id"; + + $stmt = $this->db->prepare($sql); + + // Bind-Werte + $fieldsToUpdate['id'] = $data['id']; + return $stmt->execute($fieldsToUpdate); + } + +} diff --git a/src/view/bestellung_edit.php b/src/view/bestellung_edit.php new file mode 100644 index 0000000..cfadd4a --- /dev/null +++ b/src/view/bestellung_edit.php @@ -0,0 +1,66 @@ +updateBestellung($data); + + if ($success) { + $message = '