'Oczekujące', 'status_pending_payment' => 'Oczekuje na płatność', 'status_paid' => 'Zapłacone', 'status_in_progress' => 'W realizacji', 'status_shipped' => 'Wysłane', 'status_partially_shipped' => 'Częściowo wysłane', 'status_completed' => 'Zrealizowane', 'status_cancelled' => 'Anulowane', 'payment_bank_transfer' => 'Przelew tradycyjny', 'payment_online' => 'Płatność online (Przelewy24)', 'payment_credit' => 'Kredyt kupiecki', ]; $payment_methods = ['bank_transfer', 'online', 'credit']; if (in_array($key, $payment_methods)) { $translation_key = 'payment_' . $key; } else { $translation_key = 'status_' . $key; } return $translations[$translation_key] ?? ucfirst(str_replace('_', ' ', $key)); } $order_id = isset($_GET['id']) ? (int)$_GET['id'] : 0; if ($order_id === 0) { header('Location: orders.php'); exit; } $client_id = $_SESSION['client_id'] ?? 0; $error_message = null; $order = null; $order_items = []; $product_images = []; if ($client_id === 0) { $error_message = 'Brak uprawnień do wyświetlenia tego zamówienia.'; } else { try { $pdo = db(); $stmt = $pdo->prepare('SELECT * FROM orders WHERE id = :order_id AND client_id = :client_id'); $stmt->execute([':order_id' => $order_id, ':client_id' => $client_id]); $order = $stmt->fetch(); if (!$order) { $error_message = 'Nie znaleziono zamówienia lub nie masz do niego dostępu.'; } else { $stmt = $pdo->prepare( 'SELECT oi.*, p.name as product_name FROM order_items oi JOIN products p ON oi.product_id = p.id WHERE oi.order_id = ?' ); $stmt->execute([$order_id]); $order_items = $stmt->fetchAll(); if (!empty($order_items)) { $product_ids = array_map(fn($item) => $item['product_id'], $order_items); $placeholders = implode(',', array_fill(0, count($product_ids), '?')); $image_stmt = $pdo->prepare( "SELECT product_id, file_path, is_primary, id FROM product_images WHERE product_id IN ($placeholders) ORDER BY product_id, is_primary DESC, id ASC" ); $image_stmt->execute($product_ids); $images_data = $image_stmt->fetchAll(); $product_images_temp = []; foreach ($images_data as $image) { if (!isset($product_images_temp[$image['product_id']])) { $product_images_temp[$image['product_id']] = 'uploads/products/' . $image['product_id'] . '/' . basename($image['file_path']); } } $product_images = $product_images_temp; } } } catch (PDOException $e) { $error_message = 'Błąd bazy danych. Prosimy spróbować ponownie później.'; error_log($e->getMessage()); } } $page_title = $order ? 'Szczegóły zamówienia #' . $order['id'] : 'Szczegóły zamówienia'; $user_role = get_user_role(); $lang = 'pl'; ?> <?php echo htmlspecialchars($page_title); ?> - B2B Commerce
Wróć do listy zamówień

Podsumowanie

Data zamówienia:

Status:

Metoda płatności:

Suma (brutto):

Uwagi:

Szczegóły zamówienia
Zdjęcie Produkt Cena jedn. netto Cena jedn. brutto Ilość Suma (brutto)
<?php echo htmlspecialchars($item['product_name']); ?>
Wróć do listy zamówień