feat(130): erli shipments and labels
This commit is contained in:
@@ -15,6 +15,20 @@ $statusSyncIntervalMinutes = (int) ($statusSyncIntervalMinutes ?? 15);
|
||||
$orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : [];
|
||||
$erliStatusMappings = is_array($erliStatusMappings ?? null) ? $erliStatusMappings : [];
|
||||
$erliPullStatusMappings = is_array($erliPullStatusMappings ?? null) ? $erliPullStatusMappings : [];
|
||||
$erliDeliveryOrderMethods = is_array($erliDeliveryOrderMethods ?? null) ? $erliDeliveryOrderMethods : [];
|
||||
$erliDeliveryMappings = is_array($erliDeliveryMappings ?? null) ? $erliDeliveryMappings : [];
|
||||
$erliShippingMethods = is_array($erliShippingMethods ?? null) ? $erliShippingMethods : [];
|
||||
$erliDeliveryVendors = is_array($erliDeliveryVendors ?? null) ? $erliDeliveryVendors : [];
|
||||
$inpostDeliveryServices = is_array($inpostDeliveryServices ?? null) ? $inpostDeliveryServices : [];
|
||||
$apaczkaDeliveryServices = is_array($apaczkaDeliveryServices ?? null) ? $apaczkaDeliveryServices : [];
|
||||
$erliDeliveryMetadataError = trim((string) ($erliDeliveryMetadataError ?? ''));
|
||||
$erliDeliveryMappingsByMethod = [];
|
||||
foreach ($erliDeliveryMappings as $mappingRow) {
|
||||
$methodKey = trim((string) ($mappingRow['order_delivery_method'] ?? ''));
|
||||
if ($methodKey !== '') {
|
||||
$erliDeliveryMappingsByMethod[$methodKey] = $mappingRow;
|
||||
}
|
||||
}
|
||||
$activeTab = (string) ($activeTab ?? 'integration');
|
||||
?>
|
||||
|
||||
@@ -47,6 +61,9 @@ $activeTab = (string) ($activeTab ?? 'integration');
|
||||
<button type="button" class="content-tab-btn<?= $activeTab === 'statuses' ? ' is-active' : '' ?>" data-tab-target="erli-tab-statuses">
|
||||
<?= $e($t('settings.erli.tabs.statuses')) ?>
|
||||
</button>
|
||||
<button type="button" class="content-tab-btn<?= $activeTab === 'delivery' ? ' is-active' : '' ?>" data-tab-target="erli-tab-delivery">
|
||||
<?= $e($t('settings.erli.tabs.delivery')) ?>
|
||||
</button>
|
||||
<button type="button" class="content-tab-btn<?= $activeTab === 'settings' ? ' is-active' : '' ?>" data-tab-target="erli-tab-settings">
|
||||
<?= $e($t('settings.erli.tabs.settings')) ?>
|
||||
</button>
|
||||
@@ -261,6 +278,149 @@ $activeTab = (string) ($activeTab ?? 'integration');
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content-tab-panel<?= $activeTab === 'delivery' ? ' is-active' : '' ?>" data-tab-panel="erli-tab-delivery">
|
||||
<section class="mt-16">
|
||||
<h3 class="section-title"><?= $e($t('settings.erli.delivery.title')) ?></h3>
|
||||
<p class="muted mt-12"><?= $e($t('settings.erli.delivery.description')) ?></p>
|
||||
|
||||
<?php if ($erliDeliveryMetadataError !== ''): ?>
|
||||
<div class="mt-12"><?php $type='warning'; $message=(string) $erliDeliveryMetadataError; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="/settings/integrations/erli/delivery/save" method="post" class="mt-12">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<div class="table-wrap mt-12">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $e($t('settings.erli.delivery.fields.order_method')) ?></th>
|
||||
<th><?= $e($t('settings.erli.delivery.fields.erli_vendor')) ?></th>
|
||||
<th><?= $e($t('settings.erli.delivery.fields.provider_service')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($erliDeliveryOrderMethods === []): ?>
|
||||
<tr>
|
||||
<td colspan="3" class="muted"><?= $e($t('settings.erli.delivery.empty_methods')) ?></td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($erliDeliveryOrderMethods as $orderMethod): ?>
|
||||
<?php
|
||||
$orderMethod = trim((string) $orderMethod);
|
||||
if ($orderMethod === '') continue;
|
||||
$mappingRow = is_array($erliDeliveryMappingsByMethod[$orderMethod] ?? null) ? $erliDeliveryMappingsByMethod[$orderMethod] : [];
|
||||
$selectedVendor = trim((string) ($mappingRow['source_vendor_code'] ?? ''));
|
||||
$selectedProvider = trim((string) ($mappingRow['provider'] ?? ''));
|
||||
$selectedProviderServiceId = trim((string) ($mappingRow['provider_service_id'] ?? ''));
|
||||
$selectedProviderCarrierId = trim((string) ($mappingRow['provider_carrier_id'] ?? ''));
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?= $e($orderMethod) ?></strong>
|
||||
<input type="hidden" name="order_delivery_method[]" value="<?= $e($orderMethod) ?>">
|
||||
<input type="hidden" name="source_service_id[]" value="<?= $e((string) ($mappingRow['source_service_id'] ?? '')) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" name="source_vendor_code[]">
|
||||
<option value=""><?= $e($t('settings.erli.delivery.fields.no_vendor')) ?></option>
|
||||
<?php foreach ($erliDeliveryVendors as $vendor): ?>
|
||||
<?php
|
||||
$vendorCode = trim((string) ($vendor['id'] ?? $vendor['code'] ?? $vendor['vendor'] ?? ''));
|
||||
if ($vendorCode === '') continue;
|
||||
$vendorName = trim((string) ($vendor['name'] ?? $vendorCode));
|
||||
?>
|
||||
<option value="<?= $e($vendorCode) ?>"<?= $selectedVendor === $vendorCode ? ' selected' : '' ?>>
|
||||
<?= $e($vendorName) ?> (<?= $e($vendorCode) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select class="form-control" name="provider_service_choice[]">
|
||||
<option value=""><?= $e($t('settings.erli.delivery.fields.no_provider')) ?></option>
|
||||
<?php if ($inpostDeliveryServices !== []): ?>
|
||||
<optgroup label="InPost">
|
||||
<?php foreach ($inpostDeliveryServices as $service): ?>
|
||||
<?php
|
||||
$serviceId = trim((string) ($service['id'] ?? ''));
|
||||
if ($serviceId === '') continue;
|
||||
$serviceName = trim((string) ($service['name'] ?? $serviceId));
|
||||
$carrierId = 'inpost';
|
||||
$choice = 'inpost|' . $serviceId . '|' . $carrierId . '|' . $serviceName;
|
||||
$isSelected = $selectedProvider === 'inpost' && $selectedProviderServiceId === $serviceId;
|
||||
?>
|
||||
<option value="<?= $e($choice) ?>"<?= $isSelected ? ' selected' : '' ?>>
|
||||
<?= $e($serviceName) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endif; ?>
|
||||
<?php if ($apaczkaDeliveryServices !== []): ?>
|
||||
<optgroup label="Apaczka">
|
||||
<?php foreach ($apaczkaDeliveryServices as $service): ?>
|
||||
<?php
|
||||
if (!is_array($service)) continue;
|
||||
$serviceId = trim((string) ($service['service_id'] ?? $service['id'] ?? ''));
|
||||
if ($serviceId === '') continue;
|
||||
$serviceName = trim((string) ($service['name'] ?? ('ID ' . $serviceId)));
|
||||
$carrierId = trim((string) ($service['carrier_code'] ?? ''));
|
||||
$choice = 'apaczka|' . $serviceId . '|' . $carrierId . '|' . $serviceName;
|
||||
$isSelected = $selectedProvider === 'apaczka'
|
||||
&& $selectedProviderServiceId === $serviceId
|
||||
&& ($selectedProviderCarrierId === '' || $selectedProviderCarrierId === $carrierId);
|
||||
?>
|
||||
<option value="<?= $e($choice) ?>"<?= $isSelected ? ' selected' : '' ?>>
|
||||
<?= $e($serviceName) ?><?= $carrierId !== '' ? ' [' . $e($carrierId) . ']' : '' ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php if ($erliDeliveryOrderMethods !== []): ?>
|
||||
<div class="form-actions mt-12">
|
||||
<button type="submit" class="btn btn--primary"><?= $e($t('settings.erli.delivery.actions.save')) ?></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
|
||||
<?php if ($erliShippingMethods !== []): ?>
|
||||
<h3 class="section-title mt-16"><?= $e($t('settings.erli.delivery.shipping_methods_title')) ?></h3>
|
||||
<div class="table-wrap mt-12">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $e($t('settings.erli.delivery.fields.shipping_method')) ?></th>
|
||||
<th><?= $e($t('settings.erli.delivery.fields.shipping_vendor')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($erliShippingMethods as $method): ?>
|
||||
<?php
|
||||
$methodId = trim((string) ($method['id'] ?? $method['typeId'] ?? ''));
|
||||
$methodName = trim((string) ($method['name'] ?? $methodId));
|
||||
$methodVendor = trim((string) ($method['vendor'] ?? ''));
|
||||
if ($methodId === '' && $methodName === '') continue;
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $e($methodName) ?><?= $methodId !== '' ? ' <code class="muted">' . $e($methodId) . '</code>' : '' ?></td>
|
||||
<td><?= $e($methodVendor !== '' ? $methodVendor : '-') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="content-tab-panel<?= $activeTab === 'settings' ? ' is-active' : '' ?>" data-tab-panel="erli-tab-settings">
|
||||
<section class="mt-16">
|
||||
<h3 class="section-title"><?= $e($t('settings.erli.import.title')) ?></h3>
|
||||
@@ -315,6 +475,7 @@ $activeTab = (string) ($activeTab ?? 'integration');
|
||||
var tabNameMap = {
|
||||
'erli-tab-integration': 'integration',
|
||||
'erli-tab-statuses': 'statuses',
|
||||
'erli-tab-delivery': 'delivery',
|
||||
'erli-tab-settings': 'settings'
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user