boerse
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-22 01:31:18 +02:00
parent a1bab34bd3
commit 91dc84d027
16 changed files with 1697 additions and 86 deletions

View File

@@ -1,3 +1,4 @@
<?php $ownerQuery = $isAdmin ? '?owner_sub=' . urlencode((string) $ownerSub) : ''; ?>
<div class="card">
<div class="pill">Boersenchecker</div>
<h1 style="margin-top:.75rem;">Depotverwaltung</h1>
@@ -16,11 +17,31 @@
</div>
<?php endif; ?>
<?php if ($isAdmin): ?>
<div class="card" style="margin-top:1rem; background:var(--panel-2);">
<strong>Benutzer-Scope</strong>
<form method="get" style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap; align-items:end;">
<label class="setup-field muted" style="margin:0; min-width:260px;">
<span>Depots von Benutzer</span>
<select name="owner_sub">
<?php foreach ($availableOwners as $owner): ?>
<option value="<?= e((string) $owner['sub']) ?>" <?= (string) $ownerSub === (string) $owner['sub'] ? 'selected' : '' ?>>
<?= e((string) $owner['label']) ?>
</option>
<?php endforeach; ?>
</select>
</label>
<button class="cta-button" type="submit">Anzeigen</button>
</form>
</div>
<?php endif; ?>
<div class="grid" style="margin-top:1rem;">
<div class="card" style="background:var(--panel-2);">
<strong><?= $editPortfolio ? 'Depot bearbeiten' : 'Neues Depot' ?></strong>
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
<input type="hidden" name="action" value="save_portfolio">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="portfolio_id" value="<?= e((string) ($editPortfolio['id'] ?? '0')) ?>">
<label class="setup-field muted">
<span>Depotname</span>
@@ -37,7 +58,7 @@
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<button class="cta-button" type="submit">Depot speichern</button>
<?php if ($editPortfolio): ?>
<a class="nav-link" href="/module/boersenchecker">Abbrechen</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung<?= e($ownerQuery) ?>">Abbrechen</a>
<?php endif; ?>
</div>
</form>
@@ -55,10 +76,12 @@
<div style="display:flex; gap:10px; flex-wrap:wrap; margin-top:1rem;">
<form method="post">
<input type="hidden" name="action" value="refresh_fx">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<button class="cta-button" type="submit">FX-Daten aktualisieren</button>
</form>
<form method="post">
<input type="hidden" name="action" value="refresh_alpha_vantage_all">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<button class="nav-link" type="submit">Alle API-Kurse abrufen</button>
</form>
</div>
@@ -81,6 +104,7 @@
<?php else: ?>
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
<input type="hidden" name="action" value="save_position">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="position_id" value="<?= e((string) ($editPosition['id'] ?? '0')) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) ($editPosition['instrument_id'] ?? '0')) ?>">
<label class="setup-field muted">
@@ -149,7 +173,7 @@
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<button class="cta-button" type="submit">Position speichern</button>
<?php if ($editPosition): ?>
<a class="nav-link" href="/module/boersenchecker">Abbrechen</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung<?= e($ownerQuery) ?>">Abbrechen</a>
<?php endif; ?>
</div>
</form>
@@ -163,6 +187,7 @@
</p>
<form method="post" style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap; align-items:end;">
<input type="hidden" name="action" value="search_symbol">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<label class="setup-field muted" style="margin:0; min-width:260px; flex:1;">
<span>Suchbegriff</span>
<input type="text" name="search_keywords" value="<?= e($symbolSearchKeywords) ?>" placeholder="z.B. Mercedes, AAPL, Allianz" required>
@@ -194,7 +219,7 @@
<td style="padding:8px;"><?= e((string) ($result['currency'] ?? '')) ?></td>
<td style="padding:8px;"><?= e((string) ($result['match_score'] ?? '')) ?></td>
<td style="padding:8px;">
<a class="nav-link" href="/module/boersenchecker?symbol_candidate=<?= urlencode((string) ($result['symbol'] ?? '')) ?>&instrument_name_candidate=<?= urlencode((string) ($result['name'] ?? '')) ?>&market_candidate=<?= urlencode((string) ($result['region'] ?? '')) ?>&quote_currency_candidate=<?= urlencode((string) ($result['currency'] ?? '')) ?>">
<a class="nav-link" href="/module/boersenchecker/depotverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&symbol_candidate=<?= urlencode((string) ($result['symbol'] ?? '')) ?>&instrument_name_candidate=<?= urlencode((string) ($result['name'] ?? '')) ?>&market_candidate=<?= urlencode((string) ($result['region'] ?? '')) ?>&quote_currency_candidate=<?= urlencode((string) ($result['currency'] ?? '')) ?>">
In Formular uebernehmen
</a>
</td>
@@ -213,6 +238,7 @@
<?php else: ?>
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
<input type="hidden" name="action" value="save_quote">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<div class="grid" style="grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px;">
<label class="setup-field muted">
<span>Aktie</span>
@@ -267,9 +293,10 @@
<div class="muted"><?= e((string) $portfolio['base_currency']) ?> · <?= e((string) $stats['positions']) ?> Position(en)</div>
</div>
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<a class="nav-link" href="/module/boersenchecker?edit_portfolio=<?= e((string) $portfolioId) ?>">Bearbeiten</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&edit_portfolio=<?= e((string) $portfolioId) ?>">Bearbeiten</a>
<form method="post" onsubmit="return confirm('Depot wirklich loeschen?')">
<input type="hidden" name="action" value="delete_portfolio">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="portfolio_id" value="<?= e((string) $portfolioId) ?>">
<button class="nav-link" type="submit">Loeschen</button>
</form>
@@ -360,15 +387,17 @@
</td>
<td style="padding:8px;">
<div style="display:flex; gap:8px; flex-wrap:wrap;">
<a class="nav-link" href="/module/boersenchecker?edit_position=<?= e((string) $position['id']) ?>">Bearbeiten</a>
<a class="nav-link" href="/module/boersenchecker?instrument_id=<?= e((string) $position['instrument_id']) ?>">Kurs erfassen</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&edit_position=<?= e((string) $position['id']) ?>">Bearbeiten</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&instrument_id=<?= e((string) $position['instrument_id']) ?>">Kurs erfassen</a>
<form method="post">
<input type="hidden" name="action" value="refresh_alpha_vantage_position">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="position_id" value="<?= e((string) $position['id']) ?>">
<button class="nav-link" type="submit">API-Kurs</button>
</form>
<form method="post" onsubmit="return confirm('Position wirklich loeschen?')">
<input type="hidden" name="action" value="delete_position">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="position_id" value="<?= e((string) $position['id']) ?>">
<button class="nav-link" type="submit">Loeschen</button>
</form>
@@ -397,7 +426,7 @@
<?= e((string) ($instrument['symbol'] ?: '-')) ?> · <?= e((string) ($instrument['isin'] ?: '-')) ?>
</div>
</div>
<a class="nav-link" href="/module/boersenchecker?instrument_id=<?= e((string) $instrumentId) ?>">Neuen Kurs erfassen</a>
<a class="nav-link" href="/module/boersenchecker/depotverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&instrument_id=<?= e((string) $instrumentId) ?>">Neuen Kurs erfassen</a>
</div>
<?php if ($history === []): ?>
<div class="muted" style="margin-top:.75rem;">Noch keine historischen Kurse vorhanden.</div>
@@ -421,6 +450,7 @@
<td style="padding:8px;">
<form method="post" onsubmit="return confirm('Kurseintrag wirklich loeschen?')">
<input type="hidden" name="action" value="delete_quote">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="quote_id" value="<?= e((string) $quote['id']) ?>">
<button class="nav-link" type="submit">Loeschen</button>
</form>

