first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?= $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 = $cat ? site_url('categories/' . $cat['id']) : site_url('categories'); ?>
|
||||
<?= form_open($action) ?>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Nazwa</label>
|
||||
<input type="text" name="name" class="form-control" required
|
||||
value="<?= esc(old('name', $cat['name'] ?? '')) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Typ</label>
|
||||
<?php $t = old('type', $cat['type'] ?? 'expense'); ?>
|
||||
<select name="type" class="form-select" required>
|
||||
<option value="income" <?= $t === 'income' ? 'selected' : '' ?>>Przychód</option>
|
||||
<option value="expense" <?= $t === 'expense' ? 'selected' : '' ?>>Wydatek</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Kategoria nadrzędna (opcjonalnie)</label>
|
||||
<?php $p = old('parent_id', $cat['parent_id'] ?? ''); ?>
|
||||
<select name="parent_id" class="form-select">
|
||||
<option value="">— brak —</option>
|
||||
<?php foreach ($parents as $pc): ?>
|
||||
<?php if ($cat && $pc['id'] == $cat['id']) continue; ?>
|
||||
<option value="<?= $pc['id'] ?>" <?= (string) $p === (string) $pc['id'] ? 'selected' : '' ?>>
|
||||
<?= esc($pc['indent_label']) ?> (<?= $pc['type'] === 'income' ? 'przychód' : 'wydatek' ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Zapisz</button>
|
||||
<a href="<?= site_url('categories') ?>" class="btn btn-link">Anuluj</a>
|
||||
<?= form_close() ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?= $this->extend('layout/main') ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h1 class="h4 mb-0">Kategorie</h1>
|
||||
<a href="<?= site_url('categories/new') ?>" class="btn btn-primary">+ Nowa kategoria</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>Nazwa</th>
|
||||
<th>Typ</th>
|
||||
<th class="text-end">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($categories)): ?>
|
||||
<tr><td colspan="3" class="text-center text-muted py-4">Brak kategorii.</td></tr>
|
||||
<?php else: foreach ($categories as $c): ?>
|
||||
<tr>
|
||||
<td><?= esc($c['indent_label']) ?></td>
|
||||
<td>
|
||||
<?php if ($c['type'] === 'income'): ?>
|
||||
<span class="badge bg-success">Przychód</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-danger">Wydatek</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a href="<?= site_url('categories/' . $c['id'] . '/edit') ?>" class="btn btn-sm btn-outline-secondary">Edytuj</a>
|
||||
<a href="<?= site_url('categories/' . $c['id'] . '/delete') ?>" class="btn btn-sm btn-outline-danger"
|
||||
onclick="return confirm('Usunąć kategorię?')">Usuń</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
Reference in New Issue
Block a user