This commit is contained in:
@@ -583,6 +583,7 @@ $sectionLinks = [
|
||||
<div class="stack gap-6">
|
||||
<label class="label" for="cAge">Alter (Jahre)</label>
|
||||
<input id="cAge" name="age_years" class="input" type="number" min="0" max="18" value="<?= htmlspecialchars((string)($editChild['age_years'] ?? ''), ENT_QUOTES) ?>">
|
||||
<p class="muted small" style="margin:0;">Mit Geburtsdatum wird das Alter automatisch berechnet und jaehrlich aktualisiert. Ohne Geburtsdatum gilt der manuelle Wert.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stack gap-6">
|
||||
@@ -880,6 +881,47 @@ $sectionLinks = [
|
||||
})();
|
||||
<?php endif; ?>
|
||||
|
||||
(function(){
|
||||
const birthInput = document.getElementById('cBirth');
|
||||
const ageInput = document.getElementById('cAge');
|
||||
|
||||
if (!birthInput || !ageInput) return;
|
||||
|
||||
const calculateAge = (value) => {
|
||||
if (!value) return null;
|
||||
const birthDate = new Date(`${value}T00:00:00`);
|
||||
if (Number.isNaN(birthDate.getTime())) return null;
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
if (birthDate > today) return null;
|
||||
|
||||
let age = today.getFullYear() - birthDate.getFullYear();
|
||||
const monthDiff = today.getMonth() - birthDate.getMonth();
|
||||
const dayDiff = today.getDate() - birthDate.getDate();
|
||||
if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
|
||||
age -= 1;
|
||||
}
|
||||
return Math.max(0, age);
|
||||
};
|
||||
|
||||
const syncAgeField = () => {
|
||||
const calculatedAge = calculateAge(birthInput.value);
|
||||
if (calculatedAge === null) {
|
||||
ageInput.readOnly = false;
|
||||
ageInput.removeAttribute('aria-readonly');
|
||||
return;
|
||||
}
|
||||
|
||||
ageInput.value = String(calculatedAge);
|
||||
ageInput.readOnly = true;
|
||||
ageInput.setAttribute('aria-readonly', 'true');
|
||||
};
|
||||
|
||||
birthInput.addEventListener('input', syncAgeField);
|
||||
syncAgeField();
|
||||
})();
|
||||
|
||||
(function(){
|
||||
const statusText = document.getElementById('locationBrowserStatusText');
|
||||
const hintText = document.getElementById('locationBrowserStatusHint');
|
||||
|
||||
@@ -15,10 +15,10 @@ if ($isLoggedIn) {
|
||||
static fn(string $column): string => $column,
|
||||
\App\Avatar\AvatarManager::allProfileColumns()
|
||||
));
|
||||
$stmt = $pdo->prepare("SELECT user_id, display_name, first_name, $avatarColumns FROM user_profiles WHERE user_id = :id LIMIT 1");
|
||||
$stmt = $pdo->prepare("SELECT user_id, display_name, $avatarColumns FROM user_profiles WHERE user_id = :id LIMIT 1");
|
||||
$stmt->execute(['id' => (int)$_SESSION['user_id']]);
|
||||
$profileRow = $stmt->fetch(PDO::FETCH_ASSOC) ?: [];
|
||||
$displayName = trim((string)($profileRow['display_name'] ?? '')) ?: trim((string)($profileRow['first_name'] ?? '')) ?: 'Profil';
|
||||
$displayName = trim((string)($profileRow['display_name'] ?? '')) ?: 'Profil';
|
||||
|
||||
$communityCfg = dirname(__DIR__, 2) . '/config/community.php';
|
||||
if (file_exists($communityCfg)) {
|
||||
|
||||
Reference in New Issue
Block a user