Add Allegro shipment service and related components

- Implement AllegroShipmentService for managing shipment creation and status checks.
- Create ShipmentController to handle shipment preparation and label downloading.
- Introduce ShipmentPackageRepository for database interactions related to shipment packages.
- Add methods for retrieving delivery services, creating shipments, checking creation status, and downloading labels.
- Implement address validation and token management for Allegro API integration.
This commit is contained in:
2026-03-06 01:06:59 +01:00
parent 9df7a63244
commit 1b5e403c31
46 changed files with 6705 additions and 133 deletions

View File

@@ -47,6 +47,9 @@ $orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : []
<button type="button" class="content-tab-btn<?= $activeTab === 'settings' ? ' is-active' : '' ?>" data-tab-target="allegro-tab-settings">
<?= $e($t('settings.allegro.tabs.settings')) ?>
</button>
<button type="button" class="content-tab-btn<?= $activeTab === 'delivery' ? ' is-active' : '' ?>" data-tab-target="allegro-tab-delivery">
<?= $e($t('settings.allegro.tabs.delivery')) ?>
</button>
</nav>
<div class="content-tab-panel<?= $activeTab === 'integration' ? ' is-active' : '' ?>" data-tab-panel="allegro-tab-integration">
@@ -63,10 +66,11 @@ $orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : []
<label class="form-field">
<span class="field-label"><?= $e($t('settings.allegro.fields.environment')) ?></span>
<select class="form-control" name="environment">
<select class="form-control" name="environment" id="allegro-env-select">
<option value="sandbox"<?= $environment === 'sandbox' ? ' selected' : '' ?>><?= $e($t('settings.allegro.environment.sandbox')) ?></option>
<option value="production"<?= $environment === 'production' ? ' selected' : '' ?>><?= $e($t('settings.allegro.environment.production')) ?></option>
</select>
<span class="muted"><?= $e($t('settings.allegro.fields.environment_hint')) ?></span>
</label>
<label class="form-field">
@@ -283,6 +287,125 @@ $orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : []
</form>
</section>
</div>
<?php
$dmMappings = is_array($deliveryMappings ?? null) ? $deliveryMappings : [];
$dmOrderMethods = is_array($orderDeliveryMethods ?? null) ? $orderDeliveryMethods : [];
$dmAllegroServices = is_array($allegroDeliveryServices ?? null) ? $allegroDeliveryServices : [];
$dmInpostServices = is_array($inpostDeliveryServices ?? null) ? $inpostDeliveryServices : [];
$dmServicesError = (string) ($allegroDeliveryServicesError ?? '');
$dmMappingsByMethod = [];
foreach ($dmMappings as $dm) {
$dmMappingsByMethod[trim((string) ($dm['order_delivery_method'] ?? ''))] = $dm;
}
?>
<div class="content-tab-panel<?= $activeTab === 'delivery' ? ' is-active' : '' ?>" data-tab-panel="allegro-tab-delivery">
<section class="mt-16">
<h3 class="section-title"><?= $e($t('settings.allegro.delivery.title')) ?></h3>
<p class="muted mt-12"><?= $e($t('settings.allegro.delivery.description')) ?></p>
<?php if ($dmServicesError !== ''): ?>
<div class="alert alert--danger mt-12"><?= $e($dmServicesError) ?></div>
<?php endif; ?>
<?php if ($dmOrderMethods === []): ?>
<p class="muted mt-12"><?= $e($t('settings.allegro.delivery.empty_orders')) ?></p>
<?php else: ?>
<form action="/settings/integrations/allegro/delivery/save" method="post">
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<div class="table-wrap table-wrap--visible mt-12">
<table class="table">
<thead>
<tr>
<th><?= $e($t('settings.allegro.delivery.fields.order_method')) ?></th>
<th><?= $e($t('settings.allegro.delivery.fields.carrier')) ?></th>
<th><?= $e($t('settings.allegro.delivery.fields.allegro_service')) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($dmOrderMethods as $rowIdx => $orderMethod): ?>
<?php
$currentMapping = $dmMappingsByMethod[$orderMethod] ?? null;
$currentCarrier = $currentMapping !== null ? trim((string) ($currentMapping['carrier'] ?? 'allegro')) : '';
$currentAllegroId = $currentMapping !== null ? trim((string) ($currentMapping['allegro_delivery_method_id'] ?? '')) : '';
$currentServiceName = $currentMapping !== null ? trim((string) ($currentMapping['allegro_service_name'] ?? '')) : '';
?>
<tr data-dm-row="<?= $rowIdx ?>">
<td>
<strong><?= $e($orderMethod) ?></strong>
<input type="hidden" name="order_delivery_method[]" value="<?= $e($orderMethod) ?>">
</td>
<td>
<select class="form-control dm-carrier-select" name="carrier[]" data-row="<?= $rowIdx ?>">
<option value="">-- <?= $e($t('settings.allegro.delivery.fields.no_mapping')) ?> --</option>
<option value="allegro"<?= $currentCarrier === 'allegro' && $currentAllegroId !== '' ? ' selected' : '' ?>>Allegro</option>
<option value="inpost"<?= $currentCarrier === 'inpost' ? ' selected' : '' ?>>InPost</option>
</select>
</td>
<td>
<div class="dm-service-wrap" data-row="<?= $rowIdx ?>">
<input type="hidden" name="allegro_delivery_method_id[]" class="dm-hidden-method-id" value="<?= $e($currentAllegroId) ?>">
<input type="hidden" name="allegro_credentials_id[]" class="dm-hidden-credentials-id" value="<?= $e(trim((string) ($currentMapping['allegro_credentials_id'] ?? ''))) ?>">
<input type="hidden" name="allegro_carrier_id[]" class="dm-hidden-carrier-id" value="<?= $e(trim((string) ($currentMapping['allegro_carrier_id'] ?? ''))) ?>">
<input type="hidden" name="allegro_service_name[]" class="dm-hidden-service-name" value="<?= $e($currentServiceName) ?>">
<?php // Allegro searchable select ?>
<div class="dm-allegro-panel dm-searchable-select" data-current-id="<?= $e($currentCarrier === 'allegro' ? $currentAllegroId : '') ?>" data-current-name="<?= $e($currentCarrier === 'allegro' ? $currentServiceName : '') ?>" style="<?= $currentCarrier !== 'allegro' || $currentAllegroId === '' && $currentCarrier === '' ? 'display:none' : '' ?>">
<input type="text" class="form-control dm-search-input" placeholder="<?= $e($t('settings.allegro.delivery.fields.search_placeholder')) ?>" value="<?= $e($currentCarrier === 'allegro' ? $currentServiceName : '') ?>" autocomplete="off">
<div class="searchable-select__dropdown dm-dropdown">
<div class="searchable-select__option dm-option-clear" data-value="" data-label="" data-credentials-id="" data-carrier-id="">
<em class="muted">-- <?= $e($t('settings.allegro.delivery.fields.no_mapping')) ?> --</em>
</div>
<?php foreach ($dmAllegroServices as $svc): ?>
<?php
$svcId = is_array($svc['id'] ?? null) ? $svc['id'] : [];
$svcMethodId = trim((string) ($svcId['deliveryMethodId'] ?? ''));
$svcCredentialsId = trim((string) ($svcId['credentialsId'] ?? ''));
$svcName = trim((string) ($svc['name'] ?? ''));
$svcCarrierId = trim((string) ($svc['carrierId'] ?? ''));
$svcOwner = trim((string) ($svc['owner'] ?? ''));
$svcLabel = $svcName . ' (' . $svcOwner . ')';
?>
<div class="searchable-select__option"
data-value="<?= $e($svcMethodId) ?>"
data-label="<?= $e($svcLabel) ?>"
data-credentials-id="<?= $e($svcCredentialsId) ?>"
data-carrier-id="<?= $e($svcCarrierId) ?>"
><?= $e($svcName) ?> <span class="muted">(<?= $e($svcOwner) ?>)</span></div>
<?php endforeach; ?>
</div>
</div>
<?php // InPost simple select ?>
<div class="dm-inpost-panel" style="<?= $currentCarrier !== 'inpost' ? 'display:none' : '' ?>">
<select class="form-control dm-inpost-select">
<option value="">-- <?= $e($t('settings.allegro.delivery.fields.no_mapping')) ?> --</option>
<?php foreach ($dmInpostServices as $inSvc): ?>
<option value="<?= $e((string) ($inSvc['id'] ?? '')) ?>"<?= $currentCarrier === 'inpost' && $currentAllegroId === (string) ($inSvc['id'] ?? '') ? ' selected' : '' ?>>
<?= $e((string) ($inSvc['name'] ?? '')) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php // Empty state ?>
<div class="dm-empty-panel muted" style="<?= $currentCarrier !== '' ? 'display:none' : ($currentAllegroId !== '' ? 'display:none' : '') ?>">
<?= $e($t('settings.allegro.delivery.fields.select_carrier_first')) ?>
</div>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="form-actions mt-12">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.allegro.delivery.actions.save')) ?></button>
</div>
</form>
<?php endif; ?>
</section>
</div>
</section>
<script>
@@ -293,9 +416,29 @@ $orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : []
return;
}
var tabNameMap = {
'allegro-tab-integration': 'integration',
'allegro-tab-statuses': 'statuses',
'allegro-tab-settings': 'settings',
'allegro-tab-delivery': 'delivery'
};
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);
var currentTab = url.searchParams.get('tab') || 'integration';
url.searchParams.set('tab', tabName);
// Tabs that need server data require a full reload
if (tabName === 'delivery' && currentTab !== 'delivery') {
window.location.href = url.toString();
return;
}
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');
@@ -306,4 +449,128 @@ $orderproStatuses = is_array($orderproStatuses ?? null) ? $orderproStatuses : []
});
});
})();
(function () {
var envSelect = document.getElementById('allegro-env-select');
if (!envSelect) return;
envSelect.addEventListener('change', function () {
window.location.href = '/settings/integrations/allegro?env=' + encodeURIComponent(envSelect.value);
});
})();
(function () {
// Carrier switching logic
document.querySelectorAll('.dm-carrier-select').forEach(function (carrierSelect) {
var rowIdx = carrierSelect.getAttribute('data-row');
var serviceWrap = document.querySelector('.dm-service-wrap[data-row="' + rowIdx + '"]');
if (!serviceWrap) return;
var allegroPanel = serviceWrap.querySelector('.dm-allegro-panel');
var inpostPanel = serviceWrap.querySelector('.dm-inpost-panel');
var emptyPanel = serviceWrap.querySelector('.dm-empty-panel');
var hiddenMethodId = serviceWrap.querySelector('.dm-hidden-method-id');
var hiddenCredentialsId = serviceWrap.querySelector('.dm-hidden-credentials-id');
var hiddenCarrierId = serviceWrap.querySelector('.dm-hidden-carrier-id');
var hiddenServiceName = serviceWrap.querySelector('.dm-hidden-service-name');
function showPanel(carrier) {
if (allegroPanel) allegroPanel.style.display = carrier === 'allegro' ? '' : 'none';
if (inpostPanel) inpostPanel.style.display = carrier === 'inpost' ? '' : 'none';
if (emptyPanel) emptyPanel.style.display = carrier === '' ? '' : 'none';
}
carrierSelect.addEventListener('change', function () {
var carrier = carrierSelect.value;
showPanel(carrier);
// Clear hidden values when switching carrier
if (hiddenMethodId) hiddenMethodId.value = '';
if (hiddenCredentialsId) hiddenCredentialsId.value = '';
if (hiddenCarrierId) hiddenCarrierId.value = '';
if (hiddenServiceName) hiddenServiceName.value = '';
// Reset Allegro search input
var allegroInput = allegroPanel ? allegroPanel.querySelector('.dm-search-input') : null;
if (allegroInput) allegroInput.value = '';
// Reset InPost select
var inpostSelect = inpostPanel ? inpostPanel.querySelector('.dm-inpost-select') : null;
if (inpostSelect) inpostSelect.value = '';
});
// InPost select change -> update hidden fields
var inpostSelect = inpostPanel ? inpostPanel.querySelector('.dm-inpost-select') : null;
if (inpostSelect) {
inpostSelect.addEventListener('change', function () {
var opt = inpostSelect.options[inpostSelect.selectedIndex];
if (hiddenMethodId) hiddenMethodId.value = inpostSelect.value;
if (hiddenCredentialsId) hiddenCredentialsId.value = '';
if (hiddenCarrierId) hiddenCarrierId.value = '';
if (hiddenServiceName) hiddenServiceName.value = opt ? opt.textContent.trim() : '';
});
}
});
// Allegro searchable selects
document.querySelectorAll('.dm-searchable-select').forEach(function (wrapper) {
var searchInput = wrapper.querySelector('.dm-search-input');
var dropdown = wrapper.querySelector('.dm-dropdown');
var serviceWrap = wrapper.closest('.dm-service-wrap');
if (!searchInput || !dropdown || !serviceWrap) return;
var hiddenMethodId = serviceWrap.querySelector('.dm-hidden-method-id');
var hiddenCredentialsId = serviceWrap.querySelector('.dm-hidden-credentials-id');
var hiddenCarrierId = serviceWrap.querySelector('.dm-hidden-carrier-id');
var hiddenServiceName = serviceWrap.querySelector('.dm-hidden-service-name');
var options = dropdown.querySelectorAll('.searchable-select__option');
wrapper.style.position = 'relative';
function selectOption(opt) {
hiddenMethodId.value = opt.getAttribute('data-value') || '';
hiddenCredentialsId.value = opt.getAttribute('data-credentials-id') || '';
hiddenCarrierId.value = opt.getAttribute('data-carrier-id') || '';
hiddenServiceName.value = opt.getAttribute('data-label') || '';
searchInput.value = opt.getAttribute('data-label') || '';
dropdown.classList.remove('is-open');
options.forEach(function (o) { o.classList.remove('is-selected'); });
opt.classList.add('is-selected');
}
function filterOptions(query) {
var q = query.toLowerCase().trim();
options.forEach(function (opt) {
var label = (opt.getAttribute('data-label') || '').toLowerCase();
opt.style.display = (q === '' || label.indexOf(q) !== -1) ? '' : 'none';
});
}
searchInput.addEventListener('focus', function () {
filterOptions(searchInput.value);
dropdown.classList.add('is-open');
});
searchInput.addEventListener('input', function () {
filterOptions(searchInput.value);
dropdown.classList.add('is-open');
});
options.forEach(function (opt) {
opt.addEventListener('mousedown', function (e) {
e.preventDefault();
selectOption(opt);
});
});
searchInput.addEventListener('blur', function () {
setTimeout(function () { dropdown.classList.remove('is-open'); }, 150);
});
var currentId = wrapper.getAttribute('data-current-id') || '';
if (currentId !== '') {
options.forEach(function (opt) {
if (opt.getAttribute('data-value') === currentId) {
opt.classList.add('is-selected');
}
});
}
});
})();
</script>

