order-pdf.php 696 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. require_once __DIR__ . "/../config.php";
  3. require_once __DIR__ . "/../includes/functions.php";
  4. if (empty($_SESSION['admin_logged_in'])) {
  5. header("Location: login.php");
  6. exit();
  7. }
  8. $orderId = trim((string) ($_GET['id'] ?? ""));
  9. if ($orderId === "") {
  10. http_response_code(400);
  11. header("Content-Type: text/plain; charset=UTF-8");
  12. echo "Keine Bestellnummer angegeben.";
  13. exit();
  14. }
  15. $order = getOrderById($orderId);
  16. if ($order === null) {
  17. http_response_code(404);
  18. header("Content-Type: text/plain; charset=UTF-8");
  19. echo "Bestellung nicht gefunden.";
  20. exit();
  21. }
  22. streamOrderPdf(
  23. $order,
  24. "bestellung-" . strtolower($order["id"]) . ".pdf",
  25. true,
  26. );