prepare("SELECT p.* FROM products p WHERE p.id = :product_id"); $stmt->execute(['product_id' => $product_id]); $product = $stmt->fetch(PDO::FETCH_ASSOC); if (!$product) { header('Location: index.php'); exit; } // Get the correct price pair using the centralized function $prices = getEffectivePrice($pdo, $product['id'], $_SESSION['client_id'] ?? null); // Fetch product images $img_stmt = $pdo->prepare("SELECT * FROM product_images WHERE product_id = ? ORDER BY is_primary DESC, id ASC"); $img_stmt->execute([$product_id]); $product_images = $img_stmt->fetchAll(PDO::FETCH_ASSOC); $primary_image = $product_images[0] ?? null; } catch (PDOException $e) { die(t('db_connection_error') . $e->getMessage()); } $page_title = htmlspecialchars($product['name']); require_once __DIR__ . '/includes/html_head.php'; require_once __DIR__ . '/includes/header.php'; ?>
<?= htmlspecialchars($product['name']) ?>
1): ?>


:

prepare("SELECT ak.name, pa.value FROM product_attributes pa JOIN attribute_keys ak ON pa.attribute_key_id = ak.id WHERE pa.product_id = ? AND pa.value IS NOT NULL AND pa.value != '' ORDER BY ak.name"); $attrs_stmt->execute([$product_id]); $product_attributes = $attrs_stmt->fetchAll(PDO::FETCH_ASSOC); if ($product_attributes) { echo ''; echo ''; foreach ($product_attributes as $attr) { echo ''; echo ''; echo ''; echo ''; } echo ''; echo '
' . htmlspecialchars($attr['name']) . '' . htmlspecialchars($attr['value']) . '
'; } else { echo '

' . t('no_technical_data') . '

'; } ?>
prepare("SELECT * FROM product_documents WHERE product_id = ?"); $docs_stmt->execute([$product_id]); $product_documents = $docs_stmt->fetchAll(PDO::FETCH_ASSOC); if ($product_documents) { echo ''; } else { echo '

' . t('no_documents') . '

'; } ?>