Steuerkram/src/Views/settings/_suggestion_card.php
fds2610-bot 23efce3196 Fix #161: Restposten aus Tech-Debt-Analyse (O-CHAT.html, fints.php/bankimport.php, Request-Klasse)
(a) public/O-CHAT.html nach BEISPIELE/ verschoben, Test 93 hält den Webroot sauber.
(b) bank/fints.php in Teil-Views + public/static/js/fints.js aufgeteilt.
(c) settings/bankimport.php in Teil-Views + public/static/js/bankimport.js aufgeteilt.
(d) src/Request.php angelegt, BankController als erster Controller umgestellt.
2026-08-18 13:12:12 +02:00

172 lines
11 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
$sugHeader = $suggestion['header'] ?? [];
$sugMapping = $suggestion['mapping'] ?? [];
$allMappingFields = [
'buchungstag' => 'Buchungstag',
'wertstellung' => 'Wertstellung',
'vorgang' => 'Vorgang / Umsatztyp',
'wert' => 'Betrag',
'zahlungspflichtiger' => 'Zahlungspflichtiger',
'zahlungsempfaenger' => 'Zahlungsempfänger',
'verwendungszweck' => 'Verwendungszweck',
];
?>
<div class="card mb-2" id="suggestion-card" style="border:2px solid #6366f1">
<div class="card-header" style="background:#eef2ff;display:flex;align-items:center;gap:.75rem">
<div class="card-title" style="flex:1">Neues Format (automatischer Vorschlag)</div>
<span style="font-size:.75rem;font-weight:600;padding:.2rem .6rem;border-radius:9999px;background:#818cf8;color:#fff">Nicht gespeichert</span>
</div>
<div class="card-body">
<form method="post" action="/settings/bankimport/create">
<p style="font-size:.8rem;color:var(--color-muted);margin:0 0 1.25rem">
Das Programm hat die Headerzeile in der CSV gefunden und Spalten automatisch zugeordnet.
Bitte prüfe die Einstellungen und klicke auf <strong>Speichern</strong>, um das neue Format anzulegen.
</p>
<div class="bi-section-label">Format-Konfiguration</div>
<table class="bi-table" style="margin-bottom:1.5rem">
<tbody>
<tr>
<td class="bi-label">Name</td>
<td><input type="text" name="name" value="Neues Format" required maxlength="100" style="width:220px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius)"></td>
</tr>
<tr>
<td class="bi-label">Anzeige-Kürzel</td>
<td><input type="text" name="kuerzel" value="NEU" required maxlength="10" style="width:80px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius)"></td>
</tr>
<tr>
<td class="bi-label">Übersprungene Zeilen</td>
<td><input type="number" name="skip_rows" value="<?= (int)($suggestion['skip_rows'] ?? 0) ?>" min="0" max="99" style="width:70px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius)"></td>
</tr>
<tr>
<td class="bi-label">Headerzeile vorhanden</td>
<td>
<select name="has_header_row" style="padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius)">
<option value="1" <?= ($suggestion['has_header_row'] ?? 1) ? 'selected' : '' ?>>Ja</option>
<option value="0" <?= !($suggestion['has_header_row'] ?? 1) ? 'selected' : '' ?>>Nein</option>
</select>
</td>
</tr>
<tr>
<td class="bi-label">Trennzeichen</td>
<td><input type="text" name="delimiter" value="<?= $h($suggestion['delimiter'] ?? ';') ?>" maxlength="1" required style="width:50px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius);font-family:monospace"></td>
</tr>
<tr>
<td class="bi-label">Anführungszeichen</td>
<td><input type="text" name="enclosure" value="<?= $h($suggestion['enclosure'] ?? '"') ?>" maxlength="1" required style="width:50px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius);font-family:monospace"></td>
</tr>
<tr>
<td class="bi-label">Datumsformat</td>
<td>
<select name="date_format" style="padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius)">
<?php foreach ($dateFormatOptions as $dfFormat => $dfExample): ?>
<option value="<?= $h($dfFormat) ?>"><?= $h($dfFormat) ?> → <?= $h($dfExample) ?></option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<td class="bi-label">Dezimaltrennzeichen</td>
<td><input type="text" name="decimal_separator" value="," maxlength="1" required style="width:50px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius);font-family:monospace"></td>
</tr>
<tr>
<td class="bi-label">Tausendertrennzeichen</td>
<td><input type="text" name="thousands_separator" value="." maxlength="1" placeholder="(leer)" style="width:50px;padding:.3rem .5rem;border:1px solid var(--color-border);border-radius:var(--radius);font-family:monospace"></td>
</tr>
</tbody>
</table>
<?php
$sugFirstData = $suggestion['first_data'] ?? [];
if (!empty($sugHeader) || !empty($sugFirstData)):
?>
<div class="bi-section-label">Erkannte Headerzeile</div>
<div style="font-size:.8rem;font-family:monospace;background:#f8fafc;padding:.4rem .6rem;border-radius:4px;border:1px solid var(--color-border);overflow-x:auto;white-space:nowrap;margin-bottom:.5rem">
<?php foreach ($sugHeader as $i => $col): ?>
<span title="Spalte <?= $i ?>"><span style="opacity:.45"><?= $i ?>:</span><?= $h($col) ?></span><?php if ($i < count($sugHeader) - 1): ?> <span style="color:var(--color-border)">|</span> <?php endif; ?>
<?php endforeach; ?>
</div>
<?php if (!empty($sugFirstData)): ?>
<div style="font-size:.75rem;color:var(--color-muted);margin-bottom:.3rem">Erste Datenzeile</div>
<div style="font-size:.8rem;font-family:monospace;background:#f8fafc;padding:.4rem .6rem;border-radius:4px;border:1px solid var(--color-border);overflow-x:auto;white-space:nowrap;margin-bottom:1.5rem">
<?php foreach ($sugFirstData as $i => $val): ?>
<span title="Spalte <?= $i ?><?= isset($sugHeader[$i]) ? ': ' . htmlspecialchars($sugHeader[$i]) : '' ?>"><span style="opacity:.45"><?= $i ?>:</span><?= $h($val) ?></span><?php if ($i < count($sugFirstData) - 1): ?> <span style="color:var(--color-border)">|</span> <?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="bi-section-label">Feld-Zuordnungen</div>
<table class="bi-table" style="margin-bottom:1.5rem">
<thead>
<tr>
<th class="bi-label">Datenbankfeld</th>
<th style="width:100px">Spalte (0-basiert)</th>
<th style="color:var(--color-muted);font-weight:500">Erkannte CSV-Überschrift</th>
</tr>
</thead>
<tbody>
<?php foreach ($allMappingFields as $field => $label):
$colKey = 'col_' . $field;
$colIdx = $sugMapping[$colKey] ?? null;
$headerVal = ($colIdx !== null && isset($sugHeader[$colIdx])) ? $sugHeader[$colIdx] : '';
$isNullInt = in_array($field, ['zahlungspflichtiger', 'zahlungsempfaenger', 'verwendungszweck'], true);
?>
<tr>
<td class="bi-label"><?= $h($label) ?></td>
<td>
<input type="number" name="col_<?= $h($field) ?>"
value="<?= $colIdx !== null ? $colIdx : '' ?>"
min="0" max="99"
<?= $isNullInt ? '' : 'required' ?>
style="width:65px;padding:.25rem .4rem;border:1px solid var(--color-border);border-radius:var(--radius);font-family:monospace">
</td>
<td style="color:var(--color-muted);font-size:.875rem">
<?php if ($headerVal !== ''): ?>
<?= $h($headerVal) ?>
<?php if ($colIdx !== null): ?>
<span style="opacity:.5;font-size:.75rem"> (Sp.<?= $colIdx ?>)</span>
<?php endif; ?>
<?php else: ?>
<span style="font-style:italic">–</span>
<?php endif; ?>
</td>
</tr>
<?php if ($field === 'vorgang'): ?>
<tr>
<td class="bi-label">Buchungstext <small style="font-weight:400">(Betrag &lt; 0)</small></td>
<td colspan="2" style="padding-right:0">
<input type="text" name="buchungstext_template_debit" value=""
maxlength="500" placeholder="z.B. {Zahlungsempfänger} · {Verwendungszweck}"
style="width:100%;box-sizing:border-box;padding:.25rem .4rem;border:1px solid var(--color-border);border-radius:var(--radius)">
</td>
</tr>
<tr>
<td class="bi-label">Buchungstext <small style="font-weight:400">(Betrag &gt; 0)</small></td>
<td colspan="2" style="padding-right:0">
<input type="text" name="buchungstext_template_credit" value=""
maxlength="500" placeholder="z.B. {Zahlungspflichtiger} · {Verwendungszweck}"
style="width:100%;box-sizing:border-box;padding:.25rem .4rem;border:1px solid var(--color-border);border-radius:var(--radius)">
</td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<tr>
<td colspan="3" style="padding:.4rem 0 0;font-size:.78rem;color:var(--color-muted)">
Platzhalter <code>{CSV-Überschrift}</code> werden durch den Wert der jeweiligen Spalte ersetzt.
Optional: Zahlungspflichtiger, Zahlungsempfänger, Verwendungszweck (für Templates).
</td>
</tr>
</tbody>
</table>
<div style="display:flex;gap:.75rem">
<button type="submit" class="btn btn-primary">Speichern</button>
<button type="button" id="suggestion-dismiss" class="btn btn-secondary">Verwerfen</button>
</div>
</form>
</div>
</div>