update
This commit is contained in:
@@ -16,6 +16,18 @@ $recipientLabels = [
|
||||
'client_and_company' => 'Klient + e-mail z danych firmy',
|
||||
'company' => 'E-mail z danych firmy',
|
||||
];
|
||||
$receiptConfigs = is_array($receiptConfigs ?? null) ? $receiptConfigs : [];
|
||||
$receiptIssueDateModes = is_array($receiptIssueDateModes ?? null) ? $receiptIssueDateModes : [];
|
||||
$receiptDuplicatePolicies = is_array($receiptDuplicatePolicies ?? null) ? $receiptDuplicatePolicies : [];
|
||||
$receiptIssueDateModeLabels = [
|
||||
'today' => 'Data dzisiejsza',
|
||||
'order_date' => 'Data zamowienia',
|
||||
'payment_date' => 'Data platnosci (fallback: dzisiaj)',
|
||||
];
|
||||
$receiptDuplicatePolicyLabels = [
|
||||
'skip_if_exists' => 'Pomin jesli paragon juz istnieje',
|
||||
'allow_duplicates' => 'Wystawiaj kolejne paragony',
|
||||
];
|
||||
$shipmentStatusOptions = is_array($shipmentStatusOptions ?? null) ? $shipmentStatusOptions : [];
|
||||
?>
|
||||
|
||||
@@ -112,20 +124,51 @@ $shipmentStatusOptions = is_array($shipmentStatusOptions ?? null) ? $shipmentSta
|
||||
<div class="automation-row__fields">
|
||||
<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>
|
||||
</select>
|
||||
<div class="automation-row__config">
|
||||
<?php $actConfig = is_array($act['action_config'] ?? null) ? $act['action_config'] : []; ?>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][template_id]">
|
||||
<option value="">-- Wybierz szablon --</option>
|
||||
<?php foreach ($emailTemplates as $tpl): ?>
|
||||
<option value="<?= (int) $tpl['id'] ?>"<?= ((int) ($actConfig['template_id'] ?? 0)) === (int) $tpl['id'] ? ' selected' : '' ?>><?= $e((string) ($tpl['name'] ?? '')) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][recipient]">
|
||||
<?php foreach ($recipientLabels as $key => $label): ?>
|
||||
<option value="<?= $e($key) ?>"<?= ((string) ($actConfig['recipient'] ?? '')) === $key ? ' selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
$actConfig = is_array($act['action_config'] ?? null) ? $act['action_config'] : [];
|
||||
$actionType = (string) ($act['action_type'] ?? 'send_email');
|
||||
?>
|
||||
<?php if ($actionType === 'issue_receipt'): ?>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][receipt_config_id]">
|
||||
<option value="">-- Wybierz konfiguracje paragonu --</option>
|
||||
<?php foreach ($receiptConfigs as $cfg): ?>
|
||||
<option value="<?= (int) ($cfg['id'] ?? 0) ?>"<?= ((int) ($actConfig['receipt_config_id'] ?? 0)) === (int) ($cfg['id'] ?? 0) ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($cfg['name'] ?? '')) ?> (<?= $e((string) ($cfg['number_format'] ?? '')) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][issue_date_mode]">
|
||||
<?php foreach ($receiptIssueDateModes as $mode): ?>
|
||||
<?php $modeKey = (string) $mode; ?>
|
||||
<option value="<?= $e($modeKey) ?>"<?= ((string) ($actConfig['issue_date_mode'] ?? 'today')) === $modeKey ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($receiptIssueDateModeLabels[$modeKey] ?? $modeKey)) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][duplicate_policy]">
|
||||
<?php foreach ($receiptDuplicatePolicies as $policy): ?>
|
||||
<?php $policyKey = (string) $policy; ?>
|
||||
<option value="<?= $e($policyKey) ?>"<?= ((string) ($actConfig['duplicate_policy'] ?? 'skip_if_exists')) === $policyKey ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($receiptDuplicatePolicyLabels[$policyKey] ?? $policyKey)) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php else: ?>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][template_id]">
|
||||
<option value="">-- Wybierz szablon --</option>
|
||||
<?php foreach ($emailTemplates as $tpl): ?>
|
||||
<option value="<?= (int) $tpl['id'] ?>"<?= ((int) ($actConfig['template_id'] ?? 0)) === (int) $tpl['id'] ? ' selected' : '' ?>><?= $e((string) ($tpl['name'] ?? '')) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select class="form-control" name="actions[<?= $idx ?>][recipient]">
|
||||
<?php foreach ($recipientLabels as $key => $label): ?>
|
||||
<option value="<?= $e($key) ?>"<?= ((string) ($actConfig['recipient'] ?? '')) === $key ? ' selected' : '' ?>><?= $e($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn--sm btn--danger automation-row__remove" onclick="window.AutomationForm.removeRow(this)">×</button>
|
||||
@@ -150,7 +193,18 @@ window.AutomationFormData = {
|
||||
emailTemplates: <?= json_encode(array_map(function($t) {
|
||||
return ['id' => (int) $t['id'], 'name' => (string) ($t['name'] ?? '')];
|
||||
}, $emailTemplates), JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptConfigs: <?= json_encode(array_map(function($cfg) {
|
||||
return [
|
||||
'id' => (int) ($cfg['id'] ?? 0),
|
||||
'name' => (string) ($cfg['name'] ?? ''),
|
||||
'number_format' => (string) ($cfg['number_format'] ?? '')
|
||||
];
|
||||
}, $receiptConfigs), JSON_UNESCAPED_UNICODE) ?>,
|
||||
recipientLabels: <?= json_encode($recipientLabels, JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptIssueDateModes: <?= json_encode($receiptIssueDateModes, JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptIssueDateModeLabels: <?= json_encode($receiptIssueDateModeLabels, JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptDuplicatePolicies: <?= json_encode($receiptDuplicatePolicies, JSON_UNESCAPED_UNICODE) ?>,
|
||||
receiptDuplicatePolicyLabels: <?= json_encode($receiptDuplicatePolicyLabels, JSON_UNESCAPED_UNICODE) ?>,
|
||||
shipmentStatusOptions: <?= json_encode($shipmentStatusOptions, JSON_UNESCAPED_UNICODE) ?>
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user