502 lines
25 KiB
PHP
502 lines
25 KiB
PHP
<?php
|
|
$settings = is_array($settings ?? null) ? $settings : [];
|
|
$accountLabel = trim((string) ($settings['account_label'] ?? ''));
|
|
$hasApiKey = (bool) ($settings['has_api_key'] ?? false);
|
|
$isActive = (bool) ($settings['is_active'] ?? true);
|
|
$lastTestAt = trim((string) ($settings['last_test_at'] ?? ''));
|
|
$lastTestStatus = trim((string) ($settings['last_test_status'] ?? ''));
|
|
$lastTestMessage = trim((string) ($settings['last_test_message'] ?? ''));
|
|
$lastTestHttpCode = $settings['last_test_http_code'] ?? null;
|
|
$ordersFetchEnabled = (bool) ($settings['orders_fetch_enabled'] ?? false);
|
|
$ordersFetchStartDate = trim((string) ($settings['orders_fetch_start_date'] ?? ''));
|
|
$ordersImportIntervalMinutes = (int) ($ordersImportIntervalMinutes ?? 5);
|
|
$statusSyncDirection = (string) ($statusSyncDirection ?? 'erli_to_orderpro');
|
|
$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');
|
|
?>
|
|
|
|
<section class="card">
|
|
<h2 class="section-title"><?= $e($t('settings.erli.title')) ?></h2>
|
|
<p class="muted mt-12"><?= $e($t('settings.erli.description')) ?></p>
|
|
|
|
<?php if (!empty($errorMessage)): ?>
|
|
<div class="mt-12"><?php $type='danger'; $message=(string) $errorMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($successMessage)): ?>
|
|
<div class="mt-12"><?php $type='success'; $message=(string) $successMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($testMessage)): ?>
|
|
<div class="mt-12"><?php $type='info'; $message=(string) $testMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($importMessage)): ?>
|
|
<div class="mt-12"><?php $type='info'; $message=(string) $importMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<section class="card mt-16">
|
|
<nav class="content-tabs-nav" aria-label="<?= $e($t('settings.erli.tabs.label')) ?>">
|
|
<button type="button" class="content-tab-btn<?= $activeTab === 'integration' ? ' is-active' : '' ?>" data-tab-target="erli-tab-integration">
|
|
<?= $e($t('settings.erli.tabs.integration')) ?>
|
|
</button>
|
|
<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>
|
|
</nav>
|
|
|
|
<div class="content-tab-panel<?= $activeTab === 'integration' ? ' is-active' : '' ?>" data-tab-panel="erli-tab-integration">
|
|
<section class="mt-16">
|
|
<h3 class="section-title"><?= $e($t('settings.erli.config.title')) ?></h3>
|
|
|
|
<div class="muted mt-12">
|
|
<?= $e($t('settings.erli.status.secret')) ?>:
|
|
<strong><?= $e($hasApiKey ? $t('settings.erli.status.saved') : $t('settings.erli.status.missing')) ?></strong>
|
|
|
|
|
<?= $e($t('settings.erli.status.active')) ?>:
|
|
<strong><?= $e($isActive ? $t('settings.integrations_hub.active.yes') : $t('settings.integrations_hub.active.no')) ?></strong>
|
|
</div>
|
|
|
|
<form class="statuses-form mt-16" action="/settings/integrations/erli/save" method="post" novalidate>
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="return_to" value="/settings/integrations/erli?tab=integration">
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.account_label')) ?></span>
|
|
<input class="form-control" type="text" name="account_label" maxlength="128" value="<?= $e($accountLabel) ?>">
|
|
<span class="muted"><?= $e($t('settings.erli.hints.account_label')) ?></span>
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.api_key')) ?></span>
|
|
<input class="form-control" type="password" name="api_key" autocomplete="new-password" placeholder="<?= $hasApiKey ? '********' : '' ?>">
|
|
<span class="muted"><?= $e($hasApiKey ? $t('settings.erli.api_key.saved') : $t('settings.erli.api_key.missing')) ?></span>
|
|
</label>
|
|
|
|
<fieldset class="integration-settings-checkboxes">
|
|
<legend class="field-label"><?= $e($t('settings.erli.fields.options')) ?></legend>
|
|
<div class="integration-settings-checkboxes__list">
|
|
<label class="integration-settings-checkboxes__item">
|
|
<input type="checkbox" name="is_active" value="1"<?= $isActive ? ' checked' : '' ?>>
|
|
<span><?= $e($t('settings.erli.fields.is_active')) ?></span>
|
|
</label>
|
|
<label class="integration-settings-checkboxes__item">
|
|
<input type="checkbox" name="orders_fetch_enabled" value="1"<?= $ordersFetchEnabled ? ' checked' : '' ?>>
|
|
<span><?= $e($t('settings.erli.fields.orders_fetch_enabled')) ?></span>
|
|
</label>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.orders_fetch_start_date')) ?></span>
|
|
<input class="form-control" type="date" name="orders_fetch_start_date" value="<?= $e($ordersFetchStartDate) ?>">
|
|
<span class="muted"><?= $e($t('settings.erli.hints.orders_fetch_start_date')) ?></span>
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.orders_import_interval_minutes')) ?></span>
|
|
<input class="form-control" type="number" min="1" max="1440" name="orders_import_interval_minutes" value="<?= $e((string) $ordersImportIntervalMinutes) ?>">
|
|
<span class="muted"><?= $e($t('settings.erli.hints.orders_import_interval_minutes')) ?></span>
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.status_sync_direction')) ?></span>
|
|
<select class="form-control" name="status_sync_direction">
|
|
<option value="erli_to_orderpro"<?= $statusSyncDirection === 'erli_to_orderpro' ? ' selected' : '' ?>>
|
|
<?= $e($t('settings.erli.fields.status_sync_direction_pull')) ?>
|
|
</option>
|
|
<option value="orderpro_to_erli"<?= $statusSyncDirection === 'orderpro_to_erli' ? ' selected' : '' ?>>
|
|
<?= $e($t('settings.erli.fields.status_sync_direction_push')) ?>
|
|
</option>
|
|
</select>
|
|
<span class="muted"><?= $e($t('settings.erli.hints.status_sync_direction')) ?></span>
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.erli.fields.status_sync_interval_minutes')) ?></span>
|
|
<input class="form-control" type="number" min="1" max="1440" name="status_sync_interval_minutes" value="<?= $e((string) $statusSyncIntervalMinutes) ?>">
|
|
<span class="muted"><?= $e($t('settings.erli.hints.status_sync_interval_minutes')) ?></span>
|
|
</label>
|
|
|
|
<div class="form-actions mt-16">
|
|
<button type="submit" class="btn btn--primary"><?= $e($t('settings.erli.actions.save')) ?></button>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="content-tab-panel<?= $activeTab === 'statuses' ? ' is-active' : '' ?>" data-tab-panel="erli-tab-statuses">
|
|
<section class="mt-16">
|
|
<h3 class="section-title"><?= $e($t('settings.erli.statuses.pull_title')) ?></h3>
|
|
<p class="muted mt-12"><?= $e($t('settings.erli.statuses.pull_description')) ?></p>
|
|
|
|
<form action="/settings/integrations/erli/statuses/save-pull" method="post" class="mt-12">
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="return_to" value="/settings/integrations/erli?tab=statuses">
|
|
<div class="table-wrap mt-12">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th><?= $e($t('settings.erli.statuses.fields.erli_status')) ?></th>
|
|
<th><?= $e($t('settings.erli.statuses.fields.orderpro_status')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($erliPullStatusMappings === []): ?>
|
|
<tr>
|
|
<td colspan="2" class="muted"><?= $e($t('settings.erli.statuses.empty_pull')) ?></td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($erliPullStatusMappings as $mapping): ?>
|
|
<?php
|
|
$erliCode = strtolower(trim((string) ($mapping['erli_status_code'] ?? '')));
|
|
if ($erliCode === '') continue;
|
|
$erliName = trim((string) ($mapping['erli_status_name'] ?? ''));
|
|
$selectedOrderproCode = strtolower(trim((string) ($mapping['orderpro_status_code'] ?? '')));
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<?= $e($erliName !== '' ? $erliName : $erliCode) ?> <code class="muted"><?= $e($erliCode) ?></code>
|
|
<input type="hidden" name="erli_status_code[]" value="<?= $e($erliCode) ?>">
|
|
<input type="hidden" name="erli_status_name[]" value="<?= $e($erliName) ?>">
|
|
</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
|
|
$opCode = strtolower(trim((string) ($status['code'] ?? '')));
|
|
if ($opCode === '') continue;
|
|
$opName = (string) ($status['name'] ?? $opCode);
|
|
?>
|
|
<option value="<?= $e($opCode) ?>"<?= $selectedOrderproCode === $opCode ? ' selected' : '' ?>>
|
|
<?= $e($opName) ?> (<?= $e($opCode) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php if ($erliPullStatusMappings !== []): ?>
|
|
<div class="form-actions mt-12">
|
|
<button type="submit" class="btn btn--primary"><?= $e($t('settings.erli.statuses.actions.save_pull')) ?></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</form>
|
|
</section>
|
|
|
|
<section class="mt-16">
|
|
<h3 class="section-title"><?= $e($t('settings.erli.statuses.push_title')) ?></h3>
|
|
<p class="muted mt-12"><?= $e($t('settings.erli.statuses.push_description')) ?></p>
|
|
|
|
<form action="/settings/integrations/erli/statuses/save-push" method="post" class="mt-12">
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="return_to" value="/settings/integrations/erli?tab=statuses">
|
|
<div class="table-wrap mt-12">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th><?= $e($t('settings.erli.statuses.fields.erli_status')) ?></th>
|
|
<th><?= $e($t('settings.erli.statuses.fields.orderpro_status')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($erliStatusMappings === []): ?>
|
|
<tr>
|
|
<td colspan="2" class="muted"><?= $e($t('settings.erli.statuses.empty_push')) ?></td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($erliStatusMappings as $mapping): ?>
|
|
<?php
|
|
$erliCode = trim((string) ($mapping['erli_status_code'] ?? ''));
|
|
if ($erliCode === '') continue;
|
|
$erliName = trim((string) ($mapping['erli_status_name'] ?? ''));
|
|
$selectedOrderproCode = strtolower(trim((string) ($mapping['orderpro_status_code'] ?? '')));
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<?= $e($erliName !== '' ? $erliName : $erliCode) ?> <code class="muted"><?= $e($erliCode) ?></code>
|
|
<input type="hidden" name="erli_status_code[]" value="<?= $e($erliCode) ?>">
|
|
<input type="hidden" name="erli_status_name[]" value="<?= $e($erliName) ?>">
|
|
</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
|
|
$opCode = strtolower(trim((string) ($status['code'] ?? '')));
|
|
if ($opCode === '') continue;
|
|
$opName = (string) ($status['name'] ?? $opCode);
|
|
?>
|
|
<option value="<?= $e($opCode) ?>"<?= $selectedOrderproCode === $opCode ? ' selected' : '' ?>>
|
|
<?= $e($opName) ?> (<?= $e($opCode) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php if ($erliStatusMappings !== []): ?>
|
|
<div class="form-actions mt-12">
|
|
<button type="submit" class="btn btn--primary"><?= $e($t('settings.erli.statuses.actions.save_push')) ?></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</form>
|
|
</section>
|
|
|
|
</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>
|
|
<p class="muted mt-12"><?= $e($t('settings.erli.import.description')) ?></p>
|
|
|
|
<form class="statuses-form mt-16" action="/settings/integrations/erli/import" method="post">
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="return_to" value="/settings/integrations/erli?tab=settings">
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn btn--secondary"><?= $e($t('settings.erli.actions.import_now')) ?></button>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
|
|
<section class="mt-16">
|
|
<h3 class="section-title"><?= $e($t('settings.erli.test.title')) ?></h3>
|
|
<p class="muted mt-12"><?= $e($t('settings.erli.test.description')) ?></p>
|
|
|
|
<form class="statuses-form mt-16" action="/settings/integrations/erli/test" method="post">
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="return_to" value="/settings/integrations/erli?tab=settings">
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn btn--secondary"><?= $e($t('settings.erli.actions.test')) ?></button>
|
|
</div>
|
|
</form>
|
|
|
|
<?php if ($lastTestAt !== ''): ?>
|
|
<div class="mt-16"><?php
|
|
$type = $lastTestStatus === 'ok' ? 'success' : 'danger';
|
|
$messageHtml = '<strong>' . $e($t('settings.erli.status.last_test')) . ':</strong> '
|
|
. $e($lastTestAt)
|
|
. ($lastTestStatus !== '' ? ' <span class="badge badge--' . ($lastTestStatus === 'ok' ? 'success' : 'muted') . '">' . $e(strtoupper($lastTestStatus)) . '</span>' : '')
|
|
. ($lastTestHttpCode !== null ? ' <span class="badge badge--muted">HTTP ' . $e((string) $lastTestHttpCode) . '</span>' : '')
|
|
. ($lastTestMessage !== '' ? '<div class="mt-12">' . $e($lastTestMessage) . '</div>' : '');
|
|
$dismissible = false;
|
|
include dirname(__DIR__) . '/components/alert.php';
|
|
unset($messageHtml);
|
|
?></div>
|
|
<?php endif; ?>
|
|
</section>
|
|
</div>
|
|
</section>
|
|
|
|
<script>
|
|
(function () {
|
|
var tabs = document.querySelectorAll('[data-tab-target]');
|
|
var panels = document.querySelectorAll('[data-tab-panel]');
|
|
if (tabs.length === 0 || panels.length === 0) {
|
|
return;
|
|
}
|
|
|
|
var tabNameMap = {
|
|
'erli-tab-integration': 'integration',
|
|
'erli-tab-statuses': 'statuses',
|
|
'erli-tab-delivery': 'delivery',
|
|
'erli-tab-settings': 'settings'
|
|
};
|
|
|
|
tabs.forEach(function (tab) {
|
|
tab.addEventListener('click', function () {
|
|
var target = tab.getAttribute('data-tab-target');
|
|
var tabName = tabNameMap[target] || 'integration';
|
|
var url = new URL(window.location.href);
|
|
url.searchParams.set('tab', tabName);
|
|
window.history.replaceState(null, '', url.toString());
|
|
|
|
tabs.forEach(function (node) { node.classList.remove('is-active'); });
|
|
panels.forEach(function (panel) { panel.classList.remove('is-active'); });
|
|
tab.classList.add('is-active');
|
|
|
|
var panel = document.querySelector('[data-tab-panel="' + target + '"]');
|
|
if (panel) {
|
|
panel.classList.add('is-active');
|
|
}
|
|
});
|
|
});
|
|
})();
|
|
</script>
|