Files
orderPRO/resources/views/settings/erli.php
Jacek Pyziak 2565d9b754 feat(128): erli orders import
Phase 128 complete:
- add Erli /inbox order import with safe mark-read ACK
- add cron/manual import controls and sync state tracking
- map Erli orders into orderPRO aggregates with mapper tests and docs
2026-05-15 23:54:22 +02:00

131 lines
6.6 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);
?>
<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">
<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 ?? '') ?>">
<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>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.erli.actions.save')) ?></button>
</div>
</form>
</section>
<section class="card 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 ?? '') ?>">
<div class="form-actions">
<button type="submit" class="btn btn--secondary"><?= $e($t('settings.erli.actions.import_now')) ?></button>
</div>
</form>
</section>
<section class="card 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 ?? '') ?>">
<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>