View File

@@ -0,0 +1,34 @@
<?php
$integration = is_array($settings ?? null) ? $settings : [];
$hasApiKey = (bool) ($integration['has_api_key'] ?? false);
?>
<section class="card">
<h2 class="section-title"><?= $e($t('settings.apaczka.title')) ?></h2>
<p class="muted mt-12"><?= $e($t('settings.apaczka.description')) ?></p>
<?php if (!empty($errorMessage)): ?>
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
<?php endif; ?>
<?php if (!empty($successMessage)): ?>
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<h3 class="section-title"><?= $e($t('settings.apaczka.config.title')) ?></h3>
<form class="statuses-form mt-16" action="/settings/integrations/apaczka/save" method="post" novalidate>
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.apaczka.fields.api_key')) ?></span>
<input class="form-control" type="password" name="api_key" autocomplete="new-password">
<span class="muted"><?= $e($hasApiKey ? $t('settings.apaczka.api_key.saved') : $t('settings.apaczka.api_key.missing')) ?></span>
</label>
<div class="form-actions">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.apaczka.actions.save')) ?></button>
</div>
</form>
</section>

View File

@@ -0,0 +1,116 @@
<?php
$s = is_array($settings ?? null) ? $settings : [];
?>
<section class="card">
<h2 class="section-title"><?= $e($t('settings.company.title')) ?></h2>
<p class="muted mt-12"><?= $e($t('settings.company.description')) ?></p>
<?php if (!empty($errorMessage)): ?>
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
<?php endif; ?>
<?php if (!empty($successMessage)): ?>
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<form action="/settings/company/save" method="post" novalidate>
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<h3 class="section-title"><?= $e($t('settings.company.section_address')) ?></h3>
<div class="form-grid-2 mt-12">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.company_name')) ?></span>
<input class="form-control" type="text" name="company_name" maxlength="200" value="<?= $e((string) ($s['company_name'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.person_name')) ?></span>
<input class="form-control" type="text" name="person_name" maxlength="200" value="<?= $e((string) ($s['person_name'] ?? '')) ?>">
</label>
</div>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.street')) ?></span>
<input class="form-control" type="text" name="street" maxlength="200" value="<?= $e((string) ($s['street'] ?? '')) ?>">
</label>
<div class="form-grid-3 mt-0">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.postal_code')) ?></span>
<input class="form-control" type="text" name="postal_code" maxlength="16" value="<?= $e((string) ($s['postal_code'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.city')) ?></span>
<input class="form-control" type="text" name="city" maxlength="128" value="<?= $e((string) ($s['city'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.country_code')) ?></span>
<input class="form-control" type="text" name="country_code" maxlength="2" value="<?= $e((string) ($s['country_code'] ?? 'PL')) ?>">
</label>
</div>
<div class="form-grid-2">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.phone')) ?></span>
<input class="form-control" type="tel" name="phone" maxlength="64" value="<?= $e((string) ($s['phone'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.email')) ?></span>
<input class="form-control" type="email" name="email" maxlength="128" value="<?= $e((string) ($s['email'] ?? '')) ?>">
</label>
</div>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.tax_number')) ?></span>
<input class="form-control" type="text" name="tax_number" maxlength="64" value="<?= $e((string) ($s['tax_number'] ?? '')) ?>">
</label>
<h3 class="section-title mt-16"><?= $e($t('settings.company.section_bank')) ?></h3>
<div class="form-grid-2 mt-12">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.bank_account')) ?></span>
<input class="form-control" type="text" name="bank_account" maxlength="64" value="<?= $e((string) ($s['bank_account'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.bank_owner_name')) ?></span>
<input class="form-control" type="text" name="bank_owner_name" maxlength="200" value="<?= $e((string) ($s['bank_owner_name'] ?? '')) ?>">
</label>
</div>
<h3 class="section-title mt-16"><?= $e($t('settings.company.section_defaults')) ?></h3>
<div class="form-grid-4 mt-12">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.length_cm')) ?></span>
<input class="form-control" type="number" name="default_package_length_cm" step="0.1" min="0.1" value="<?= $e((string) ($s['default_package_length_cm'] ?? '25')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.width_cm')) ?></span>
<input class="form-control" type="number" name="default_package_width_cm" step="0.1" min="0.1" value="<?= $e((string) ($s['default_package_width_cm'] ?? '20')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.height_cm')) ?></span>
<input class="form-control" type="number" name="default_package_height_cm" step="0.1" min="0.1" value="<?= $e((string) ($s['default_package_height_cm'] ?? '8')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.weight_kg')) ?></span>
<input class="form-control" type="number" name="default_package_weight_kg" step="0.001" min="0.001" value="<?= $e((string) ($s['default_package_weight_kg'] ?? '1')) ?>">
</label>
</div>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.company.fields.label_format')) ?></span>
<select class="form-control" name="default_label_format">
<option value="PDF"<?= ((string) ($s['default_label_format'] ?? 'PDF')) === 'PDF' ? ' selected' : '' ?>>PDF</option>
<option value="ZPL"<?= ((string) ($s['default_label_format'] ?? 'PDF')) === 'ZPL' ? ' selected' : '' ?>>ZPL</option>
</select>
</label>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.company.actions.save')) ?></button>
</div>
</form>
</section>

