<?php
session_start();
$host = "localhost";
$user = "yoveraes_userdb";
$pass =  "t7@s5FxYn1GB";
$db = "yoveraes_botica";
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
    die("Error de conexión: " . $conn->connect_error);
}
require 'fpdf/fpdf.php';

$id_pedido = $_GET['id'] ?? '';
$pedido = $conn->query("SELECT * FROM ventas WHERE id='$id_pedido'")->fetch_assoc();
$detalles = $conn->query("SELECT * FROM detalle_ventas WHERE id_venta='$id_pedido'");

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(40, 10, 'Factura/Boleta');
$pdf->Ln(10);
$pdf->Cell(40, 10, "Numero: " . $pedido['num_docpe']);
$pdf->Ln(10);
while ($row = $detalles->fetch_assoc()) {
    $pdf->Cell(40, 10, $row['presentacion'] . ' - ' . $row['cantidad'] . ' - ' . $row['precio']);
    $pdf->Ln(5);
}
$pdf->Output();
?>