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
|
|
@ -28,26 +28,39 @@ require __DIR__ . '/../partials/header.php';
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="rounds">Runden:</label>
|
||||
<input type="number" id="rounds" name="rounds" value="<?php echo htmlspecialchars($editSeason['rounds'] ?? '34'); ?>" <?php echo $editSeason ? 'readonly' : 'required' ?>>
|
||||
<input type="number" id="rounds" name="rounds" value="<?php echo htmlspecialchars($editSeason['rounds'] ?? '34'); ?>" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="stake">Einsatz (€):</label>
|
||||
<input type="number" step="0.01" id="stake" name="stake" value="<?php echo htmlspecialchars($editSeason['stake'] ?? '25.00'); ?>" required>
|
||||
</div>
|
||||
|
||||
<?php if ($editSeason && !empty($roundsOfSeason)): ?>
|
||||
<hr style="margin: 2rem 0;">
|
||||
<h2>Runden dieser Saison</h2>
|
||||
<?php foreach ($roundsOfSeason as $round): ?>
|
||||
<div class="form-group">
|
||||
<label for="round_<?php echo $round['id']; ?>">
|
||||
Runde <?php echo htmlspecialchars(preg_replace('/[^0-9]/', '', $round['name'])); ?>:
|
||||
</label>
|
||||
<input type="text"
|
||||
id="round_<?php echo $round['id']; ?>"
|
||||
name="rounds_names[<?php echo $round['id']; ?>]"
|
||||
value="<?php echo htmlspecialchars($round['name']); ?>"
|
||||
required>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<h2>Quoten</h2>
|
||||
<div id="quotas-container">
|
||||
<?php
|
||||
$quotas = $quotasOfSeason ?? [];
|
||||
if ($editSeason === null && empty($quotasOfSeason)) {
|
||||
$quotas = [
|
||||
['name' => '1. Platz', 'prc' => '50'],
|
||||
['name' => '2. Platz', 'prc' => '30'],
|
||||
['name' => '3. Platz', 'prc' => '20'],
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($quotas as $index => $quota): ?>
|
||||
<div class="form-group quota-item">
|
||||
<label>Quote <?php echo $index + 1; ?>:</label>
|
||||
<input type="text" name="quotas[<?php echo $index; ?>][name]" value="<?php echo htmlspecialchars($quota['name'] ?? ''); ?>" placeholder="z.B. 1. Platz" style="width: 200px; margin-right: 10px;">
|
||||
<input type="number" step="0.01" name="quotas[<?php echo $index; ?>][prc]" value="<?php echo htmlspecialchars($quota['prc'] ?? ''); ?>" placeholder="Anteil in %" style="width: 120px;">
|
||||
<button type="button" class="remove-quota" style="margin-left: 10px;">Entfernen</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="button" id="add-quota">Quote hinzufügen</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button type="submit"><?php echo $editSeason ? 'Speichern' : 'Anlegen'; ?></button>
|
||||
<?php if ($editSeason): ?>
|
||||
|
|
@ -56,6 +69,38 @@ require __DIR__ . '/../partials/header.php';
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
let quotaIndex = <?php echo count($quotas ?? []); ?>;
|
||||
|
||||
document.getElementById('add-quota').addEventListener('click', function() {
|
||||
const container = document.getElementById('quotas-container');
|
||||
const newItem = document.createElement('div');
|
||||
newItem.className = 'form-group quota-item';
|
||||
const newIndex = container.getElementsByClassName('quota-item').length;
|
||||
newItem.innerHTML = `
|
||||
<label>Quote ${newIndex + 1}:</label>
|
||||
<input type="text" name="quotas[${newIndex}][name]" placeholder="z.B. Tagessieger" style="width: 200px; margin-right: 10px;">
|
||||
<input type="number" step="0.01" name="quotas[${newIndex}][prc]" placeholder="Anteil in %" style="width: 120px;">
|
||||
<button type="button" class="remove-quota" style="margin-left: 10px;">Entfernen</button>
|
||||
`;
|
||||
container.appendChild(newItem);
|
||||
});
|
||||
|
||||
document.getElementById('quotas-container').addEventListener('click', function(e) {
|
||||
if (e.target && e.target.classList.contains('remove-quota')) {
|
||||
e.target.closest('.quota-item').remove();
|
||||
|
||||
const container = document.getElementById('quotas-container');
|
||||
const items = container.querySelectorAll('.quota-item');
|
||||
items.forEach((item, index) => {
|
||||
item.querySelector('label').textContent = `Quote ${index + 1}:`;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Season List -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue