This commit is contained in:
2026-07-13 21:46:29 +02:00
parent 41cb412cb0
commit 9d96ecadfb
17 changed files with 638 additions and 124 deletions
+23 -7
View File
@@ -3,7 +3,7 @@
<?= $this->section('content') ?>
<?php $fmt = static fn ($v) => number_format((float) $v, 2, ',', ' ') . ' zł'; ?>
<div class="d-flex justify-content-between align-items-center mb-3">
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-sm-center gap-2 mb-3">
<h1 class="h4 mb-0">Przegląd paragonu</h1>
<a href="<?= site_url('receipts') ?>" class="btn btn-link">← Historia importów</a>
</div>
@@ -23,7 +23,7 @@
(podpowiedź zaznaczona; „— pomiń —” = nie księguj)
</div>
<div class="table-responsive">
<table class="table table-hover mb-0 align-middle">
<table class="table table-hover mb-0 align-middle receipt-items">
<thead class="table-light">
<tr>
<th style="width:40%">Pozycja</th>
@@ -37,17 +37,17 @@
<?php else: foreach ($items as $it): ?>
<?php $sel = $it['chosen_category_id'] ?? $it['suggested_category_id']; ?>
<tr>
<td>
<td data-label="Pozycja">
<input type="text" name="display[<?= $it['id'] ?>]" class="form-control form-control-sm"
value="<?= esc($it['display_name'] ?: $it['name']) ?>" maxlength="255">
<span class="text-muted small">z paragonu: <?= esc($it['name']) ?></span>
</td>
<td>
<td data-label="Kwota (zł)">
<input type="number" step="0.01" min="0" name="amount[<?= $it['id'] ?>]"
class="form-control form-control-sm text-end js-amount"
value="<?= esc(number_format((float) $it['amount'], 2, '.', '')) ?>">
</td>
<td>
<td data-label="Kategoria">
<select name="chosen_category_id[<?= $it['id'] ?>]" class="form-select form-select-sm js-cat">
<option value="">— pomiń —</option>
<?php foreach ($categories as $c): ?>
@@ -71,12 +71,28 @@
</div>
</div>
<div class="mb-4">
<div class="d-grid d-sm-flex gap-2 mb-4">
<button type="submit" class="btn btn-primary">Zaksięguj</button>
<a href="<?= site_url('receipts/' . $receipt['id'] . '/delete') ?>" class="btn btn-outline-danger"
onclick="return confirm('Usunąć ten import?')">Usuń import</a>
</div>
<?= form_close() ?>
<style>
@media (max-width: 767.98px) {
.receipt-items thead { display: none; }
.receipt-items, .receipt-items tbody, .receipt-items tr, .receipt-items td { display: block; width: 100%; }
.receipt-items tr { padding: .75rem; border-bottom: 1px solid var(--bs-border-color); }
.receipt-items td { padding: .25rem 0; border: 0; }
.receipt-items td::before {
content: attr(data-label);
display: block;
margin-bottom: .25rem;
color: var(--bs-secondary-color);
font-size: .875em;
}
}
</style>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
@@ -104,7 +120,7 @@
return;
}
preview.innerHTML = keys.map((k) =>
`<li class="list-group-item d-flex justify-content-between"><span>${groups[k].label}</span><strong>${fmt(groups[k].sum)}</strong></li>`
`<li class="list-group-item d-flex flex-column flex-sm-row justify-content-between gap-1"><span>${groups[k].label}</span><strong>${fmt(groups[k].sum)}</strong></li>`
).join('');
}
rows.forEach((row) => {