162 lines
10 KiB
PHP
162 lines
10 KiB
PHP
<?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'] ?? '')) ?>"e_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>
|