first commit

This commit is contained in:
2026-07-06 20:16:00 +02:00
commit 352e6d9e22
147 changed files with 12242 additions and 0 deletions
+52
View File
@@ -0,0 +1,52 @@
<?= $this->extend('layout/main') ?>
<?= $this->section('content') ?>
<h1 class="h4 mb-3"><?= esc($title) ?></h1>
<div class="card shadow-sm">
<div class="card-body">
<?php $action = $op ? site_url('investments/operations/' . $op['id']) : site_url('investments/operations'); ?>
<?= form_open($action, ['class' => 'row g-3']) ?>
<div class="col-md-4">
<label class="form-label">Instrument</label>
<?php $selIns = old('instrument_id', $op['instrument_id'] ?? ''); ?>
<select name="instrument_id" class="form-select" required>
<option value="">— wybierz —</option>
<?php foreach ($instruments as $i): ?>
<option value="<?= $i['id'] ?>" <?= (string) $selIns === (string) $i['id'] ? 'selected' : '' ?>>
<?= esc($i['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-4">
<label class="form-label">Data</label>
<input type="date" name="date" class="form-control" required
value="<?= esc(old('date', $op['date'] ?? date('Y-m-d'))) ?>">
</div>
<div class="col-md-4">
<label class="form-label">Typ</label>
<?php $t = old('type', $op['type'] ?? 'deposit'); ?>
<select name="type" class="form-select" required>
<option value="deposit" <?= $t === 'deposit' ? 'selected' : '' ?>>Wpłata</option>
<option value="withdraw" <?= $t === 'withdraw' ? 'selected' : '' ?>>Wypłata</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label">Kwota (zł)</label>
<input type="number" step="0.01" min="0.01" name="amount" class="form-control" required
value="<?= esc(old('amount', $op['amount'] ?? '')) ?>">
</div>
<div class="col-md-8">
<label class="form-label">Opis (opcjonalnie)</label>
<input type="text" name="description" class="form-control" maxlength="255"
value="<?= esc(old('description', $op['description'] ?? '')) ?>">
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Zapisz</button>
<a href="<?= site_url('investments/operations') ?>" class="btn btn-link">Anuluj</a>
</div>
<?= form_close() ?>
</div>
</div>
<?= $this->endSection() ?>
+89
View File
@@ -0,0 +1,89 @@
<?= $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">Operacje inwestycyjne</h1>
<a href="<?= site_url('investments/operations/new') ?>" class="btn btn-primary">+ Nowa operacja</a>
</div>
<div class="card shadow-sm mb-3">
<div class="card-body">
<?= form_open('investments/operations', ['method' => 'get', 'class' => 'row g-2 align-items-end']) ?>
<div class="col-6 col-md-3">
<label class="form-label small mb-1">Od</label>
<input type="date" name="from" class="form-control" value="<?= esc($filter['from'] ?? '') ?>">
</div>
<div class="col-6 col-md-3">
<label class="form-label small mb-1">Do</label>
<input type="date" name="to" class="form-control" value="<?= esc($filter['to'] ?? '') ?>">
</div>
<div class="col-6 col-md-3">
<label class="form-label small mb-1">Instrument</label>
<select name="instrument_id" class="form-select">
<option value="">— wszystkie —</option>
<?php foreach ($instruments as $i): ?>
<option value="<?= $i['id'] ?>" <?= (string) ($filter['instrument_id'] ?? '') === (string) $i['id'] ? 'selected' : '' ?>>
<?= esc($i['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-6 col-md-2">
<label class="form-label small mb-1">Typ</label>
<select name="type" class="form-select">
<option value="">— oba —</option>
<option value="deposit" <?= ($filter['type'] ?? '') === 'deposit' ? 'selected' : '' ?>>Wpłata</option>
<option value="withdraw" <?= ($filter['type'] ?? '') === 'withdraw' ? 'selected' : '' ?>>Wypłata</option>
</select>
</div>
<div class="col-md-1">
<button class="btn btn-outline-primary w-100">Filtruj</button>
</div>
<?= form_close() ?>
</div>
</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>Data</th>
<th>Instrument</th>
<th>Typ</th>
<th>Opis</th>
<th class="text-end">Kwota</th>
<th class="text-end">Akcje</th>
</tr>
</thead>
<tbody>
<?php if (empty($operations)): ?>
<tr><td colspan="6" class="text-center text-muted py-4">Brak operacji dla wybranych filtrów.</td></tr>
<?php else: foreach ($operations as $o): ?>
<?php $isDep = $o['type'] === 'deposit'; ?>
<tr>
<td><?= esc($o['date']) ?></td>
<td><?= esc($o['instrument_name'] ?? '—') ?></td>
<td>
<span class="badge <?= $isDep ? 'bg-success' : 'bg-secondary' ?>">
<?= $isDep ? 'Wpłata' : 'Wypłata' ?>
</span>
</td>
<td class="text-muted"><?= esc($o['description'] ?? '') ?></td>
<td class="text-end <?= $isDep ? 'amount-income' : 'amount-expense' ?>">
<?= $isDep ? '+' : '' ?><?= $fmt($o['amount']) ?>
</td>
<td class="text-end">
<a href="<?= site_url('investments/operations/' . $o['id'] . '/edit') ?>" class="btn btn-sm btn-outline-secondary">Edytuj</a>
<a href="<?= site_url('investments/operations/' . $o['id'] . '/delete') ?>" class="btn btn-sm btn-outline-danger"
onclick="return confirm('Usunąć operację?')">Usuń</a>
</td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>
</div>
</div>
<?= $this->endSection() ?>