View File

@@ -0,0 +1,147 @@
<div class="card bc-hero" data-bc-home data-chart-endpoint="<?= e($chartEndpoint) ?>">
<script type="application/json" data-bc-instruments-json><?= json_encode(array_map(static function (array $position): array {
return [
'instrument_id' => (int) ($position['instrument_id'] ?? 0),
'instrument_name' => (string) ($position['instrument_name'] ?? ''),
'symbol' => (string) ($position['symbol'] ?? ''),
'isin' => (string) ($position['isin'] ?? ''),
];
}, $positions), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?></script>
<div class="pill">Boersenchecker</div>
<h1 style="margin-top:.75rem;">Startseite</h1>
<p class="muted">Depotauswahl, Aktienauswahl und animierte Kurscharts auf Basis von Schlusskursen.</p>
<?php if ($error): ?>
<div class="card" style="margin-top:1rem; border-color:#ffb4a8; background:#fff5f3; color:#7a2114;"><?= e($error) ?></div>
<?php elseif ($notice): ?>
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);"><?= e($notice) ?></div>
<?php endif; ?>
<div class="bc-toolbar" style="margin-top:1rem;">
<?php if ($isAdmin): ?>
<form class="bc-surface" method="get">
<strong>Benutzer</strong>
<label class="setup-field muted" style="margin-top:.75rem;">
<span>Scope</span>
<select name="owner_sub">
<?php foreach ($availableOwners as $owner): ?>
<option value="<?= e((string) $owner['sub']) ?>" <?= (string) $ownerSub === (string) $owner['sub'] ? 'selected' : '' ?>><?= e((string) $owner['label']) ?></option>
<?php endforeach; ?>
</select>
</label>
<button class="cta-button" type="submit">Anzeigen</button>
</form>
<?php endif; ?>
<form class="bc-surface" method="get">
<?php if ($isAdmin): ?><input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>"><?php endif; ?>
<strong>Depot</strong>
<?php if ($portfolios === []): ?>
<div class="muted" style="margin-top:.75rem;">Keine Depots vorhanden.</div>
<?php else: ?>
<label class="setup-field muted" style="margin-top:.75rem;">
<span>Auswahl</span>
<select name="portfolio_id" onchange="this.form.submit()">
<?php foreach ($portfolios as $portfolio): ?>
<option value="<?= e((string) $portfolio['id']) ?>" <?= (string) $selectedPortfolioId === (string) $portfolio['id'] ? 'selected' : '' ?>>
<?= e((string) $portfolio['name']) ?>
</option>
<?php endforeach; ?>
</select>
</label>
<?php endif; ?>
</form>
<form class="bc-surface" method="get">
<?php if ($isAdmin): ?><input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>"><?php endif; ?>
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
<strong>Aktie</strong>
<?php if ($positions === []): ?>
<div class="muted" style="margin-top:.75rem;">Keine Aktien im ausgewaehlten Depot.</div>
<?php else: ?>
<label class="setup-field muted" style="margin-top:.75rem;">
<span>Auswahl</span>
<select name="instrument_id" data-bc-instrument>
<?php foreach ($positions as $position): ?>
<option value="<?= e((string) $position['instrument_id']) ?>" <?= (string) $selectedInstrumentId === (string) $position['instrument_id'] ? 'selected' : '' ?>>
<?= e((string) $position['instrument_name']) ?><?= !empty($position['symbol']) ? ' (' . e((string) $position['symbol']) . ')' : '' ?>
</option>
<?php endforeach; ?>
</select>
</label>
<?php endif; ?>
</form>
<form class="bc-surface" method="post">
<input type="hidden" name="action" value="refresh_current_quotes_home">
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<strong>Aktuelle Kurse</strong>
<p class="muted" style="margin:.75rem 0 1rem;">Abruf der aktuellen Kurse fuer das gewaehlte Depot.</p>
<button class="cta-button" type="submit" <?= $selectedPortfolioId > 0 ? '' : 'disabled' ?>>Aktuelle Kurse abrufen</button>
</form>
</div>
<div class="bc-card-grid" style="margin-top:1rem;">
<?php foreach (array_slice($positions, 0, 4) as $position): ?>
<div class="bc-stat">
<div class="muted"><?= e((string) $position['instrument_name']) ?></div>
<div class="bc-stat-value"><?= $position['latest_price'] !== null ? e(number_format((float) $position['latest_price'], 2, ',', '.')) . ' ' . e((string) $position['latest_currency']) : 'n/a' ?></div>
<div class="muted" style="margin-top:6px;"><?= e((string) ($position['latest_quoted_at'] ?: 'kein Kurs')) ?></div>
</div>
<?php endforeach; ?>
</div>
<div class="bc-surface" style="margin-top:1rem;">
<div style="display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; align-items:center;">
<div>
<strong data-bc-instrument-name><?= e((string) ($selectedInstrument['instrument_name'] ?? 'Keine Aktie ausgewaehlt')) ?></strong>
<?php if ($selectedInstrument): ?>
<div class="muted" data-bc-instrument-meta><?= e((string) ($selectedInstrument['symbol'] ?? '')) ?> · <?= e((string) ($selectedInstrument['isin'] ?? '-')) ?></div>
<?php endif; ?>
</div>
<div class="bc-range-list">
<button type="button" class="bc-range-button" data-range="1d" aria-pressed="false">Tag</button>
<button type="button" class="bc-range-button" data-range="5d" aria-pressed="false">5 Tage</button>
<button type="button" class="bc-range-button" data-range="1m" aria-pressed="true">Monat</button>
<button type="button" class="bc-range-button" data-range="3m" aria-pressed="false">3 Monate</button>
<button type="button" class="bc-range-button" data-range="6m" aria-pressed="false">6 Monate</button>
<button type="button" class="bc-range-button" data-range="1y" aria-pressed="false">Jahr</button>
<button type="button" class="bc-range-button" data-range="5y" aria-pressed="false">5 Jahre</button>
</div>
</div>
<div class="muted" data-bc-chart-status style="margin-top:.75rem;">Chartdaten werden geladen...</div>
<div class="bc-stat-value" data-bc-chart-summary style="margin-top:.35rem;">-</div>
<div class="bc-chart-shell" data-bc-chart style="margin-top:1rem;"></div>
</div>
<div class="bc-surface" style="margin-top:1rem;">
<strong>Aktien im Depot</strong>
<?php if ($positions === []): ?>
<div class="muted" style="margin-top:.75rem;">Keine Aktien im ausgewaehlten Depot.</div>
<?php else: ?>
<div class="bc-position-list" style="margin-top:1rem;">
<?php foreach ($positions as $position): ?>
<div class="bc-position-row">
<div>
<strong><?= e((string) $position['instrument_name']) ?></strong>
<div class="muted"><?= e((string) ($position['symbol'] ?? '')) ?> · <?= e((string) ($position['isin'] ?? '-')) ?></div>
</div>
<div>
<div class="muted">Stueckzahl</div>
<div><?= e(number_format((float) $position['quantity'], 6, ',', '.')) ?></div>
</div>
<div>
<div class="muted">Kaufpreis</div>
<div><?= e(number_format((float) $position['purchase_price'], 2, ',', '.')) ?> <?= e((string) $position['purchase_currency']) ?></div>
</div>
<div>
<div class="muted">Letzter Kurs</div>
<div><?= $position['latest_price'] !== null ? e(number_format((float) $position['latest_price'], 2, ',', '.')) . ' ' . e((string) $position['latest_currency']) : 'n/a' ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>

