فهرست منبع

adding open products to admin

Medowar 6 روز پیش
والد
کامیت
3b405b0e2e
1فایلهای تغییر یافته به همراه71 افزوده شده و 1 حذف شده
  1. 71 1
      admin/index.php

+ 71 - 1
admin/index.php

@@ -42,7 +42,40 @@ $recentOrders = $orders;
 usort($recentOrders, function ($left, $right) {
     return strcmp($right['created_at'], $left['created_at']);
 });
-$recentOrders = array_slice($recentOrders, 0, 8);
+$recentOrders = array_slice($recentOrders, 0, 5);
+
+$outstandingItems = [];
+foreach ($orders as $order) {
+    $label = getOrderStatusLabel($order);
+    if ($label !== 'Offen' && $label !== 'Teilweise bearbeitet') {
+        continue;
+    }
+    foreach ($order['items'] as $item) {
+        if (!empty($item['is_processed'])) {
+            continue;
+        }
+        $outstandingItems[] = [
+            'order_id' => $order['id'],
+            'customer_name' => $order['customer_name'],
+            'organization_label' => $order['organization_label'],
+            'created_at' => $order['created_at'],
+            'product_name' => $item['product_name'],
+            'size' => $item['size'],
+            'availability_label' => $item['availability_label'],
+        ];
+    }
+}
+usort($outstandingItems, function ($left, $right) {
+    $cmp = strcmp($left['created_at'], $right['created_at']);
+    if ($cmp !== 0) {
+        return $cmp;
+    }
+    $cmp = strcmp($left['order_id'], $right['order_id']);
+    if ($cmp !== 0) {
+        return $cmp;
+    }
+    return strcmp($left['product_name'], $right['product_name']);
+});
 
 $bodyClass = 'admin-page';
 include __DIR__ . '/../includes/header.php';
@@ -134,4 +167,41 @@ include __DIR__ . '/../includes/header.php';
     </div>
 <?php endif; ?>
 
+<h3 class="section-title mt-4">Offene Positionen</h3>
+
+<?php if (empty($outstandingItems)): ?>
+    <p>Keine offenen Positionen vorhanden.</p>
+<?php else: ?>
+    <div class="table-responsive">
+        <table class="responsive-table">
+            <thead>
+                <tr>
+                    <th>Bestellnummer</th>
+                    <th>Name</th>
+                    <th>Organisation</th>
+                    <th>Artikel</th>
+                    <th>Größe</th>
+                    <th>Lieferhinweis</th>
+                    <th>Erstellt</th>
+                    <th>Aktionen</th>
+                </tr>
+            </thead>
+            <tbody>
+                <?php foreach ($outstandingItems as $row): ?>
+                    <tr>
+                        <td data-label="Bestellnummer"><strong><?php echo escape($row['order_id']); ?></strong></td>
+                        <td data-label="Name"><?php echo escape($row['customer_name']); ?></td>
+                        <td data-label="Organisation"><?php echo escape($row['organization_label']); ?></td>
+                        <td data-label="Artikel"><?php echo escape($row['product_name']); ?></td>
+                        <td data-label="Größe"><?php echo $row['size'] !== '' ? escape($row['size']) : '-'; ?></td>
+                        <td data-label="Lieferhinweis"><?php echo $row['availability_label'] !== '' ? escape($row['availability_label']) : '-'; ?></td>
+                        <td data-label="Erstellt"><?php echo escape(formatDate($row['created_at'])); ?></td>
+                        <td data-label="Aktionen"><a href="orders.php?details=<?php echo urlencode($row['order_id']); ?>" class="btn btn-small">Details</a></td>
+                    </tr>
+                <?php endforeach; ?>
+            </tbody>
+        </table>
+    </div>
+<?php endif; ?>
+
 <?php include __DIR__ . '/../includes/footer.php'; ?>