Files

186 lines
9.6 KiB
PHP

<section class="page-grid">
<article class="glass-panel form-panel form-panel--wide">
<div class="section-head">
<div>
<p class="eyebrow">Tag erfassen</p>
<h3><?= e(format_display_date($entry['date'])) ?></h3>
</div>
<div class="section-head__actions">
<a class="ghost-link" href="/archive?view=days&amp;date=<?= e(rawurlencode($entry['date'])) ?>">Im Archiv ansehen</a>
<a class="ghost-link" href="/track?date=<?= e(today()) ?>">Heute</a>
</div>
</div>
<form method="post" action="/track" class="tracker-form" id="tracker-form" autocomplete="off">
<?= csrf_field() ?>
<input type="hidden" name="date" value="<?= e($entry['date']) ?>">
<?php $walkMode = ($entry['walk_mode'] ?? ($settings['walk']['mode'] ?? 'time')) === 'steps' ? 'steps' : 'time'; ?>
<input type="hidden" name="walk_mode" value="<?= e($walkMode) ?>">
<div class="field-grid field-grid--three">
<label class="range-card">
<span>Stimmung</span>
<output data-output-for="mood"><?= e((string) $entry['mood']) ?></output>
<input type="range" min="1" max="10" step="1" name="mood" value="<?= e((string) $entry['mood']) ?>">
</label>
<label class="range-card">
<span>Energie</span>
<output data-output-for="energy"><?= e((string) $entry['energy']) ?></output>
<input type="range" min="1" max="10" step="1" name="energy" value="<?= e((string) $entry['energy']) ?>">
</label>
<label class="range-card">
<span>Stress</span>
<output data-output-for="stress"><?= e((string) $entry['stress']) ?></output>
<input type="range" min="1" max="10" step="1" name="stress" value="<?= e((string) $entry['stress']) ?>">
</label>
</div>
<?php if (!empty($settings['tracking']['pain_enabled'])): ?>
<div class="field-grid field-grid--two">
<label class="range-card">
<span>Schmerzen</span>
<output data-output-for="pain"><?= e((string) $entry['pain']) ?></output>
<input type="range" min="1" max="10" step="1" name="pain" value="<?= e((string) $entry['pain']) ?>">
</label>
<div class="sport-choice-field sport-choice-field--single">
<div class="sport-choice-list sport-choice-list--single">
<label class="sport-choice">
<input type="checkbox" name="alcohol" value="1" <?= !empty($entry['alcohol']) ? 'checked' : '' ?>>
<span class="sport-choice__card sport-choice__card--toggle">
<img src="<?= e(icon_path('alcohol')) ?>" alt="">
<strong>Alkohol</strong>Heute was getrunken?
</span>
</label>
</div>
</div>
</div>
<?php else: ?>
<div class="field-grid field-grid--single">
<div class="sport-choice-field sport-choice-field--single">
<div class="sport-choice-list sport-choice-list--single">
<label class="sport-choice">
<input type="checkbox" name="alcohol" value="1" <?= !empty($entry['alcohol']) ? 'checked' : '' ?>>
<span class="sport-choice__card sport-choice__card--toggle">
<img src="<?= e(icon_path('alcohol')) ?>" alt="">
<strong>Alkohol</strong>Heute was getrunken?
</span>
</label>
</div>
</div>
</div>
<?php endif; ?>
<div class="field-grid field-grid--two">
<label>
<span>Schlafdauer in Stunden</span>
<input type="number" min="0" max="24" step="0.25" name="sleep_hours" value="<?= e((string) $entry['sleep_hours']) ?>" required>
</label>
<label>
<span>Schlafgefühl</span>
<select name="sleep_feeling">
<?php foreach ($settings['labels']['sleep_feeling'] as $value => $label): ?>
<option value="<?= e((string) $value) ?>" <?= (int) $entry['sleep_feeling'] === (int) $value ? 'selected' : '' ?>>
<?= e((string) $value) ?> · <?= e($label) ?>
</option>
<?php endforeach; ?>
</select>
</label>
</div>
<div class="field-grid field-grid--two">
<label>
<span>Sport in Minuten</span>
<input type="number" min="0" max="1440" step="1" name="sport_minutes" value="<?= e((string) $entry['sport_minutes']) ?>" required>
</label>
<label>
<span><?= $walkMode === 'steps' ? 'Spaziergang in Schritten' : 'Spaziergang in Minuten' ?></span>
<input
type="number"
min="0"
max="<?= $walkMode === 'steps' ? '50000' : '1440' ?>"
step="1"
name="<?= $walkMode === 'steps' ? 'walk_steps' : 'walk_minutes' ?>"
value="<?= e((string) ($walkMode === 'steps' ? ($entry['walk_steps'] ?? 0) : $entry['walk_minutes'])) ?>"
required
>
</label>
</div>
<div class="field-grid field-grid--single">
<fieldset class="sport-choice-field">
<legend>Sportarten</legend>
<div class="sport-choice-list">
<?php foreach ($sportTypes as $sportType): ?>
<?php $isChecked = in_array($sportType['id'], $entry['sport_types'], true); ?>
<label class="sport-choice">
<input type="checkbox" name="sport_types[]" value="<?= e($sportType['id']) ?>" <?= $isChecked ? 'checked' : '' ?>>
<span class="sport-choice__card">
<img src="<?= e(sport_icon_path($sportType['icon'])) ?>" alt="">
<strong><?= e($sportType['label']) ?></strong>
<?php if (!empty($sportType['location'])): ?>
<small><?= e(sport_location_label((string) $sportType['location'])) ?></small>
<?php endif; ?>
</span>
</label>
<?php endforeach; ?>
</div>
</fieldset>
</div>
<label>
<span>Tagebuchnotiz</span>
<textarea name="note" rows="8" placeholder="Was war heute wichtig, schwer oder schön?"><?= e($entry['note']) ?></textarea>
</label>
<div class="form-actions">
<span class="helper-text">Werte ändern, speichern und bei Bedarf vergangene Tage bequem nachtragen.</span>
<button class="primary-button" type="submit">Tag speichern</button>
</div>
</form>
</article>
<aside class="stack-column">
<article class="glass-panel preview-card" id="live-score-card" data-payload="<?= e($trackPayload) ?>" data-sentiment="<?= e($evaluation['sentiment']) ?>">
<p class="eyebrow">Live-Bewertung</p>
<div class="preview-status">
<div class="preview-status__icon">
<img data-preview-icon src="<?= e(mood_icon_path($evaluation['sentiment'])) ?>" alt="">
</div>
<div>
<p class="preview-status__label" data-preview-label><?= e($evaluation['label']) ?></p>
<p class="helper-text">Die Einschätzung passt sich beim Ändern der Werte sofort an.</p>
</div>
</div>
<p class="preview-scoreline"><span data-preview-total><?= e(format_points((float) $evaluation['total'])) ?></span> Punkte</p>
<dl class="component-list" data-preview-components>
<?php
$componentLabels = [
'mood' => 'Stimmung',
'energy' => 'Energie',
'stress' => 'Stress',
'pain' => 'Schmerzen',
'sleep_hours' => 'Schlafdauer',
'sleep_feeling' => 'Schlafgefühl',
'sport_minutes' => 'Sport',
'sport_bonus' => 'Sportbonus',
'walk_minutes' => 'Spaziergang',
'alcohol' => 'Alkohol',
'note' => 'Notiz',
];
?>
<?php foreach ($evaluation['components'] as $name => $value): ?>
<div>
<dt><?= e($componentLabels[$name] ?? $name) ?></dt>
<dd><?= e(format_points((float) $value)) ?></dd>
</div>
<?php endforeach; ?>
</dl>
</article>
</aside>
</section>