Merge branch 'main' of https://git.project-pro.pl/Project-Pro/orderPRO
# Conflicts: # .paul/PROJECT.md # .paul/ROADMAP.md # .paul/STATE.md # .paul/codebase/tech_changelog.md # resources/lang/pl.php # resources/views/shipments/prepare.php # routes/web.php # src/Modules/Settings/IntegrationsHubController.php # src/Modules/Shipments/ShipmentController.php
This commit is contained in:
@@ -190,6 +190,15 @@ return [
|
||||
'address_invoice' => 'Dane do faktury',
|
||||
'address_delivery' => 'Dane wysylki',
|
||||
'notes_title' => 'Wiadomosci i zalaczniki',
|
||||
'notes_user_title' => 'Notatki',
|
||||
'notes_user_empty' => 'Brak notatek.',
|
||||
'notes_user_add_placeholder' => 'Wpisz notatke...',
|
||||
'notes_user_save' => 'Zapisz',
|
||||
'notes_user_edit' => 'Edytuj',
|
||||
'notes_user_delete' => 'Usun',
|
||||
'notes_user_cancel' => 'Anuluj',
|
||||
'notes_user_confirm_delete' => 'Usunac notatke?',
|
||||
'notes_imported_title' => 'Wiadomosci ze zrodla',
|
||||
'history_title' => 'Historia statusow',
|
||||
'fields' => [
|
||||
'status' => 'Status',
|
||||
@@ -587,6 +596,7 @@ return [
|
||||
'hostedsms' => 'HostedSMS',
|
||||
'smsplanet' => 'SMSPLANET',
|
||||
'erli' => 'Erli',
|
||||
'polkurier' => 'polkurier.pl',
|
||||
'shoppro_instances' => ':count instancji',
|
||||
],
|
||||
'status' => [
|
||||
@@ -742,6 +752,47 @@ return [
|
||||
'test_failed' => 'Nie udalo sie polaczyc z API Apaczka.',
|
||||
],
|
||||
],
|
||||
'polkurier' => [
|
||||
'title' => 'Integracja polkurier.pl',
|
||||
'description' => 'Broker kurierski polkurier.pl - alternatywa dla Apaczki. Token API generujesz w Panel Klienta > Ustawienia > Token API.',
|
||||
'config' => [
|
||||
'title' => 'Konfiguracja API',
|
||||
],
|
||||
'test' => [
|
||||
'title' => 'Test polaczenia',
|
||||
'description' => 'Test realnie wywoluje metode test_auth_api w API polkurier (bez tworzenia przesylki).',
|
||||
],
|
||||
'fields' => [
|
||||
'login' => 'Login (e-mail z panelu klienta)',
|
||||
'api_token' => 'Token API',
|
||||
'default_label_format' => 'Domyslny format etykiety',
|
||||
'is_active' => 'Integracja aktywna',
|
||||
],
|
||||
'hints' => [
|
||||
'login' => 'Login uzywany przy generowaniu Token API w Panel Klienta polkurier.',
|
||||
],
|
||||
'token' => [
|
||||
'saved' => 'Token API jest zapisany. Pozostaw pole puste, aby nie zmieniac.',
|
||||
'missing' => 'Brak zapisanego Token API.',
|
||||
],
|
||||
'status' => [
|
||||
'token' => 'Token API',
|
||||
'active' => 'Aktywna',
|
||||
'saved' => 'zapisany',
|
||||
'missing' => 'brak',
|
||||
'last_test' => 'Ostatni test',
|
||||
],
|
||||
'actions' => [
|
||||
'save' => 'Zapisz ustawienia polkurier',
|
||||
'send_test' => 'Testuj polaczenie',
|
||||
],
|
||||
'flash' => [
|
||||
'saved' => 'Ustawienia polkurier zostaly zapisane.',
|
||||
'save_failed' => 'Nie udalo sie zapisac ustawien polkurier.',
|
||||
'test_success' => 'Polaczenie z polkurier dziala. :message',
|
||||
'test_failed' => 'Nie udalo sie polaczyc z API polkurier.',
|
||||
],
|
||||
],
|
||||
'hostedsms' => [
|
||||
'title' => 'Integracja HostedSMS',
|
||||
'description' => 'Konfiguracja konta HostedSMS do wysylki SMS z orderPRO.',
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
@use "modules/project-mappings";
|
||||
@use "modules/customer-risk-alert";
|
||||
@use "modules/sms-templates";
|
||||
@use "modules/order-notes";
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
|
||||
112
resources/scss/modules/_order-notes.scss
Normal file
112
resources/scss/modules/_order-notes.scss
Normal file
@@ -0,0 +1,112 @@
|
||||
// Phase 129-01: notatki autorskie operatora w szczegolach zamowienia + badge na liscie.
|
||||
|
||||
.order-notes-badge {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 1px 6px;
|
||||
border-radius: 10px;
|
||||
background: #eef2ff;
|
||||
color: #4338ca;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
text-decoration: none;
|
||||
vertical-align: middle;
|
||||
transition: background 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #e0e7ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.order-notes-subtitle {
|
||||
margin: 0 0 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: var(--c-muted, #64748b);
|
||||
}
|
||||
|
||||
.order-user-notes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.order-event--user {
|
||||
border-left: 3px solid #6366f1;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.order-event__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.order-event__meta {
|
||||
font-size: 11px;
|
||||
color: var(--c-muted, #64748b);
|
||||
}
|
||||
|
||||
.order-event__actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.order-imported-notes {
|
||||
.order-event--imported {
|
||||
opacity: 0.75;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
color: var(--c-primary, #2563eb);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&--danger {
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
.order-note-form,
|
||||
.order-note-edit-form {
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 60px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.order-note-form__actions,
|
||||
.order-note-edit-form__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.order-note-edit-form {
|
||||
margin-top: 6px;
|
||||
|
||||
.order-note-edit-form__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,7 @@
|
||||
<script src="/assets/js/modules/alert-dismiss.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/alert-dismiss.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/notifications.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/notifications.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/sms-template-picker.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/sms-template-picker.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/order-notes.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/order-notes.js') ?: 0 ?>"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
|
||||
<script src="/assets/js/modules/statistics-summary-charts.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/statistics-summary-charts.js') ?: 0 ?>"></script>
|
||||
<script>
|
||||
|
||||
@@ -7,6 +7,9 @@ $shipmentsList = is_array($shipments ?? null) ? $shipments : [];
|
||||
$packagesList = is_array($packages ?? null) ? $packages : [];
|
||||
$documentsList = is_array($documents ?? null) ? $documents : [];
|
||||
$notesList = is_array($notes ?? null) ? $notes : [];
|
||||
$userNotesList = is_array($userNotes ?? null) ? $userNotes : [];
|
||||
$currentUserIdValue = (int) ($currentUserId ?? 0);
|
||||
$csrfTokenValue = (string) ($csrfToken ?? '');
|
||||
$receiptsList = is_array($receipts ?? null) ? $receipts : [];
|
||||
$receiptConfigsList = is_array($receiptConfigs ?? null) ? $receiptConfigs : [];
|
||||
$invoicesList = is_array($invoices ?? null) ? $invoices : [];
|
||||
@@ -447,19 +450,70 @@ foreach ($addressesList as $address) {
|
||||
</section>
|
||||
|
||||
<section class="mt-16 order-grid-2">
|
||||
<article class="card">
|
||||
<article class="card" id="notes">
|
||||
<h3 class="section-title"><?= $e($t('orders.details.notes_title')) ?></h3>
|
||||
<div class="order-events mt-12">
|
||||
<?php if ($notesList === []): ?>
|
||||
<div class="muted">-</div>
|
||||
|
||||
<div class="order-user-notes mt-12" data-order-id="<?= (int) ($orderId ?? 0) ?>">
|
||||
<h4 class="order-notes-subtitle"><?= $e($t('orders.details.notes_user_title')) ?></h4>
|
||||
<?php if ($userNotesList === []): ?>
|
||||
<div class="muted"><?= $e($t('orders.details.notes_user_empty')) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($userNotesList as $userNote): ?>
|
||||
<?php
|
||||
$noteId = (int) ($userNote['id'] ?? 0);
|
||||
$noteAuthorId = (int) ($userNote['user_id'] ?? 0);
|
||||
$noteAuthorName = trim((string) ($userNote['author_name'] ?? ''));
|
||||
$noteCreatedAt = (string) ($userNote['created_at'] ?? '');
|
||||
$noteBody = (string) ($userNote['body'] ?? '');
|
||||
$canEdit = $currentUserIdValue > 0 && $noteAuthorId === $currentUserIdValue;
|
||||
?>
|
||||
<div class="order-event order-event--user" data-note-id="<?= $noteId ?>">
|
||||
<div class="order-event__head">
|
||||
<span class="order-event__meta"><?= $e($noteCreatedAt) ?><?php if ($noteAuthorName !== ''): ?> · <?= $e($noteAuthorName) ?><?php endif; ?></span>
|
||||
<?php if ($canEdit): ?>
|
||||
<span class="order-event__actions">
|
||||
<button type="button" class="btn-link js-order-note-edit" data-note-id="<?= $noteId ?>"><?= $e($t('orders.details.notes_user_edit')) ?></button>
|
||||
<form method="post" action="/orders/<?= (int) ($orderId ?? 0) ?>/notes/<?= $noteId ?>/delete" class="js-order-note-delete" style="display:inline">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfTokenValue) ?>">
|
||||
<button type="submit" class="btn-link btn-link--danger"><?= $e($t('orders.details.notes_user_delete')) ?></button>
|
||||
</form>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="order-event__body js-order-note-body"><?= nl2br($e($noteBody)) ?></div>
|
||||
<?php if ($canEdit): ?>
|
||||
<form method="post" action="/orders/<?= (int) ($orderId ?? 0) ?>/notes/<?= $noteId ?>/update" class="order-note-edit-form js-order-note-edit-form" style="display:none">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfTokenValue) ?>">
|
||||
<textarea name="body" class="form-control" rows="3" maxlength="2000" required><?= $e($noteBody) ?></textarea>
|
||||
<div class="order-note-edit-form__actions">
|
||||
<button type="submit" class="btn btn-primary btn-sm"><?= $e($t('orders.details.notes_user_save')) ?></button>
|
||||
<button type="button" class="btn btn-default btn-sm js-order-note-edit-cancel"><?= $e($t('orders.details.notes_user_cancel')) ?></button>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<form method="post" action="/orders/<?= (int) ($orderId ?? 0) ?>/notes" class="order-note-form mt-12">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfTokenValue) ?>">
|
||||
<textarea name="body" class="form-control" rows="3" maxlength="2000" placeholder="<?= $e($t('orders.details.notes_user_add_placeholder')) ?>" required></textarea>
|
||||
<div class="order-note-form__actions">
|
||||
<button type="submit" class="btn btn-primary btn-sm"><?= $e($t('orders.details.notes_user_save')) ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php if ($notesList !== []): ?>
|
||||
<div class="order-imported-notes mt-16">
|
||||
<h4 class="order-notes-subtitle"><?= $e($t('orders.details.notes_imported_title')) ?></h4>
|
||||
<?php foreach ($notesList as $note): ?>
|
||||
<div class="order-event">
|
||||
<div class="order-event order-event--imported">
|
||||
<div class="order-event__head"><?= $e((string) ($note['note_type'] ?? '')) ?> | <?= $e((string) ($note['created_at_external'] ?? '')) ?></div>
|
||||
<div class="order-event__body"><?= $e((string) ($note['comment'] ?? '')) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
|
||||
<article class="card">
|
||||
|
||||
110
resources/views/settings/polkurier.php
Normal file
110
resources/views/settings/polkurier.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
$settings = is_array($settings ?? null) ? $settings : [];
|
||||
$login = trim((string) ($settings['login'] ?? ''));
|
||||
$labelFormat = strtoupper(trim((string) ($settings['default_label_format'] ?? 'PDF'))) ?: 'PDF';
|
||||
$hasToken = (bool) ($settings['has_api_token'] ?? 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;
|
||||
$labelFormats = ['PDF', 'ZPL', 'EPL'];
|
||||
?>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="section-title"><?= $e($t('settings.polkurier.title')) ?></h2>
|
||||
<p class="muted mt-12"><?= $e($t('settings.polkurier.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; ?>
|
||||
</section>
|
||||
|
||||
<section class="card mt-16">
|
||||
<h3 class="section-title"><?= $e($t('settings.polkurier.config.title')) ?></h3>
|
||||
|
||||
<div class="muted mt-12">
|
||||
<?= $e($t('settings.polkurier.status.token')) ?>:
|
||||
<strong><?= $e($hasToken ? $t('settings.polkurier.status.saved') : $t('settings.polkurier.status.missing')) ?></strong>
|
||||
|
|
||||
<?= $e($t('settings.polkurier.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/polkurier/save" method="post" novalidate>
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.polkurier.fields.login')) ?></span>
|
||||
<input class="form-control" type="text" name="login" maxlength="190" value="<?= $e($login) ?>" required>
|
||||
<span class="muted"><?= $e($t('settings.polkurier.hints.login')) ?></span>
|
||||
</label>
|
||||
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.polkurier.fields.api_token')) ?></span>
|
||||
<input class="form-control" type="password" name="api_token" autocomplete="new-password" placeholder="<?= $hasToken ? '********' : '' ?>" <?= $hasToken ? '' : 'required' ?>>
|
||||
<span class="muted"><?= $e($hasToken ? $t('settings.polkurier.token.saved') : $t('settings.polkurier.token.missing')) ?></span>
|
||||
</label>
|
||||
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('settings.polkurier.fields.default_label_format')) ?></span>
|
||||
<select class="form-control" name="default_label_format">
|
||||
<?php foreach ($labelFormats as $fmt): ?>
|
||||
<option value="<?= $e($fmt) ?>"<?= $fmt === $labelFormat ? ' selected' : '' ?>><?= $e($fmt) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="form-field form-field--inline">
|
||||
<input type="checkbox" name="is_active" value="1"<?= $isActive ? ' checked' : '' ?>>
|
||||
<span class="field-label"><?= $e($t('settings.polkurier.fields.is_active')) ?></span>
|
||||
</label>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--primary"><?= $e($t('settings.polkurier.actions.save')) ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="card mt-16">
|
||||
<h3 class="section-title"><?= $e($t('settings.polkurier.test.title')) ?></h3>
|
||||
<p class="muted mt-12"><?= $e($t('settings.polkurier.test.description')) ?></p>
|
||||
|
||||
<form class="statuses-form mt-16" action="/settings/integrations/polkurier/test" method="post" novalidate>
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<div class="form-actions mt-16">
|
||||
<button type="submit" class="btn btn--secondary"><?= $e($t('settings.polkurier.actions.send_test')) ?></button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<?php if ($lastTestAt !== ''): ?>
|
||||
<div class="mt-16">
|
||||
<?php
|
||||
$type = $lastTestStatus === 'ok' ? 'success' : 'danger';
|
||||
$parts = [];
|
||||
$parts[] = $e($t('settings.polkurier.status.last_test')) . ': ' . $e($lastTestAt);
|
||||
if ($lastTestStatus !== '') {
|
||||
$parts[] = '<span class="badge badge--' . ($lastTestStatus === 'ok' ? 'success' : 'muted') . '">' . $e(strtoupper($lastTestStatus)) . '</span>';
|
||||
}
|
||||
if ($lastTestHttpCode !== null) {
|
||||
$parts[] = '<span class="badge badge--muted">HTTP ' . $e((string) $lastTestHttpCode) . '</span>';
|
||||
}
|
||||
if ($lastTestMessage !== '') {
|
||||
$parts[] = $e($lastTestMessage);
|
||||
}
|
||||
$messageHtml = implode(' · ', $parts);
|
||||
$dismissible = false;
|
||||
include dirname(__DIR__) . '/components/alert.php';
|
||||
unset($messageHtml);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
@@ -6,6 +6,7 @@ $prefs = is_array($preferences ?? null) ? $preferences : [];
|
||||
$comp = is_array($company ?? null) ? $company : [];
|
||||
$services = is_array($deliveryServices ?? null) ? $deliveryServices : [];
|
||||
$apaczkaSvcList = is_array($apaczkaServices ?? null) ? $apaczkaServices : [];
|
||||
$polkurierSvcList = is_array($polkurierServices ?? null) ? $polkurierServices : [];
|
||||
$packages = is_array($existingPackages ?? null) ? $existingPackages : [];
|
||||
$pendingPrintIds = is_array($pendingPrintPackageIds ?? null) ? $pendingPrintPackageIds : [];
|
||||
$servicesError = (string) ($deliveryServicesError ?? '');
|
||||
@@ -105,6 +106,7 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
<option value="allegro"<?= $preselectedCarrier === 'allegro' ? ' selected' : '' ?>>Allegro</option>
|
||||
<option value="inpost"<?= $preselectedCarrier === 'inpost' ? ' selected' : '' ?>>InPost</option>
|
||||
<option value="apaczka"<?= $preselectedCarrier === 'apaczka' ? ' selected' : '' ?>>Apaczka</option>
|
||||
<option value="polkurier"<?= $preselectedCarrier === 'polkurier' ? ' selected' : '' ?>>polkurier</option>
|
||||
</select>
|
||||
<?php if ($deliveryMethodName !== ''): ?>
|
||||
<div class="muted mt-4" style="font-size:12px">Metoda z zamowienia: <strong><?= $e($deliveryMethodName) ?></strong><?php if ($mappedServiceName !== ''): ?> → <?= $e($mappedCarrier === 'inpost' ? 'InPost' : ($mappedCarrier === 'apaczka' ? 'Apaczka' : 'Allegro')) ?>: <?= $e($mappedServiceName) ?><?php endif; ?></div>
|
||||
@@ -213,12 +215,46 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="shipment-polkurier-panel" style="<?= $preselectedCarrier !== 'polkurier' ? 'display:none' : '' ?>">
|
||||
<?php if ($polkurierSvcList === []): ?>
|
||||
<div class="muted">Brak uslug polkurier (sprawdz konfiguracje w Ustawienia → Integracje → polkurier).</div>
|
||||
<?php else: ?>
|
||||
<select class="form-control" id="shipment-polkurier-select">
|
||||
<option value="">-- Wybierz usluge polkurier --</option>
|
||||
<?php foreach ($polkurierSvcList as $pSvc): ?>
|
||||
<?php
|
||||
if (!is_array($pSvc)) {
|
||||
continue;
|
||||
}
|
||||
$pSvcId = trim((string) ($pSvc['id'] ?? ''));
|
||||
$pSvcName = trim((string) ($pSvc['name'] ?? $pSvcId));
|
||||
if ($pSvcId === '') {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<option
|
||||
value="<?= $e($pSvcId) ?>"
|
||||
data-carrier-id="<?= $e($pSvcId) ?>">
|
||||
<?= $e($pSvcName) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="muted mt-4" style="font-size:12px">Dla uslug paczkomatowych wpisz ID punktu w pole "Punkt odbioru" w sekcji Adres odbiorcy ponizej (np. <code>POP-RZE54</code>).</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div id="shipment-empty-panel" class="muted" style="<?= $preselectedCarrier !== '' ? 'display:none' : '' ?>">Wybierz przewoznika</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="credentials_id" id="shipment-credentials-id" value="">
|
||||
<input type="hidden" name="carrier_id" id="shipment-carrier-id" value="">
|
||||
<input type="hidden" name="provider_code" id="shipment-provider-code" value="<?= $e($preselectedCarrier === 'apaczka' ? 'apaczka' : ($preselectedCarrier === 'inpost' ? 'inpost' : 'allegro_wza')) ?>">
|
||||
<input type="hidden" name="service_code" id="shipment-service-code" value="">
|
||||
<input type="hidden" name="provider_code" id="shipment-provider-code" value="<?php
|
||||
if ($preselectedCarrier === 'apaczka') { echo 'apaczka'; }
|
||||
elseif ($preselectedCarrier === 'inpost') { echo 'inpost'; }
|
||||
elseif ($preselectedCarrier === 'polkurier') { echo 'polkurier'; }
|
||||
else { echo 'allegro_wza'; }
|
||||
?>">
|
||||
|
||||
<label class="form-field">
|
||||
<span class="field-label">Typ paczki</span>
|
||||
@@ -586,6 +622,8 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
var carrierSelect = document.getElementById('shipment-carrier-select');
|
||||
var inpostSelect = document.getElementById('shipment-inpost-select');
|
||||
var apaczkaSelect = document.getElementById('shipment-apaczka-select');
|
||||
var polkurierSelect = document.getElementById('shipment-polkurier-select');
|
||||
var serviceCodeInput = document.getElementById('shipment-service-code');
|
||||
|
||||
document.querySelectorAll('form select.form-control').forEach(function (sel) {
|
||||
enhanceSelect(sel);
|
||||
@@ -594,6 +632,7 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
var allegroPanel = document.getElementById('shipment-allegro-panel');
|
||||
var inpostPanel = document.getElementById('shipment-inpost-panel');
|
||||
var apaczkaPanel = document.getElementById('shipment-apaczka-panel');
|
||||
var polkurierPanel = document.getElementById('shipment-polkurier-panel');
|
||||
var emptyPanel = document.getElementById('shipment-empty-panel');
|
||||
|
||||
var wrapper = document.getElementById('shipment-service-wrapper');
|
||||
@@ -612,14 +651,21 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
hiddenInput.value = '';
|
||||
credentialsInput.value = '';
|
||||
carrierInput.value = '';
|
||||
if (serviceCodeInput) serviceCodeInput.value = '';
|
||||
}
|
||||
|
||||
function showPanel(carrier) {
|
||||
if (allegroPanel) allegroPanel.style.display = carrier === 'allegro' ? '' : 'none';
|
||||
if (inpostPanel) inpostPanel.style.display = carrier === 'inpost' ? '' : 'none';
|
||||
if (apaczkaPanel) apaczkaPanel.style.display = carrier === 'apaczka' ? '' : 'none';
|
||||
if (polkurierPanel) polkurierPanel.style.display = carrier === 'polkurier' ? '' : 'none';
|
||||
if (emptyPanel) emptyPanel.style.display = carrier === '' ? '' : 'none';
|
||||
if (providerInput) providerInput.value = carrier === 'apaczka' ? 'apaczka' : (carrier === 'inpost' ? 'inpost' : 'allegro_wza');
|
||||
if (providerInput) {
|
||||
if (carrier === 'apaczka') providerInput.value = 'apaczka';
|
||||
else if (carrier === 'inpost') providerInput.value = 'inpost';
|
||||
else if (carrier === 'polkurier') providerInput.value = 'polkurier';
|
||||
else providerInput.value = 'allegro_wza';
|
||||
}
|
||||
}
|
||||
|
||||
var weekendWrap = document.getElementById('shipment-apaczka-weekend-wrap');
|
||||
@@ -648,6 +694,10 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
apaczkaSelect.selectedIndex = 0;
|
||||
if (apaczkaSelect._syncTrigger) apaczkaSelect._syncTrigger();
|
||||
}
|
||||
if (polkurierSelect) {
|
||||
polkurierSelect.selectedIndex = 0;
|
||||
if (polkurierSelect._syncTrigger) polkurierSelect._syncTrigger();
|
||||
}
|
||||
allegroOpts.forEach(function (o) { o.classList.remove('is-selected'); });
|
||||
showPanel(carrierSelect.value);
|
||||
toggleWeekendOption();
|
||||
@@ -683,6 +733,24 @@ $defaultCodAmount = $isCod ? number_format($totalWithTax, 2, '.', '') : '0';
|
||||
}
|
||||
toggleWeekendOption();
|
||||
|
||||
if (polkurierSelect) {
|
||||
function syncPolkurierFields() {
|
||||
var opt = polkurierSelect.options[polkurierSelect.selectedIndex];
|
||||
var serviceCode = polkurierSelect.value;
|
||||
hiddenInput.value = serviceCode;
|
||||
if (serviceCodeInput) serviceCodeInput.value = serviceCode;
|
||||
credentialsInput.value = '';
|
||||
carrierInput.value = opt ? (opt.getAttribute('data-carrier-id') || serviceCode) : serviceCode;
|
||||
if (providerInput) providerInput.value = 'polkurier';
|
||||
}
|
||||
|
||||
polkurierSelect.addEventListener('change', syncPolkurierFields);
|
||||
|
||||
if (carrierSelect.value === 'polkurier' && polkurierSelect.value !== '') {
|
||||
syncPolkurierFields();
|
||||
}
|
||||
}
|
||||
|
||||
if (wrapper && searchInput && dropdown) {
|
||||
var isAllegroOpen = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user