feat(v1.5): complete phases 40-43 workflow cleanup

This commit is contained in:
2026-03-25 22:46:51 +01:00
parent b8dda81e7b
commit 3610571949
37 changed files with 1557 additions and 259 deletions

View File

@@ -8,6 +8,7 @@ $actions = $isEdit ? (is_array($rule['actions'] ?? null) ? $rule['actions'] : []
$eventLabels = [
'receipt.created' => 'Utworzono paragon',
'shipment.status_changed' => 'Zmiana statusu przesylki',
];
$recipientLabels = [
@@ -15,6 +16,7 @@ $recipientLabels = [
'client_and_company' => 'Klient + e-mail z danych firmy',
'company' => 'E-mail z danych firmy',
];
$shipmentStatusOptions = is_array($shipmentStatusOptions ?? null) ? $shipmentStatusOptions : [];
?>
<section class="card">
@@ -62,20 +64,35 @@ $recipientLabels = [
<div class="automation-row__fields">
<select class="form-control automation-row__type" name="conditions[<?= $idx ?>][type]" onchange="window.AutomationForm.onConditionTypeChange(this)">
<option value="integration"<?= ((string) ($cond['condition_type'] ?? '')) === 'integration' ? ' selected' : '' ?>>Integracja (kanal sprzedazy)</option>
<option value="shipment_status"<?= ((string) ($cond['condition_type'] ?? '')) === 'shipment_status' ? ' selected' : '' ?>>Status przesylki</option>
</select>
<div class="automation-row__config">
<?php
$condValue = is_array($cond['condition_value'] ?? null) ? $cond['condition_value'] : [];
$conditionType = (string) ($cond['condition_type'] ?? 'integration');
$selectedIds = is_array($condValue['integration_ids'] ?? null) ? $condValue['integration_ids'] : [];
$selectedStatusKeys = is_array($condValue['status_keys'] ?? null) ? $condValue['status_keys'] : [];
?>
<div class="checkbox-group">
<?php foreach ($integrations as $integ): ?>
<label class="checkbox-label">
<input type="checkbox" name="conditions[<?= $idx ?>][integration_ids][]" value="<?= (int) $integ['id'] ?>"<?= in_array((int) $integ['id'], $selectedIds, true) ? ' checked' : '' ?>>
<?= $e((string) ($integ['name'] ?? '')) ?> <span class="muted">(<?= $e((string) ($integ['type'] ?? '')) ?>)</span>
</label>
<?php endforeach; ?>
</div>
<?php if ($conditionType === 'shipment_status'): ?>
<div class="checkbox-group">
<?php foreach ($shipmentStatusOptions as $statusKey => $statusConfig): ?>
<?php $statusLabel = (string) ($statusConfig['label'] ?? $statusKey); ?>
<label class="checkbox-label">
<input type="checkbox" name="conditions[<?= $idx ?>][shipment_status_keys][]" value="<?= $e((string) $statusKey) ?>"<?= in_array((string) $statusKey, $selectedStatusKeys, true) ? ' checked' : '' ?>>
<?= $e($statusLabel) ?>
</label>
<?php endforeach; ?>
</div>
<?php else: ?>
<div class="checkbox-group">
<?php foreach ($integrations as $integ): ?>
<label class="checkbox-label">
<input type="checkbox" name="conditions[<?= $idx ?>][integration_ids][]" value="<?= (int) $integ['id'] ?>"<?= in_array((int) $integ['id'], $selectedIds, true) ? ' checked' : '' ?>>
<?= $e((string) ($integ['name'] ?? '')) ?> <span class="muted">(<?= $e((string) ($integ['type'] ?? '')) ?>)</span>
</label>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<button type="button" class="btn btn--sm btn--danger automation-row__remove" onclick="window.AutomationForm.removeRow(this)">&times;</button>
@@ -133,7 +150,8 @@ window.AutomationFormData = {
emailTemplates: <?= json_encode(array_map(function($t) {
return ['id' => (int) $t['id'], 'name' => (string) ($t['name'] ?? '')];
}, $emailTemplates), JSON_UNESCAPED_UNICODE) ?>,
recipientLabels: <?= json_encode($recipientLabels, JSON_UNESCAPED_UNICODE) ?>
recipientLabels: <?= json_encode($recipientLabels, JSON_UNESCAPED_UNICODE) ?>,
shipmentStatusOptions: <?= json_encode($shipmentStatusOptions, JSON_UNESCAPED_UNICODE) ?>
};
</script>
<script src="/assets/js/modules/automation-form.js"></script>

View File

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