210 lines
12 KiB
PHP
210 lines
12 KiB
PHP
<div class="bc-app">
|
|
<div class="bc-grid-bg">
|
|
<div class="bc-shell bc-stack" 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>
|
|
|
|
<header class="bc-hero">
|
|
<div class="bc-hero-top">
|
|
<div class="bc-hero-copy">
|
|
<div class="bc-eyebrow">Boersenchecker Modul</div>
|
|
<h1 class="bc-title">Depot-Ueberblick</h1>
|
|
<p class="bc-text">Depots, Aktien und Kursverlaeufe in einer Oberflaeche. Die Navigation folgt jetzt dem gleichen sichtbaren Prinzip wie beim Mining-Checker.</p>
|
|
</div>
|
|
<div class="bc-hero-controls">
|
|
<a class="bc-button bc-button--ghost" href="/">Zur Startseite</a>
|
|
<div class="bc-form-card">
|
|
<div class="bc-field-label">Aktives Depot</div>
|
|
<div class="bc-text" style="margin-top:8px;"><?= $selectedPortfolioId > 0 && $portfolios !== [] ? e((string) (($portfolios[array_search($selectedPortfolioId, array_column($portfolios, 'id'), true)]['name'] ?? 'Auswahl aktiv'))) : 'Kein Depot ausgewaehlt' ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bc-tabs">
|
|
<a class="bc-button bc-button--tab-active" href="/module/boersenchecker">Ueberblick</a>
|
|
<a class="bc-button bc-button--tab" href="/module/boersenchecker/depotverwaltung">Depotverwaltung</a>
|
|
<a class="bc-button bc-button--tab" href="/module/boersenchecker/aktienverwaltung">Aktienverwaltung</a>
|
|
</div>
|
|
</header>
|
|
|
|
<?php if ($error): ?>
|
|
<div class="bc-alert bc-alert--error"><?= e($error) ?></div>
|
|
<?php elseif ($notice): ?>
|
|
<div class="bc-alert bc-alert--success"><?= e($notice) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="bc-toolbar">
|
|
<form class="bc-panel" method="get">
|
|
<div class="bc-field-label">Depotauswahl</div>
|
|
<?php if ($portfolios === []): ?>
|
|
<div class="bc-text" style="margin-top:12px;">Keine Depots vorhanden.</div>
|
|
<?php else: ?>
|
|
<label class="setup-field" style="margin-top:12px;">
|
|
<span class="bc-text">Depot</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-panel" method="get">
|
|
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
|
|
<div class="bc-field-label">Aktienauswahl</div>
|
|
<?php if ($positions === []): ?>
|
|
<div class="bc-text" style="margin-top:12px;">Keine Aktien im ausgewaehlten Depot.</div>
|
|
<?php else: ?>
|
|
<label class="setup-field" style="margin-top:12px;">
|
|
<span class="bc-text">Aktie</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-panel" method="post">
|
|
<input type="hidden" name="action" value="refresh_current_quotes_home">
|
|
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
|
|
<div class="bc-field-label">Marktdaten</div>
|
|
<p class="bc-text" style="margin-top:12px;">Aktuelle Kurse fuer das gewaehlte Depot ueber Alpha Vantage abrufen.</p>
|
|
<div class="bc-actions" style="margin-top:16px;">
|
|
<button class="bc-button bc-button--primary" type="submit" <?= $selectedPortfolioId > 0 ? '' : 'disabled' ?>>Aktuelle Kurse abrufen</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="bc-overview-grid">
|
|
<div class="bc-stat">
|
|
<div class="bc-field-label">Positionen</div>
|
|
<div class="bc-stat-value"><?= e((string) ($summary['positions'] ?? 0)) ?></div>
|
|
<div class="bc-text" style="margin-top:6px;">Aktien im aktuell gewaehlten Depot</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="bc-field-label">Investiert</div>
|
|
<div class="bc-stat-value"><?= isset($summary['invested']) && $summary['invested'] !== null ? e(number_format((float) $summary['invested'], 2, ',', '.')) . ' ' . e($defaultReportCurrency) : 'n/a' ?></div>
|
|
<div class="bc-text" style="margin-top:6px;">In Berichtswahrung bewertet</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="bc-field-label">Aktueller Wert</div>
|
|
<div class="bc-stat-value"><?= isset($summary['current']) && $summary['current'] !== null ? e(number_format((float) $summary['current'], 2, ',', '.')) . ' ' . e($defaultReportCurrency) : 'n/a' ?></div>
|
|
<div class="bc-text" style="margin-top:6px;">Basierend auf dem letzten gespeicherten Kurs</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="bc-field-label">Performance</div>
|
|
<div class="bc-stat-value"><?= isset($summary['gain']) && $summary['gain'] !== null ? e(number_format((float) $summary['gain'], 2, ',', '.')) . ' ' . e($defaultReportCurrency) : 'n/a' ?></div>
|
|
<div class="bc-text" style="margin-top:6px;"><?= !empty($summary['best']['instrument_name']) ? 'Top-Wert: ' . e((string) $summary['best']['instrument_name']) : 'Noch keine Vergleichsdaten' ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bc-card-grid">
|
|
<div class="bc-panel">
|
|
<div class="bc-field-label">Bester Wert</div>
|
|
<?php if (!empty($summary['best'])): ?>
|
|
<div class="bc-stat-value"><?= e((string) $summary['best']['instrument_name']) ?></div>
|
|
<div class="bc-pill-soft" style="margin-top:12px;"><?= e(number_format((float) ($summary['best']['gain_percent'] ?? 0), 2, ',', '.')) ?>%</div>
|
|
<?php else: ?>
|
|
<div class="bc-text" style="margin-top:12px;">Noch keine Performance verfuegbar.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="bc-panel">
|
|
<div class="bc-field-label">Schwaechster Wert</div>
|
|
<?php if (!empty($summary['worst'])): ?>
|
|
<div class="bc-stat-value"><?= e((string) $summary['worst']['instrument_name']) ?></div>
|
|
<div class="bc-pill-soft" style="margin-top:12px;"><?= e(number_format((float) ($summary['worst']['gain_percent'] ?? 0), 2, ',', '.')) ?>%</div>
|
|
<?php else: ?>
|
|
<div class="bc-text" style="margin-top:12px;">Noch keine Performance verfuegbar.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php foreach (array_slice($positions, 0, 2) as $position): ?>
|
|
<div class="bc-stat">
|
|
<div class="bc-field-label"><?= 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="bc-text" style="margin-top:6px;"><?= e((string) ($position['latest_quoted_at'] ?: 'kein Kurs')) ?></div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<section class="bc-chart-card">
|
|
<div style="display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; align-items:center;">
|
|
<div>
|
|
<div class="bc-field-label">Kursverlauf</div>
|
|
<div class="bc-stat-value" data-bc-instrument-name><?= e((string) ($selectedInstrument['instrument_name'] ?? 'Keine Aktie ausgewaehlt')) ?></div>
|
|
<?php if ($selectedInstrument): ?>
|
|
<div class="bc-text" 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="bc-text" data-bc-chart-status style="margin-top:12px;">Chartdaten werden geladen...</div>
|
|
<div class="bc-stat-value" data-bc-chart-summary style="margin-top:6px;">-</div>
|
|
<div class="bc-chart-shell" data-bc-chart style="margin-top:18px;"></div>
|
|
</section>
|
|
|
|
<section class="bc-panel">
|
|
<div class="bc-field-label">Aktien im Depot</div>
|
|
<?php if ($positions === []): ?>
|
|
<div class="bc-text" style="margin-top:12px;">Keine Aktien im ausgewaehlten Depot.</div>
|
|
<?php else: ?>
|
|
<div class="bc-position-list" style="margin-top:16px;">
|
|
<?php foreach ($positions as $position): ?>
|
|
<?php $gainClass = (($position['gain_report'] ?? 0) >= 0) ? 'is-positive' : 'is-negative'; ?>
|
|
<div class="bc-position-row">
|
|
<div>
|
|
<strong><?= e((string) $position['instrument_name']) ?></strong>
|
|
<div class="bc-text" style="margin-top:4px;"><?= e((string) ($position['symbol'] ?? '')) ?> · <?= e((string) ($position['isin'] ?? '-')) ?></div>
|
|
<?php if (!empty($position['market'])): ?>
|
|
<div class="bc-pill-soft" style="margin-top:10px;"><?= e((string) $position['market']) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div>
|
|
<div class="bc-field-label">Stueckzahl</div>
|
|
<div><?= e(number_format((float) $position['quantity'], 6, ',', '.')) ?></div>
|
|
</div>
|
|
<div>
|
|
<div class="bc-field-label">Kaufpreis</div>
|
|
<div><?= e(number_format((float) $position['purchase_price'], 2, ',', '.')) ?> <?= e((string) $position['purchase_currency']) ?></div>
|
|
</div>
|
|
<div>
|
|
<div class="bc-field-label">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>
|
|
<div class="bc-field-label">Performance</div>
|
|
<div class="bc-performance <?= e($gainClass) ?>">
|
|
<?= isset($position['gain_report']) && $position['gain_report'] !== null ? e(number_format((float) $position['gain_report'], 2, ',', '.')) . ' ' . e($defaultReportCurrency) : 'n/a' ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</div>
|