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>
This commit is contained in:
@@ -191,6 +191,8 @@
|
||||
<script src="/assets/js/modules/jquery-alerts.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/jquery-alerts.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/global-search.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/global-search.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/checkbox-multiselect.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/checkbox-multiselect.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/invoice-config-form.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/invoice-config-form.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/confirm-delete.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/confirm-delete.js') ?: 0 ?>"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
|
||||
<script src="/assets/js/modules/statistics-summary-charts.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/statistics-summary-charts.js') ?: 0 ?>"></script>
|
||||
<script>
|
||||
|
||||
133
resources/views/settings/accounting-invoice-edit.php
Normal file
133
resources/views/settings/accounting-invoice-edit.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/** @var array<string, mixed>|null $config */
|
||||
$config = is_array($config ?? null) ? $config : null;
|
||||
$accounts = is_array($fakturowniaAccounts ?? null) ? $fakturowniaAccounts : [];
|
||||
$isEdit = $config !== null;
|
||||
$cid = (int) ($config['id'] ?? 0);
|
||||
|
||||
$name = (string) ($config['name'] ?? '');
|
||||
$numberFormat = (string) ($config['number_format'] ?? 'FV/%N/%M/%Y');
|
||||
$numberingType = (string) ($config['numbering_type'] ?? 'monthly');
|
||||
$saleDateSource = (string) ($config['sale_date_source'] ?? 'issue_date');
|
||||
$orderReference = (string) ($config['order_reference'] ?? 'none');
|
||||
$paymentToDays = (int) ($config['payment_to_days'] ?? 7);
|
||||
$defaultKind = (string) ($config['default_kind'] ?? 'vat');
|
||||
$isDelegated = ((int) ($config['is_delegated'] ?? 0)) === 1;
|
||||
$integrationId = (int) ($config['integration_id'] ?? 0);
|
||||
$isActive = $isEdit ? ((int) ($config['is_active'] ?? 0)) === 1 : true;
|
||||
|
||||
$success = trim((string) ($successMessage ?? ''));
|
||||
$error = trim((string) ($errorMessage ?? ''));
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<p class="muted" style="margin-bottom:8px"><a href="/settings/accounting">Ksiegowosc</a> » <a href="/settings/accounting/invoices">Faktury</a></p>
|
||||
<h2 class="section-title"><?= $isEdit ? 'Edycja konfiguracji faktury' : 'Nowa konfiguracja faktury' ?></h2>
|
||||
|
||||
<?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">
|
||||
<form action="/settings/accounting/invoices/save" method="post" novalidate class="mt-12">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= $cid ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Nazwa *</span>
|
||||
<input class="form-control" type="text" name="name" maxlength="128" required value="<?= $e($name) ?>">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Format numeru *</span>
|
||||
<input class="form-control" type="text" name="number_format" maxlength="64" required placeholder="FV/%N/%M/%Y" value="<?= $e($numberFormat) ?>">
|
||||
<small class="field-hint"><code>%N</code> = numer, <code>%M</code> = miesiac (01-12), <code>%Y</code> = rok (4 cyfry)</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-3 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Numerowanie</span>
|
||||
<select class="form-control" name="numbering_type">
|
||||
<option value="monthly"<?= $numberingType === 'monthly' ? ' selected' : '' ?>>Miesieczne</option>
|
||||
<option value="yearly"<?= $numberingType === 'yearly' ? ' selected' : '' ?>>Roczne</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Data sprzedazy</span>
|
||||
<select class="form-control" name="sale_date_source">
|
||||
<option value="issue_date"<?= $saleDateSource === 'issue_date' ? ' selected' : '' ?>>Data wystawienia</option>
|
||||
<option value="order_date"<?= $saleDateSource === 'order_date' ? ' selected' : '' ?>>Data zamowienia</option>
|
||||
<option value="payment_date"<?= $saleDateSource === 'payment_date' ? ' selected' : '' ?>>Data platnosci</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Numer referencyjny zamowienia</span>
|
||||
<select class="form-control" name="order_reference">
|
||||
<option value="none"<?= $orderReference === 'none' ? ' selected' : '' ?>>Brak</option>
|
||||
<option value="orderpro"<?= $orderReference === 'orderpro' ? ' selected' : '' ?>>orderPRO</option>
|
||||
<option value="integration"<?= $orderReference === 'integration' ? ' selected' : '' ?>>Zewnetrzny</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-3 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Termin platnosci (dni)</span>
|
||||
<input class="form-control" type="number" name="payment_to_days" min="0" max="365" value="<?= $paymentToDays ?>">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Typ dokumentu</span>
|
||||
<select class="form-control" name="default_kind">
|
||||
<option value="vat"<?= $defaultKind === 'vat' ? ' selected' : '' ?>>Faktura VAT</option>
|
||||
<option value="proforma"<?= $defaultKind === 'proforma' ? ' selected' : '' ?>>Proforma</option>
|
||||
<option value="invoice_other"<?= $defaultKind === 'invoice_other' ? ' selected' : '' ?>>Inna</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field" style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isActive ? ' checked' : '' ?>>
|
||||
<span class="field-label" style="margin:0">Konfiguracja aktywna</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-field mt-12">
|
||||
<label style="display:flex;align-items:center;gap:6px">
|
||||
<input type="checkbox" name="is_delegated" value="1" data-invoice-delegated<?= $isDelegated ? ' checked' : '' ?>>
|
||||
<span class="field-label" style="margin:0">Deleguj wystawianie do Fakturowni</span>
|
||||
</label>
|
||||
<small class="field-hint">Gdy zaznaczone, faktury beda generowane po stronie Fakturowni (numer + PDF). W przeciwnym razie numeracja i PDF lokalne.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-field mt-12" data-invoice-delegation<?= $isDelegated ? '' : ' style="display:none"' ?>>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Konto Fakturowni *</span>
|
||||
<select class="form-control" name="integration_id"<?= $isDelegated ? ' required' : '' ?>>
|
||||
<option value="">— wybierz konto —</option>
|
||||
<?php foreach ($accounts as $acc):
|
||||
$aid = (int) ($acc['integration_id'] ?? 0);
|
||||
$accName = (string) ($acc['name'] ?? '');
|
||||
$accPrefix = (string) ($acc['account_prefix'] ?? '');
|
||||
?>
|
||||
<option value="<?= $aid ?>"<?= $aid === $integrationId ? ' selected' : '' ?>>
|
||||
<?= $e($accName) ?><?= $accPrefix !== '' ? ' (' . $e($accPrefix) . '.fakturownia.pl)' : '' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if ($accounts === []): ?>
|
||||
<small class="field-hint">Brak skonfigurowanych kont Fakturowni. <a href="/settings/integrations/fakturownia/new">Dodaj konto</a> aby moc delegowac.</small>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj konfiguracje' ?></button>
|
||||
<a href="/settings/accounting/invoices" class="btn btn--secondary">Anuluj</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
96
resources/views/settings/accounting-invoices.php
Normal file
96
resources/views/settings/accounting-invoices.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?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">← 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>
|
||||
92
resources/views/settings/accounting-receipt-edit.php
Normal file
92
resources/views/settings/accounting-receipt-edit.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/** @var array<string, mixed>|null $config */
|
||||
$config = is_array($config ?? null) ? $config : null;
|
||||
$isEdit = $config !== null;
|
||||
$cid = (int) ($config['id'] ?? 0);
|
||||
|
||||
$name = (string) ($config['name'] ?? '');
|
||||
$numberFormat = (string) ($config['number_format'] ?? 'PAR/%N/%M/%Y');
|
||||
$numberingType = (string) ($config['numbering_type'] ?? 'monthly');
|
||||
$saleDateSource = (string) ($config['sale_date_source'] ?? 'issue_date');
|
||||
$orderReference = (string) ($config['order_reference'] ?? 'none');
|
||||
$isNamed = ((int) ($config['is_named'] ?? 0)) === 1;
|
||||
$isActive = $isEdit ? ((int) ($config['is_active'] ?? 0)) === 1 : true;
|
||||
|
||||
$success = trim((string) ($successMessage ?? ''));
|
||||
$error = trim((string) ($errorMessage ?? ''));
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<p class="muted" style="margin-bottom:8px"><a href="/settings/accounting">Ksiegowosc</a> » <a href="/settings/accounting/receipts">Paragony</a></p>
|
||||
<h2 class="section-title"><?= $isEdit ? 'Edycja konfiguracji paragonu' : 'Nowa konfiguracja paragonu' ?></h2>
|
||||
|
||||
<?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">
|
||||
<form action="/settings/accounting/receipts/save" method="post" novalidate class="mt-12">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= $cid ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Nazwa *</span>
|
||||
<input class="form-control" type="text" name="name" maxlength="128" required value="<?= $e($name) ?>">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Format numeru *</span>
|
||||
<input class="form-control" type="text" name="number_format" maxlength="64" required placeholder="PAR/%N/%M/%Y" value="<?= $e($numberFormat) ?>">
|
||||
<small class="field-hint"><code>%N</code> = numer, <code>%M</code> = miesiac, <code>%Y</code> = rok</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-3 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label">Numerowanie</span>
|
||||
<select class="form-control" name="numbering_type">
|
||||
<option value="monthly"<?= $numberingType === 'monthly' ? ' selected' : '' ?>>Miesieczne</option>
|
||||
<option value="yearly"<?= $numberingType === 'yearly' ? ' selected' : '' ?>>Roczne</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Data sprzedazy</span>
|
||||
<select class="form-control" name="sale_date_source">
|
||||
<option value="issue_date"<?= $saleDateSource === 'issue_date' ? ' selected' : '' ?>>Data wystawienia</option>
|
||||
<option value="order_date"<?= $saleDateSource === 'order_date' ? ' selected' : '' ?>>Data zamowienia</option>
|
||||
<option value="payment_date"<?= $saleDateSource === 'payment_date' ? ' selected' : '' ?>>Data platnosci</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label">Numer referencyjny zamowienia</span>
|
||||
<select class="form-control" name="order_reference">
|
||||
<option value="none"<?= $orderReference === 'none' ? ' selected' : '' ?>>Brak</option>
|
||||
<option value="orderpro"<?= $orderReference === 'orderpro' ? ' selected' : '' ?>>orderPRO</option>
|
||||
<option value="integration"<?= $orderReference === 'integration' ? ' selected' : '' ?>>Zewnetrzny</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field" style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_named" value="1"<?= $isNamed ? ' checked' : '' ?>>
|
||||
<span class="field-label" style="margin:0">Paragon imienny (z danymi kupujacego)</span>
|
||||
</label>
|
||||
<label class="form-field" style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isActive ? ' checked' : '' ?>>
|
||||
<span class="field-label" style="margin:0">Konfiguracja aktywna</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj konfiguracje' ?></button>
|
||||
<a href="/settings/accounting/receipts" class="btn btn--secondary">Anuluj</a>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
79
resources/views/settings/accounting-receipts.php
Normal file
79
resources/views/settings/accounting-receipts.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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">← Ksiegowosc</a></p>
|
||||
<h2 class="section-title">Konfiguracje paragonow</h2>
|
||||
<p class="muted mt-12">Zarzadzaj konfiguracjami wystawiania paragonow.</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/receipts/new">Dodaj konfiguracje</a>
|
||||
</div>
|
||||
|
||||
<?php if ($configs === []): ?>
|
||||
<p class="muted mt-12">Brak konfiguracji paragonow. 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>Status</th>
|
||||
<th>Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($configs as $cfg):
|
||||
$cid = (int) ($cfg['id'] ?? 0);
|
||||
$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 ($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/receipts/edit?id=<?= $cid ?>" class="btn btn--sm btn--secondary">Edytuj</a>
|
||||
<form action="/settings/accounting/receipts/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/receipts/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>
|
||||
@@ -1,158 +1,35 @@
|
||||
<?php
|
||||
$configs = is_array($configs ?? null) ? $configs : [];
|
||||
$ec = is_array($editConfig ?? null) ? $editConfig : null;
|
||||
$isEdit = $ec !== null;
|
||||
$success = trim((string) ($successMessage ?? ''));
|
||||
$error = trim((string) ($errorMessage ?? ''));
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="section-title"><?= $e($t('settings.accounting.title')) ?></h2>
|
||||
<p class="muted mt-12"><?= $e($t('settings.accounting.description')) ?></p>
|
||||
<h2 class="section-title">Ksiegowosc</h2>
|
||||
<p class="muted mt-12">Wybierz typ dokumentu ktorego konfiguracje chcesz zarzadzac.</p>
|
||||
|
||||
<?php if (!empty($errorMessage)): ?>
|
||||
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
|
||||
<?php if ($error !== ''): ?>
|
||||
<div class="alert alert--danger mt-12" role="alert"><?= $e($error) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($successMessage)): ?>
|
||||
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
|
||||
<?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"><?= $e($t('settings.accounting.table.heading')) ?></h3>
|
||||
|
||||
<?php if (count($configs) === 0): ?>
|
||||
<p class="muted mt-12"><?= $e($t('settings.accounting.table.empty')) ?></p>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap mt-12">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $e($t('settings.accounting.table.name')) ?></th>
|
||||
<th><?= $e($t('settings.accounting.table.number_format')) ?></th>
|
||||
<th><?= $e($t('settings.accounting.table.numbering_type')) ?></th>
|
||||
<th><?= $e($t('settings.accounting.table.status')) ?></th>
|
||||
<th><?= $e($t('settings.accounting.table.actions')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($configs as $cfg): ?>
|
||||
<tr>
|
||||
<td><?= $e((string) ($cfg['name'] ?? '')) ?></td>
|
||||
<td><code><?= $e((string) ($cfg['number_format'] ?? '')) ?></code></td>
|
||||
<td><?= $e($t('settings.accounting.options.numbering_type.' . ($cfg['numbering_type'] ?? 'monthly'))) ?></td>
|
||||
<td>
|
||||
<?php if (((int) ($cfg['is_active'] ?? 0)) === 1): ?>
|
||||
<span class="badge badge--success"><?= $e($t('settings.accounting.options.active')) ?></span>
|
||||
<?php else: ?>
|
||||
<span class="badge badge--muted"><?= $e($t('settings.accounting.options.inactive')) ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td style="white-space:nowrap">
|
||||
<a href="/settings/accounting?edit=<?= (int) ($cfg['id'] ?? 0) ?>" class="btn btn--sm btn--secondary"><?= $e($t('settings.accounting.actions.edit')) ?></a>
|
||||
<form action="/settings/accounting/toggle" method="post" style="display:inline">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="id" value="<?= (int) ($cfg['id'] ?? 0) ?>">
|
||||
<button type="submit" class="btn btn--sm btn--secondary">
|
||||
<?= ((int) ($cfg['is_active'] ?? 0)) === 1 ? $e($t('settings.accounting.actions.deactivate')) : $e($t('settings.accounting.actions.activate')) ?>
|
||||
</button>
|
||||
</form>
|
||||
<form action="/settings/accounting/delete" method="post" style="display:inline" class="js-confirm-delete">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<input type="hidden" name="id" value="<?= (int) ($cfg['id'] ?? 0) ?>">
|
||||
<button type="button" class="btn btn--sm btn--danger js-delete-btn"><?= $e($t('settings.accounting.actions.delete')) ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-grid-2">
|
||||
<div style="border:1px solid var(--border-color, #e5e7eb);border-radius:8px;padding:16px">
|
||||
<h3 class="section-title" style="margin-top:0">Paragony</h3>
|
||||
<p class="muted mt-12">Konfiguracje wystawiania paragonow: format numeracji, sposob numerowania, oznaczenie zamowienia.</p>
|
||||
<div class="form-actions mt-16">
|
||||
<a class="btn btn--primary" href="/settings/accounting/receipts">Zarzadzaj paragonami</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div style="border:1px solid var(--border-color, #e5e7eb);border-radius:8px;padding:16px">
|
||||
<h3 class="section-title" style="margin-top:0">Faktury</h3>
|
||||
<p class="muted mt-12">Konfiguracje wystawiania faktur: numeracja lokalna lub delegacja do Fakturowni, termin platnosci, typ dokumentu.</p>
|
||||
<div class="form-actions mt-16">
|
||||
<a class="btn btn--primary" href="/settings/accounting/invoices">Zarzadzaj fakturami</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card mt-16">
|
||||
<h3 class="section-title"><?= $isEdit ? $e($t('settings.accounting.form.edit_heading')) : $e($t('settings.accounting.form.add_heading')) ?></h3>
|
||||
|
||||
<form action="/settings/accounting/save" method="post" novalidate class="mt-12">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?= (int) ($ec['id'] ?? 0) ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="form-grid-2">
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.accounting.fields.name')) ?> *</span>
|
||||
<input class="form-control" type="text" name="name" maxlength="128" required value="<?= $e((string) ($ec['name'] ?? '')) ?>">
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.accounting.fields.number_format')) ?> *</span>
|
||||
<input class="form-control" type="text" name="number_format" maxlength="64" required placeholder="PAR/%N/%M/%Y" value="<?= $e((string) ($ec['number_format'] ?? 'PAR/%N/%M/%Y')) ?>">
|
||||
<small class="field-hint"><?= $e($t('settings.accounting.fields.number_format_hint')) ?></small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-3 mt-0">
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.accounting.fields.numbering_type')) ?></span>
|
||||
<select class="form-control" name="numbering_type">
|
||||
<option value="monthly"<?= ((string) ($ec['numbering_type'] ?? 'monthly')) === 'monthly' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.numbering_type.monthly')) ?></option>
|
||||
<option value="yearly"<?= ((string) ($ec['numbering_type'] ?? '')) === 'yearly' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.numbering_type.yearly')) ?></option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.accounting.fields.sale_date_source')) ?></span>
|
||||
<select class="form-control" name="sale_date_source">
|
||||
<option value="issue_date"<?= ((string) ($ec['sale_date_source'] ?? 'issue_date')) === 'issue_date' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.sale_date_source.issue_date')) ?></option>
|
||||
<option value="order_date"<?= ((string) ($ec['sale_date_source'] ?? '')) === 'order_date' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.sale_date_source.order_date')) ?></option>
|
||||
<option value="payment_date"<?= ((string) ($ec['sale_date_source'] ?? '')) === 'payment_date' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.sale_date_source.payment_date')) ?></option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.accounting.fields.order_reference')) ?></span>
|
||||
<select class="form-control" name="order_reference">
|
||||
<option value="none"<?= ((string) ($ec['order_reference'] ?? 'none')) === 'none' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.order_reference.none')) ?></option>
|
||||
<option value="orderpro"<?= ((string) ($ec['order_reference'] ?? '')) === 'orderpro' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.order_reference.orderpro')) ?></option>
|
||||
<option value="integration"<?= ((string) ($ec['order_reference'] ?? '')) === 'integration' ? ' selected' : '' ?>><?= $e($t('settings.accounting.options.order_reference.integration')) ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-grid-2 mt-0">
|
||||
<label class="form-field" style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_named" value="1"<?= ((int) ($ec['is_named'] ?? 0)) === 1 ? ' checked' : '' ?>>
|
||||
<span class="field-label" style="margin:0"><?= $e($t('settings.accounting.fields.is_named')) ?></span>
|
||||
</label>
|
||||
<label class="form-field" style="display:flex;align-items:center;gap:6px;flex-direction:row">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isEdit ? (((int) ($ec['is_active'] ?? 0)) === 1 ? ' checked' : '') : ' checked' ?>>
|
||||
<span class="field-label" style="margin:0"><?= $e($t('settings.accounting.fields.is_active')) ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $isEdit ? $e($t('settings.accounting.actions.save_edit')) : $e($t('settings.accounting.actions.save_new')) ?></button>
|
||||
<?php if ($isEdit): ?>
|
||||
<a href="/settings/accounting" class="btn btn--secondary"><?= $e($t('settings.accounting.actions.cancel')) ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.js-delete-btn').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var form = this.closest('form');
|
||||
if (window.OrderProAlerts && window.OrderProAlerts.confirm) {
|
||||
window.OrderProAlerts.confirm(
|
||||
'<?= $e($t('settings.accounting.confirm.delete_title')) ?>',
|
||||
'<?= $e($t('settings.accounting.confirm.delete_message')) ?>',
|
||||
function() { form.submit(); }
|
||||
);
|
||||
} else {
|
||||
if (confirm('<?= $e($t('settings.accounting.confirm.delete_message')) ?>')) {
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user