143 lines
8.5 KiB
PHP
143 lines
8.5 KiB
PHP
<?= module_shell_header('boersenchecker', [
|
|
'title' => 'Aktienverwaltung',
|
|
]) ?>
|
|
<div class="bc-app">
|
|
<div class="bc-grid-bg">
|
|
<div class="bc-shell bc-stack module-flow">
|
|
|
|
<?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="grid" style="margin-top:1rem;">
|
|
<div class="bc-panel">
|
|
<strong>Aktie waehlen</strong>
|
|
<form method="get" style="margin-top:.75rem;">
|
|
<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="bc-panel">
|
|
<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="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="bc-button bc-button--primary" type="submit">Suchen</button>
|
|
</form>
|
|
<?php if ($searchResults !== []): ?>
|
|
<div class="bc-table-shell" style="margin-top:1rem;">
|
|
<table class="bc-table">
|
|
<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="bc-button bc-button--secondary" 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
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bc-panel" style="margin-top:1rem;">
|
|
<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="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="bc-button bc-button--primary" 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="instrument_id" value="<?= e((string) ($selectedInstrument['id'] ?? 0)) ?>">
|
|
<button class="bc-button bc-button--secondary" type="submit">Aktuellen API-Kurs abrufen</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="bc-panel" style="margin-top:1rem;">
|
|
<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="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="bc-button bc-button--primary" type="submit">Kurs speichern</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="bc-panel" style="margin-top:1rem;">
|
|
<strong>Kursverlauf</strong>
|
|
<?php if ($quotes === []): ?>
|
|
<div class="muted" style="margin-top:.75rem;">Keine Kursdaten vorhanden.</div>
|
|
<?php else: ?>
|
|
<div class="bc-table-shell" style="margin-top:.75rem;">
|
|
<table class="bc-table">
|
|
<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="instrument_id" value="<?= e((string) $selectedInstrumentId) ?>">
|
|
<input type="hidden" name="quote_id" value="<?= e((string) $quote['id']) ?>">
|
|
<button class="bc-button bc-button--secondary" type="submit">Loeschen</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= module_shell_footer() ?>
|