sdsfd
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
);
|
);
|
||||||
let displayBase = String(page.display_base_currency || '').trim().toUpperCase();
|
let displayBase = String(page.display_base_currency || '').trim().toUpperCase();
|
||||||
|
const savedDisplayBase = String(page.saved_display_base_currency || displayBase || '').trim().toUpperCase();
|
||||||
|
|
||||||
const nodes = {
|
const nodes = {
|
||||||
tokenList: root.querySelector('[data-fx-token-list]'),
|
tokenList: root.querySelector('[data-fx-token-list]'),
|
||||||
@@ -152,6 +153,15 @@
|
|||||||
nodes.displayBaseSelect?.addEventListener('change', () => {
|
nodes.displayBaseSelect?.addEventListener('change', () => {
|
||||||
displayBase = String(nodes.displayBaseSelect?.value || '').trim().toUpperCase();
|
displayBase = String(nodes.displayBaseSelect?.value || '').trim().toUpperCase();
|
||||||
renderHiddenInputs();
|
renderHiddenInputs();
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
if (displayBase) {
|
||||||
|
url.searchParams.set('base', displayBase);
|
||||||
|
} else if (savedDisplayBase) {
|
||||||
|
url.searchParams.set('base', savedDisplayBase);
|
||||||
|
} else {
|
||||||
|
url.searchParams.delete('base');
|
||||||
|
}
|
||||||
|
window.location.href = url.toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
renderAll();
|
renderAll();
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ if (strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET')) === 'POST') {
|
|||||||
|
|
||||||
$catalog = is_array($settings['currency_catalog'] ?? null) ? $settings['currency_catalog'] : [];
|
$catalog = is_array($settings['currency_catalog'] ?? null) ? $settings['currency_catalog'] : [];
|
||||||
$preferredCurrencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : [];
|
$preferredCurrencies = is_array($settings['preferred_currencies'] ?? null) ? $settings['preferred_currencies'] : [];
|
||||||
$displayBaseCurrency = strtoupper(trim((string) ($settings['display_base_currency'] ?? $settings['default_base_currency'] ?? 'EUR')));
|
$savedDisplayBaseCurrency = strtoupper(trim((string) ($settings['display_base_currency'] ?? $settings['default_base_currency'] ?? 'EUR')));
|
||||||
|
$requestedDisplayBaseCurrency = strtoupper(trim((string) ($_GET['base'] ?? '')));
|
||||||
$latest = $service->latestStatus();
|
$latest = $service->latestStatus();
|
||||||
$recentFetches = $service->recentFetches(15);
|
$recentFetches = $service->recentFetches(15);
|
||||||
|
|
||||||
@@ -86,10 +87,29 @@ foreach ($currencies as $currency) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$catalogCodes = [];
|
||||||
|
foreach ($currencies as $currency) {
|
||||||
|
$catalogCodes[(string) $currency['code']] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$displayBaseCurrency = $requestedDisplayBaseCurrency !== '' ? $requestedDisplayBaseCurrency : $savedDisplayBaseCurrency;
|
||||||
|
if ($displayBaseCurrency === '' || (!isset($catalogCodes[$displayBaseCurrency]) && $preferredCurrencies !== [])) {
|
||||||
|
$displayBaseCurrency = $savedDisplayBaseCurrency !== '' ? $savedDisplayBaseCurrency : (string) ($preferredCurrencies[0] ?? 'EUR');
|
||||||
|
}
|
||||||
|
|
||||||
|
$tableCurrencies = [];
|
||||||
|
foreach ([$displayBaseCurrency, ...$preferredCurrencies] as $currency) {
|
||||||
|
$currency = strtoupper(trim((string) $currency));
|
||||||
|
if ($currency !== '' && !in_array($currency, $tableCurrencies, true)) {
|
||||||
|
$tableCurrencies[] = $currency;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$currencyPageData = json_encode([
|
$currencyPageData = json_encode([
|
||||||
'currencies' => $currencies,
|
'currencies' => $currencies,
|
||||||
'preferred_currencies' => array_values(array_unique(array_map(static fn (mixed $code): string => strtoupper(trim((string) $code)), $preferredCurrencies))),
|
'preferred_currencies' => array_values(array_unique(array_map(static fn (mixed $code): string => strtoupper(trim((string) $code)), $preferredCurrencies))),
|
||||||
'display_base_currency' => $displayBaseCurrency,
|
'display_base_currency' => $displayBaseCurrency,
|
||||||
|
'saved_display_base_currency' => $savedDisplayBaseCurrency,
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
|
||||||
$tabs = [
|
$tabs = [
|
||||||
@@ -177,7 +197,7 @@ $tabs = [
|
|||||||
<th>Zeit</th>
|
<th>Zeit</th>
|
||||||
<th>Stichtag</th>
|
<th>Stichtag</th>
|
||||||
<th>Fetch-Basis</th>
|
<th>Fetch-Basis</th>
|
||||||
<?php foreach ($preferredCurrencies as $currency): ?>
|
<?php foreach ($tableCurrencies as $currency): ?>
|
||||||
<th><?= e((string) $currency) ?></th>
|
<th><?= e((string) $currency) ?></th>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<th>Provider</th>
|
<th>Provider</th>
|
||||||
@@ -185,18 +205,18 @@ $tabs = [
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if ($recentFetches === []): ?>
|
<?php if ($recentFetches === []): ?>
|
||||||
<tr><td colspan="<?= 4 + count($preferredCurrencies) ?>">Noch keine Abrufe vorhanden.</td></tr>
|
<tr><td colspan="<?= 4 + count($tableCurrencies) ?>">Noch keine Abrufe vorhanden.</td></tr>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach ($recentFetches as $fetch): ?>
|
<?php foreach ($recentFetches as $fetch): ?>
|
||||||
<?php
|
<?php
|
||||||
$snapshot = $service->snapshotByFetchId((int) ($fetch['id'] ?? 0), $displayBaseCurrency, $preferredCurrencies);
|
$snapshot = $service->snapshotByFetchId((int) ($fetch['id'] ?? 0), $displayBaseCurrency, $tableCurrencies);
|
||||||
$rates = is_array($snapshot['rates'] ?? null) ? $snapshot['rates'] : [];
|
$rates = is_array($snapshot['rates'] ?? null) ? $snapshot['rates'] : [];
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?= e((string) ($fetch['fetched_at_display'] ?? $fetch['fetched_at'] ?? '')) ?></td>
|
<td><?= e((string) ($fetch['fetched_at_display'] ?? $fetch['fetched_at'] ?? '')) ?></td>
|
||||||
<td><?= e((string) ($fetch['rate_date'] ?? '')) ?></td>
|
<td><?= e((string) ($fetch['rate_date'] ?? '')) ?></td>
|
||||||
<td><?= e((string) ($fetch['base_currency'] ?? '')) ?></td>
|
<td><?= e((string) ($fetch['base_currency'] ?? '')) ?></td>
|
||||||
<?php foreach ($preferredCurrencies as $currency): ?>
|
<?php foreach ($tableCurrencies as $currency): ?>
|
||||||
<?php $value = $rates[(string) $currency] ?? null; ?>
|
<?php $value = $rates[(string) $currency] ?? null; ?>
|
||||||
<td><?= is_numeric($value) ? e(number_format((float) $value, 8, ',', '')) : '–' ?></td>
|
<td><?= is_numeric($value) ? e(number_format((float) $value, 8, ',', '')) : '–' ?></td>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user