asdasd
This commit is contained in:
@@ -11,9 +11,28 @@ if ($assets) {
|
||||
|
||||
$settings = module_fn('fx-rates', 'settings');
|
||||
$service = module_fn('fx-rates', 'service');
|
||||
$preferredCurrencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : [];
|
||||
$notice = trim((string) ($_GET['notice'] ?? ''));
|
||||
$error = trim((string) ($_GET['error'] ?? ''));
|
||||
|
||||
if ((string) ($_GET['refresh'] ?? '') === '1') {
|
||||
try {
|
||||
$result = $service->refreshLatestRates(null, (string) ($settings['default_base_currency'] ?? ''));
|
||||
$params = [
|
||||
'notice' => sprintf(
|
||||
'Aktuelle Kurse gespeichert. %d Werte aktualisiert.',
|
||||
(int) ($result['updated_count'] ?? 0)
|
||||
),
|
||||
];
|
||||
} catch (\Throwable $exception) {
|
||||
$params = ['error' => $exception->getMessage() !== '' ? $exception->getMessage() : 'Kurse konnten nicht aktualisiert werden.'];
|
||||
}
|
||||
|
||||
redirect('/module/fx-rates?' . http_build_query($params));
|
||||
}
|
||||
|
||||
$latest = $service->latestStatus();
|
||||
$recentFetches = $service->recentFetches(12);
|
||||
$preferredCurrencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : [];
|
||||
$pageData = json_encode([
|
||||
'settings' => $settings,
|
||||
'latest' => $latest,
|
||||
@@ -21,49 +40,22 @@ $pageData = json_encode([
|
||||
'recent_fetches' => $recentFetches,
|
||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
?>
|
||||
<?= module_shell_header('fx-rates', ['title' => 'Waehrungskurse']) ?>
|
||||
<?= module_shell_header('fx-rates', [
|
||||
'title' => 'Waehrungskurse',
|
||||
'actions' => [
|
||||
['label' => 'Setup', 'href' => '/modules/setup/fx-rates', 'variant' => 'secondary', 'size' => 'sm'],
|
||||
['label' => 'Aktuelle Kurse abrufen', 'href' => '/module/fx-rates?refresh=1', 'variant' => 'secondary', 'size' => 'sm'],
|
||||
],
|
||||
]) ?>
|
||||
<div id="fx-rates-app" data-page='<?= e(is_string($pageData) ? $pageData : '{}') ?>'>
|
||||
<div class="fx-stack">
|
||||
<div class="fx-card">
|
||||
<div class="fx-card-head">
|
||||
<div>
|
||||
<h1>Waehrungskurse</h1>
|
||||
<p>Zentrale Quelle fuer FX-Snapshots, Zeitabfragen und manuelle Aktualisierung.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fx-meta-grid">
|
||||
<div><strong>Standard-Basis:</strong> <span data-bind="default-base"><?= e((string) ($settings['default_base_currency'] ?? 'EUR')) ?></span></div>
|
||||
<div><strong>Anzeige-Basis:</strong> <span data-bind="display-base"><?= e((string) ($settings['display_base_currency'] ?? 'EUR')) ?></span></div>
|
||||
<div><strong>Scheduler:</strong> taeglich um <?= e(str_pad((string) ($settings['daily_refresh_hour'] ?? 18), 2, '0', STR_PAD_LEFT)) ?>:00 (<?= e((string) ($settings['schedule_timezone'] ?? 'Europe/Berlin')) ?>)</div>
|
||||
<div><strong>Letzter Abruf:</strong> <span data-bind="last-fetch"><?= e((string) ($latest['fetched_at'] ?? 'noch keiner')) ?></span></div>
|
||||
</div>
|
||||
<div class="fx-message" data-bind="message"></div>
|
||||
</div>
|
||||
<?php if ($notice !== ''): ?>
|
||||
<div class="fx-message is-success"><?= e($notice) ?></div>
|
||||
<?php elseif ($error !== ''): ?>
|
||||
<div class="fx-message is-error"><?= e($error) ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="fx-card">
|
||||
<h2>Setup</h2>
|
||||
<p>Die Auswahl wird in den Modul-Settings gespeichert und steuert den Standardaufruf der letzten Kurse.</p>
|
||||
<div class="fx-form-grid">
|
||||
<label>
|
||||
<span>Standard-Basiswaehrung</span>
|
||||
<input type="text" name="default_base_currency" value="<?= e((string) ($settings['default_base_currency'] ?? 'EUR')) ?>">
|
||||
</label>
|
||||
<label>
|
||||
<span>Anzeige-Basiswaehrung</span>
|
||||
<input type="text" name="display_base_currency" value="<?= e((string) ($settings['display_base_currency'] ?? 'EUR')) ?>">
|
||||
</label>
|
||||
</div>
|
||||
<label class="fx-block">
|
||||
<span>Bevorzugte Waehrungen</span>
|
||||
<input type="text" name="preferred_currencies" value="<?= e(implode(', ', $preferredCurrencies)) ?>" placeholder="EUR, USD, DOGE, BTC">
|
||||
</label>
|
||||
<div class="fx-actions">
|
||||
<button type="button" class="fx-button" data-action="save-settings">Auswahl speichern</button>
|
||||
<button type="button" class="fx-button fx-button--primary" data-action="refresh-rates">Aktuelle Kurse abrufen</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fx-card">
|
||||
<h2>Umrechnung</h2>
|
||||
<p>Umrechnung auf Basis des letzten verfuegbaren Kurses zwischen den bevorzugten Waehrungen.</p>
|
||||
<div class="fx-form-grid">
|
||||
@@ -92,7 +84,16 @@ $pageData = json_encode([
|
||||
</div>
|
||||
|
||||
<div class="fx-card">
|
||||
<h2>Letzter Snapshot</h2>
|
||||
<div class="fx-card-head">
|
||||
<div>
|
||||
<h2>Letzte Kurse</h2>
|
||||
<p>Letzter gespeicherter Snapshot fuer <?= e((string) ($settings['display_base_currency'] ?? $settings['default_base_currency'] ?? 'EUR')) ?>.</p>
|
||||
</div>
|
||||
<div class="fx-card-meta">
|
||||
<div><strong>Letzter Abruf:</strong> <?= e((string) ($latest['fetched_at_display'] ?? $latest['fetched_at'] ?? 'noch keiner')) ?></div>
|
||||
<div><strong>Basis:</strong> <?= e((string) ($latest['base_currency'] ?? $settings['default_base_currency'] ?? '')) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fx-table-wrap">
|
||||
<table class="fx-table">
|
||||
<thead>
|
||||
@@ -106,32 +107,33 @@ $pageData = json_encode([
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="fx-history-block">
|
||||
<h3>Letzte Abrufe</h3>
|
||||
<div class="fx-table-wrap">
|
||||
<table class="fx-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Basis</th>
|
||||
<th>Provider</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="fetches-body">
|
||||
<?php if ($recentFetches === []): ?>
|
||||
<tr><td colspan="3">Noch keine Abrufe vorhanden.</td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($recentFetches as $fetch): ?>
|
||||
<tr>
|
||||
<td><?= e((string) ($fetch['fetched_at'] ?? '')) ?></td>
|
||||
<td><?= e((string) ($fetch['base_currency'] ?? '')) ?></td>
|
||||
<td><?= e((string) ($fetch['provider'] ?? '')) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fx-card">
|
||||
<h2>Letzte Abrufe</h2>
|
||||
<div class="fx-table-wrap">
|
||||
<table class="fx-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Basis</th>
|
||||
<th>Provider</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="fetches-body">
|
||||
<?php if ($recentFetches === []): ?>
|
||||
<tr><td colspan="3">Noch keine Abrufe vorhanden.</td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($recentFetches as $fetch): ?>
|
||||
<tr>
|
||||
<td><?= e((string) ($fetch['fetched_at_display'] ?? $fetch['fetched_at'] ?? '')) ?></td>
|
||||
<td><?= e((string) ($fetch['base_currency'] ?? '')) ?></td>
|
||||
<td><?= e((string) ($fetch['provider'] ?? '')) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user