erwre
This commit is contained in:
@@ -1,3 +1,30 @@
|
|||||||
|
.bc-module-nav {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bc-module-tab {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-radius: 999px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--text);
|
||||||
|
border: 1px solid rgba(255,255,255,0.08);
|
||||||
|
background: rgba(255,255,255,0.04);
|
||||||
|
transition: transform .18s ease, background .18s ease, border-color .18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bc-module-tab:hover,
|
||||||
|
.bc-module-tab:focus-visible,
|
||||||
|
.bc-module-tab.is-active {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
background: rgba(71, 169, 255, 0.12);
|
||||||
|
border-color: rgba(71, 169, 255, 0.32);
|
||||||
|
}
|
||||||
|
|
||||||
.bc-hero {
|
.bc-hero {
|
||||||
background:
|
background:
|
||||||
radial-gradient(circle at top right, rgba(71, 169, 255, 0.22), transparent 32%),
|
radial-gradient(circle at top right, rgba(71, 169, 255, 0.22), transparent 32%),
|
||||||
@@ -19,11 +46,18 @@
|
|||||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bc-overview-grid {
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
.bc-stat {
|
.bc-stat {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
|
background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
|
||||||
border: 1px solid rgba(255,255,255,0.08);
|
border: 1px solid rgba(255,255,255,0.08);
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
.bc-stat-value {
|
.bc-stat-value {
|
||||||
@@ -109,7 +143,7 @@
|
|||||||
|
|
||||||
.bc-position-row {
|
.bc-position-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(100px, .8fr));
|
grid-template-columns: minmax(0, 1.8fr) repeat(4, minmax(100px, .75fr));
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 14px 16px;
|
padding: 14px 16px;
|
||||||
@@ -118,6 +152,18 @@
|
|||||||
border: 1px solid rgba(255,255,255,0.06);
|
border: 1px solid rgba(255,255,255,0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bc-performance {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bc-performance.is-positive {
|
||||||
|
color: #84f2b7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bc-performance.is-negative {
|
||||||
|
color: #ff9b8d;
|
||||||
|
}
|
||||||
|
|
||||||
.bc-pill-soft {
|
.bc-pill-soft {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -4,12 +4,7 @@ declare(strict_types=1);
|
|||||||
require_auth();
|
require_auth();
|
||||||
|
|
||||||
$user = auth_user() ?? [];
|
$user = auth_user() ?? [];
|
||||||
$isAdmin = auth_is_admin();
|
|
||||||
$ownerSub = trim((string) ($user['sub'] ?? 'local'));
|
$ownerSub = trim((string) ($user['sub'] ?? 'local'));
|
||||||
$requestedOwner = trim((string) ($_GET['owner_sub'] ?? ''));
|
|
||||||
if ($isAdmin && $requestedOwner !== '') {
|
|
||||||
$ownerSub = $requestedOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
$instrumentId = (int) ($_GET['instrument_id'] ?? 0);
|
$instrumentId = (int) ($_GET['instrument_id'] ?? 0);
|
||||||
if ($instrumentId <= 0) {
|
if ($instrumentId <= 0) {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?php $ownerQuery = $isAdmin ? '?owner_sub=' . urlencode((string) $ownerSub) : ''; ?>
|
<?php $ownerQuery = $isAdmin ? '?owner_sub=' . urlencode((string) $ownerSub) : ''; ?>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<div class="bc-module-nav">
|
||||||
|
<a class="bc-module-tab" href="/module/boersenchecker">Startseite</a>
|
||||||
|
<a class="bc-module-tab is-active" href="/module/boersenchecker/depotverwaltung">Depotverwaltung</a>
|
||||||
|
<a class="bc-module-tab" href="/module/boersenchecker/aktienverwaltung">Aktienverwaltung</a>
|
||||||
|
</div>
|
||||||
<div class="pill">Boersenchecker</div>
|
<div class="pill">Boersenchecker</div>
|
||||||
<h1 style="margin-top:.75rem;">Depotverwaltung</h1>
|
<h1 style="margin-top:.75rem;">Depotverwaltung</h1>
|
||||||
<p class="muted">
|
<p class="muted">
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
<div class="card bc-hero" data-bc-home data-chart-endpoint="<?= e($chartEndpoint) ?>">
|
<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 {
|
<script type="application/json" data-bc-instruments-json><?= json_encode(array_map(static function (array $position): array {
|
||||||
return [
|
return [
|
||||||
'instrument_id' => (int) ($position['instrument_id'] ?? 0),
|
'instrument_id' => (int) ($position['instrument_id'] ?? 0),
|
||||||
@@ -18,23 +23,7 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="bc-toolbar" style="margin-top:1rem;">
|
<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">
|
<form class="bc-surface" method="get">
|
||||||
<?php if ($isAdmin): ?><input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>"><?php endif; ?>
|
|
||||||
<strong>Depot</strong>
|
<strong>Depot</strong>
|
||||||
<?php if ($portfolios === []): ?>
|
<?php if ($portfolios === []): ?>
|
||||||
<div class="muted" style="margin-top:.75rem;">Keine Depots vorhanden.</div>
|
<div class="muted" style="margin-top:.75rem;">Keine Depots vorhanden.</div>
|
||||||
@@ -53,7 +42,6 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form class="bc-surface" method="get">
|
<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) ?>">
|
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
|
||||||
<strong>Aktie</strong>
|
<strong>Aktie</strong>
|
||||||
<?php if ($positions === []): ?>
|
<?php if ($positions === []): ?>
|
||||||
@@ -75,15 +63,55 @@
|
|||||||
<form class="bc-surface" method="post">
|
<form class="bc-surface" method="post">
|
||||||
<input type="hidden" name="action" value="refresh_current_quotes_home">
|
<input type="hidden" name="action" value="refresh_current_quotes_home">
|
||||||
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
|
<input type="hidden" name="portfolio_id" value="<?= e((string) $selectedPortfolioId) ?>">
|
||||||
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
|
|
||||||
<strong>Aktuelle Kurse</strong>
|
<strong>Aktuelle Kurse</strong>
|
||||||
<p class="muted" style="margin:.75rem 0 1rem;">Abruf der aktuellen Kurse fuer das gewaehlte Depot.</p>
|
<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>
|
<button class="cta-button" type="submit" <?= $selectedPortfolioId > 0 ? '' : 'disabled' ?>>Aktuelle Kurse abrufen</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</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-card-grid" style="margin-top:1rem;">
|
||||||
<?php foreach (array_slice($positions, 0, 4) as $position): ?>
|
<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="bc-stat">
|
||||||
<div class="muted"><?= e((string) $position['instrument_name']) ?></div>
|
<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="bc-stat-value"><?= $position['latest_price'] !== null ? e(number_format((float) $position['latest_price'], 2, ',', '.')) . ' ' . e((string) $position['latest_currency']) : 'n/a' ?></div>
|
||||||
@@ -122,10 +150,14 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<div class="bc-position-list" style="margin-top:1rem;">
|
<div class="bc-position-list" style="margin-top:1rem;">
|
||||||
<?php foreach ($positions as $position): ?>
|
<?php foreach ($positions as $position): ?>
|
||||||
|
<?php $gainClass = (($position['gain_report'] ?? 0) >= 0) ? 'is-positive' : 'is-negative'; ?>
|
||||||
<div class="bc-position-row">
|
<div class="bc-position-row">
|
||||||
<div>
|
<div>
|
||||||
<strong><?= e((string) $position['instrument_name']) ?></strong>
|
<strong><?= e((string) $position['instrument_name']) ?></strong>
|
||||||
<div class="muted"><?= e((string) ($position['symbol'] ?? '')) ?> · <?= e((string) ($position['isin'] ?? '-')) ?></div>
|
<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>
|
<div>
|
||||||
<div class="muted">Stueckzahl</div>
|
<div class="muted">Stueckzahl</div>
|
||||||
@@ -139,6 +171,12 @@
|
|||||||
<div class="muted">Letzter Kurs</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><?= $position['latest_price'] !== null ? e(number_format((float) $position['latest_price'], 2, ',', '.')) . ' ' . e((string) $position['latest_currency']) : 'n/a' ?></div>
|
||||||
</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>
|
</div>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
<?php $ownerQuery = $isAdmin ? '?owner_sub=' . urlencode((string) $ownerSub) : ''; ?>
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
<div class="bc-module-nav">
|
||||||
|
<a class="bc-module-tab" href="/module/boersenchecker">Startseite</a>
|
||||||
|
<a class="bc-module-tab" href="/module/boersenchecker/depotverwaltung">Depotverwaltung</a>
|
||||||
|
<a class="bc-module-tab is-active" href="/module/boersenchecker/aktienverwaltung">Aktienverwaltung</a>
|
||||||
|
</div>
|
||||||
<div class="pill">Boersenchecker</div>
|
<div class="pill">Boersenchecker</div>
|
||||||
<h1 style="margin-top:.75rem;">Aktienverwaltung</h1>
|
<h1 style="margin-top:.75rem;">Aktienverwaltung</h1>
|
||||||
<p class="muted">Aktien aller Depots des ausgewaehlten Benutzers bearbeiten und manuelle Kurse pflegen.</p>
|
<p class="muted">Aktien aus deinen Depots bearbeiten und manuelle Kurse pflegen.</p>
|
||||||
|
|
||||||
<?php if ($error): ?>
|
<?php if ($error): ?>
|
||||||
<div class="card" style="margin-top:1rem; border-color:#ffb4a8; background:#fff5f3; color:#7a2114;"><?= e($error) ?></div>
|
<div class="card" style="margin-top:1rem; border-color:#ffb4a8; background:#fff5f3; color:#7a2114;"><?= e($error) ?></div>
|
||||||
@@ -10,28 +14,10 @@
|
|||||||
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);"><?= e($notice) ?></div>
|
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);"><?= e($notice) ?></div>
|
||||||
<?php endif; ?>
|
<?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="grid" style="margin-top:1rem;">
|
||||||
<div class="card" style="background:var(--panel-2);">
|
<div class="card" style="background:var(--panel-2);">
|
||||||
<strong>Aktie waehlen</strong>
|
<strong>Aktie waehlen</strong>
|
||||||
<form method="get" style="margin-top:.75rem;">
|
<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">
|
<label class="setup-field muted">
|
||||||
<span>Aktien aller Depots</span>
|
<span>Aktien aller Depots</span>
|
||||||
<select name="instrument_id" onchange="this.form.submit()">
|
<select name="instrument_id" onchange="this.form.submit()">
|
||||||
@@ -49,7 +35,6 @@
|
|||||||
<strong>Symbolsuche</strong>
|
<strong>Symbolsuche</strong>
|
||||||
<form method="post" style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap; align-items:end;">
|
<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="action" value="search_symbol">
|
||||||
<input type="hidden" name="owner_sub" value="<?= e((string) $ownerSub) ?>">
|
|
||||||
<input type="hidden" name="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
|
<input type="hidden" name="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
|
||||||
<label class="setup-field muted" style="margin:0; min-width:260px; flex:1;">
|
<label class="setup-field muted" style="margin:0; min-width:260px; flex:1;">
|
||||||
<span>Suchbegriff</span>
|
<span>Suchbegriff</span>
|
||||||
@@ -68,7 +53,7 @@
|
|||||||
<td style="padding:8px;"><?= e((string) ($result['region'] ?? '')) ?></td>
|
<td style="padding:8px;"><?= e((string) ($result['region'] ?? '')) ?></td>
|
||||||
<td style="padding:8px;"><?= e((string) ($result['currency'] ?? '')) ?></td>
|
<td style="padding:8px;"><?= e((string) ($result['currency'] ?? '')) ?></td>
|
||||||
<td style="padding:8px;">
|
<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'] ?? '')) ?>"e_currency_candidate=<?= urlencode((string) ($result['currency'] ?? '')) ?>">
|
<a class="nav-link" href="/module/boersenchecker/aktienverwaltung?instrument_id=<?= e((string) $selectedInstrumentId) ?>&symbol_candidate=<?= urlencode((string) ($result['symbol'] ?? '')) ?>&instrument_name_candidate=<?= urlencode((string) ($result['name'] ?? '')) ?>&market_candidate=<?= urlencode((string) ($result['region'] ?? '')) ?>"e_currency_candidate=<?= urlencode((string) ($result['currency'] ?? '')) ?>">
|
||||||
Uebernehmen
|
Uebernehmen
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -88,7 +73,6 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
|
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
|
||||||
<input type="hidden" name="action" value="save_instrument">
|
<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)) ?>">
|
<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;">
|
<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>Name</span><input type="text" name="instrument_name" value="<?= e((string) (($selectedInstrument['name'] ?? '') ?: ($_GET['instrument_name_candidate'] ?? ''))) ?>" required></label>
|
||||||
@@ -102,7 +86,6 @@
|
|||||||
</form>
|
</form>
|
||||||
<form method="post" style="margin-top:.75rem;">
|
<form method="post" style="margin-top:.75rem;">
|
||||||
<input type="hidden" name="action" value="refresh_alpha_vantage_instrument">
|
<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)) ?>">
|
<input type="hidden" name="instrument_id" value="<?= e((string) ($selectedInstrument['id'] ?? 0)) ?>">
|
||||||
<button class="nav-link" type="submit">Aktuellen API-Kurs abrufen</button>
|
<button class="nav-link" type="submit">Aktuellen API-Kurs abrufen</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -116,7 +99,6 @@
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
|
<form method="post" style="margin-top:.75rem; display:grid; gap:10px;">
|
||||||
<input type="hidden" name="action" value="save_quote">
|
<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)) ?>">
|
<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;">
|
<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>Kurs</span><input type="number" name="quote_price" min="0" step="0.00000001" required></label>
|
||||||
@@ -145,7 +127,6 @@
|
|||||||
<td style="padding:8px;">
|
<td style="padding:8px;">
|
||||||
<form method="post" onsubmit="return confirm('Kurseintrag wirklich loeschen?')">
|
<form method="post" onsubmit="return confirm('Kurseintrag wirklich loeschen?')">
|
||||||
<input type="hidden" name="action" value="delete_quote">
|
<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="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
|
||||||
<input type="hidden" name="quote_id" value="<?= e((string) $quote['id']) ?>">
|
<input type="hidden" name="quote_id" value="<?= e((string) $quote['id']) ?>">
|
||||||
<button class="nav-link" type="submit">Loeschen</button>
|
<button class="nav-link" type="submit">Loeschen</button>
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ use RuntimeException;
|
|||||||
final class HomePage
|
final class HomePage
|
||||||
{
|
{
|
||||||
private PDO $pdo;
|
private PDO $pdo;
|
||||||
private array $user;
|
|
||||||
private bool $isAdmin;
|
|
||||||
private string $ownerSub;
|
private string $ownerSub;
|
||||||
private array $availableOwners = [];
|
|
||||||
private string $portfolioTable;
|
private string $portfolioTable;
|
||||||
private string $instrumentTable;
|
private string $instrumentTable;
|
||||||
private string $positionTable;
|
private string $positionTable;
|
||||||
@@ -24,16 +21,8 @@ final class HomePage
|
|||||||
{
|
{
|
||||||
$this->pdo = \module_fn('boersenchecker', 'pdo');
|
$this->pdo = \module_fn('boersenchecker', 'pdo');
|
||||||
\module_fn('boersenchecker', 'ensure_schema');
|
\module_fn('boersenchecker', 'ensure_schema');
|
||||||
$this->user = \auth_user() ?? [];
|
$user = \auth_user() ?? [];
|
||||||
$this->isAdmin = \auth_is_admin();
|
$this->ownerSub = trim((string) ($user['sub'] ?? 'local'));
|
||||||
$this->ownerSub = trim((string) ($this->user['sub'] ?? 'local'));
|
|
||||||
$this->availableOwners = $this->buildAvailableOwners();
|
|
||||||
if ($this->isAdmin) {
|
|
||||||
$requestedOwner = trim((string) ($_GET['owner_sub'] ?? $_POST['owner_sub'] ?? ''));
|
|
||||||
if ($requestedOwner !== '' && isset($this->availableOwners[$requestedOwner])) {
|
|
||||||
$this->ownerSub = $requestedOwner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$settings = \modules()->settings('boersenchecker');
|
$settings = \modules()->settings('boersenchecker');
|
||||||
$this->defaultReportCurrency = strtoupper(trim((string) ($settings['report_currency'] ?? 'EUR'))) ?: 'EUR';
|
$this->defaultReportCurrency = strtoupper(trim((string) ($settings['report_currency'] ?? 'EUR'))) ?: 'EUR';
|
||||||
@@ -79,6 +68,24 @@ final class HomePage
|
|||||||
$position['latest_price'] = is_array($latestQuote) && is_numeric($latestQuote['price'] ?? null) ? (float) $latestQuote['price'] : null;
|
$position['latest_price'] = is_array($latestQuote) && is_numeric($latestQuote['price'] ?? null) ? (float) $latestQuote['price'] : null;
|
||||||
$position['latest_currency'] = is_array($latestQuote) ? (string) ($latestQuote['currency'] ?? '') : '';
|
$position['latest_currency'] = is_array($latestQuote) ? (string) ($latestQuote['currency'] ?? '') : '';
|
||||||
$position['latest_quoted_at'] = is_array($latestQuote) ? (string) ($latestQuote['quoted_at'] ?? '') : '';
|
$position['latest_quoted_at'] = is_array($latestQuote) ? (string) ($latestQuote['quoted_at'] ?? '') : '';
|
||||||
|
$position['current_total_report'] = null;
|
||||||
|
$position['gain_report'] = null;
|
||||||
|
$position['gain_percent'] = null;
|
||||||
|
if ($position['latest_price'] !== null) {
|
||||||
|
$currentNative = (float) $position['latest_price'] * (float) ($position['quantity'] ?? 0);
|
||||||
|
$currentReport = $this->convertAmount(
|
||||||
|
$currentNative,
|
||||||
|
(string) ($position['latest_currency'] ?: ($position['quote_currency'] ?? $this->defaultReportCurrency)),
|
||||||
|
$this->defaultReportCurrency
|
||||||
|
);
|
||||||
|
$position['current_total_report'] = $currentReport;
|
||||||
|
if ($position['purchase_total_report'] !== null && $currentReport !== null) {
|
||||||
|
$gain = $currentReport - (float) $position['purchase_total_report'];
|
||||||
|
$position['gain_report'] = $gain;
|
||||||
|
$base = (float) $position['purchase_total_report'];
|
||||||
|
$position['gain_percent'] = $base > 0 ? ($gain / $base) * 100 : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unset($position);
|
unset($position);
|
||||||
|
|
||||||
@@ -93,15 +100,14 @@ final class HomePage
|
|||||||
return [
|
return [
|
||||||
'notice' => $notice,
|
'notice' => $notice,
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'isAdmin' => $this->isAdmin,
|
|
||||||
'ownerSub' => $this->ownerSub,
|
|
||||||
'availableOwners' => array_values($this->availableOwners),
|
|
||||||
'portfolios' => $portfolios,
|
'portfolios' => $portfolios,
|
||||||
'selectedPortfolioId' => $selectedPortfolioId,
|
'selectedPortfolioId' => $selectedPortfolioId,
|
||||||
'positions' => $positions,
|
'positions' => $positions,
|
||||||
'selectedInstrumentId' => $selectedInstrumentId,
|
'selectedInstrumentId' => $selectedInstrumentId,
|
||||||
'selectedInstrument' => $selectedInstrument,
|
'selectedInstrument' => $selectedInstrument,
|
||||||
'chartEndpoint' => '/module/boersenchecker/chart_data?owner_sub=' . urlencode($this->ownerSub),
|
'summary' => $this->buildSummary($positions),
|
||||||
|
'defaultReportCurrency' => $this->defaultReportCurrency,
|
||||||
|
'chartEndpoint' => '/module/boersenchecker/chart_data',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +190,21 @@ final class HomePage
|
|||||||
'owner_sub' => $this->ownerSub,
|
'owner_sub' => $this->ownerSub,
|
||||||
'portfolio_id' => $portfolioId,
|
'portfolio_id' => $portfolioId,
|
||||||
]);
|
]);
|
||||||
return $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||||
|
foreach ($rows as &$row) {
|
||||||
|
$quantity = (float) ($row['quantity'] ?? 0);
|
||||||
|
$purchasePrice = (float) ($row['purchase_price'] ?? 0);
|
||||||
|
$fees = is_numeric($row['fees'] ?? null) ? (float) $row['fees'] : 0.0;
|
||||||
|
$purchaseTotal = ($quantity * $purchasePrice) + $fees;
|
||||||
|
$row['purchase_total'] = $purchaseTotal;
|
||||||
|
$row['purchase_total_report'] = $this->convertAmount(
|
||||||
|
$purchaseTotal,
|
||||||
|
(string) ($row['purchase_currency'] ?? $this->defaultReportCurrency),
|
||||||
|
$this->defaultReportCurrency
|
||||||
|
);
|
||||||
|
}
|
||||||
|
unset($row);
|
||||||
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fetchLatestQuotes(array $instrumentIds): array
|
private function fetchLatestQuotes(array $instrumentIds): array
|
||||||
@@ -227,26 +247,66 @@ final class HomePage
|
|||||||
return is_array($row) ? $row : null;
|
return is_array($row) ? $row : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildAvailableOwners(): array
|
private function buildSummary(array $positions): array
|
||||||
{
|
{
|
||||||
$owners = [];
|
$invested = 0.0;
|
||||||
$currentSub = trim((string) ($this->user['sub'] ?? 'local'));
|
$current = 0.0;
|
||||||
$owners[$currentSub] = [
|
$hasInvested = false;
|
||||||
'sub' => $currentSub,
|
$hasCurrent = false;
|
||||||
'label' => trim((string) ($this->user['name'] ?? $this->user['email'] ?? $currentSub)) ?: $currentSub,
|
$best = null;
|
||||||
];
|
$worst = null;
|
||||||
if (!$this->isAdmin) {
|
|
||||||
return $owners;
|
foreach ($positions as $position) {
|
||||||
}
|
if (is_numeric($position['purchase_total_report'] ?? null)) {
|
||||||
foreach (\modules()->knownAuthUsers() as $knownUser) {
|
$invested += (float) $position['purchase_total_report'];
|
||||||
$sub = trim((string) ($knownUser['sub'] ?? ''));
|
$hasInvested = true;
|
||||||
if ($sub === '') {
|
}
|
||||||
continue;
|
if (is_numeric($position['current_total_report'] ?? null)) {
|
||||||
|
$current += (float) $position['current_total_report'];
|
||||||
|
$hasCurrent = true;
|
||||||
|
}
|
||||||
|
if (is_numeric($position['gain_percent'] ?? null)) {
|
||||||
|
if ($best === null || (float) $position['gain_percent'] > (float) ($best['gain_percent'] ?? 0)) {
|
||||||
|
$best = $position;
|
||||||
|
}
|
||||||
|
if ($worst === null || (float) $position['gain_percent'] < (float) ($worst['gain_percent'] ?? 0)) {
|
||||||
|
$worst = $position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$label = trim((string) ($knownUser['name'] ?? $knownUser['email'] ?? $knownUser['username'] ?? $sub));
|
|
||||||
$owners[$sub] = ['sub' => $sub, 'label' => $label !== '' ? $label : $sub];
|
|
||||||
}
|
}
|
||||||
uasort($owners, static fn (array $left, array $right): int => strcmp((string) $left['label'], (string) $right['label']));
|
|
||||||
return $owners;
|
return [
|
||||||
|
'positions' => count($positions),
|
||||||
|
'invested' => $hasInvested ? $invested : null,
|
||||||
|
'current' => $hasCurrent ? $current : null,
|
||||||
|
'gain' => ($hasInvested && $hasCurrent) ? $current - $invested : null,
|
||||||
|
'best' => $best,
|
||||||
|
'worst' => $worst,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function convertAmount(?float $amount, string $from, string $to): ?float
|
||||||
|
{
|
||||||
|
if ($amount === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$from = strtoupper(trim($from)) ?: $this->defaultReportCurrency;
|
||||||
|
$to = strtoupper(trim($to)) ?: $this->defaultReportCurrency;
|
||||||
|
if ($from === $to) {
|
||||||
|
return $amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fxService = \module_fn('boersenchecker', 'fx_service');
|
||||||
|
if (!$fxService || !method_exists($fxService, 'convert')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$value = $fxService->convert($amount, $from, $to);
|
||||||
|
return is_numeric($value) ? (float) $value : null;
|
||||||
|
} catch (\Throwable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ use RuntimeException;
|
|||||||
final class InstrumentPage
|
final class InstrumentPage
|
||||||
{
|
{
|
||||||
private PDO $pdo;
|
private PDO $pdo;
|
||||||
private array $user;
|
|
||||||
private bool $isAdmin;
|
|
||||||
private string $ownerSub;
|
private string $ownerSub;
|
||||||
private array $availableOwners = [];
|
|
||||||
private string $instrumentTable;
|
private string $instrumentTable;
|
||||||
private string $positionTable;
|
private string $positionTable;
|
||||||
private string $quoteTable;
|
private string $quoteTable;
|
||||||
@@ -26,16 +23,8 @@ final class InstrumentPage
|
|||||||
{
|
{
|
||||||
$this->pdo = \module_fn('boersenchecker', 'pdo');
|
$this->pdo = \module_fn('boersenchecker', 'pdo');
|
||||||
\module_fn('boersenchecker', 'ensure_schema');
|
\module_fn('boersenchecker', 'ensure_schema');
|
||||||
$this->user = \auth_user() ?? [];
|
$user = \auth_user() ?? [];
|
||||||
$this->isAdmin = \auth_is_admin();
|
$this->ownerSub = trim((string) ($user['sub'] ?? 'local'));
|
||||||
$this->ownerSub = trim((string) ($this->user['sub'] ?? 'local'));
|
|
||||||
$this->availableOwners = $this->buildAvailableOwners();
|
|
||||||
if ($this->isAdmin) {
|
|
||||||
$requestedOwner = trim((string) ($_GET['owner_sub'] ?? $_POST['owner_sub'] ?? ''));
|
|
||||||
if ($requestedOwner !== '' && isset($this->availableOwners[$requestedOwner])) {
|
|
||||||
$this->ownerSub = $requestedOwner;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$settings = \modules()->settings('boersenchecker');
|
$settings = \modules()->settings('boersenchecker');
|
||||||
$this->defaultReportCurrency = strtoupper(trim((string) ($settings['report_currency'] ?? 'EUR'))) ?: 'EUR';
|
$this->defaultReportCurrency = strtoupper(trim((string) ($settings['report_currency'] ?? 'EUR'))) ?: 'EUR';
|
||||||
@@ -100,9 +89,6 @@ final class InstrumentPage
|
|||||||
return [
|
return [
|
||||||
'notice' => $notice,
|
'notice' => $notice,
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'isAdmin' => $this->isAdmin,
|
|
||||||
'ownerSub' => $this->ownerSub,
|
|
||||||
'availableOwners' => array_values($this->availableOwners),
|
|
||||||
'instruments' => $instruments,
|
'instruments' => $instruments,
|
||||||
'selectedInstrument' => $selectedInstrument,
|
'selectedInstrument' => $selectedInstrument,
|
||||||
'selectedInstrumentId' => $selectedInstrumentId,
|
'selectedInstrumentId' => $selectedInstrumentId,
|
||||||
@@ -261,29 +247,6 @@ final class InstrumentPage
|
|||||||
return (string) ($result['message'] ?? 'Suche abgeschlossen.');
|
return (string) ($result['message'] ?? 'Suche abgeschlossen.');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildAvailableOwners(): array
|
|
||||||
{
|
|
||||||
$owners = [];
|
|
||||||
$currentSub = trim((string) ($this->user['sub'] ?? 'local'));
|
|
||||||
$owners[$currentSub] = [
|
|
||||||
'sub' => $currentSub,
|
|
||||||
'label' => trim((string) ($this->user['name'] ?? $this->user['email'] ?? $currentSub)) ?: $currentSub,
|
|
||||||
];
|
|
||||||
if (!$this->isAdmin) {
|
|
||||||
return $owners;
|
|
||||||
}
|
|
||||||
foreach (\modules()->knownAuthUsers() as $knownUser) {
|
|
||||||
$sub = trim((string) ($knownUser['sub'] ?? ''));
|
|
||||||
if ($sub === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$label = trim((string) ($knownUser['name'] ?? $knownUser['email'] ?? $knownUser['username'] ?? $sub));
|
|
||||||
$owners[$sub] = ['sub' => $sub, 'label' => $label !== '' ? $label : $sub];
|
|
||||||
}
|
|
||||||
uasort($owners, static fn (array $left, array $right): int => strcmp((string) $left['label'], (string) $right['label']));
|
|
||||||
return $owners;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function assertInstrumentAccessible(int $instrumentId): array
|
private function assertInstrumentAccessible(int $instrumentId): array
|
||||||
{
|
{
|
||||||
if ($instrumentId <= 0) {
|
if ($instrumentId <= 0) {
|
||||||
@@ -303,7 +266,7 @@ final class InstrumentPage
|
|||||||
]);
|
]);
|
||||||
$instrument = $stmt->fetch(PDO::FETCH_ASSOC);
|
$instrument = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
if (!is_array($instrument)) {
|
if (!is_array($instrument)) {
|
||||||
throw new RuntimeException('Aktie ist in diesem Benutzer-Scope nicht verfuegbar.');
|
throw new RuntimeException('Aktie ist nicht verfuegbar.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $instrument;
|
return $instrument;
|
||||||
|
|||||||
Reference in New Issue
Block a user