Files
orderPRO/resources/views/settings/delivery-status-form.php
Jacek Pyziak 933dfcc67b feat(120): alert component unification
Phase 120 - Plan 01:
- Reusable PHP alert component (resources/views/components/alert.php)
  with inline SVG icon per type, optional dismiss button.
- Missing .alert--info SCSS variant added (#eff6ff/#bfdbfe/#1e3a8a) -
  fixes black-on-white alert after Fakturownia test connection.
- Flash::push(type, message) + Flash::all() with BC for set/get;
  legacy key heuristic (error/.save/warning -> typed entries).
- Central flash renderer in 3 layouts (app/auth/public) iterating
  Flash::all() through component (.alerts-stack wrap).
- Vanilla JS alert-dismiss.js with idempotent guard and delegated
  click handler on [data-alert-dismiss].
- 36 views migrated off inline <div class="alert alert--TYPE">;
  .flash--error/success removed from views (orders/show, shipments/prepare).
- SCSS rebuilt: public/assets/css/{app,login}.css.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:47:41 +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="mt-12"><?php $type='danger'; $message=(string) $errorMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></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>