79 lines
3.5 KiB
PHP
79 lines
3.5 KiB
PHP
<?= $this->extend('layout/main') ?>
|
|
|
|
<?= $this->section('content') ?>
|
|
<?php $fmt = static fn ($v) => number_format((float) $v, 2, ',', ' ') . ' zł'; ?>
|
|
|
|
<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">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 instrument-history">
|
|
<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 class="instrument-row">
|
|
<td data-label="Instrument"><?= esc($i['name']) ?></td>
|
|
<td data-label="Wpłacono netto" class="text-end"><?= $fmt($i['net_invested']) ?></td>
|
|
<td data-label="Wartość" class="text-end"><?= $i['has_value'] ? $fmt($i['value']) : '<span class="text-muted">brak wyceny</span>' ?></td>
|
|
<td data-label="Zarobek" class="text-end <?= $i['profit'] >= 0 ? 'amount-income' : 'amount-expense' ?>">
|
|
<?= $i['has_value'] ? $fmt($i['profit']) : '—' ?>
|
|
</td>
|
|
<td data-label="Procent" class="text-end <?= $i['profit'] >= 0 ? 'amount-income' : 'amount-expense' ?>">
|
|
<?= $i['percent'] !== null && $i['has_value'] ? number_format($i['percent'], 2, ',', ' ') . '%' : '—' ?>
|
|
</td>
|
|
<td data-label="Akcje" class="text-end instrument-actions">
|
|
<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>
|
|
|
|
<style>
|
|
@media (max-width: 767.98px) {
|
|
.instrument-history thead { display: none; }
|
|
.instrument-history, .instrument-history tbody,
|
|
.instrument-history .instrument-row, .instrument-history .instrument-row td {
|
|
display: block;
|
|
width: 100%;
|
|
}
|
|
.instrument-history .instrument-row { padding: .75rem; border-bottom: 1px solid var(--bs-border-color); }
|
|
.instrument-history .instrument-row td {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
gap: 1rem;
|
|
padding: .3rem 0;
|
|
border: 0;
|
|
text-align: right !important;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
.instrument-history .instrument-row td::before {
|
|
content: attr(data-label);
|
|
flex: 0 0 auto;
|
|
color: var(--bs-secondary-color);
|
|
font-size: .875em;
|
|
text-align: left;
|
|
}
|
|
.instrument-history .instrument-actions { align-items: center; flex-wrap: wrap; }
|
|
}
|
|
</style>
|
|
<?= $this->endSection() ?>
|