Files
finansePRO/app/Views/instruments/index.php
T
2026-07-06 20:16:00 +02:00

50 lines
2.4 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">Instrumenty</h1>
<a href="<?= site_url('instruments/new') ?>" class="btn btn-primary">+ Nowy instrument</a>
</div>
<div class="card shadow-sm">
<div class="table-responsive">
<table class="table table-hover mb-0 align-middle">
<thead class="table-light">
<tr>
<th>Instrument</th>
<th class="text-end">Wpłacono netto</th>
<th class="text-end">Wartość</th>
<th class="text-end">Zarobek</th>
<th class="text-end">%</th>
<th class="text-end">Akcje</th>
</tr>
</thead>
<tbody>
<?php if (empty($instruments)): ?>
<tr><td colspan="6" class="text-center text-muted py-4">Brak instrumentów.</td></tr>
<?php else: foreach ($instruments as $i): ?>
<tr>
<td><?= esc($i['name']) ?></td>
<td class="text-end"><?= $fmt($i['net_invested']) ?></td>
<td class="text-end"><?= $i['has_value'] ? $fmt($i['value']) : '<span class="text-muted">brak wyceny</span>' ?></td>
<td class="text-end <?= $i['profit'] >= 0 ? 'amount-income' : 'amount-expense' ?>">
<?= $i['has_value'] ? $fmt($i['profit']) : '—' ?>
</td>
<td class="text-end <?= $i['profit'] >= 0 ? 'amount-income' : 'amount-expense' ?>">
<?= $i['percent'] !== null && $i['has_value'] ? number_format($i['percent'], 2, ',', ' ') . '%' : '—' ?>
</td>
<td class="text-end">
<a href="<?= site_url('instruments/' . $i['id'] . '/edit') ?>" class="btn btn-sm btn-outline-secondary">Edytuj</a>
<a href="<?= site_url('instruments/' . $i['id'] . '/delete') ?>" class="btn btn-sm btn-outline-danger"
onclick="return confirm('Usunąć instrument?')">Usuń</a>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div>
</div>
<?= $this->endSection() ?>