diff --git a/public/index.php b/public/index.php index 8cd5658..cceb579 100644 --- a/public/index.php +++ b/public/index.php @@ -15,6 +15,7 @@ use App\Models\Round; use App\Models\Season; use App\Models\Ranking; use App\Models\Payment; +use App\Models\Quota; $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $page = $_GET['page'] ?? null; @@ -122,14 +123,18 @@ if ($page === 'login') { $data = [ 'name' => $_POST['name'], 'rounds' => $_POST['rounds'], + 'stake' => $_POST['stake'], ]; - if (empty($data['name']) || !is_numeric($data['rounds'])) { - throw new \Exception('Name und Anzahl der Runden sind erforderlich.'); + if (empty($data['name']) || !is_numeric($data['rounds']) || !is_numeric($data['stake'])) { + throw new \Exception('Name, Runden und Einsatz sind erforderlich.'); } if ($action === 'create') { $newSeasonId = Season::create($data); if ($newSeasonId) { + if (isset($_POST['quotas'])) { + Quota::updateForSeason($newSeasonId, $_POST['quotas']); + } Season::setCurrent($newSeasonId); $_SESSION['admin_message'] = "Saison erfolgreich erstellt und als aktiv gesetzt."; } else { @@ -138,12 +143,8 @@ if ($page === 'login') { } elseif ($seasonId) { Season::update($seasonId, $data); - if (isset($_POST['rounds_names']) && is_array($_POST['rounds_names'])) { - foreach ($_POST['rounds_names'] as $roundId => $roundName) { - if (!empty($roundName)) { - Round::updateName($roundId, $roundName); - } - } + if (isset($_POST['quotas'])) { + Quota::updateForSeason($seasonId, $_POST['quotas']); } $_SESSION['admin_message'] = "Saison erfolgreich aktualisiert."; @@ -175,11 +176,11 @@ if ($page === 'login') { $seasons = Season::getAll(); $currentSeason = Season::getCurrent(); $editSeason = null; - $roundsOfSeason = []; + $quotasOfSeason = []; if (isset($_GET['edit_id'])) { $editSeason = Season::findById((int)$_GET['edit_id']); if ($editSeason) { - $roundsOfSeason = Round::getBySeason($editSeason['id']); + $quotasOfSeason = Quota::getBySeason($editSeason['id']); } } diff --git a/schema.sql b/schema.sql index 8a0632a..497b8df 100644 --- a/schema.sql +++ b/schema.sql @@ -63,6 +63,7 @@ CREATE TABLE `seasons` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `rounds` int(11) NOT NULL DEFAULT '36', + `stake` decimal(8,2) NOT NULL DEFAULT '25.00', `active` tinyint(1) NOT NULL DEFAULT '1', `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, diff --git a/src/Models/Season.php b/src/Models/Season.php index 671621b..c4d7f46 100644 --- a/src/Models/Season.php +++ b/src/Models/Season.php @@ -75,11 +75,12 @@ class Season { try { $stmt = $db->prepare( - "INSERT INTO seasons (name, rounds, created_at, updated_at) VALUES (:name, :rounds, NOW(), NOW())" + "INSERT INTO seasons (name, rounds, stake, created_at, updated_at) VALUES (:name, :rounds, :stake, NOW(), NOW())" ); $stmt->execute([ ':name' => $data['name'], ':rounds' => $data['rounds'], + ':stake' => $data['stake'], ]); $seasonId = $db->lastInsertId(); @@ -110,12 +111,13 @@ class Season { public static function update($id, $data) { $db = Database::getConnection(); $stmt = $db->prepare( - "UPDATE seasons SET name = :name, rounds = :rounds, updated_at = NOW() WHERE id = :id" + "UPDATE seasons SET name = :name, rounds = :rounds, stake = :stake, updated_at = NOW() WHERE id = :id" ); return $stmt->execute([ ':id' => $id, ':name' => $data['name'], ':rounds' => $data['rounds'], + ':stake' => $data['stake'], ]); } diff --git a/src/Views/admin/seasons.php b/src/Views/admin/seasons.php index a3c70e7..2ab26db 100644 --- a/src/Views/admin/seasons.php +++ b/src/Views/admin/seasons.php @@ -28,26 +28,39 @@ require __DIR__ . '/../partials/header.php';
- > + +
+
+ +
-
-

Runden dieser Saison

- -
- - -
- - +

Quoten

+
+ '1. Platz', 'prc' => '50'], + ['name' => '2. Platz', 'prc' => '30'], + ['name' => '3. Platz', 'prc' => '20'], + ]; + } + foreach ($quotas as $index => $quota): ?> +
+ + + + +
+ +
+
+ +
+
@@ -56,6 +69,38 @@ require __DIR__ . '/../partials/header.php';
+ +