Files
orderPRO/resources/views/settings/delivery-status-form.php
Jacek Pyziak 0063402897 feat(108): delivery status management
Phase 108 complete (v3.2 milestone):

Plan 108-01 — Delivery Status DB & CRUD:
- Tabela delivery_statuses z seedem 11 statusow systemowych
- DeliveryStatusRepository (CRUD + per-request static cache)
- DeliveryStatus::setRepository() — DB fallback dla static final class
- Panel /settings/delivery-statuses (zakladki Statusy + Mapowanie)
- Sidebar przebudowany: Statusy zamowien + Statusy przesylek

Plan 108-02 — Automation Dropdowns z DB + UI Refactor:
- Dropdowny automatyzacji ladowane z DB (warunek shipment_status + akcja update_shipment_status)
- Walidacja przez DeliveryStatus::getAllStatuses()
- Osobna podstrona formularza CRUD (delivery-status-form.php)
- Lista uproszczona: rename Terminal -> Koncowy, usunieta kolumna Typ
- BREAKING: drop backward compat dla starych grupowych kluczy automatyzacji
- Bug fix: path params w DeliveryStatusesController via \$request->input('id')

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 22:10:24 +02:00

77 lines
3.0 KiB
PHP

<?php
$row = is_array($row ?? null) ? $row : null;
$isEdit = (bool) ($isEdit ?? false);
$errorMessage = (string) ($errorMessage ?? '');
$csrfToken = (string) ($csrfToken ?? '');
$rowId = (int) ($row['id'] ?? 0);
$rowKey = (string) ($row['key'] ?? '');
$rowLabel = (string) ($row['label_pl'] ?? '');
$rowColor = (string) ($row['color'] ?? '#6c757d');
$rowSortOrder = (int) ($row['sort_order'] ?? 100);
$rowIsTerminal = !empty($row['is_terminal']);
$action = $isEdit
? '/settings/delivery-statuses/' . $rowId . '/update'
: '/settings/delivery-statuses';
?>
<section class="card">
<h2 class="section-title"><?= $isEdit ? 'Edytuj status przesyłki' : 'Nowy status przesyłki' ?></h2>
<?php if ($errorMessage !== ''): ?>
<div class="alert alert--danger mt-12" role="alert"><?= $e($errorMessage) ?></div>
<?php endif; ?>
<form action="<?= $e($action) ?>" method="post" novalidate class="mt-12">
<input type="hidden" name="_token" value="<?= $e($csrfToken) ?>">
<div class="form-grid-2">
<label class="form-field">
<span class="field-label">Klucz *</span>
<?php if ($isEdit): ?>
<input class="form-control" type="text" value="<?= $e($rowKey) ?>" disabled>
<small class="muted">Klucz nie może być zmieniany po utworzeniu.</small>
<?php else: ?>
<input class="form-control" type="text" name="key" maxlength="50" required
pattern="[a-z][a-z0-9_]{0,49}"
placeholder="np. custom_status"
value="<?= $e($rowKey) ?>">
<small class="muted">Małe litery, cyfry, _, max 50 znaków, zaczyna się literą.</small>
<?php endif; ?>
</label>
<label class="form-field">
<span class="field-label">Etykieta *</span>
<input class="form-control" type="text" name="label_pl" maxlength="100" required
placeholder="np. Mój status" value="<?= $e($rowLabel) ?>">
</label>
</div>
<div class="form-grid-2 mt-0">
<label class="form-field">
<span class="field-label">Kolor</span>
<input class="form-control" type="color" name="color" value="<?= $e($rowColor) ?>">
</label>
<label class="form-field">
<span class="field-label">Kolejność</span>
<input class="form-control" type="number" name="sort_order"
min="0" max="9999" value="<?= $rowSortOrder ?>">
</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_terminal" value="1"<?= $rowIsTerminal ? ' checked' : '' ?>>
<span class="field-label" style="margin:0">Końcowy</span>
</label>
</div>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--primary"><?= $isEdit ? 'Zapisz zmiany' : 'Utwórz status' ?></button>
<a href="/settings/delivery-statuses?tab=statuses" class="btn btn--secondary">Anuluj</a>
</div>
</form>
</section>