Finanzmanager/src/Views/konten/formular.php
fds2610-bot a22c33bb12 Kontoformular zweispaltig
Konto bearbeiten und Neues Konto zeigen ihre vierzehn Felder in zwei
Spalten, damit alles ohne vertikales Scrollen auf einen Bildschirm passt.

- Neue Formularvariante .formular.zweispaltig: Grid mit zwei Spalten, je
  Feld ein .feld aus Beschriftung, Eingabe und Hinweis. Überschriften,
  Knopfleiste und .feld.ganz laufen über beide Spalten, unter 720 px
  fällt das Formular auf eine Spalte zurück.
- Feldreihenfolge zeilenweise; Namen, Werte und Feld-IDs unverändert.
- E2E-Test: Kontoart steht rechts neben dem Namen, das Formular endet
  oberhalb der Fensterhöhe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 23:12:35 +02:00

142 lines
5.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Finanzmanager\Models\Konto;
use Finanzmanager\View;
/** @var array<string,mixed>|null $konto */
/** @var list<array<string,mixed>> $gruppen */
/** @var string $csrfToken */
$neu = $konto === null;
$ziel = $neu ? '/konten/neu' : '/konten/' . (int)$konto['id'] . '/bearbeiten';
$wert = static fn(string $feld, string $standard = ''): string
=> View::h((string)($konto[$feld] ?? $standard));
include __DIR__ . '/../layout/kopf.php';
?>
<div class="seitenaktionen">
<a href="/konten" class="knopf">Zurück zur Kontenübersicht</a>
</div>
<form method="post" action="<?= View::h($ziel) ?>" class="formular breit zweispaltig">
<input type="hidden" name="csrf_token" value="<?= View::h($csrfToken) ?>">
<div class="feld">
<label for="name">Name des Kontos</label>
<input type="text" id="name" name="name" value="<?= $wert('name') ?>" required autofocus>
</div>
<div class="feld">
<label for="kontoart">Kontoart</label>
<select id="kontoart" name="kontoart">
<?php foreach (Konto::ARTEN as $schluessel => $beschriftung): ?>
<option value="<?= View::h($schluessel) ?>"
<?= ($konto['kontoart'] ?? 'bank') === $schluessel ? 'selected' : '' ?>>
<?= View::h($beschriftung) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="feld">
<label for="kontengruppe_id">Kontengruppe</label>
<select id="kontengruppe_id" name="kontengruppe_id">
<option value="">Nicht gruppiert</option>
<?php foreach ($gruppen as $gruppe): ?>
<option value="<?= (int)$gruppe['id'] ?>"
<?= (int)($konto['kontengruppe_id'] ?? 0) === (int)$gruppe['id'] ? 'selected' : '' ?>>
<?= View::h($gruppe['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="feld">
<label for="beschreibung">Beschreibung <span class="optional">(optional)</span></label>
<input type="text" id="beschreibung" name="beschreibung" value="<?= $wert('beschreibung') ?>">
</div>
<div class="feld">
<label for="bankname">Bank <span class="optional">(optional)</span></label>
<input type="text" id="bankname" name="bankname" value="<?= $wert('bankname') ?>">
</div>
<div class="feld">
<label for="kontonummer">Kontonummer <span class="optional">(optional)</span></label>
<input type="text" id="kontonummer" name="kontonummer" value="<?= $wert('kontonummer') ?>">
</div>
<div class="feld">
<label for="iban">IBAN <span class="optional">(optional)</span></label>
<input type="text" id="iban" name="iban" value="<?= $wert('iban') ?>">
</div>
<div class="feld">
<label for="bic">BIC <span class="optional">(optional)</span></label>
<input type="text" id="bic" name="bic" value="<?= $wert('bic') ?>">
</div>
<div class="feld">
<label for="anfangssaldo">Anfangssaldo</label>
<input type="text" id="anfangssaldo" name="anfangssaldo" inputmode="decimal"
value="<?= View::h(View::betrag($konto['anfangssaldo'] ?? 0, false)) ?>">
<p class="feldhinweis">
Kontostand vor der ersten erfassten Buchung. Der QIF-Export enthält ihn nicht –
nach einem Import wird er hier je Konto nachgetragen.
</p>
</div>
<div class="feld">
<label for="kreditlimit">Kreditlimit <span class="optional">(optional)</span></label>
<input type="text" id="kreditlimit" name="kreditlimit" inputmode="decimal"
value="<?= $konto === null || $konto['kreditlimit'] === null
? '' : View::h(View::betrag($konto['kreditlimit'], false)) ?>">
</div>
<div class="feld">
<label for="sortierung">Sortierung</label>
<input type="number" id="sortierung" name="sortierung" value="<?= $wert('sortierung', '0') ?>" step="1">
<p class="feldhinweis">Kleinere Werte stehen in der Kontenübersicht weiter oben.</p>
</div>
<div class="feld">
<label class="ankreuzfeld">
<input type="checkbox" name="aktiv" value="1" <?= $neu || (int)$konto['aktiv'] === 1 ? 'checked' : '' ?>>
Konto ist aktiv
</label>
<label class="ankreuzfeld">
<input type="checkbox" name="in_summe" value="1"
<?= $neu || (int)$konto['in_summe'] === 1 ? 'checked' : '' ?>>
Zählt zur Summe der Kontostände
</label>
<p class="feldhinweis">
Entspricht der Σ-Spalte im FinanzManager. Konten, die kein eigenes Vermögen
darstellen – durchlaufende Auslagen etwa –, bleiben so aus der Gesamtsumme heraus,
erscheinen aber weiter in der Übersicht.
</p>
</div>
<div class="knopfleiste">
<button type="submit" class="knopf primaer"><?= $neu ? 'Konto anlegen' : 'Speichern' ?></button>
<a href="/konten" class="knopf">Abbrechen</a>
</div>
</form>
<?php if (!$neu): ?>
<form method="post" action="/konten/<?= (int)$konto['id'] ?>/loeschen" class="formular breit zweispaltig"
data-bestaetigen="Konto „<?= View::h($konto['name']) ?>“ wirklich löschen?">
<input type="hidden" name="csrf_token" value="<?= View::h($csrfToken) ?>">
<h3>Konto löschen</h3>
<p class="feldhinweis">
Ein Konto, das nur nicht mehr genutzt wird, sollte auf inaktiv gesetzt statt
gelöscht werden – gelöschte Konten nehmen später ihre Buchungen mit.
</p>
<div class="knopfleiste">
<button type="submit" class="knopf gefahr">Konto löschen</button>
</div>
</form>
<?php endif; ?>
<?php include __DIR__ . '/../layout/fuss.php'; ?>