Operacje: nowrap dla daty/kwoty, ucinanie opisu i stronicowanie 10/str

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-06 22:17:16 +02:00
parent a9da3a3e7d
commit f2d944b117
3 changed files with 76 additions and 13 deletions
+40 -8
View File
@@ -2,6 +2,9 @@
<?= $this->section('content') ?>
<?php $fmt = static fn ($v) => number_format((float) $v, 2, ',', ' ') . ' zł'; ?>
<style>
.col-desc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
</style>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h4 mb-0">Operacje</h1>
@@ -65,10 +68,10 @@
<table class="table table-hover mb-0 align-middle">
<thead class="table-light">
<tr>
<th>Data</th>
<th>Kategoria</th>
<th class="text-nowrap">Data</th>
<th class="text-nowrap">Kategoria</th>
<th>Opis</th>
<th class="text-end">Kwota</th>
<th class="text-end text-nowrap">Kwota</th>
<th class="text-end">Akcje</th>
</tr>
</thead>
@@ -77,8 +80,8 @@
<tr><td colspan="5" class="text-center text-muted py-4">Brak operacji dla wybranych filtrów.</td></tr>
<?php else: foreach ($operations as $o): ?>
<tr>
<td><?= esc($o['date']) ?></td>
<td>
<td class="text-nowrap"><?= esc($o['date']) ?></td>
<td class="text-nowrap">
<?php
if (! empty($o['category_name'])) {
echo esc(! empty($o['parent_name'])
@@ -89,11 +92,11 @@
}
?>
</td>
<td class="text-muted"><?= esc($o['description'] ?? '') ?></td>
<td class="text-end <?= $o['type'] === 'income' ? 'amount-income' : 'amount-expense' ?>">
<td class="text-muted col-desc" title="<?= esc($o['description'] ?? '') ?>"><?= esc($o['description'] ?? '') ?></td>
<td class="text-end text-nowrap <?= $o['type'] === 'income' ? 'amount-income' : 'amount-expense' ?>">
<?= $o['type'] === 'income' ? '+' : '' ?><?= $fmt($o['amount']) ?>
</td>
<td class="text-end">
<td class="text-end text-nowrap">
<a href="<?= site_url('operations/' . $o['id'] . '/edit') ?>" class="btn btn-sm btn-outline-secondary">Edytuj</a>
<a href="<?= site_url('operations/' . $o['id'] . '/delete') ?>" class="btn btn-sm btn-outline-danger"
onclick="return confirm('Usunąć operację?')">Usuń</a>
@@ -103,5 +106,34 @@
</tbody>
</table>
</div>
<?php if ($pages > 1): ?>
<?php
$qs = array_filter([
'from' => $filter['from'] ?? '',
'to' => $filter['to'] ?? '',
'category_id' => $filter['category_id'] ?? '',
'type' => $filter['type'] ?? '',
], static fn ($v) => $v !== '' && $v !== null);
$link = static fn (int $p) => site_url('operations') . '?' . http_build_query($qs + ['page' => $p]);
?>
<div class="card-footer d-flex justify-content-between align-items-center flex-wrap gap-2">
<span class="text-muted small">Strona <?= $page ?> z <?= $pages ?> (<?= $total ?> operacji)</span>
<nav>
<ul class="pagination pagination-sm mb-0">
<li class="page-item <?= $page <= 1 ? 'disabled' : '' ?>">
<a class="page-link" href="<?= $link(max(1, $page - 1)) ?>"></a>
</li>
<?php for ($p = 1; $p <= $pages; $p++): ?>
<li class="page-item <?= $p === $page ? 'active' : '' ?>">
<a class="page-link" href="<?= $link($p) ?>"><?= $p ?></a>
</li>
<?php endfor; ?>
<li class="page-item <?= $page >= $pages ? 'disabled' : '' ?>">
<a class="page-link" href="<?= $link(min($pages, $page + 1)) ?>"></a>
</li>
</ul>
</nav>
</div>
<?php endif; ?>
</div>
<?= $this->endSection() ?>