85 lines
3.5 KiB
PHP
85 lines
3.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once dirname(__DIR__) . '/bootstrap.php';
|
|
|
|
$assets = app()->assets();
|
|
if ($assets) {
|
|
$assets->addStyle('/module/fx-rates/asset?file=fx-rates.css');
|
|
$assets->addScript('/module/fx-rates/asset?file=fx-rates.js', 'footer', true);
|
|
}
|
|
|
|
$settings = module_fn('fx-rates', 'settings');
|
|
$service = module_fn('fx-rates', 'service');
|
|
$latest = $service->latestStatus();
|
|
$preferredCurrencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : [];
|
|
$pageData = json_encode([
|
|
'settings' => $settings,
|
|
'latest' => $latest,
|
|
'preferred_currencies' => $preferredCurrencies,
|
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
?>
|
|
<?= module_shell_header('fx-rates', ['title' => 'Waehrungskurse']) ?>
|
|
<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 class="fx-actions">
|
|
<button type="button" class="fx-button fx-button--primary" data-action="refresh-rates">Aktuelle Kurse abrufen</button>
|
|
</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>
|
|
|
|
<div class="fx-card">
|
|
<h2>Anzeige und Waehrungen</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>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fx-card">
|
|
<h2>Letzter Snapshot</h2>
|
|
<div class="fx-table-wrap">
|
|
<table class="fx-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Waehrung</th>
|
|
<th>Kurs</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody data-bind="rates-body">
|
|
<tr><td colspan="2">Noch keine Daten geladen.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= module_shell_footer() ?>
|