Phase 3 complete: - Zmieniono _csrf_token -> _token w OrdersController (1x), ShipmentController (2x) - Zmieniono name="_csrf_token" -> name="_token" w orders/show.php (1x), shipments/prepare.php (2x) - Usunięto concern z .paul/codebase/CONCERNS.md Co-Authored-By: Claude <noreply@anthropic.com>
550 lines
27 KiB
PHP
550 lines
27 KiB
PHP
<?php
|
|
$orderRow = is_array($order ?? null) ? $order : [];
|
|
$itemsList = is_array($items ?? null) ? $items : [];
|
|
$addressesList = is_array($addresses ?? null) ? $addresses : [];
|
|
$paymentsList = is_array($payments ?? null) ? $payments : [];
|
|
$shipmentsList = is_array($shipments ?? null) ? $shipments : [];
|
|
$packagesList = is_array($packages ?? null) ? $packages : [];
|
|
$documentsList = is_array($documents ?? null) ? $documents : [];
|
|
$notesList = is_array($notes ?? null) ? $notes : [];
|
|
$historyList = is_array($history ?? null) ? $history : [];
|
|
$activityLogList = is_array($activityLog ?? null) ? $activityLog : [];
|
|
$statusPanelList = is_array($statusPanel ?? null) ? $statusPanel : [];
|
|
$statusPanelTitle = 'Statusy';
|
|
$allStatusesList = is_array($allStatuses ?? null) ? $allStatuses : [];
|
|
$currentStatusCodeValue = (string) ($currentStatusCode ?? '');
|
|
$flashSuccessMsg = (string) ($flashSuccess ?? '');
|
|
$flashErrorMsg = (string) ($flashError ?? '');
|
|
$carrierRaw = (string) ($orderRow['external_carrier_id'] ?? '');
|
|
$carrierDisplay = trim(html_entity_decode(strip_tags($carrierRaw), ENT_QUOTES | ENT_HTML5, 'UTF-8'));
|
|
|
|
$addressByType = [
|
|
'customer' => null,
|
|
'invoice' => null,
|
|
'delivery' => null,
|
|
];
|
|
foreach ($addressesList as $address) {
|
|
$type = (string) ($address['address_type'] ?? '');
|
|
if ($type !== '' && array_key_exists($type, $addressByType) && $addressByType[$type] === null) {
|
|
$addressByType[$type] = $address;
|
|
}
|
|
}
|
|
?>
|
|
|
|
<section class="order-show-layout">
|
|
<?php require __DIR__ . '/../components/order-status-panel.php'; ?>
|
|
|
|
<div class="order-show-main">
|
|
<section class="card order-details-page">
|
|
<div class="order-details-head">
|
|
<div>
|
|
<a href="/orders/list" class="order-back-link">← <?= $e($t('navigation.orders_list')) ?></a>
|
|
<h2 class="section-title mt-12"><?= $e($t('orders.details.title')) ?> <?= $e((string) ($orderRow['internal_order_number'] ?? ('#' . ($orderId ?? 0)))) ?></h2>
|
|
<div class="order-details-sub mt-12">
|
|
<span><?= $e(ucfirst((string) ($orderRow['source'] ?? ''))) ?> <?= $e((string) ($orderRow['external_order_id'] ?? '')) ?></span>
|
|
</div>
|
|
</div>
|
|
<div class="order-details-actions">
|
|
<button type="button" class="btn btn--secondary">Strefa klienta</button>
|
|
<a href="/orders/<?= $e((string) ($orderId ?? 0)) ?>/shipment/prepare" class="btn btn--secondary">Przygotuj przesylke</a>
|
|
<button type="button" class="btn btn--secondary">Platnosc</button>
|
|
<button type="button" class="btn btn--secondary">Drukuj</button>
|
|
<button type="button" class="btn btn--primary">Pakuj</button>
|
|
<button type="button" class="btn btn--secondary">Edytuj</button>
|
|
</div>
|
|
</div>
|
|
<?php if ($flashSuccessMsg !== ''): ?>
|
|
<div class="flash flash--success mt-12"><?= $e($flashSuccessMsg) ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($flashErrorMsg !== ''): ?>
|
|
<div class="flash flash--error mt-12"><?= $e($flashErrorMsg) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="order-status-change mt-12">
|
|
<span class="order-details-pill"><?= $e((string) ($statusLabel ?? '-')) ?></span>
|
|
<?php if ($allStatusesList !== []): ?>
|
|
<form method="post" action="/orders/<?= $e((string) ($orderId ?? 0)) ?>/status" class="order-status-change__form">
|
|
<input type="hidden" name="_token" value="<?= $e((string) ($csrfToken ?? '')) ?>">
|
|
<select name="new_status" class="input input--sm order-status-change__select">
|
|
<option value=""><?= $e($t('orders.details.status_change.placeholder')) ?></option>
|
|
<?php
|
|
$lastGroup = null;
|
|
foreach ($allStatusesList as $statusOption):
|
|
$optCode = (string) ($statusOption['code'] ?? '');
|
|
$optName = (string) ($statusOption['name'] ?? $optCode);
|
|
$optGroup = (string) ($statusOption['group'] ?? '');
|
|
if ($optGroup !== $lastGroup):
|
|
if ($lastGroup !== null): ?>
|
|
</optgroup>
|
|
<?php endif;
|
|
if ($optGroup !== ''): ?>
|
|
<optgroup label="<?= $e($optGroup) ?>">
|
|
<?php endif;
|
|
$lastGroup = $optGroup;
|
|
endif;
|
|
?>
|
|
<option value="<?= $e($optCode) ?>"<?= $optCode === $currentStatusCodeValue ? ' selected' : '' ?>><?= $e($optName) ?></option>
|
|
<?php endforeach;
|
|
if ($lastGroup !== null && $lastGroup !== ''): ?>
|
|
</optgroup>
|
|
<?php endif; ?>
|
|
</select>
|
|
<button type="submit" class="btn btn--primary btn--sm"><?= $e($t('orders.details.status_change.save')) ?></button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="card mt-16 order-details-tabs">
|
|
<button type="button" class="order-details-tab is-active" data-order-tab-target="details"><?= $e($t('orders.details.tabs.details')) ?></button>
|
|
<button type="button" class="order-details-tab" data-order-tab-target="history"><?= $e($t('orders.details.tabs.history')) ?> (<?= $e((string) count($activityLogList)) ?>)</button>
|
|
<button type="button" class="order-details-tab" data-order-tab-target="shipments"><?= $e($t('orders.details.tabs.shipments')) ?> (<?= $e((string) (count($shipmentsList) + count($packagesList))) ?>)</button>
|
|
<button type="button" class="order-details-tab" data-order-tab-target="payments"><?= $e($t('orders.details.tabs.payments')) ?> (<?= $e((string) count($paymentsList)) ?>)</button>
|
|
<button type="button" class="order-details-tab" data-order-tab-target="documents"><?= $e($t('orders.details.tabs.documents')) ?> (<?= $e((string) count($documentsList)) ?>)</button>
|
|
</section>
|
|
|
|
<div class="order-tab-panel is-active" data-order-tab-panel="details">
|
|
<section class="card mt-16">
|
|
<h3 class="section-title"><?= $e($t('orders.details.items_title')) ?> (<?= $e((string) count($itemsList)) ?>)</h3>
|
|
<div class="table-wrap mt-12">
|
|
<table class="table table--details">
|
|
<thead>
|
|
<tr>
|
|
<th>Lp.</th>
|
|
<th><?= $e($t('orders.details.item_name')) ?></th>
|
|
<th>SKU/EAN</th>
|
|
<th><?= $e($t('orders.details.item_qty')) ?></th>
|
|
<th><?= $e($t('orders.details.item_price')) ?></th>
|
|
<th><?= $e($t('orders.details.item_sum')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($itemsList === []): ?>
|
|
<tr><td colspan="6" class="muted"><?= $e($t('orders.empty')) ?></td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($itemsList as $idx => $item): ?>
|
|
<?php
|
|
$qty = (float) ($item['quantity'] ?? 0);
|
|
$price = $item['original_price_with_tax'] !== null ? (float) $item['original_price_with_tax'] : null;
|
|
$sum = $price === null ? null : ($qty * $price);
|
|
$media = trim((string) ($item['media_url'] ?? ''));
|
|
?>
|
|
<tr>
|
|
<td><?= $e((string) ($idx + 1)) ?></td>
|
|
<td>
|
|
<div class="order-item-cell">
|
|
<?php if ($media !== ''): ?>
|
|
<img src="<?= $e($media) ?>" alt="" class="order-item-thumb">
|
|
<?php else: ?>
|
|
<span class="order-item-thumb order-item-thumb--empty"></span>
|
|
<?php endif; ?>
|
|
<div>
|
|
<div class="order-item-name"><?= $e((string) ($item['original_name'] ?? '')) ?></div>
|
|
<div class="muted"><?= $e((string) ($item['item_type'] ?? '')) ?></div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div><?= $e((string) ($item['sku'] ?? '-')) ?></div>
|
|
<div class="muted"><?= $e((string) ($item['ean'] ?? '-')) ?></div>
|
|
</td>
|
|
<td><?= $e((string) $qty) ?></td>
|
|
<td><?= $e($price !== null ? number_format($price, 2, '.', ' ') : '-') ?></td>
|
|
<td><?= $e($sum !== null ? number_format($sum, 2, '.', ' ') : '-') ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mt-16 order-grid-2">
|
|
<article class="card">
|
|
<h3 class="section-title"><?= $e($t('orders.details.order_info')) ?></h3>
|
|
<dl class="order-kv mt-12">
|
|
<dt><?= $e($t('orders.details.fields.status')) ?></dt><dd><?= $e((string) ($statusLabel ?? '-')) ?></dd>
|
|
<dt>Nr zamowienia</dt><dd><strong><?= $e((string) ($orderRow['internal_order_number'] ?? '-')) ?></strong></dd>
|
|
<dt><?= $e($t('orders.details.fields.source_order_id')) ?></dt><dd><?= $e((string) ($orderRow['source_order_id'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.external_order_id')) ?></dt><dd><?= $e((string) ($orderRow['external_order_id'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.ordered_at')) ?></dt><dd><?= $e((string) ($orderRow['ordered_at'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.customer_login')) ?></dt><dd><?= $e((string) ($orderRow['customer_login'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.currency')) ?></dt><dd><?= $e((string) ($orderRow['currency'] ?? '-')) ?></dd>
|
|
</dl>
|
|
</article>
|
|
|
|
<article class="card">
|
|
<h3 class="section-title"><?= $e($t('orders.details.payment_shipping')) ?></h3>
|
|
<dl class="order-kv mt-12">
|
|
<dt><?= $e($t('orders.details.fields.payment_status')) ?></dt><dd><?= $e((string) ($orderRow['payment_status'] ?? '-')) ?></dd>
|
|
<dt>Typ platnosci</dt>
|
|
<dd>
|
|
<?php
|
|
$paymentTypeRaw = strtoupper(trim((string) ($orderRow['external_payment_type_id'] ?? '')));
|
|
$paymentTypeLabels = [
|
|
'CASH_ON_DELIVERY' => 'Za pobraniem',
|
|
'ONLINE' => 'Platnosc online',
|
|
'TRANSFER' => 'Przelew',
|
|
];
|
|
$paymentTypeLabel = $paymentTypeLabels[$paymentTypeRaw] ?? ($paymentTypeRaw !== '' ? $paymentTypeRaw : '-');
|
|
?>
|
|
<?php if ($paymentTypeRaw === 'CASH_ON_DELIVERY'): ?>
|
|
<span class="order-tag is-cod"><?= $e($paymentTypeLabel) ?></span>
|
|
<?php else: ?>
|
|
<?= $e($paymentTypeLabel) ?>
|
|
<?php endif; ?>
|
|
</dd>
|
|
<dt><?= $e($t('orders.details.fields.total_with_tax')) ?></dt><dd><?= $e((string) ($orderRow['total_with_tax'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.total_paid')) ?></dt><dd><?= $e((string) ($orderRow['total_paid'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.carrier')) ?></dt><dd><?= $e($carrierDisplay !== '' ? $carrierDisplay : '-') ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.send_date')) ?></dt><dd><?= $e((string) ($orderRow['send_date_max'] ?? '-')) ?></dd>
|
|
<dt><?= $e($t('orders.details.fields.shipments_count')) ?></dt><dd><?= $e((string) count($shipmentsList)) ?></dd>
|
|
</dl>
|
|
</article>
|
|
</section>
|
|
|
|
<section class="mt-16 order-grid-3">
|
|
<?php foreach (['customer' => $t('orders.details.address_customer'), 'invoice' => $t('orders.details.address_invoice'), 'delivery' => $t('orders.details.address_delivery')] as $addrType => $addrTitle): ?>
|
|
<?php $addr = is_array($addressByType[$addrType] ?? null) ? $addressByType[$addrType] : []; ?>
|
|
<article class="card">
|
|
<h3 class="section-title"><?= $e((string) $addrTitle) ?></h3>
|
|
<div class="order-address mt-12">
|
|
<?php if ($addr === []): ?>
|
|
<?php if ($addrType === 'delivery' && $carrierDisplay !== ''): ?>
|
|
<div><?= $e($carrierDisplay) ?></div>
|
|
<?php else: ?>
|
|
<div class="muted">-</div>
|
|
<?php endif; ?>
|
|
<?php else: ?>
|
|
<div><?= $e((string) ($addr['name'] ?? '')) ?></div>
|
|
<?php
|
|
$invoiceCompanyName = $addrType === 'invoice' ? trim((string) ($addr['company_name'] ?? '')) : '';
|
|
$invoiceName = $addrType === 'invoice' ? trim((string) ($addr['name'] ?? '')) : '';
|
|
?>
|
|
<?php if ($addrType === 'invoice' && $invoiceCompanyName !== '' && $invoiceCompanyName !== $invoiceName): ?>
|
|
<div><?= $e((string) $addr['company_name']) ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($addrType === 'invoice' && !empty($addr['company_tax_number'])): ?>
|
|
<div>NIP: <?= $e((string) $addr['company_tax_number']) ?></div>
|
|
<?php endif; ?>
|
|
<div><?= $e((string) (($addr['street_name'] ?? '') . ' ' . ($addr['street_number'] ?? ''))) ?></div>
|
|
<div><?= $e((string) (($addr['zip_code'] ?? '') . ' ' . ($addr['city'] ?? ''))) ?></div>
|
|
<div><?= $e((string) ($addr['country'] ?? '')) ?></div>
|
|
<?php if ($addrType === 'delivery' && !empty($addr['parcel_name'])): ?>
|
|
<div><?= $e((string) $addr['parcel_name']) ?></div>
|
|
<?php endif; ?>
|
|
<?php if ($addrType === 'delivery' && !empty($addr['parcel_external_id'])): ?>
|
|
<div><?= $e((string) $addr['parcel_external_id']) ?></div>
|
|
<?php endif; ?>
|
|
<div><?= $e((string) ($addr['phone'] ?? '')) ?></div>
|
|
<div><?= $e((string) ($addr['email'] ?? '')) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</section>
|
|
|
|
<section class="mt-16 order-grid-2">
|
|
<article class="card">
|
|
<h3 class="section-title"><?= $e($t('orders.details.notes_title')) ?></h3>
|
|
<div class="order-events mt-12">
|
|
<?php if ($notesList === []): ?>
|
|
<div class="muted">-</div>
|
|
<?php endif; ?>
|
|
<?php foreach ($notesList as $note): ?>
|
|
<div class="order-event">
|
|
<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>
|
|
</article>
|
|
|
|
<article class="card">
|
|
<h3 class="section-title"><?= $e($t('orders.details.history_title')) ?></h3>
|
|
<div class="order-events mt-12">
|
|
<?php if ($historyList === []): ?>
|
|
<div class="muted">-</div>
|
|
<?php endif; ?>
|
|
<?php foreach ($historyList as $event): ?>
|
|
<div class="order-event">
|
|
<div class="order-event__head">
|
|
<?= $e((string) ($event['changed_at'] ?? '')) ?>
|
|
<?php $changeSource = (string) ($event['change_source'] ?? ''); ?>
|
|
<?php if ($changeSource !== ''): ?>
|
|
<span class="muted">(<?= $e($changeSource) ?>)</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="order-event__body"><?= $e((string) ($event['from_label'] ?? '-')) ?> → <?= $e((string) ($event['to_label'] ?? '-')) ?></div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</article>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="order-tab-panel" data-order-tab-panel="history">
|
|
<section class="card mt-16">
|
|
<h3 class="section-title"><?= $e($t('orders.details.tabs.history')) ?></h3>
|
|
<div class="table-wrap mt-12">
|
|
<table class="table table--details">
|
|
<thead>
|
|
<tr>
|
|
<th><?= $e($t('orders.details.activity.date')) ?></th>
|
|
<th><?= $e($t('orders.details.activity.type')) ?></th>
|
|
<th><?= $e($t('orders.details.activity.summary')) ?></th>
|
|
<th><?= $e($t('orders.details.activity.actor')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($activityLogList === []): ?>
|
|
<tr><td colspan="4" class="muted"><?= $e($t('orders.details.activity.empty')) ?></td></tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($activityLogList as $activity): ?>
|
|
<?php
|
|
$eventType = (string) ($activity['event_type'] ?? '');
|
|
$eventTypeKey = 'orders.details.activity.types.' . $eventType;
|
|
$eventTypeLabel = $t($eventTypeKey);
|
|
if ($eventTypeLabel === $eventTypeKey) {
|
|
$eventTypeLabel = $eventType;
|
|
}
|
|
$actorType = (string) ($activity['actor_type'] ?? 'system');
|
|
$actorName = trim((string) ($activity['actor_name'] ?? ''));
|
|
if ($actorName !== '') {
|
|
$actorLabel = $actorName;
|
|
} else {
|
|
$actorKey = 'orders.details.activity.actors.' . $actorType;
|
|
$actorLabel = $t($actorKey);
|
|
if ($actorLabel === $actorKey) {
|
|
$actorLabel = $actorType;
|
|
}
|
|
}
|
|
?>
|
|
<tr>
|
|
<td class="text-nowrap"><?= $e((string) ($activity['created_at'] ?? '')) ?></td>
|
|
<td><span class="activity-type-badge activity-type-badge--<?= $e($eventType) ?>"><?= $e($eventTypeLabel) ?></span></td>
|
|
<td><?= $e((string) ($activity['summary'] ?? '')) ?></td>
|
|
<td class="muted"><?= $e($actorLabel) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="order-tab-panel" data-order-tab-panel="shipments">
|
|
<?php if ($packagesList !== []): ?>
|
|
<section class="card mt-16">
|
|
<h3 class="section-title">Wygenerowane przesylki (WZA)</h3>
|
|
<div class="table-wrap mt-12">
|
|
<table class="table table--details">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Status</th>
|
|
<th>Nr sledzenia</th>
|
|
<th>Przewoznik</th>
|
|
<th>Etykieta</th>
|
|
<th>Utworzono</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($packagesList as $pkg): ?>
|
|
<?php
|
|
$pkgStatus = (string) ($pkg['status'] ?? 'draft');
|
|
$pkgTracking = trim((string) ($pkg['tracking_number'] ?? ''));
|
|
$pkgCarrier = trim((string) ($pkg['carrier_id'] ?? ''));
|
|
$pkgLabelPath = trim((string) ($pkg['label_path'] ?? ''));
|
|
$pkgError = trim((string) ($pkg['error_message'] ?? ''));
|
|
?>
|
|
<tr>
|
|
<td><?= $e((string) ($pkg['id'] ?? '')) ?></td>
|
|
<td>
|
|
<span class="order-tag <?= $pkgStatus === 'label_ready' || $pkgStatus === 'created' ? 'is-success' : ($pkgStatus === 'error' ? 'is-danger' : 'is-warn') ?>">
|
|
<?= $e($pkgStatus) ?>
|
|
</span>
|
|
<?php if ($pkgError !== ''): ?>
|
|
<div class="muted mt-4" style="font-size:0.75rem"><?= $e($pkgError) ?></div>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?= $e($pkgTracking !== '' ? $pkgTracking : '-') ?></td>
|
|
<td><?= $e($pkgCarrier !== '' ? $pkgCarrier : '-') ?></td>
|
|
<td>
|
|
<?php if ($pkgLabelPath !== ''): ?>
|
|
<a href="/orders/<?= $e((string) ($orderId ?? 0)) ?>/shipment/prepare" class="btn btn--sm btn--secondary">Pobierz</a>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</td>
|
|
<td class="text-nowrap"><?= $e((string) ($pkg['created_at'] ?? '')) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($shipmentsList !== []): ?>
|
|
<section class="card mt-16">
|
|
<h3 class="section-title">Wysylki z Allegro</h3>
|
|
<div class="table-wrap mt-12">
|
|
<table class="table table--details">
|
|
<thead>
|
|
<tr>
|
|
<th>Nr sledzenia</th>
|
|
<th>Przewoznik</th>
|
|
<th>Data nadania</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($shipmentsList as $sh): ?>
|
|
<tr>
|
|
<td><?= $e(trim((string) ($sh['tracking_number'] ?? '-'))) ?></td>
|
|
<td><?= $e(trim((string) ($sh['carrier_provider_id'] ?? '-'))) ?></td>
|
|
<td class="text-nowrap"><?= $e(trim((string) ($sh['posted_at'] ?? '-'))) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($packagesList === [] && $shipmentsList === []): ?>
|
|
<section class="card mt-16">
|
|
<h3 class="section-title"><?= $e($t('orders.details.tabs.shipments')) ?></h3>
|
|
<p class="muted mt-12">Brak przesylek dla tego zamowienia.</p>
|
|
</section>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="order-tab-panel" data-order-tab-panel="payments">
|
|
<section class="card mt-16">
|
|
<h3 class="section-title"><?= $e($t('orders.details.tabs.payments')) ?></h3>
|
|
|
|
<?php
|
|
$paymentStatusNum = isset($orderRow['payment_status']) ? (int) $orderRow['payment_status'] : null;
|
|
$paymentStatusLabels = [0 => 'Nieopłacone', 1 => 'Częściowo opłacone', 2 => 'Opłacone', 3 => 'Zwrócone'];
|
|
$paymentStatusClasses = [0 => 'is-danger', 1 => 'is-warn', 2 => 'is-success', 3 => 'is-neutral'];
|
|
$paymentTypeLabels = [
|
|
'ONLINE' => 'Płatność online',
|
|
'CASH_ON_DELIVERY' => 'Za pobraniem',
|
|
'TRANSFER' => 'Przelew bankowy',
|
|
];
|
|
$providerLabels = [
|
|
'AF' => 'Allegro Pay',
|
|
'PAYU' => 'PayU',
|
|
'PRZELEWY24' => 'Przelewy24',
|
|
];
|
|
?>
|
|
|
|
<div class="payment-summary mt-12">
|
|
<div class="payment-summary__row">
|
|
<span class="payment-summary__label">Status płatności</span>
|
|
<span class="payment-summary__value">
|
|
<?php if ($paymentStatusNum !== null && isset($paymentStatusLabels[$paymentStatusNum])): ?>
|
|
<span class="order-tag <?= $e($paymentStatusClasses[$paymentStatusNum] ?? 'is-neutral') ?>">
|
|
<?= $e($paymentStatusLabels[$paymentStatusNum]) ?>
|
|
</span>
|
|
<?php else: ?>
|
|
<span class="muted">—</span>
|
|
<?php endif; ?>
|
|
</span>
|
|
</div>
|
|
<div class="payment-summary__row">
|
|
<span class="payment-summary__label">Kwota do zapłaty</span>
|
|
<span class="payment-summary__value">
|
|
<?= $e($orderRow['total_with_tax'] !== null ? number_format((float) $orderRow['total_with_tax'], 2, '.', ' ') . ' ' . ($orderRow['currency'] ?? '') : '—') ?>
|
|
</span>
|
|
</div>
|
|
<div class="payment-summary__row">
|
|
<span class="payment-summary__label">Kwota opłacona</span>
|
|
<span class="payment-summary__value">
|
|
<?= $e($orderRow['total_paid'] !== null ? number_format((float) $orderRow['total_paid'], 2, '.', ' ') . ' ' . ($orderRow['currency'] ?? '') : '—') ?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($paymentsList === []): ?>
|
|
<p class="muted mt-16">Brak zarejestrowanych płatności.</p>
|
|
<?php else: ?>
|
|
<div class="table-wrap mt-16">
|
|
<table class="table table--details">
|
|
<thead>
|
|
<tr>
|
|
<th>Data płatności</th>
|
|
<th>Typ</th>
|
|
<th>Dostawca</th>
|
|
<th>Kwota</th>
|
|
<th>ID płatności</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($paymentsList as $payment): ?>
|
|
<?php
|
|
$ptRaw = strtoupper(trim((string) ($payment['payment_type_id'] ?? '')));
|
|
$ptLabel = $paymentTypeLabels[$ptRaw] ?? ($ptRaw !== '' ? $ptRaw : '—');
|
|
$providerRaw = strtoupper(trim((string) ($payment['comment'] ?? '')));
|
|
$providerLabel = $providerLabels[$providerRaw] ?? ($providerRaw !== '' ? $providerRaw : '—');
|
|
$amount = $payment['amount'] !== null
|
|
? number_format((float) $payment['amount'], 2, '.', ' ') . ' ' . ($payment['currency'] ?? '')
|
|
: '—';
|
|
$payDate = (string) ($payment['payment_date'] ?? '');
|
|
?>
|
|
<tr>
|
|
<td class="text-nowrap"><?= $e($payDate !== '' ? $payDate : '—') ?></td>
|
|
<td>
|
|
<?php if ($ptRaw === 'CASH_ON_DELIVERY'): ?>
|
|
<span class="order-tag is-cod"><?= $e($ptLabel) ?></span>
|
|
<?php else: ?>
|
|
<?= $e($ptLabel) ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?= $e($providerLabel) ?></td>
|
|
<td class="text-nowrap"><strong><?= $e($amount) ?></strong></td>
|
|
<td class="muted" style="font-size:11px"><?= $e((string) ($payment['source_payment_id'] ?? '—')) ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="order-tab-panel" data-order-tab-panel="documents">
|
|
<section class="card mt-16">
|
|
<h3 class="section-title"><?= $e($t('orders.details.tabs.documents')) ?></h3>
|
|
<div class="order-empty-placeholder mt-12"></div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<script>
|
|
(function () {
|
|
var tabButtons = document.querySelectorAll('[data-order-tab-target]');
|
|
var tabPanels = document.querySelectorAll('[data-order-tab-panel]');
|
|
if (!tabButtons.length || !tabPanels.length) return;
|
|
|
|
function setActiveTab(target) {
|
|
var key = target || 'details';
|
|
tabButtons.forEach(function (btn) {
|
|
btn.classList.toggle('is-active', btn.getAttribute('data-order-tab-target') === key);
|
|
});
|
|
tabPanels.forEach(function (panel) {
|
|
panel.classList.toggle('is-active', panel.getAttribute('data-order-tab-panel') === key);
|
|
});
|
|
}
|
|
|
|
tabButtons.forEach(function (button) {
|
|
button.addEventListener('click', function () {
|
|
setActiveTab(button.getAttribute('data-order-tab-target') || 'details');
|
|
});
|
|
});
|
|
|
|
setActiveTab('details');
|
|
})();
|
|
</script>
|