feat(47-shipment-created-automation): immediate shipment automation trigger

Phase 47 complete:

- add event shipment.created triggered immediately after shipment creation

- add action update_shipment_status with real-change guard and chain-safe emit

- update automation UI/options, docs, and PAUL state artifacts
This commit is contained in:
2026-03-28 13:24:20 +01:00
parent d3f4bdaecd
commit ad9087d5e4
17 changed files with 784 additions and 310 deletions

View File

@@ -8,6 +8,7 @@ $actions = $isEdit ? (is_array($rule['actions'] ?? null) ? $rule['actions'] : []
$eventLabels = [
'receipt.created' => 'Utworzono paragon',
'shipment.created' => 'Utworzenie przesylki',
'shipment.status_changed' => 'Zmiana statusu przesylki',
];
@@ -125,6 +126,7 @@ $shipmentStatusOptions = is_array($shipmentStatusOptions ?? null) ? $shipmentSta
<select class="form-control automation-row__type" name="actions[<?= $idx ?>][type]" onchange="window.AutomationForm.onActionTypeChange(this)">
<option value="send_email"<?= ((string) ($act['action_type'] ?? '')) === 'send_email' ? ' selected' : '' ?>>Wyslij e-mail</option>
<option value="issue_receipt"<?= ((string) ($act['action_type'] ?? '')) === 'issue_receipt' ? ' selected' : '' ?>>Wystaw paragon</option>
<option value="update_shipment_status"<?= ((string) ($act['action_type'] ?? '')) === 'update_shipment_status' ? ' selected' : '' ?>>Zmiana statusu przesylki</option>
</select>
<div class="automation-row__config">
<?php
@@ -156,6 +158,16 @@ $shipmentStatusOptions = is_array($shipmentStatusOptions ?? null) ? $shipmentSta
</option>
<?php endforeach; ?>
</select>
<?php elseif ($actionType === 'update_shipment_status'): ?>
<select class="form-control" name="actions[<?= $idx ?>][shipment_status_key]">
<option value="">-- Wybierz docelowy status przesylki --</option>
<?php foreach ($shipmentStatusOptions as $statusKey => $statusConfig): ?>
<?php $statusLabel = (string) ($statusConfig['label'] ?? $statusKey); ?>
<option value="<?= $e((string) $statusKey) ?>"<?= ((string) ($actConfig['status_key'] ?? '')) === (string) $statusKey ? ' selected' : '' ?>>
<?= $e($statusLabel) ?>
</option>
<?php endforeach; ?>
</select>
<?php else: ?>
<select class="form-control" name="actions[<?= $idx ?>][template_id]">
<option value="">-- Wybierz szablon --</option>

View File

@@ -3,6 +3,7 @@ $rules = is_array($rules ?? null) ? $rules : [];
$eventLabels = [
'receipt.created' => 'Utworzono paragon',
'shipment.created' => 'Utworzenie przesylki',
'shipment.status_changed' => 'Zmiana statusu przesylki',
];
?>