update
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
<?php
|
||||
$rule = is_array($rule ?? null) ? $rule : null;
|
||||
$isEdit = $rule !== null;
|
||||
$isEdit = $rule !== null && isset($rule['id']);
|
||||
$integrations = is_array($integrations ?? null) ? $integrations : [];
|
||||
$emailTemplates = is_array($emailTemplates ?? null) ? $emailTemplates : [];
|
||||
$conditions = $isEdit ? (is_array($rule['conditions'] ?? null) ? $rule['conditions'] : []) : [];
|
||||
$actions = $isEdit ? (is_array($rule['actions'] ?? null) ? $rule['actions'] : []) : [];
|
||||
$conditions = $rule !== null && is_array($rule['conditions'] ?? null) ? $rule['conditions'] : [];
|
||||
$actions = $rule !== null && is_array($rule['actions'] ?? null) ? $rule['actions'] : [];
|
||||
|
||||
$eventLabels = [
|
||||
'receipt.created' => 'Utworzono paragon',
|
||||
'shipment.created' => 'Utworzenie przesylki',
|
||||
'shipment.status_changed' => 'Zmiana statusu przesylki',
|
||||
'payment.status_changed' => 'Zmiana statusu platnosci',
|
||||
'order.status_changed' => 'Zmiana statusu zamowienia',
|
||||
'order.status_aged' => 'Minelo X dni od zmiany statusu',
|
||||
];
|
||||
|
||||
$recipientLabels = [
|
||||
@@ -63,7 +66,7 @@ $orderStatusOptions = is_array($orderStatusOptions ?? null) ? $orderStatusOption
|
||||
|
||||
<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_active" value="1"<?= $isEdit ? (((int) ($rule['is_active'] ?? 0)) === 1 ? ' checked' : '') : ' checked' ?>>
|
||||
<input type="checkbox" name="is_active" value="1"<?= $rule !== null ? (((int) ($rule['is_active'] ?? 0)) === 1 ? ' checked' : '') : ' checked' ?>>
|
||||
<span class="field-label" style="margin:0">Aktywne</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -79,6 +82,9 @@ $orderStatusOptions = is_array($orderStatusOptions ?? null) ? $orderStatusOption
|
||||
<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>
|
||||
<option value="payment_status"<?= ((string) ($cond['condition_type'] ?? '')) === 'payment_status' ? ' selected' : '' ?>>Status platnosci</option>
|
||||
<option value="order_status"<?= ((string) ($cond['condition_type'] ?? '')) === 'order_status' ? ' selected' : '' ?>>Status zamowienia</option>
|
||||
<option value="days_in_status"<?= ((string) ($cond['condition_type'] ?? '')) === 'days_in_status' ? ' selected' : '' ?>>Liczba dni w statusie</option>
|
||||
</select>
|
||||
<div class="automation-row__config">
|
||||
<?php
|
||||
@@ -86,6 +92,7 @@ $orderStatusOptions = is_array($orderStatusOptions ?? null) ? $orderStatusOption
|
||||
$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'] : [];
|
||||
$selectedOrderStatusCodes = is_array($condValue['order_status_codes'] ?? null) ? $condValue['order_status_codes'] : [];
|
||||
?>
|
||||
<?php if ($conditionType === 'shipment_status'): ?>
|
||||
<div class="checkbox-group">
|
||||
@@ -97,6 +104,27 @@ $orderStatusOptions = is_array($orderStatusOptions ?? null) ? $orderStatusOption
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($conditionType === 'payment_status'): ?>
|
||||
<div class="checkbox-group">
|
||||
<?php foreach ($paymentStatusOptions as $statusKey => $statusLabel): ?>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="conditions[<?= $idx ?>][payment_status_keys][]" value="<?= $e((string) $statusKey) ?>"<?= in_array((string) $statusKey, $selectedStatusKeys, true) ? ' checked' : '' ?>>
|
||||
<?= $e($statusLabel) ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($conditionType === 'order_status'): ?>
|
||||
<div class="checkbox-group">
|
||||
<?php foreach ($orderStatusOptions as $statusOption): ?>
|
||||
<?php $statusCode = strtolower(trim((string) ($statusOption['code'] ?? ''))); ?>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="conditions[<?= $idx ?>][order_status_codes][]" value="<?= $e($statusCode) ?>"<?= in_array($statusCode, $selectedOrderStatusCodes, true) ? ' checked' : '' ?>>
|
||||
<?= $e((string) ($statusOption['name'] ?? $statusCode)) ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php elseif ($conditionType === 'days_in_status'): ?>
|
||||
<input type="number" min="1" step="1" class="form-control" name="conditions[<?= $idx ?>][days]" value="<?= (int) ($condValue['days'] ?? '') > 0 ? (int) $condValue['days'] : '' ?>" placeholder="Liczba dni">
|
||||
<?php else: ?>
|
||||
<div class="checkbox-group">
|
||||
<?php foreach ($integrations as $integ): ?>
|
||||
@@ -233,6 +261,7 @@ window.AutomationFormData = {
|
||||
receiptDuplicatePolicies: <?= json_encode($receiptDuplicatePolicies, JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptDuplicatePolicyLabels: <?= json_encode($receiptDuplicatePolicyLabels, JSON_UNESCAPED_UNICODE) ?>,
|
||||
shipmentStatusOptions: <?= json_encode($shipmentStatusOptions, JSON_UNESCAPED_UNICODE) ?>,
|
||||
paymentStatusOptions: <?= json_encode($paymentStatusOptions, JSON_UNESCAPED_UNICODE) ?>,
|
||||
orderStatusOptions: <?= json_encode(array_map(function($status) {
|
||||
return [
|
||||
'code' => (string) ($status['code'] ?? ''),
|
||||
|
||||
@@ -15,6 +15,9 @@ $eventLabels = [
|
||||
'receipt.created' => 'Utworzono paragon',
|
||||
'shipment.created' => 'Utworzenie przesylki',
|
||||
'shipment.status_changed' => 'Zmiana statusu przesylki',
|
||||
'payment.status_changed' => 'Zmiana statusu platnosci',
|
||||
'order.status_changed' => 'Zmiana statusu zamowienia',
|
||||
'order.status_aged' => 'Minelo X dni od zmiany statusu',
|
||||
];
|
||||
|
||||
$statusLabels = [
|
||||
|
||||
Reference in New Issue
Block a user