61 lines
2.7 KiB
HTML
61 lines
2.7 KiB
HTML
<?php
|
||
/**
|
||
* @package Bicycle
|
||
* @description Transactions/index.html — список последних 50 транзакций.
|
||
*
|
||
* @var array $user
|
||
* @var object[] $transactions
|
||
*/
|
||
|
||
$month_names_gen = [
|
||
1 => 'января', 2 => 'февраля', 3 => 'марта', 4 => 'апреля', 5 => 'мая', 6 => 'июня',
|
||
7 => 'июля', 8 => 'августа', 9 => 'сентября', 10 => 'октября', 11 => 'ноября', 12 => 'декабря',
|
||
];
|
||
|
||
// В дизайне доход подсвечен зелёным, а расход — обычным текстом (не красным); тут же приводим
|
||
// зелёный к общему токену --positive-text вместо отдельного литерала oklch(...).
|
||
$type_colors = [
|
||
'income' => 'var(--positive-text)',
|
||
'expense' => 'var(--ink)',
|
||
'transfer' => 'var(--muted)',
|
||
];
|
||
|
||
$type_signs = [
|
||
'income' => '+',
|
||
'expense' => '−',
|
||
'transfer' => '',
|
||
];
|
||
?>
|
||
|
||
<h1 style="margin:0 0 20px;font-size:24px">Транзакции</h1>
|
||
|
||
<?php if (empty($transactions)): ?>
|
||
<div class="empty-state">Нет операций — транзакции появятся здесь после добавления</div>
|
||
<?php else: ?>
|
||
<div class="card elev-md pm-wrap" style="padding:6px 0">
|
||
<?php foreach ($transactions as $tx): ?>
|
||
<?php
|
||
$d = new DateTime($tx->date);
|
||
$dateLabel = (int)$d->format('j') . ' ' . $month_names_gen[(int)$d->format('n')];
|
||
$amount = (float)$tx->summa * ((float)($tx->rate_to_rub ?? 1));
|
||
$color = $type_colors[$tx->type] ?? 'var(--muted)';
|
||
$sign = $type_signs[$tx->type] ?? '';
|
||
$category = $tx->category_title ?? ($tx->type === 'transfer' ? 'Перевод' : '—');
|
||
$account = $tx->account_f_title ?? $tx->account_in_title ?? '';
|
||
?>
|
||
<div class="stat-row">
|
||
<div style="width:auto;flex:1">
|
||
<div style="font-size:13px;font-weight:600"><?= htmlspecialchars($category, ENT_QUOTES, 'UTF-8') ?></div>
|
||
<div class="card-meta" style="font-size:11px;margin-top:2px">
|
||
<?= htmlspecialchars($dateLabel, ENT_QUOTES, 'UTF-8') ?>
|
||
<?php if ($account): ?> · <?= htmlspecialchars($account, ENT_QUOTES, 'UTF-8') ?><?php endif; ?>
|
||
</div>
|
||
</div>
|
||
<div class="num" style="width:auto;flex-shrink:0;font-size:14px;font-weight:600;color:<?= $color ?>">
|
||
<?= $sign . number_format($amount, 0, ',', ' ') ?> ₽
|
||
</div>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|