View File

@@ -0,0 +1,133 @@
<?php
$s = is_array($settings ?? null) ? $settings : [];
$hasToken = (bool) ($s['has_api_token'] ?? false);
$env = (string) ($s['environment'] ?? 'sandbox');
$dispatchMethod = (string) ($s['default_dispatch_method'] ?? 'pop');
$lockerSize = (string) ($s['default_locker_size'] ?? 'small');
$labelFormat = (string) ($s['label_format'] ?? 'Pdf');
?>
<section class="card">
<h2 class="section-title"><?= $e($t('settings.inpost.title')) ?></h2>
<p class="muted mt-12"><?= $e($t('settings.inpost.description')) ?></p>
<?php if (!empty($errorMessage)): ?>
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
<?php endif; ?>
<?php if (!empty($successMessage)): ?>
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<h3 class="section-title"><?= $e($t('settings.inpost.config.title')) ?></h3>
<form action="/settings/integrations/inpost/save" method="post" novalidate>
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<label class="form-field mt-16">
<span class="field-label"><?= $e($t('settings.inpost.fields.api_token')) ?></span>
<input class="form-control" type="password" name="api_token" autocomplete="new-password">
<span class="muted"><?= $e($hasToken ? $t('settings.inpost.api_token.saved') : $t('settings.inpost.api_token.missing')) ?></span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.organization_id')) ?></span>
<input class="form-control" type="text" name="organization_id" value="<?= $e((string) ($s['organization_id'] ?? '')) ?>">
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.environment')) ?></span>
<select class="form-control" name="environment">
<option value="sandbox"<?= $env === 'sandbox' ? ' selected' : '' ?>>Sandbox</option>
<option value="production"<?= $env === 'production' ? ' selected' : '' ?>>Production</option>
</select>
</label>
<h4 class="section-title mt-16"><?= $e($t('settings.inpost.sections.dispatch')) ?></h4>
<label class="form-field mt-12">
<span class="field-label"><?= $e($t('settings.inpost.fields.default_dispatch_method')) ?></span>
<select class="form-control" name="default_dispatch_method">
<option value="pop"<?= $dispatchMethod === 'pop' ? ' selected' : '' ?>><?= $e($t('settings.inpost.dispatch_methods.pop')) ?></option>
<option value="parcel_locker"<?= $dispatchMethod === 'parcel_locker' ? ' selected' : '' ?>><?= $e($t('settings.inpost.dispatch_methods.parcel_locker')) ?></option>
<option value="courier"<?= $dispatchMethod === 'courier' ? ' selected' : '' ?>><?= $e($t('settings.inpost.dispatch_methods.courier')) ?></option>
</select>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.default_dispatch_point')) ?></span>
<input class="form-control" type="text" name="default_dispatch_point" value="<?= $e((string) ($s['default_dispatch_point'] ?? '')) ?>" placeholder="np. RZE14N">
</label>
<h4 class="section-title mt-16"><?= $e($t('settings.inpost.sections.locker')) ?></h4>
<label class="form-field mt-12">
<span class="field-label"><?= $e($t('settings.inpost.fields.default_locker_size')) ?></span>
<select class="form-control" name="default_locker_size">
<option value="small"<?= $lockerSize === 'small' ? ' selected' : '' ?>>A (8 x 38 x 64 cm)</option>
<option value="medium"<?= $lockerSize === 'medium' ? ' selected' : '' ?>>B (19 x 38 x 64 cm)</option>
<option value="large"<?= $lockerSize === 'large' ? ' selected' : '' ?>>C (41 x 38 x 64 cm)</option>
</select>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.default_insurance')) ?></span>
<input class="form-control" type="number" name="default_insurance" step="0.01" min="0" value="<?= $e($s['default_insurance'] !== null ? (string) $s['default_insurance'] : '') ?>" placeholder="<?= $e($t('settings.inpost.fields.insurance_placeholder')) ?>">
</label>
<h4 class="section-title mt-16"><?= $e($t('settings.inpost.sections.courier')) ?></h4>
<div class="form-grid-3 mt-12">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.courier_length')) ?></span>
<input class="form-control" type="number" name="default_courier_length" min="1" value="<?= $e((string) ($s['default_courier_length'] ?? 20)) ?>">
<span class="muted">cm</span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.courier_width')) ?></span>
<input class="form-control" type="number" name="default_courier_width" min="1" value="<?= $e((string) ($s['default_courier_width'] ?? 15)) ?>">
<span class="muted">cm</span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.inpost.fields.courier_height')) ?></span>
<input class="form-control" type="number" name="default_courier_height" min="1" value="<?= $e((string) ($s['default_courier_height'] ?? 8)) ?>">
<span class="muted">cm</span>
</label>
</div>
<h4 class="section-title mt-16"><?= $e($t('settings.inpost.sections.other')) ?></h4>
<label class="form-field mt-12">
<span class="field-label"><?= $e($t('settings.inpost.fields.label_format')) ?></span>
<select class="form-control" name="label_format">
<option value="Pdf"<?= $labelFormat === 'Pdf' ? ' selected' : '' ?>>PDF A6</option>
<option value="Zpl"<?= $labelFormat === 'Zpl' ? ' selected' : '' ?>>ZPL</option>
<option value="Epl"<?= $labelFormat === 'Epl' ? ' selected' : '' ?>>EPL</option>
</select>
</label>
<div class="mt-12">
<label class="form-field form-field--inline">
<input type="checkbox" name="weekend_delivery" value="1"<?= !empty($s['weekend_delivery']) ? ' checked' : '' ?>>
<span class="field-label"><?= $e($t('settings.inpost.fields.weekend_delivery')) ?></span>
</label>
<label class="form-field form-field--inline">
<input type="checkbox" name="auto_insurance_value" value="1"<?= !empty($s['auto_insurance_value']) ? ' checked' : '' ?>>
<span class="field-label"><?= $e($t('settings.inpost.fields.auto_insurance_value')) ?></span>
</label>
<label class="form-field form-field--inline">
<input type="checkbox" name="multi_parcel" value="1"<?= !empty($s['multi_parcel']) ? ' checked' : '' ?>>
<span class="field-label"><?= $e($t('settings.inpost.fields.multi_parcel')) ?></span>
</label>
</div>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.inpost.actions.save')) ?></button>
</div>
</form>
</section>