78 lines
4.0 KiB
PHP
78 lines
4.0 KiB
PHP
<?= $this->extend('layout/main') ?>
|
|
|
|
<?= $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">
|
|
<h1 class="h4 mb-0">Paragon <?= esc($receipt['merchant'] ?: '#' . $receipt['id']) ?></h1>
|
|
<a href="<?= site_url('receipts') ?>" class="btn btn-link">← Historia importów</a>
|
|
</div>
|
|
|
|
<div class="row g-3">
|
|
<div class="col-lg-7">
|
|
<div class="card shadow-sm mb-3">
|
|
<div class="card-body row g-2">
|
|
<div class="col-6"><span class="text-muted small d-block">Data</span><?= esc($receipt['receipt_date'] ?: '—') ?></div>
|
|
<div class="col-6"><span class="text-muted small d-block">Suma (AI)</span><?= $receipt['total'] !== null ? $fmt($receipt['total']) : '—' ?></div>
|
|
<div class="col-6"><span class="text-muted small d-block">Status</span><?= esc($receipt['status']) ?></div>
|
|
<div class="col-6"><span class="text-muted small d-block">Plik</span>
|
|
<a href="<?= site_url('receipts/' . $receipt['id'] . '/file') ?>" target="_blank"><?= esc($receipt['original_name']) ?></a>
|
|
</div>
|
|
<?php if ($receipt['status'] === 'failed' && $receipt['error_msg']): ?>
|
|
<div class="col-12"><div class="alert alert-danger mb-0 mt-2"><?= esc($receipt['error_msg']) ?></div></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card shadow-sm mb-3">
|
|
<div class="card-header bg-white"><strong>Pozycje</strong></div>
|
|
<div class="table-responsive">
|
|
<table class="table mb-0 align-middle">
|
|
<thead class="table-light"><tr><th>Pozycja</th><th class="text-end">Kwota</th></tr></thead>
|
|
<tbody>
|
|
<?php if (empty($items)): ?>
|
|
<tr><td colspan="2" class="text-center text-muted py-3">Brak pozycji.</td></tr>
|
|
<?php else: foreach ($items as $it): ?>
|
|
<tr><td><?= esc($it['display_name'] ?: $it['name']) ?></td><td class="text-end"><?= $fmt($it['amount']) ?></td></tr>
|
|
<?php endforeach; endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<?php if ($receipt['status'] === 'parsed'): ?>
|
|
<a href="<?= site_url('receipts/' . $receipt['id'] . '/review') ?>" class="btn btn-primary">Przejdź do przeglądu</a>
|
|
<?php endif; ?>
|
|
<a href="<?= site_url('receipts/' . $receipt['id'] . '/delete') ?>" class="btn btn-outline-danger"
|
|
onclick="return confirm('Usunąć ten import?')">Usuń import</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-lg-5">
|
|
<?php if ($receipt['status'] === 'imported'): ?>
|
|
<div class="card shadow-sm">
|
|
<div class="card-header bg-white"><strong>Zaksięgowane operacje</strong></div>
|
|
<ul class="list-group list-group-flush">
|
|
<?php foreach ($operations as $o): ?>
|
|
<li class="list-group-item d-flex justify-content-between">
|
|
<span><?= esc($o['category_name'] ?: '(bez kategorii)') ?></span>
|
|
<strong class="amount-expense"><?= $fmt($o['amount']) ?></strong>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (str_starts_with((string) $receipt['mime'], 'image/')): ?>
|
|
<div class="card shadow-sm mt-3">
|
|
<div class="card-header bg-white"><strong>Skan</strong></div>
|
|
<div class="card-body text-center">
|
|
<img src="<?= site_url('receipts/' . $receipt['id'] . '/file') ?>" class="img-fluid" alt="Skan paragonu">
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?= $this->endSection() ?>
|