Selaa lähdekoodia

enhance backorder management in admin panel with new statistics and recent orders display

Medowar 2 kuukautta sitten
vanhempi
sitoutus
10a100e131
1 muutettua tiedostoa jossa 60 lisäystä ja 0 poistoa
  1. 60 0
      admin/index.php

+ 60 - 0
admin/index.php

@@ -21,6 +21,9 @@ $reservations = getReservations(); // Refresh after expiry
 $regularReservations = array_filter($reservations, function($r) {
     return !isset($r['type']) || $r['type'] !== 'backorder';
 });
+$backorderReservations = array_filter($reservations, function($r) {
+    return isset($r['type']) && $r['type'] === 'backorder';
+});
 
 $totalProducts = count($products);
 $totalStock = 0;
@@ -33,6 +36,12 @@ $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';
+}));
 
 include __DIR__ . '/../includes/header.php';
 ?>
@@ -67,6 +76,16 @@ include __DIR__ . '/../includes/header.php';
         <h3>Abgeholt</h3>
         <div class="stat-value"><?php echo $pickedUpReservations; ?></div>
     </div>
+    
+    <div class="stat-card">
+        <h3>Offene Nachbestellungen</h3>
+        <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>
@@ -112,4 +131,45 @@ if (empty($recentReservations)):
     </table>
 <?php endif; ?>
 
+<h3 style="margin-top: 2rem;">Letzte Nachbestellungen</h3>
+<?php
+$recentBackorders = array_slice(array_reverse($backorderReservations), 0, 5);
+if (empty($recentBackorders)):
+?>
+    <p>Keine Nachbestellungen vorhanden.</p>
+<?php else: ?>
+    <table>
+        <thead>
+            <tr>
+                <th>Code</th>
+                <th>Kunde</th>
+                <th>Erstellt</th>
+                <th>Status</th>
+                <th>Aktionen</th>
+            </tr>
+        </thead>
+        <tbody>
+            <?php foreach ($recentBackorders as $reservation): ?>
+                <tr>
+                    <td><strong><?php echo htmlspecialchars($reservation['code']); ?></strong></td>
+                    <td><?php echo htmlspecialchars($reservation['customer_name']); ?></td>
+                    <td><?php echo formatDate($reservation['created']); ?></td>
+                    <td>
+                        <?php
+                        if (isset($reservation['backorder_status']) && $reservation['backorder_status'] === 'notified') {
+                            echo '<span style="color: #28a745;">Informiert</span>';
+                        } else {
+                            echo '<span style="color: #ffc107;">Offen</span>';
+                        }
+                        ?>
+                    </td>
+                    <td>
+                        <a href="backorders.php?code=<?php echo urlencode($reservation['code']); ?>" class="btn btn-small">Details</a>
+                    </td>
+                </tr>
+            <?php endforeach; ?>
+        </tbody>
+    </table>
+<?php endif; ?>
+
 <?php include __DIR__ . '/../includes/footer.php'; ?>