update
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
$list = is_array($rows ?? null) ? $rows : [];
|
||||
$selected = is_array($selectedIntegration ?? null) ? $selectedIntegration : null;
|
||||
$formValues = is_array($form ?? null) ? $form : [];
|
||||
$statusRows = is_array($statusRows ?? null) ? $statusRows : [];
|
||||
$mappingIndex = is_array($mappingIndex ?? null) ? $mappingIndex : [];
|
||||
$orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : [];
|
||||
$shopproStatuses = is_array($shopproStatuses ?? null) ? $shopproStatuses : [];
|
||||
$ordersImportIntervalMinutes = max(1, (int) ($ordersImportIntervalMinutes ?? 5));
|
||||
$statusSyncIntervalMinutes = max(1, (int) ($statusSyncIntervalMinutes ?? 15));
|
||||
$paymentSyncIntervalMinutes = max(1, (int) ($paymentSyncIntervalMinutes ?? 10));
|
||||
@@ -210,43 +211,44 @@ foreach ($dmMappings as $dm) {
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $e($t('settings.order_statuses.fields.shoppro_code')) ?></th>
|
||||
<th><?= $e($t('settings.order_statuses.fields.shoppro_name')) ?></th>
|
||||
<th><?= $e($t('settings.order_statuses.fields.orderpro_status')) ?></th>
|
||||
<th><?= $e($t('settings.order_statuses.fields.shoppro_status')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($statusRows === []): ?>
|
||||
<?php if ($orderproStatuses === []): ?>
|
||||
<tr>
|
||||
<td colspan="3" class="muted"><?= $e($t('settings.integrations.statuses.empty')) ?></td>
|
||||
<td colspan="2" class="muted"><?= $e($t('settings.integrations.statuses.no_orderpro_statuses')) ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($statusRows as $row): ?>
|
||||
<?php foreach ($orderproStatuses as $opStatus): ?>
|
||||
<?php
|
||||
$shopCode = (string) ($row['shoppro_status_code'] ?? '');
|
||||
$shopName = (string) ($row['shoppro_status_name'] ?? '');
|
||||
$selectedOrderpro = strtolower(trim((string) ($row['orderpro_status_code'] ?? '')));
|
||||
$opCode = strtolower(trim((string) ($opStatus['code'] ?? '')));
|
||||
if ($opCode === '') continue;
|
||||
$opName = (string) ($opStatus['name'] ?? $opCode);
|
||||
$mapped = $mappingIndex[$opCode] ?? null;
|
||||
$selectedShopCode = $mapped !== null ? (string) ($mapped['shoppro_status_code'] ?? '') : '';
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<code><?= $e($shopCode) ?></code>
|
||||
<input type="hidden" name="shoppro_status_code[]" value="<?= $e($shopCode) ?>">
|
||||
<?= $e($opName) ?> <code class="muted"><?= $e($opCode) ?></code>
|
||||
<input type="hidden" name="orderpro_status_code[]" value="<?= $e($opCode) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<?= $e($shopName) ?>
|
||||
<input type="hidden" name="shoppro_status_name[]" value="<?= $e($shopName) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" name="orderpro_status_code[]">
|
||||
<option value=""><?= $e($t('settings.order_statuses.fields.no_mapping')) ?></option>
|
||||
<?php foreach ($orderproStatuses as $status): ?>
|
||||
<?php $statusCode = strtolower(trim((string) ($status['code'] ?? ''))); ?>
|
||||
<?php if ($statusCode === '') continue; ?>
|
||||
<option value="<?= $e($statusCode) ?>"<?= $selectedOrderpro === $statusCode ? ' selected' : '' ?>>
|
||||
<?= $e((string) ($status['name'] ?? $statusCode)) ?> (<?= $e($statusCode) ?>)
|
||||
<select class="form-control" name="shoppro_status_code[]" data-shoppro-name-target="shoppro_status_name_<?= $e($opCode) ?>">
|
||||
<option value="" data-name=""><?= $e($t('settings.order_statuses.fields.no_mapping')) ?></option>
|
||||
<?php foreach ($shopproStatuses as $extStatus): ?>
|
||||
<?php
|
||||
$extCode = (string) ($extStatus['code'] ?? '');
|
||||
$extName = (string) ($extStatus['name'] ?? $extCode);
|
||||
if ($extCode === '') continue;
|
||||
?>
|
||||
<option value="<?= $e($extCode) ?>" data-name="<?= $e($extName) ?>"<?= $selectedShopCode === $extCode ? ' selected' : '' ?>>
|
||||
<?= $e($extName) ?> (<?= $e($extCode) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<input type="hidden" name="shoppro_status_name[]" id="shoppro_status_name_<?= $e($opCode) ?>" value="<?= $e($mapped !== null ? (string) ($mapped['shoppro_status_name'] ?? '') : '') ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -254,7 +256,7 @@ foreach ($dmMappings as $dm) {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php if ($statusRows !== []): ?>
|
||||
<?php if ($orderproStatuses !== []): ?>
|
||||
<div class="form-actions mt-12">
|
||||
<button type="submit" class="btn btn--primary"><?= $e($t('settings.order_statuses.actions.save')) ?></button>
|
||||
</div>
|
||||
@@ -740,4 +742,16 @@ foreach ($dmMappings as $dm) {
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
(function () {
|
||||
document.querySelectorAll('select[data-shoppro-name-target]').forEach(function (select) {
|
||||
select.addEventListener('change', function () {
|
||||
var targetId = select.getAttribute('data-shoppro-name-target');
|
||||
var hidden = document.getElementById(targetId);
|
||||
if (!hidden) return;
|
||||
var selected = select.options[select.selectedIndex];
|
||||
hidden.value = selected ? (selected.getAttribute('data-name') || '') : '';
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user