View File

@@ -0,0 +1,161 @@
<?php $ownerQuery = $isAdmin ? '?owner_sub=' . urlencode((string) $ownerSub) : ''; ?>
<div class="card">
<div class="pill">Boersenchecker</div>
<h1 style="margin-top:.75rem;">Aktienverwaltung</h1>
<p class="muted">Aktien aller Depots des ausgewaehlten Benutzers bearbeiten und manuelle Kurse pflegen.</p>
<?php if ($error): ?>
<div class="card" style="margin-top:1rem; border-color:#ffb4a8; background:#fff5f3; color:#7a2114;"><?= e($error) ?></div>
<?php elseif ($notice): ?>
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);"><?= e($notice) ?></div>
<?php endif; ?>
<?php if ($isAdmin): ?>
<div class="card" style="margin-top:1rem; background:var(--panel-2);">
<strong>Benutzer-Scope</strong>
<form method="get" style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap; align-items:end;">
<label class="setup-field muted" style="margin:0; min-width:260px;">
<span>Benutzer</span>
<select name="owner_sub">
<?php foreach ($availableOwners as $owner): ?>
<option value="<?= e((string) $owner['sub']) ?>" <?= (string) $ownerSub === (string) $owner['sub'] ? 'selected' : '' ?>><?= e((string) $owner['label']) ?></option>
<?php endforeach; ?>
</select>
</label>
<button class="cta-button" type="submit">Anzeigen</button>
</form>
</div>
<?php endif; ?>
<div class="grid" style="margin-top:1rem;">
<div class="card" style="background:var(--panel-2);">
<strong>Aktie waehlen</strong>
<form method="get" style="margin-top:.75rem;">
<?php if ($isAdmin): ?><input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>"><?php endif; ?>
<label class="setup-field muted">
<span>Aktien aller Depots</span>
<select name="instrument_id" onchange="this.form.submit()">
<?php foreach ($instruments as $instrument): ?>
<option value="<?= e((string) $instrument['id']) ?>" <?= (string) $selectedInstrumentId === (string) $instrument['id'] ? 'selected' : '' ?>>
<?= e((string) $instrument['name']) ?><?= !empty($instrument['symbol']) ? ' (' . e((string) $instrument['symbol']) . ')' : '' ?>
</option>
<?php endforeach; ?>
</select>
</label>
</form>
</div>
<div class="card" style="background:var(--panel-2);">
<strong>Symbolsuche</strong>
<form method="post" style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap; align-items:end;">
<input type="hidden" name="action" value="search_symbol">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
<label class="setup-field muted" style="margin:0; min-width:260px; flex:1;">
<span>Suchbegriff</span>
<input type="text" name="search_keywords" value="<?= e($searchKeywords) ?>" placeholder="z.B. Apple, AAPL, Allianz" required>
</label>
<button class="cta-button" type="submit">Suchen</button>
</form>
<?php if ($searchResults !== []): ?>
<div style="overflow:auto; margin-top:1rem;">
<table style="width:100%; border-collapse:collapse;">
<tbody>
<?php foreach ($searchResults as $result): ?>
<tr style="border-bottom:1px solid var(--border);">
<td style="padding:8px;"><strong><?= e((string) ($result['symbol'] ?? '')) ?></strong></td>
<td style="padding:8px;"><?= e((string) ($result['name'] ?? '')) ?></td>
<td style="padding:8px;"><?= e((string) ($result['region'] ?? '')) ?></td>
<td style="padding:8px;"><?= e((string) ($result['currency'] ?? '')) ?></td>
<td style="padding:8px;">
<a class="nav-link" href="/module/boersenchecker/aktienverwaltung?owner_sub=<?= urlencode((string) $ownerSub) ?>&instrument_id=<?= e((string) $selectedInstrumentId) ?>&symbol_candidate=<?= urlencode((string) ($result['symbol'] ?? '')) ?>&instrument_name_candidate=<?= urlencode((string) ($result['name'] ?? '')) ?>&market_candidate=<?= urlencode((string) ($result['region'] ?? '')) ?>&quote_currency_candidate=<?= urlencode((string) ($result['currency'] ?? '')) ?>">
Uebernehmen
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
<div class="card" style="margin-top:1rem; background:var(--panel-2);">
<strong>Aktie bearbeiten</strong>
<?php if (!$selectedInstrument || empty($selectedInstrument['id'])): ?>
<div class="muted" style="margin-top:.75rem;">Keine Aktie vorhanden.</div>
<?php else: ?>
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
<input type="hidden" name="action" value="save_instrument">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) ($selectedInstrument['id'] ?? 0)) ?>">
<div class="grid" style="grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px;">
<label class="setup-field muted"><span>Name</span><input type="text" name="instrument_name" value="<?= e((string) (($selectedInstrument['name'] ?? '') ?: ($_GET['instrument_name_candidate'] ?? ''))) ?>" required></label>
<label class="setup-field muted"><span>Symbol</span><input type="text" name="symbol" value="<?= e((string) (($selectedInstrument['symbol'] ?? '') ?: ($_GET['symbol_candidate'] ?? ''))) ?>"></label>
<label class="setup-field muted"><span>ISIN</span><input type="text" name="isin" value="<?= e((string) ($selectedInstrument['isin'] ?? '')) ?>"></label>
<label class="setup-field muted"><span>WKN</span><input type="text" name="wkn" value="<?= e((string) ($selectedInstrument['wkn'] ?? '')) ?>"></label>
<label class="setup-field muted"><span>Markt</span><input type="text" name="market" value="<?= e((string) (($selectedInstrument['market'] ?? '') ?: ($_GET['market_candidate'] ?? ''))) ?>"></label>
<label class="setup-field muted"><span>Kurswaehrung</span><input type="text" name="quote_currency" value="<?= e((string) (($selectedInstrument['quote_currency'] ?? $defaultReportCurrency) ?: ($_GET['quote_currency_candidate'] ?? $defaultReportCurrency))) ?>"></label>
</div>
<button class="cta-button" type="submit">Aktie speichern</button>
</form>
<form method="post" style="margin-top:.75rem;">
<input type="hidden" name="action" value="refresh_alpha_vantage_instrument">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) ($selectedInstrument['id'] ?? 0)) ?>">
<button class="nav-link" type="submit">Aktuellen API-Kurs abrufen</button>
</form>
<?php endif; ?>
</div>
<div class="card" style="margin-top:1rem; background:var(--panel-2);">
<strong>Manuellen Kurs eingeben</strong>
<?php if (!$selectedInstrument || empty($selectedInstrument['id'])): ?>
<div class="muted" style="margin-top:.75rem;">Keine Aktie vorhanden.</div>
<?php else: ?>
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
<input type="hidden" name="action" value="save_quote">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) ($selectedInstrument['id'] ?? 0)) ?>">
<div class="grid" style="grid-template-columns:repeat(auto-fit, minmax(180px, 1fr)); gap:10px;">
<label class="setup-field muted"><span>Kurs</span><input type="number" name="quote_price" min="0" step="0.00000001" required></label>
<label class="setup-field muted"><span>Waehrung</span><input type="text" name="quote_currency" value="<?= e((string) ($selectedInstrument['quote_currency'] ?? $defaultReportCurrency)) ?>" required></label>
<label class="setup-field muted"><span>Zeitpunkt</span><input type="datetime-local" name="quoted_at" value="<?= e(date('Y-m-d\TH:i')) ?>" required></label>
<label class="setup-field muted"><span>Quelle</span><input type="text" name="quote_source" value="manual"></label>
</div>
<button class="cta-button" type="submit">Kurs speichern</button>
</form>
<?php endif; ?>
</div>
<div class="card" style="margin-top:1rem;">
<strong>Kursverlauf</strong>
<?php if ($quotes === []): ?>
<div class="muted" style="margin-top:.75rem;">Keine Kursdaten vorhanden.</div>
<?php else: ?>
<div style="overflow:auto; margin-top:.75rem;">
<table style="width:100%; border-collapse:collapse;">
<tbody>
<?php foreach ($quotes as $quote): ?>
<tr style="border-bottom:1px solid var(--border);">
<td style="padding:8px;"><?= e((string) $quote['quoted_at']) ?></td>
<td style="padding:8px;"><?= e(number_format((float) $quote['price'], 4, ',', '.')) ?> <?= e((string) $quote['currency']) ?></td>
<td style="padding:8px;"><?= e((string) $quote['source']) ?></td>
<td style="padding:8px;">
<form method="post" onsubmit="return confirm('Kurseintrag wirklich loeschen?')">
<input type="hidden" name="action" value="delete_quote">
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
<input type="hidden" name="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
<input type="hidden" name="quote_id" value="<?= e((string) $quote['id']) ?>">
<button class="nav-link" type="submit">Loeschen</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>