reservation.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. require_once __DIR__ . '/config.php';
  3. require_once __DIR__ . '/includes/functions.php';
  4. $pageTitle = 'Reservierung bestätigt';
  5. $orderNumber = isset($_GET['order_number']) ? sanitize($_GET['order_number']) : '';
  6. $backorderNumber = isset($_GET['backorder_number']) ? sanitize($_GET['backorder_number']) : '';
  7. $reservation = null;
  8. $backorderReservation = null;
  9. if ($orderNumber) {
  10. $reservation = getReservationByOrderNumber($orderNumber);
  11. }
  12. if ($backorderNumber) {
  13. $backorderReservation = getReservationByOrderNumber($backorderNumber);
  14. }
  15. if (!$reservation && !$backorderReservation) {
  16. header('Location: index.php');
  17. exit;
  18. }
  19. function buildReservationItems($reservation) {
  20. $items = [];
  21. foreach ($reservation['items'] as $item) {
  22. $product = getProductById($item['product_id']);
  23. if ($product) {
  24. $items[] = [
  25. 'product' => $product,
  26. 'quantity' => $item['quantity'],
  27. 'size' => isset($item['size']) ? $item['size'] : null
  28. ];
  29. }
  30. }
  31. return $items;
  32. }
  33. include __DIR__ . '/includes/header.php';
  34. ?>
  35. <style media="print">
  36. header, footer, .btn, nav {
  37. display: none !important;
  38. }
  39. body {
  40. padding: 20px;
  41. }
  42. .order-number {
  43. page-break-inside: avoid;
  44. }
  45. table {
  46. page-break-inside: avoid;
  47. }
  48. </style>
  49. <?php if ($reservation): ?>
  50. <?php $items = buildReservationItems($reservation); ?>
  51. <div class="alert alert-success">
  52. <h2>Reservierung erfolgreich!</h2>
  53. <p>Vielen Dank für Ihre Reservierung, <?php echo htmlspecialchars($reservation['customer_name']); ?>.</p>
  54. </div>
  55. <div class="order-number">
  56. <h3>Ihre Bestellnummer:</h3>
  57. <h2><?php echo htmlspecialchars($reservation['id']); ?></h2>
  58. <p>Bitte notieren Sie sich diese Bestellnummer und nennen Sie sie bei der Abholung.</p>
  59. </div>
  60. <div class="panel" style="padding: 2rem; margin: 2rem 0;">
  61. <h3>Reservierungsdetails</h3>
  62. <p><strong>Bestellnummer:</strong> <?php echo htmlspecialchars($reservation['id']); ?></p>
  63. <p><strong>Name:</strong> <?php echo htmlspecialchars($reservation['customer_name']); ?></p>
  64. <p><strong>E-Mail:</strong> <?php echo htmlspecialchars($reservation['customer_email']); ?></p>
  65. <p><strong>Erstellt am:</strong> <?php echo formatDate($reservation['created']); ?></p>
  66. <p><strong>Gültig bis:</strong> <?php echo formatDate($reservation['expires']); ?></p>
  67. <h4 style="margin-top: 1.5rem;">Reservierte Artikel:</h4>
  68. <table style="margin-top: 1rem;">
  69. <thead>
  70. <tr>
  71. <th>Produkt</th>
  72. <?php if (array_filter($items, function($i) { return !empty($i['size']); })): ?>
  73. <th>Größe</th>
  74. <?php endif; ?>
  75. <th>Menge</th>
  76. </tr>
  77. </thead>
  78. <tbody>
  79. <?php foreach ($items as $item): ?>
  80. <tr>
  81. <td><?php echo htmlspecialchars($item['product']['name']); ?></td>
  82. <?php if (array_filter($items, function($i) { return !empty($i['size']); })): ?>
  83. <td><?php echo isset($item['size']) && !empty($item['size']) ? htmlspecialchars($item['size']) : '-'; ?></td>
  84. <?php endif; ?>
  85. <td><?php echo $item['quantity']; ?></td>
  86. </tr>
  87. <?php endforeach; ?>
  88. </tbody>
  89. </table>
  90. </div>
  91. <div class="alert alert-info">
  92. <p><strong>Wichtig:</strong> Bitte nennen Sie die Bestellnummer bei der Abholung. Die Reservierung ist bis zum <?php echo formatDate($reservation['expires']); ?> gültig.</p>
  93. </div>
  94. <?php endif; ?>
  95. <?php if ($backorderReservation): ?>
  96. <?php $backorderItems = buildReservationItems($backorderReservation); ?>
  97. <div class="alert alert-warning" style="margin-top: 2rem;">
  98. <h2>Nachbestellung bestätigt</h2>
  99. <p>Vielen Dank für Ihre Nachbestellung, <?php echo htmlspecialchars($backorderReservation['customer_name']); ?>.</p>
  100. </div>
  101. <div class="order-number">
  102. <h3>Ihre Bestellnummer:</h3>
  103. <h2><?php echo htmlspecialchars($backorderReservation['id']); ?></h2>
  104. <p>Bitte notieren Sie sich diese Bestellnummer. Wir informieren Sie, sobald die komplette Nachbestellung zur Abholung bereit ist.</p>
  105. </div>
  106. <div class="panel" style="padding: 2rem; margin: 2rem 0;">
  107. <h3>Nachbestellungsdetails</h3>
  108. <p><strong>Bestellnummer:</strong> <?php echo htmlspecialchars($backorderReservation['id']); ?></p>
  109. <p><strong>Name:</strong> <?php echo htmlspecialchars($backorderReservation['customer_name']); ?></p>
  110. <p><strong>E-Mail:</strong> <?php echo htmlspecialchars($backorderReservation['customer_email']); ?></p>
  111. <p><strong>Erstellt am:</strong> <?php echo formatDate($backorderReservation['created']); ?></p>
  112. <h4 style="margin-top: 1.5rem;">Nachbestellte Artikel:</h4>
  113. <table style="margin-top: 1rem;">
  114. <thead>
  115. <tr>
  116. <th>Produkt</th>
  117. <?php if (array_filter($backorderItems, function($i) { return !empty($i['size']); })): ?>
  118. <th>Größe</th>
  119. <?php endif; ?>
  120. <th>Menge</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. <?php foreach ($backorderItems as $item): ?>
  125. <tr>
  126. <td><?php echo htmlspecialchars($item['product']['name']); ?></td>
  127. <?php if (array_filter($backorderItems, function($i) { return !empty($i['size']); })): ?>
  128. <td><?php echo isset($item['size']) && !empty($item['size']) ? htmlspecialchars($item['size']) : '-'; ?></td>
  129. <?php endif; ?>
  130. <td><?php echo $item['quantity']; ?></td>
  131. </tr>
  132. <?php endforeach; ?>
  133. </tbody>
  134. </table>
  135. </div>
  136. <div class="alert alert-warning">
  137. <p><strong>Hinweis:</strong> Lieferzeiten sind nicht bekannt, da die Bestellung in Chargen erfolgt.</p>
  138. </div>
  139. <?php endif; ?>
  140. <div style="text-align: center; margin-top: 2rem;">
  141. <button onclick="window.print()" class="btn">Reservierung drucken</button>
  142. <a href="index.php" class="btn btn-secondary" style="margin-left: 1rem;">Zurück zur Startseite</a>
  143. </div>
  144. <?php include __DIR__ . '/includes/footer.php'; ?>