Pārlūkot izejas kodu

removing code system, moving to ordernumbers

Medowar 2 mēneši atpakaļ
vecāks
revīzija
3d6af28a2f
10 mainītis faili ar 187 papildinājumiem un 124 dzēšanām
  1. 9 16
      admin/backorders.php
  2. 7 16
      admin/index.php
  3. 9 10
      admin/reservations.php
  4. 3 3
      assets/css/style.css
  5. 3 3
      checkout.php
  6. 1 0
      config.php
  7. 7 7
      data/products.json
  8. 76 2
      data/reservations.json
  9. 54 49
      includes/functions.php
  10. 18 18
      reservation.php

+ 9 - 16
admin/backorders.php

@@ -20,24 +20,19 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['notify_available']))
 
 $reservations = getReservations();
 $filter = isset($_GET['filter']) ? sanitize($_GET['filter']) : 'pending';
-$searchCode = isset($_GET['code']) ? sanitize($_GET['code']) : '';
+$searchOrderNumber = isset($_GET['order_number']) ? sanitize($_GET['order_number']) : '';
 
 // Filter backorders
 $reservations = array_filter($reservations, function($r) {
     return isset($r['type']) && $r['type'] === 'backorder';
 });
 
-if ($searchCode) {
-    $reservations = array_filter($reservations, function($r) use ($searchCode) {
-        return stripos($r['code'], $searchCode) !== false || stripos($r['id'], $searchCode) !== false;
+if ($searchOrderNumber) {
+    $reservations = array_filter($reservations, function($r) use ($searchOrderNumber) {
+        return stripos($r['id'], $searchOrderNumber) !== false;
     });
 } else {
     switch ($filter) {
-        case 'notified':
-            $reservations = array_filter($reservations, function($r) {
-                return isset($r['backorder_status']) && $r['backorder_status'] === 'notified';
-            });
-            break;
         case 'pending':
             $reservations = array_filter($reservations, function($r) {
                 return !isset($r['backorder_status']) || $r['backorder_status'] !== 'notified';
@@ -112,14 +107,13 @@ include __DIR__ . '/../includes/header.php';
 <div class="panel">
     <form method="GET" style="display: flex; gap: 1rem; align-items: end; flex-wrap: wrap;">
         <div style="flex: 1; min-width: 200px;">
-            <label for="code">Code/ID suchen:</label>
-            <input type="text" id="code" name="code" value="<?php echo htmlspecialchars($searchCode); ?>" placeholder="Abholcode oder Nachbestellungsnummer">
+            <label for="order_number">Bestellnummer suchen:</label>
+            <input type="text" id="order_number" name="order_number" value="<?php echo htmlspecialchars($searchOrderNumber); ?>" placeholder="Bestellnummer">
         </div>
         <div>
             <label for="filter">Filter:</label>
             <select id="filter" name="filter">
                 <option value="pending" <?php echo $filter === 'pending' ? 'selected' : ''; ?>>Offen</option>
-                <option value="notified" <?php echo $filter === 'notified' ? 'selected' : ''; ?>>Informiert</option>
                 <option value="all" <?php echo $filter === 'all' ? 'selected' : ''; ?>>Alle</option>
             </select>
         </div>
@@ -163,7 +157,7 @@ include __DIR__ . '/../includes/header.php';
     <table>
         <thead>
             <tr>
-                <th>Code</th>
+                <th>Bestellnummer</th>
                 <th>Kunde</th>
                 <th>E-Mail</th>
                 <th>Artikel</th>
@@ -175,7 +169,7 @@ include __DIR__ . '/../includes/header.php';
         <tbody>
             <?php foreach ($reservations as $reservation): ?>
                 <tr>
-                    <td><strong><?php echo htmlspecialchars($reservation['code']); ?></strong></td>
+                    <td><strong><?php echo htmlspecialchars($reservation['id']); ?></strong></td>
                     <td><?php echo htmlspecialchars($reservation['customer_name']); ?></td>
                     <td><?php echo htmlspecialchars($reservation['customer_email']); ?></td>
                     <td>
@@ -249,8 +243,7 @@ function showDetails(reservationId) {
     const statusClass = reservation.backorder_status === 'notified' ? 'status-notified' : 'status-open';
     const html = `
         <h2>Nachbestellungsdetails</h2>
-        <p><strong>Nachbestellungsnummer:</strong> ${reservation.id}</p>
-        <p><strong>Abholcode:</strong> <strong class="code-highlight">${reservation.code}</strong></p>
+        <p><strong>Bestellnummer:</strong> <strong class="order-highlight">${reservation.id}</strong></p>
         <p><strong>Kunde:</strong> ${reservation.customer_name}</p>
         <p><strong>E-Mail:</strong> ${reservation.customer_email}</p>
         <p><strong>Erstellt:</strong> ${reservation.created}</p>

+ 7 - 16
admin/index.php

@@ -36,12 +36,7 @@ $openReservations = count(array_filter($regularReservations, function($r) {
 $pickedUpReservations = count(array_filter($regularReservations, function($r) {
     return $r['picked_up'];
 }));
-$openBackorders = count(array_filter($backorderReservations, function($r) {
-    return !isset($r['backorder_status']) || $r['backorder_status'] !== 'notified';
-}));
-$notifiedBackorders = count(array_filter($backorderReservations, function($r) {
-    return isset($r['backorder_status']) && $r['backorder_status'] === 'notified';
-}));
+$openBackorders = count($backorderReservations);
 
 include __DIR__ . '/../includes/header.php';
 ?>
@@ -82,10 +77,6 @@ include __DIR__ . '/../includes/header.php';
         <div class="stat-value"><?php echo $openBackorders; ?></div>
     </div>
     
-    <div class="stat-card">
-        <h3>Nachbestellungen informiert</h3>
-        <div class="stat-value"><?php echo $notifiedBackorders; ?></div>
-    </div>
 </div>
 
 <h3 style="margin-top: 2rem;">Letzte Reservierungen</h3>
@@ -98,7 +89,7 @@ if (empty($recentReservations)):
     <table>
         <thead>
             <tr>
-                <th>Code</th>
+                <th>Bestellnummer</th>
                 <th>Kunde</th>
                 <th>Erstellt</th>
                 <th>Status</th>
@@ -108,7 +99,7 @@ if (empty($recentReservations)):
         <tbody>
             <?php foreach ($recentReservations as $reservation): ?>
                 <tr>
-                    <td><strong><?php echo htmlspecialchars($reservation['code']); ?></strong></td>
+                    <td><strong><?php echo htmlspecialchars($reservation['id']); ?></strong></td>
                     <td><?php echo htmlspecialchars($reservation['customer_name']); ?></td>
                     <td><?php echo formatDate($reservation['created']); ?></td>
                     <td>
@@ -123,7 +114,7 @@ if (empty($recentReservations)):
                         ?>
                     </td>
                     <td>
-                        <a href="reservations.php?code=<?php echo urlencode($reservation['code']); ?>" class="btn btn-small">Details</a>
+                        <a href="reservations.php?order_number=<?php echo urlencode($reservation['id']); ?>" class="btn btn-small">Details</a>
                     </td>
                 </tr>
             <?php endforeach; ?>
@@ -141,7 +132,7 @@ if (empty($recentBackorders)):
     <table>
         <thead>
             <tr>
-                <th>Code</th>
+                <th>Bestellnummer</th>
                 <th>Kunde</th>
                 <th>Erstellt</th>
                 <th>Status</th>
@@ -151,7 +142,7 @@ if (empty($recentBackorders)):
         <tbody>
             <?php foreach ($recentBackorders as $reservation): ?>
                 <tr>
-                    <td><strong><?php echo htmlspecialchars($reservation['code']); ?></strong></td>
+                    <td><strong><?php echo htmlspecialchars($reservation['id']); ?></strong></td>
                     <td><?php echo htmlspecialchars($reservation['customer_name']); ?></td>
                     <td><?php echo formatDate($reservation['created']); ?></td>
                     <td>
@@ -164,7 +155,7 @@ if (empty($recentBackorders)):
                         ?>
                     </td>
                     <td>
-                        <a href="backorders.php?code=<?php echo urlencode($reservation['code']); ?>" class="btn btn-small">Details</a>
+                        <a href="backorders.php?order_number=<?php echo urlencode($reservation['id']); ?>" class="btn btn-small">Details</a>
                     </td>
                 </tr>
             <?php endforeach; ?>

+ 9 - 10
admin/reservations.php

@@ -23,7 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['mark_picked_up'])) {
 
 $reservations = getReservations();
 $filter = isset($_GET['filter']) ? sanitize($_GET['filter']) : 'all';
-$searchCode = isset($_GET['code']) ? sanitize($_GET['code']) : '';
+$searchOrderNumber = isset($_GET['order_number']) ? sanitize($_GET['order_number']) : '';
 
 // Exclude backorders
 $reservations = array_filter($reservations, function($r) {
@@ -31,9 +31,9 @@ $reservations = array_filter($reservations, function($r) {
 });
 
 // Filter reservations
-if ($searchCode) {
-    $reservations = array_filter($reservations, function($r) use ($searchCode) {
-        return stripos($r['code'], $searchCode) !== false || stripos($r['id'], $searchCode) !== false;
+if ($searchOrderNumber) {
+    $reservations = array_filter($reservations, function($r) use ($searchOrderNumber) {
+        return stripos($r['id'], $searchOrderNumber) !== false;
     });
 } else {
     switch ($filter) {
@@ -76,8 +76,8 @@ include __DIR__ . '/../includes/header.php';
 <div class="panel">
     <form method="GET" style="display: flex; gap: 1rem; align-items: end; flex-wrap: wrap;">
         <div style="flex: 1; min-width: 200px;">
-            <label for="code">Code/ID suchen:</label>
-            <input type="text" id="code" name="code" value="<?php echo htmlspecialchars($searchCode); ?>" placeholder="Abholcode oder Reservierungsnummer">
+            <label for="order_number">Bestellnummer suchen:</label>
+            <input type="text" id="order_number" name="order_number" value="<?php echo htmlspecialchars($searchOrderNumber); ?>" placeholder="Bestellnummer">
         </div>
         <div>
             <label for="filter">Filter:</label>
@@ -103,7 +103,7 @@ include __DIR__ . '/../includes/header.php';
     <table>
         <thead>
             <tr>
-                <th>Code</th>
+                <th>Bestellnummer</th>
                 <th>Kunde</th>
                 <th>E-Mail</th>
                 <th>Artikel</th>
@@ -116,7 +116,7 @@ include __DIR__ . '/../includes/header.php';
         <tbody>
             <?php foreach ($reservations as $reservation): ?>
                 <tr>
-                    <td><strong><?php echo htmlspecialchars($reservation['code']); ?></strong></td>
+                    <td><strong><?php echo htmlspecialchars($reservation['id']); ?></strong></td>
                     <td><?php echo htmlspecialchars($reservation['customer_name']); ?></td>
                     <td><?php echo htmlspecialchars($reservation['customer_email']); ?></td>
                     <td>
@@ -188,8 +188,7 @@ function showDetails(reservationId) {
     const statusClass = reservation.picked_up ? 'status-picked' : (reservation.status === 'expired' ? 'status-expired' : 'status-open');
     const html = `
         <h2>Reservierungsdetails</h2>
-        <p><strong>Reservierungsnummer:</strong> ${reservation.id}</p>
-        <p><strong>Abholcode:</strong> <strong class="code-highlight">${reservation.code}</strong></p>
+        <p><strong>Bestellnummer:</strong> <strong class="order-highlight">${reservation.id}</strong></p>
         <p><strong>Kunde:</strong> ${reservation.customer_name}</p>
         <p><strong>E-Mail:</strong> ${reservation.customer_email}</p>
         <p><strong>Erstellt:</strong> ${reservation.created}</p>

+ 3 - 3
assets/css/style.css

@@ -332,7 +332,7 @@ footer {
 }
 
 /* Reservation Code */
-.reservation-code {
+.order-number {
     background: var(--brand-surface-alt);
     border: 2px solid var(--brand-accent);
     padding: 2rem;
@@ -341,7 +341,7 @@ footer {
     margin: 2rem 0;
 }
 
-.reservation-code h2 {
+.order-number h2 {
     font-size: 2rem;
     color: var(--brand-accent);
     letter-spacing: 0.2rem;
@@ -417,7 +417,7 @@ footer {
     border-color: var(--brand-danger);
 }
 
-.code-highlight {
+.order-highlight {
     font-size: 1.5rem;
     color: var(--brand-accent);
     letter-spacing: 0.2rem;

+ 3 - 3
checkout.php

@@ -96,10 +96,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['create_reservation'])
             $_SESSION['cart'] = [];
             $query = [];
             if ($regularResult && $regularResult['success']) {
-                $query[] = 'code=' . urlencode($regularResult['reservation']['code']);
+                $query[] = 'order_number=' . urlencode($regularResult['reservation']['id']);
             }
             if ($backorderResult && $backorderResult['success']) {
-                $query[] = 'backorder_code=' . urlencode($backorderResult['reservation']['code']);
+                $query[] = 'backorder_number=' . urlencode($backorderResult['reservation']['id']);
             }
             header('Location: reservation.php?' . implode('&', $query));
             exit;
@@ -188,7 +188,7 @@ include __DIR__ . '/includes/header.php';
             </div>
             
             <div class="alert alert-info">
-                <strong>Hinweis:</strong> Nach der Reservierung erhalten Sie einen Abholcode. Für Nachbestellungen informieren wir Sie, sobald die komplette Bestellung zur Abholung bereit ist.
+                <strong>Hinweis:</strong> Nach der Reservierung erhalten Sie eine Bestellnummer. Für Nachbestellungen informieren wir Sie, sobald die komplette Bestellung zur Abholung bereit ist.
             </div>
             
             <button type="submit" name="create_reservation" class="btn" style="width: 100%;">Reservierung abschließen</button>

+ 1 - 0
config.php

@@ -29,6 +29,7 @@ define('ADMIN_USERS', [
 
 // Reservation settings
 define('RESERVATION_EXPIRY_DAYS', 60);
+define('ORDER_PREFIX', 'ORD'); // Prefix for order number pattern: PREFIX-YEAR-SEQ
 
 // Email settings
 define('ADMIN_EMAIL', 'inbox@medowar.de'); // Change to your admin email

+ 7 - 7
data/products.json

@@ -3,13 +3,13 @@
         {
             "id": 1,
             "name": "Feuerwehr T-Shirt",
-            "description": "Hochwertiges T-Shirt aus 100% Baumwolle mit Feuerwehr-Logo. Perfekt für den Alltag oder als Geschenk.\n\nFarbe: Rot",
+            "description": "Hochwertiges T-Shirt aus 100% Baumwolle mit Feuerwehr-Logo. Perfekt für den Alltag oder als Geschenk.\r\n\r\nFarbe: Rot",
             "price": 19.99,
             "category": "apparel",
-            "image": "",
+            "image": "tshirt.jpg",
             "sizes": "S,M,L,XL",
             "stock_by_size": {
-                "S": 12,
+                "S": 10,
                 "M": 15,
                 "L": 18,
                 "XL": 5
@@ -18,13 +18,13 @@
         {
             "id": 2,
             "name": "Feuerwehr Polo-Shirt",
-            "description": "Elegantes Polo-Shirt mit gesticktem Feuerwehr-Emblem. Ideal für offizielle Anlässe.\n\nFarbe: Dunkelblau",
+            "description": "Elegantes Polo-Shirt mit gesticktem Feuerwehr-Emblem. Ideal für offizielle Anlässe.\r\n\r\nFarbe: Dunkelblau",
             "price": 29.99,
             "category": "apparel",
-            "image": "",
+            "image": "poloshirt.jpg",
             "sizes": "S,M,L,XL,XXL",
             "stock_by_size": {
-                "S": 5,
+                "S": 3,
                 "M": 8,
                 "L": 10,
                 "XL": 5,
@@ -95,4 +95,4 @@
             "image": ""
         }
     ]
-}
+}

+ 76 - 2
data/reservations.json

@@ -1,3 +1,77 @@
 {
-    "reservations": []
-}
+    "reservations": [
+        {
+            "id": "RES-2026-001",
+            "code": "6JKXCJ",
+            "customer_name": "Josef Test",
+            "customer_email": "inbox@medowar.de",
+            "items": [
+                {
+                    "product_id": 1,
+                    "quantity": 10,
+                    "size": "S"
+                }
+            ],
+            "created": "2026-02-08 21:03:07",
+            "expires": "2026-04-09 21:03:07",
+            "status": "open",
+            "picked_up": false,
+            "type": "regular"
+        },
+        {
+            "id": "RES-2026-002",
+            "code": "VPVT2Q",
+            "customer_name": "Josef Test",
+            "customer_email": "inbox@medowar.de",
+            "items": [
+                {
+                    "product_id": 1,
+                    "quantity": 2,
+                    "size": "S"
+                }
+            ],
+            "created": "2026-02-08 21:03:30",
+            "expires": "2026-04-09 21:03:30",
+            "status": "open",
+            "picked_up": false,
+            "type": "regular"
+        },
+        {
+            "id": "RES-2026-003",
+            "code": "4ADCGC",
+            "customer_name": "Josef Test",
+            "customer_email": "inbox@medowar.de",
+            "items": [
+                {
+                    "product_id": 2,
+                    "quantity": 2,
+                    "size": "S"
+                }
+            ],
+            "created": "2026-02-08 21:04:10",
+            "expires": "2026-04-09 21:04:10",
+            "status": "picked_up",
+            "picked_up": true,
+            "type": "regular"
+        },
+        {
+            "id": "RES-2026-004",
+            "code": "GNKV6D",
+            "customer_name": "Josef Test",
+            "customer_email": "inbox@medowar.de",
+            "items": [
+                {
+                    "product_id": 1,
+                    "quantity": 10,
+                    "size": "S"
+                }
+            ],
+            "created": "2026-02-08 21:04:12",
+            "expires": "",
+            "status": "open",
+            "picked_up": false,
+            "type": "backorder",
+            "backorder_status": "notified"
+        }
+    ]
+}

+ 54 - 49
includes/functions.php

@@ -65,12 +65,12 @@ function getReservations() {
 }
 
 /**
- * Get reservation by code
+ * Get reservation by order number
  */
-function getReservationByCode($code) {
+function getReservationByOrderNumber($orderNumber) {
     $reservations = getReservations();
     foreach ($reservations as $reservation) {
-        if ($reservation['code'] === $code) {
+        if (isset($reservation['id']) && $reservation['id'] === $orderNumber) {
             return $reservation;
         }
     }
@@ -86,33 +86,30 @@ function saveReservations($reservations) {
 }
 
 /**
- * Generate unique reservation code
- */
-function generateReservationCode() {
-    $code = '';
-    $characters = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // Exclude confusing characters
-    $max = strlen($characters) - 1;
-    
-    do {
-        $code = '';
-        for ($i = 0; $i < 6; $i++) {
-            $code .= $characters[random_int(0, $max)];
-        }
-        // Check if code already exists
-        $existing = getReservationByCode($code);
-    } while ($existing !== null);
-    
-    return $code;
-}
-
-/**
- * Generate reservation ID
+ * Generate order number
+ * Pattern: PREFIX-YEAR-SEQ
  */
 function generateReservationId() {
     $reservations = getReservations();
-    $count = count($reservations) + 1;
     $year = date('Y');
-    return sprintf('RES-%s-%03d', $year, $count);
+    $prefix = defined('ORDER_PREFIX') ? ORDER_PREFIX : 'ORD';
+    $max = 0;
+    $pattern = '/^' . preg_quote($prefix, '/') . '-\\d{4}-(\\d+)$/';
+
+    foreach ($reservations as $reservation) {
+        if (!isset($reservation['id'])) {
+            continue;
+        }
+        if (preg_match($pattern, $reservation['id'], $matches)) {
+            $num = (int)$matches[1];
+            if ($num > $max) {
+                $max = $num;
+            }
+        }
+    }
+
+    $next = $max + 1;
+    return sprintf('%s-%s-%03d', $prefix, $year, $next);
 }
 
 /**
@@ -256,7 +253,6 @@ function createReservation($customerName, $customerEmail, $items) {
     
     $reservation = [
         'id' => generateReservationId(),
-        'code' => generateReservationCode(),
         'customer_name' => $customerName,
         'customer_email' => $customerEmail,
         'items' => $items,
@@ -286,7 +282,6 @@ function createBackorderReservation($customerName, $customerEmail, $items) {
     
     $reservation = [
         'id' => generateReservationId(),
-        'code' => generateReservationCode(),
         'customer_name' => $customerName,
         'customer_email' => $customerEmail,
         'items' => $items,
@@ -377,7 +372,7 @@ function markBackorderAvailable($reservationId) {
     foreach ($reservations as &$reservation) {
         if ($reservation['id'] === $reservationId) {
             if (!isset($reservation['type']) || $reservation['type'] !== 'backorder') {
-                return ['success' => false, 'message' => 'Diese Reservierung ist keine Nachbestellung.'];
+                return ['success' => false, 'message' => 'Diese Nachbestellung wurde bereits in eine Bestellung umgewandelt.'];
             }
             if (isset($reservation['backorder_status']) && $reservation['backorder_status'] === 'notified') {
                 return ['success' => false, 'message' => 'Diese Nachbestellung wurde bereits informiert.'];
@@ -390,8 +385,18 @@ function markBackorderAvailable($reservationId) {
                 $size = isset($item['size']) ? $item['size'] : null;
                 allocateStock($item['product_id'], $item['quantity'], $size);
             }
-            
-            $reservation['backorder_status'] = 'notified';
+
+            $now = new DateTime();
+            $expires = clone $now;
+            $expires->modify('+' . RESERVATION_EXPIRY_DAYS . ' days');
+
+            $reservation['type'] = 'regular';
+            $reservation['status'] = 'open';
+            $reservation['picked_up'] = false;
+            $reservation['expires'] = $expires->format('Y-m-d H:i:s');
+            if (isset($reservation['backorder_status'])) {
+                unset($reservation['backorder_status']);
+            }
             saveReservations($reservations);
             
             sendBackorderAvailableEmail($reservation);
@@ -475,19 +480,19 @@ function sendReservationEmails($reservation) {
             <p>vielen Dank für Ihre Reservierung bei ' . SITE_NAME . '.</p>
             
             <div style="background: #28292a; border: 2px solid #cac300; padding: 1.5rem; margin: 1.5rem 0; border-radius: 8px; text-align: center;">
-                <h3 style="margin-top: 0; color: #f5f7fb;">Ihr Abholcode:</h3>
-                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['code']) . '</h2>
+                <h3 style="margin-top: 0; color: #f5f7fb;">Ihre Bestellnummer:</h3>
+                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['id']) . '</h2>
             </div>
             
             <h3>Reservierungsdetails:</h3>
-            <p><strong>Reservierungsnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
+            <p><strong>Bestellnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
             <p><strong>Erstellt am:</strong> ' . formatDate($reservation['created']) . '</p>
             <p><strong>Gültig bis:</strong> ' . formatDate($reservation['expires']) . '</p>
             
             <h3>Reservierte Artikel:</h3>
             ' . $itemsHtml . '
             
-            <p><strong>Wichtig:</strong> Bitte bringen Sie diesen Abholcode zur Abholung mit. Die Reservierung ist bis zum ' . formatDate($reservation['expires']) . ' gültig.</p>
+            <p><strong>Wichtig:</strong> Bitte nennen Sie diese Bestellnummer bei der Abholung. Die Reservierung ist bis zum ' . formatDate($reservation['expires']) . ' gültig.</p>
             
             <p>Mit freundlichen Grüßen<br>' . SITE_NAME . '</p>
         </div>
@@ -497,7 +502,7 @@ function sendReservationEmails($reservation) {
     sendEmail($reservation['customer_email'], $customerSubject, $customerMessage);
     
     // Admin email
-    $adminSubject = 'Neue Reservierung: ' . $reservation['code'];
+    $adminSubject = 'Neue Reservierung: ' . $reservation['id'];
     $adminMessage = '
     <html>
     <head>
@@ -509,8 +514,8 @@ function sendReservationEmails($reservation) {
             <p>Eine neue Reservierung wurde erstellt:</p>
             
             <div style="background: #28292a; border: 2px solid #cac300; padding: 1.5rem; margin: 1.5rem 0; border-radius: 8px;">
-                <h3 style="margin-top: 0;">Abholcode:</h3>
-                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['code']) . '</h2>
+                <h3 style="margin-top: 0;">Bestellnummer:</h3>
+                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['id']) . '</h2>
             </div>
             
             <h3>Kundendaten:</h3>
@@ -518,7 +523,7 @@ function sendReservationEmails($reservation) {
             <p><strong>E-Mail:</strong> ' . htmlspecialchars($reservation['customer_email']) . '</p>
             
             <h3>Reservierungsdetails:</h3>
-            <p><strong>Reservierungsnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
+            <p><strong>Bestellnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
             <p><strong>Erstellt am:</strong> ' . formatDate($reservation['created']) . '</p>
             <p><strong>Gültig bis:</strong> ' . formatDate($reservation['expires']) . '</p>
             
@@ -563,12 +568,12 @@ function sendBackorderEmails($reservation) {
             <p>vielen Dank für Ihre Nachbestellung bei ' . SITE_NAME . '.</p>
             
             <div style="background: #28292a; border: 2px solid #cac300; padding: 1.5rem; margin: 1.5rem 0; border-radius: 8px; text-align: center;">
-                <h3 style="margin-top: 0; color: #f5f7fb;">Ihr Abholcode:</h3>
-                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['code']) . '</h2>
+                <h3 style="margin-top: 0; color: #f5f7fb;">Ihre Bestellnummer:</h3>
+                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['id']) . '</h2>
             </div>
             
             <h3>Nachbestellungsdetails:</h3>
-            <p><strong>Nachbestellungsnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
+            <p><strong>Bestellnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
             <p><strong>Erstellt am:</strong> ' . formatDate($reservation['created']) . '</p>
             
             <h3>Nachbestellte Artikel:</h3>
@@ -588,7 +593,7 @@ function sendBackorderEmails($reservation) {
     sendEmail($reservation['customer_email'], $customerSubject, $customerMessage);
     
     // Admin email
-    $adminSubject = 'Neue Nachbestellung: ' . $reservation['code'];
+    $adminSubject = 'Neue Nachbestellung: ' . $reservation['id'];
     $adminMessage = '
     <html>
     <head>
@@ -600,8 +605,8 @@ function sendBackorderEmails($reservation) {
             <p>Eine neue Nachbestellung wurde erstellt:</p>
             
             <div style="background: #28292a; border: 2px solid #cac300; padding: 1.5rem; margin: 1.5rem 0; border-radius: 8px;">
-                <h3 style="margin-top: 0;">Abholcode:</h3>
-                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['code']) . '</h2>
+                <h3 style="margin-top: 0;">Bestellnummer:</h3>
+                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['id']) . '</h2>
             </div>
             
             <h3>Kundendaten:</h3>
@@ -609,7 +614,7 @@ function sendBackorderEmails($reservation) {
             <p><strong>E-Mail:</strong> ' . htmlspecialchars($reservation['customer_email']) . '</p>
             
             <h3>Nachbestellungsdetails:</h3>
-            <p><strong>Nachbestellungsnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
+            <p><strong>Bestellnummer:</strong> ' . htmlspecialchars($reservation['id']) . '</p>
             <p><strong>Erstellt am:</strong> ' . formatDate($reservation['created']) . '</p>
             
             <h3>Nachbestellte Artikel:</h3>
@@ -653,14 +658,14 @@ function sendBackorderAvailableEmail($reservation) {
             <p>Ihre komplette Nachbestellung ist jetzt zur Abholung bereit.</p>
             
             <div style="background: #28292a; border: 2px solid #cac300; padding: 1.5rem; margin: 1.5rem 0; border-radius: 8px; text-align: center;">
-                <h3 style="margin-top: 0; color: #f5f7fb;">Ihr Abholcode:</h3>
-                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['code']) . '</h2>
+                <h3 style="margin-top: 0; color: #f5f7fb;">Ihre Bestellnummer:</h3>
+                <h2 style="font-size: 2rem; letter-spacing: 0.2rem; color: #cac300; font-family: monospace;">' . htmlspecialchars($reservation['id']) . '</h2>
             </div>
             
             <h3>Bereitliegende Artikel:</h3>
             ' . $itemsHtml . '
             
-            <p>Bitte bringen Sie den Abholcode zur Abholung mit.</p>
+            <p>Bitte nennen Sie die Bestellnummer bei der Abholung.</p>
             
             <p>Mit freundlichen Grüßen<br>' . SITE_NAME . '</p>
         </div>

+ 18 - 18
reservation.php

@@ -4,16 +4,16 @@ require_once __DIR__ . '/includes/functions.php';
 
 $pageTitle = 'Reservierung bestätigt';
 
-$code = isset($_GET['code']) ? sanitize($_GET['code']) : '';
-$backorderCode = isset($_GET['backorder_code']) ? sanitize($_GET['backorder_code']) : '';
+$orderNumber = isset($_GET['order_number']) ? sanitize($_GET['order_number']) : '';
+$backorderNumber = isset($_GET['backorder_number']) ? sanitize($_GET['backorder_number']) : '';
 $reservation = null;
 $backorderReservation = null;
 
-if ($code) {
-    $reservation = getReservationByCode($code);
+if ($orderNumber) {
+    $reservation = getReservationByOrderNumber($orderNumber);
 }
-if ($backorderCode) {
-    $backorderReservation = getReservationByCode($backorderCode);
+if ($backorderNumber) {
+    $backorderReservation = getReservationByOrderNumber($backorderNumber);
 }
 
 if (!$reservation && !$backorderReservation) {
@@ -46,7 +46,7 @@ include __DIR__ . '/includes/header.php';
     body {
         padding: 20px;
     }
-    .reservation-code {
+    .order-number {
         page-break-inside: avoid;
     }
     table {
@@ -62,16 +62,16 @@ include __DIR__ . '/includes/header.php';
         <p>Vielen Dank für Ihre Reservierung, <?php echo htmlspecialchars($reservation['customer_name']); ?>.</p>
     </div>
 
-    <div class="reservation-code">
-        <h3>Ihr Abholcode:</h3>
-        <h2><?php echo htmlspecialchars($reservation['code']); ?></h2>
-        <p>Bitte notieren Sie sich diesen Code und zeigen Sie ihn bei der Abholung vor.</p>
+    <div class="order-number">
+        <h3>Ihre Bestellnummer:</h3>
+        <h2><?php echo htmlspecialchars($reservation['id']); ?></h2>
+        <p>Bitte notieren Sie sich diese Bestellnummer und nennen Sie sie bei der Abholung.</p>
     </div>
 
     <div class="panel" style="padding: 2rem; margin: 2rem 0;">
         <h3>Reservierungsdetails</h3>
         
-        <p><strong>Reservierungsnummer:</strong> <?php echo htmlspecialchars($reservation['id']); ?></p>
+        <p><strong>Bestellnummer:</strong> <?php echo htmlspecialchars($reservation['id']); ?></p>
         <p><strong>Name:</strong> <?php echo htmlspecialchars($reservation['customer_name']); ?></p>
         <p><strong>E-Mail:</strong> <?php echo htmlspecialchars($reservation['customer_email']); ?></p>
         <p><strong>Erstellt am:</strong> <?php echo formatDate($reservation['created']); ?></p>
@@ -103,7 +103,7 @@ include __DIR__ . '/includes/header.php';
     </div>
 
     <div class="alert alert-info">
-        <p><strong>Wichtig:</strong> Bitte bringen Sie diesen Abholcode zur Abholung mit. Die Reservierung ist bis zum <?php echo formatDate($reservation['expires']); ?> gültig.</p>
+        <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>
     </div>
 <?php endif; ?>
 
@@ -114,16 +114,16 @@ include __DIR__ . '/includes/header.php';
         <p>Vielen Dank für Ihre Nachbestellung, <?php echo htmlspecialchars($backorderReservation['customer_name']); ?>.</p>
     </div>
 
-    <div class="reservation-code">
-        <h3>Ihr Abholcode:</h3>
-        <h2><?php echo htmlspecialchars($backorderReservation['code']); ?></h2>
-        <p>Bitte notieren Sie sich diesen Code. Wir informieren Sie, sobald die komplette Nachbestellung zur Abholung bereit ist.</p>
+    <div class="order-number">
+        <h3>Ihre Bestellnummer:</h3>
+        <h2><?php echo htmlspecialchars($backorderReservation['id']); ?></h2>
+        <p>Bitte notieren Sie sich diese Bestellnummer. Wir informieren Sie, sobald die komplette Nachbestellung zur Abholung bereit ist.</p>
     </div>
 
     <div class="panel" style="padding: 2rem; margin: 2rem 0;">
         <h3>Nachbestellungsdetails</h3>
         
-        <p><strong>Nachbestellungsnummer:</strong> <?php echo htmlspecialchars($backorderReservation['id']); ?></p>
+        <p><strong>Bestellnummer:</strong> <?php echo htmlspecialchars($backorderReservation['id']); ?></p>
         <p><strong>Name:</strong> <?php echo htmlspecialchars($backorderReservation['customer_name']); ?></p>
         <p><strong>E-Mail:</strong> <?php echo htmlspecialchars($backorderReservation['customer_email']); ?></p>
         <p><strong>Erstellt am:</strong> <?php echo formatDate($backorderReservation['created']); ?></p>