Files
orderPRO/resources/views/settings/accounting-invoices.php
Jacek Pyziak 6129042ff6 feat(114): accounting configs refactor + invoice configs CRUD
Phase 114 complete (v3.7 Invoices):
- /settings/accounting jako hub-rozdroze (Paragony / Faktury)
- /settings/accounting/receipts + /invoices osobne podstrony list i edycji
- InvoiceConfigRepository + Controller (CRUD z walidacja delegacji)
- Seed Domyslny VAT (NOT EXISTS idempotent)
- invoice-config-form.js (toggle is_delegated -> integration_id)
- confirm-delete.js (globalny modul OrderProAlerts.confirm)
- Legacy aliasy starych endpointow /settings/accounting/save|toggle|delete

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 22:32:29 +02:00

97 lines
3.9 KiB
PHP

<?php
/** @var array<int, array<string, mixed>> $configs */
$configs = is_array($configs ?? null) ? $configs : [];
$success = trim((string) ($successMessage ?? ''));
$error = trim((string) ($errorMessage ?? ''));
?>
<section class="card">
<p class="muted" style="margin-bottom:8px"><a href="/settings/accounting">&larr; Ksiegowosc</a></p>
<h2 class="section-title">Konfiguracje faktur</h2>
<p class="muted mt-12">Zarzadzaj konfiguracjami wystawiania faktur. Mozesz dodac wiele konfiguracji (np. dla roznych dzialalnosci) i opcjonalnie delegowac wystawianie do Fakturowni.</p>
<?php if ($error !== ''): ?>
<div class="alert alert--danger mt-12" role="alert"><?= $e($error) ?></div>
<?php endif; ?>
<?php if ($success !== ''): ?>
<div class="alert alert--success mt-12" role="status"><?= $e($success) ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<h3 class="section-title">Lista konfiguracji</h3>
<div class="form-actions mt-12">
<a class="btn btn--primary" href="/settings/accounting/invoices/new">Dodaj konfiguracje</a>
</div>
<?php if ($configs === []): ?>
<p class="muted mt-12">Brak konfiguracji faktur. Dodaj pierwsza powyzej.</p>
<?php else: ?>
<div class="table-wrap mt-12">
<table class="table">
<thead>
<tr>
<th>Nazwa</th>
<th>Format numeru</th>
<th>Numerowanie</th>
<th>Tryb</th>
<th>Konto Fakturowni</th>
<th>Status</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
<?php foreach ($configs as $cfg):
$cid = (int) ($cfg['id'] ?? 0);
$isDelegated = ((int) ($cfg['is_delegated'] ?? 0)) === 1;
$isActive = ((int) ($cfg['is_active'] ?? 0)) === 1;
?>
<tr>
<td><?= $e((string) ($cfg['name'] ?? '')) ?></td>
<td><code><?= $e((string) ($cfg['number_format'] ?? '')) ?></code></td>
<td><?= ((string) ($cfg['numbering_type'] ?? 'monthly')) === 'yearly' ? 'Roczne' : 'Miesieczne' ?></td>
<td>
<?php if ($isDelegated): ?>
<span class="badge badge--success">Fakturownia</span>
<?php else: ?>
<span class="badge badge--muted">Lokalna</span>
<?php endif; ?>
</td>
<td>
<?php if ($isDelegated && !empty($cfg['integration_name'])): ?>
<?= $e((string) $cfg['integration_name']) ?>
<?php else: ?>
<span class="muted">-</span>
<?php endif; ?>
</td>
<td>
<?php if ($isActive): ?>
<span class="badge badge--success">Aktywna</span>
<?php else: ?>
<span class="badge badge--muted">Nieaktywna</span>
<?php endif; ?>
</td>
<td style="white-space:nowrap">
<a href="/settings/accounting/invoices/edit?id=<?= $cid ?>" class="btn btn--sm btn--secondary">Edytuj</a>
<form action="/settings/accounting/invoices/toggle" method="post" style="display:inline">
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<input type="hidden" name="id" value="<?= $cid ?>">
<button type="submit" class="btn btn--sm btn--secondary">
<?= $isActive ? 'Dezaktywuj' : 'Aktywuj' ?>
</button>
</form>
<form action="/settings/accounting/invoices/delete" method="post" style="display:inline" class="js-confirm-delete">
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<input type="hidden" name="id" value="<?= $cid ?>">
<button type="button" class="btn btn--sm btn--danger js-delete-btn">Usun</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</section>