feat: Implementiere Quoten- und Einsatzverwaltung für Saisons
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
parent
d571121200
commit
362966e0cd
4 changed files with 77 additions and 28 deletions
|
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue