diff --git a/CSS/Element/card.css b/CSS/Element/card.css index 3c42570..2a41193 100644 --- a/CSS/Element/card.css +++ b/CSS/Element/card.css @@ -1,104 +1,103 @@ -/* === Grundlayout === */ + body { - margin: 0; - font-family: var(--font-family-main); - background-color: var(--brand-background); - color: var(--brand-white); + margin: 0; + font-family: var(--font-family-main); + background-color: var(--brand-background); + color: var(--brand-white); } -/* === Header-Bereich === */ .welcome-header { - text-align: center; - margin: 60px 20px 40px 20px; + text-align: center; + margin: 60px 20px 40px 20px; } .welcome-heading { - font-size: 50px; - font-weight: 500; - color: var(--brand-primary); - margin-bottom: 20px; + font-size: 50px; + font-weight: 500; + color: var(--brand-primary); + margin-bottom: 20px; } .welcome-subheading { - font-size: 28px; - font-weight: bold; - color: white; - text-align: left; - max-width: 1000px; - margin: 0 auto; - padding-left: 230px; + font-size: 28px; + font-weight: bold; + color: white; + text-align: left; + max-width: 1000px; + margin: 0 auto; + padding-left: 230px; + margin-bottom: 30px; } -/* === Kurs-Grid === */ -.courses-view { - display: flex; - flex-direction: row; - flex-wrap: wrap; - gap: 30px; - justify-content: center; - padding: 30px 0 30px 0; +.course-grid { + display: flex; + flex-wrap: wrap; + gap: 30px; + margin: 0 auto; } -/* === Kurs-Karte === */ .course-card { - background: var(--brand-white); - border-radius: 12px; - overflow: hidden; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); - min-height: 300px; - display: flex; - flex-direction: column; - width: 100%; - max-width: 600px; + background: var(--brand-white); + border-radius: 12px; + overflow: hidden; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); + min-height: 300px; + display: flex; + flex-direction: column; } -/* Optional: Kurs-Bildbereich */ .course-image { - background-color: #ddd; /* Platzhalter – kannst du durch echte Bilder ersetzen */ - height: 180px; - width: 100%; + background-color: #ddd; + height: 180px; + width: 100%; } -/* === Kurs-Inhalt === */ .course-content { - background-color: var(--brand-primary); /* Orange */ - color: var(--brand-white); - padding: 20px; - font-size: 16px; - display: flex; - justify-content: space-between; - align-items: flex-start; - gap: 10px; + background-color: var(--brand-primary); + color: var(--brand-white); + padding: 20px; + font-size: 16px; + display: flex; + justify-content: space-between; + align-items: flex-start; + gap: 10px; } .course-left, .course-right { - display: flex; - flex-direction: column; - font-size: 14px; - line-height: 1.4; + display: flex; + flex-direction: column; + font-size: 14px; + line-height: 1.4; } .course-left div:first-child, .course-right div:first-child { - font-weight: bold; - font-size: 16px; + font-weight: bold; + font-size: 16px; } .course-right { - text-align: right; + text-align: right; } @media screen and (max-width: 1024px) { + .course-card { + flex: 0 0 calc(50% - 20px); + } } @media screen and (max-width: 640px) { - .welcome-heading { - font-size: 36px; - } + .course-card { + flex: 0 0 100%; + } - .welcome-subheading { - font-size: 20px; - text-align: center; - } + .welcome-heading { + font-size: 36px; + } + + .welcome-subheading { + font-size: 20px; + text-align: center; + } } diff --git a/CSS/Element/filter_box.css b/CSS/Element/filter_box.css new file mode 100644 index 0000000..007cfc0 --- /dev/null +++ b/CSS/Element/filter_box.css @@ -0,0 +1,33 @@ +.filter-box { + background: #EB8202; + color: #fff; + padding: 1em; + max-width: 300px; + border-radius: 8px; + font-family: sans-serif; + margin-bottom: 1em; +} + +.filter-box label { + display: block; + margin-top: 0.5em; +} + +.filter-box select, +.filter-box input[type="text"], +.filter-box input[type="range"] { + width: 100%; + margin-top: 0.25em; +} + +.filter-box button { + margin-top: 1em; + width: 100%; + background: white; + color: #000; + border: none; + padding: 0.5em; + font-weight: bold; + cursor: pointer; + border-radius: 4px; +} diff --git a/CSS/Element/form.css b/CSS/Element/form.css index 2ab719d..2064c7c 100644 --- a/CSS/Element/form.css +++ b/CSS/Element/form.css @@ -95,21 +95,16 @@ form .error { grid-template-columns: auto !important; } -/* fix radio buttons registration */ .radio { flex-direction: row; - justify-content: space-between; max-width: 290px; align-items: center; -} - -.radio { - display: flex; - flex-direction: row; - align-items: center; - gap: 10px; + gap: 24px; + } .radio input { margin-top: 0; + height: var(--h-sm); + width: var(--h-sm); } diff --git a/CSS/style.css b/CSS/style.css index 97a05a9..b431a18 100644 --- a/CSS/style.css +++ b/CSS/style.css @@ -7,6 +7,7 @@ @import url(Element/button.css); @import url(Element/card.css); @import url(Element/sidebar.css); +@import url(Element/filter_box.css); @import url(Element/modal.css); *, diff --git a/CSS/variables.css b/CSS/variables.css index b85371f..0db4045 100644 --- a/CSS/variables.css +++ b/CSS/variables.css @@ -21,6 +21,7 @@ /*Font-Weight*/ --font-weight-semibold: 600; + --h-sm: 24px; --h-md: 48px; --border-primary: 1px solid #998E82; diff --git a/Controller/UserController.php b/Controller/UserController.php index 978e7f3..fa28575 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -134,6 +134,26 @@ class UserController{ } } + public function validateEditKursForm(){ + foreach ($this->kursLabels as $index => $value) { + if($value === "|") continue; + if (strpos($value, "*") !== false && (!isset($_POST[$index]) || empty($_POST[$index]))) { + $this->kursErrors[$index] = "Bitte " . $value . " eingeben"; + } else { + $this->kursValidData[$index] = $_POST[$index] === '' ? null : $_POST[$index]; + } + } + if (count($this->errors) > 0) { + $this->view->setDoMethodName("showUserAccountPage"); + $this->showUserAccountPage(); + } else { + if ($this->db->writeNewCourse($this->kursValidData, $_SESSION["user_id"])) { + $this->view->setDoMethodName("showKursEditedConfirmation"); + $this->showConfirmation(); + } + } + } + public function showConfirmation(){} public function showUserLoginConfirmation(){ diff --git a/Model/UserModel.php b/Model/UserModel.php index 4dd93a7..a5ac67e 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -157,21 +157,108 @@ class UserModel extends Database } public function getMyCourses() { - $sql = "SELECT k.id, k.name, k.preis, k.dauer, k.rabatt, k.kategorie, k.beschreibung, o.stadt, o.strasse, o.plz, b.note, b.kommentar - FROM kurs AS k - JOIN ort AS o ON o.id = k.ort_id - LEFT JOIN bewertungen AS b ON b.kurs_id = k.id - ORDER BY k.name;"; + $personId = $_SESSION["user_id"]; + $isKursleiter = $_SESSION["user_role"] === "leiter"; $pdo = $this->linkDB(); + if ($isKursleiter) { + $sql = "SELECT k.id, k.name, k.preis, k.dauer, k.rabatt, k.kategorie, k.beschreibung, k.ort_id, + o.stadt, o.strasse, o.plz, b.note, b.kommentar + FROM kurs AS k + JOIN ort AS o ON o.id = k.ort_id + LEFT JOIN bewertungen AS b ON b.kurs_id = k.id + WHERE k.kursleiter = :personId + ORDER BY k.name"; + } else { + $sql = "SELECT k.id, k.name, k.preis, k.dauer, k.rabatt, k.kategorie, k.beschreibung, k.ort_id, + o.stadt, o.strasse, o.plz, b.note, b.kommentar + FROM kurs_user AS ku + JOIN kurs AS k ON k.id = ku.kurs_id + JOIN ort AS o ON o.id = k.ort_id + LEFT JOIN bewertungen AS b ON b.kurs_id = k.id + WHERE ku.user_id = :personId + ORDER BY k.name"; + } + try { $sth = $pdo->prepare($sql); - $sth->execute(); + $sth->execute([':personId' => $personId]); return $sth->fetchAll(\PDO::FETCH_ASSOC); } catch (PDOException $e) { new \Blog\Library\ErrorMsg("Fehler beim Lesen der Daten.", $e); die; } } + + + public function updateCourse($course) { + $pdo = $this->linkDB(); + + try { + if (isset($course['ort_id'])) { + $this->updateAddress($course); + $addressId = $course['ort_id']; + } else { + $addressId = $this->writeNewAddress($course); + } + + $sql = "UPDATE kurs SET + `name` = :name, + `preis` = :preis, + `dauer` = :dauer, + `rabatt` = :rabatt, + `kategorie` = :kategorie, + `beschreibung` = :beschreibung, + `ort_id` = :ort_id + WHERE `id` = :id"; + + $sth = $pdo->prepare($sql); + $sth->execute([ + ':id' => $course['id'], + ':name' => $course['name'], + ':preis' => $course['preis'], + ':dauer' => $course['dauer'], + ':rabatt' => $course['rabatt'], + ':kategorie' => $course['kategorie'], + ':beschreibung' => $course['beschreibung'], + ':ort_id' => $addressId + ]); + + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren des Kurses.", $e); + die; + } + + return true; + } + + public function updateAddress($data) { + $pdo = $this->linkDB(); + + if (!isset($data['ort_id'])) { + throw new \Exception("Keine Adress-ID vorhanden zum Aktualisieren."); + } + + $sql = "UPDATE ort SET + `strasse` = :strasse, + `stadt` = :stadt, + `plz` = :plz + WHERE `id` = :id"; + + try { + $sth = $pdo->prepare($sql); + $sth->execute([ + ':id' => $data['ort_id'], + ':strasse' => $data['strasse'], + ':stadt' => $data['stadt'], + ':plz' => $data['plz'] + ]); + } catch (PDOException $e) { + new \Blog\Library\ErrorMsg("Fehler beim Aktualisieren der Adresse.", $e); + die; + } + + return true; + } } \ No newline at end of file diff --git a/Views/User/showAdminForm.phtml b/Views/User/showAdminForm.phtml index 4929a03..0e5cff4 100644 --- a/Views/User/showAdminForm.phtml +++ b/Views/User/showAdminForm.phtml @@ -1,6 +1,21 @@
Kurs erfolgreich bearbeitet.
+Weiter +