Finanzmanager/src/Views/wertpapiere/stammdaten.php
fds2610-bot be3ee6400e Detailseite eines Wertpapiers
Der Name in Bestandsübersicht, Depotbuchungen und Stammdaten führt jetzt auf
/wertpapiere/papier/{id}: Kennzahlen über die ganze Historie, Stammdaten und
Kurs, Bestand je Depot, Wertentwicklung und die Buchungen eines Zeitraums.

Depot::bestand() und Depot::entwicklung() nehmen dafür eine Wertpapiernummer
entgegen – die Detailseite rechnet nicht selbst, sondern bekommt dieselben
Zahlen wie die Übersicht. Neu sind Wertpapier::kurseckwerte() und
Depotbuchung::datumsgrenzen().

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-13 15:08:01 +02:00

124 lines
5.6 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\Wertpapier;
use Finanzmanager\Services\Kursabruf;
use Finanzmanager\View;
/**
* @var list<array<string,mixed>> $wertpapiere
* @var string|null $anbieter
* @var bool $schluessel
* @var string $csrfToken
*/
include __DIR__ . '/../layout/kopf.php';
?>
<div class="tableiste">
<a href="/wertpapiere" class="tab">Bestände</a>
<a href="/wertpapiere/buchungen" class="tab">Depotbuchungen</a>
<span class="tab aktiv">Wertpapiere</span>
<a href="/wertpapiere/auswertung?art=veraeusserungen" class="tab">Veräußerungen</a>
<a href="/wertpapiere/auswertung?art=ertraege" class="tab">Erträge</a>
</div>
<div class="seitenaktionen">
<?php if ($schluessel): ?>
<form method="post" action="/wertpapiere/kurse" class="inline">
<input type="hidden" name="csrf_token" value="<?= View::h($csrfToken) ?>">
<button type="submit" class="knopf primaer">Kurse jetzt abrufen</button>
</form>
<span class="nebentext">
über <?= View::h(Kursabruf::ANBIETER[$anbieter] ?? (string)$anbieter) ?>
</span>
<?php else: ?>
<a href="/einstellungen?bereich=wertpapiere" class="knopf">Kursdienst einrichten</a>
<span class="nebentext">Ohne API-Schlüssel bleibt nur die Eingabe von Hand.</span>
<?php endif; ?>
</div>
<?php if ($wertpapiere === []): ?>
<p class="platzhalter">
Noch keine Wertpapiere. Sie entstehen beim QIF-Import oder beim Erfassen der ersten
Depotbuchung.
</p>
<?php else: ?>
<?php foreach ($wertpapiere as $papier): ?>
<form id="wp-<?= (int)$papier['id'] ?>" method="post"
action="/wertpapiere/stammdaten/<?= (int)$papier['id'] ?>"></form>
<form id="kurs-<?= (int)$papier['id'] ?>" method="post"
action="/wertpapiere/stammdaten/<?= (int)$papier['id'] ?>/kurs"></form>
<?php endforeach; ?>
<table class="liste">
<thead>
<tr>
<th>Name</th><th>ISIN</th><th>WKN</th><th>Art</th><th>Kürzel</th>
<th>Letzter Kurs</th><th>Kurs eintragen</th><th>Aktiv</th><th class="rechts">Aktion</th>
</tr>
</thead>
<tbody>
<?php foreach ($wertpapiere as $papier): ?>
<?php $f = 'wp-' . (int)$papier['id']; $k = 'kurs-' . (int)$papier['id']; ?>
<tr<?= (int)$papier['aktiv'] === 1 ? '' : ' class="inaktiv"' ?>>
<td>
<input type="hidden" form="<?= $f ?>" name="csrf_token" value="<?= View::h($csrfToken) ?>">
<input type="text" form="<?= $f ?>" name="name" value="<?= View::h($papier['name']) ?>" required>
</td>
<td><input type="text" form="<?= $f ?>" name="isin" class="schmal"
value="<?= View::h($papier['isin']) ?>"></td>
<td><input type="text" form="<?= $f ?>" name="wkn" class="schmal"
value="<?= View::h($papier['wkn']) ?>"></td>
<td>
<select form="<?= $f ?>" name="art">
<?php foreach (Wertpapier::ARTEN as $schluesselArt => $name): ?>
<option value="<?= View::h($schluesselArt) ?>"
<?= $papier['art'] === $schluesselArt ? 'selected' : '' ?>>
<?= View::h($name) ?>
</option>
<?php endforeach; ?>
</select>
</td>
<td>
<input type="text" form="<?= $f ?>" name="symbol" class="schmal"
value="<?= View::h($papier['symbol']) ?>"
title="Kürzel beim Kursdienst – wird beim ersten Abruf selbst ermittelt">
</td>
<td class="rechts">
<?php if ($papier['kurs'] === null): ?>
<span class="nebentext">–</span>
<?php else: ?>
<?= View::h(number_format((float)$papier['kurs'], 2, ',', '.')) ?>
<span class="nebentext"><?= View::h(View::datum($papier['kurs_datum'])) ?></span>
<?php endif; ?>
</td>
<td class="nowrap">
<input type="hidden" form="<?= $k ?>" name="csrf_token" value="<?= View::h($csrfToken) ?>">
<input type="hidden" form="<?= $k ?>" name="datum" value="<?= View::h(date('Y-m-d')) ?>">
<input type="text" form="<?= $k ?>" name="kurs" class="schmal" inputmode="decimal"
placeholder="Kurs">
<button type="submit" form="<?= $k ?>" class="knopf klein">Setzen</button>
</td>
<td>
<label class="ankreuzfeld">
<input type="checkbox" form="<?= $f ?>" name="aktiv" value="1"
<?= (int)$papier['aktiv'] === 1 ? 'checked' : '' ?>>
</label>
</td>
<td class="rechts nowrap">
<a href="/wertpapiere/papier/<?= (int)$papier['id'] ?>" class="knopf klein">Details</a>
<button type="submit" form="<?= $f ?>" class="knopf klein">Speichern</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<p class="hinweis klein">
Das <strong>Kürzel</strong> ist der Name des Papiers beim Kursdienst. Es wird beim
ersten Abruf aus der ISIN ermittelt und gemerkt – das spart bei jedem weiteren Abruf
eine Anfrage, und das Freikontingent ist knapp.
</p>
<?php endif; ?>
<?php include __DIR__ . '/../layout/fuss.php'; ?>