186 lines
10 KiB
PHP
186 lines
10 KiB
PHP
<div class="card bc-hero" data-bc-home data-chart-endpoint="<?= e($chartEndpoint) ?>">
|
|
<div class="bc-module-nav">
|
|
<a class="bc-module-tab is-active" href="/module/boersenchecker">Startseite</a>
|
|
<a class="bc-module-tab" href="/module/boersenchecker/depotverwaltung">Depotverwaltung</a>
|
|
<a class="bc-module-tab" href="/module/boersenchecker/aktienverwaltung">Aktienverwaltung</a>
|
|
</div>
|
|
<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;">
|
|
<form class="bc-surface" method="get">
|
|
<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">
|
|
<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) ?>">
|
|
<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-overview-grid" style="margin-top:1rem;">
|
|
<div class="bc-stat">
|
|
<div class="muted">Positionen</div>
|
|
<div class="bc-stat-value"><?= e((string) ($summary['positions'] ?? 0)) ?></div>
|
|
<div class="muted" style="margin-top:6px;">Aktien im aktuell gewaehlten Depot</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="muted">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="muted" style="margin-top:6px;">Auf Berichtswahrung umgerechnet</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="muted">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="muted" style="margin-top:6px;">Basierend auf letztem verfuegbarem Kurs</div>
|
|
</div>
|
|
<div class="bc-stat">
|
|
<div class="muted">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="muted" style="margin-top:6px;"><?= !empty($summary['best']['instrument_name']) ? 'Top: ' . e((string) $summary['best']['instrument_name']) : 'Noch keine Vergleichsdaten' ?></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bc-card-grid" style="margin-top:1rem;">
|
|
<div class="bc-surface">
|
|
<div class="muted">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:.75rem;"><?= e(number_format((float) ($summary['best']['gain_percent'] ?? 0), 2, ',', '.')) ?>%</div>
|
|
<?php else: ?>
|
|
<div class="muted" style="margin-top:.75rem;">Noch keine Performance verfuegbar.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="bc-surface">
|
|
<div class="muted">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:.75rem;"><?= e(number_format((float) ($summary['worst']['gain_percent'] ?? 0), 2, ',', '.')) ?>%</div>
|
|
<?php else: ?>
|
|
<div class="muted" style="margin-top:.75rem;">Noch keine Performance verfuegbar.</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php foreach (array_slice($positions, 0, 2) 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): ?>
|
|
<?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="muted"><?= e((string) ($position['symbol'] ?? '')) ?> · <?= e((string) ($position['isin'] ?? '-')) ?></div>
|
|
<?php if (!empty($position['market'])): ?>
|
|
<div class="bc-pill-soft" style="margin-top:.55rem;"><?= e((string) $position['market']) ?></div>
|
|
<?php endif; ?>
|
|
</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>
|
|
<div class="muted">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; ?>
|
|
</div>
|
|
</div>
|