Devco1
Home
Console
Upload
New File
New Folder
Tools
Info
About
/
home
/
wifiyecu
/
www
/
admin
/
Filename :
order_details.php
back
Copy
<?php session_start(); include '../includes/config.php'; // التحقق من صلاحيات المدير if (!isset($_SESSION['admin_logged_in'])) { header('Location: login.php'); exit; } if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { header('Location: orders.php'); exit; } $order_id = intval($_GET['id']); try { // الحصول على بيانات الطلب $stmt = $pdo->prepare("SELECT * FROM orders WHERE id = ?"); $stmt->execute([$order_id]); $order = $stmt->fetch(); if (!$order) { $_SESSION['message'] = [ 'text' => 'الطلب غير موجود', 'type' => 'danger' ]; header('Location: orders.php'); exit; } // الحصول على عناصر الطلب $items_stmt = $pdo->prepare(" SELECT oi.*, p.name as product_name, p.description, pi.image_url FROM order_items oi LEFT JOIN products p ON oi.product_id = p.id LEFT JOIN product_images pi ON p.id = pi.product_id AND pi.is_main = 1 WHERE oi.order_id = ? "); $items_stmt->execute([$order_id]); $order_items = $items_stmt->fetchAll(); $statuses = [ 'pending' => ['label' => 'قيد الانتظار', 'color' => 'warning', 'icon' => 'clock'], 'processing' => ['label' => 'قيد المعالجة', 'color' => 'info', 'icon' => 'cog'], 'completed' => ['label' => 'مكتمل', 'color' => 'success', 'icon' => 'check'], 'cancelled' => ['label' => 'ملغى', 'color' => 'danger', 'icon' => 'times'] ]; } catch (PDOException $e) { die("خطأ في قاعدة البيانات: " . $e->getMessage()); } ?> <!DOCTYPE html> <html lang="ar" dir="rtl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>تفاصيل الطلب #<?php echo $order_id; ?> - لوحة التحكم</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"> <style> .order-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 2rem; border-radius: 10px; margin-bottom: 2rem; } .info-card { border-left: 4px solid #007bff; margin-bottom: 1rem; } .product-img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; } .print-only { display: none; } @media print { .no-print { display: none !important; } .print-only { display: block !important; } .order-header { background: #f8f9fa !important; color: #000 !important; } } </style> </head> <body> <nav class="navbar navbar-expand-lg navbar-dark bg-dark no-print"> <div class="container"> <a class="navbar-brand" href="index.php"> <i class="fas fa-cog"></i> لوحة التحكم </a> <div class="navbar-nav ms-auto"> <a class="nav-link" href="orders.php"> <i class="fas fa-arrow-right me-1"></i> رجوع للطلبات </a> </div> </div> </nav> <div class="container mt-4"> <!-- رسائل التنبيه --> <?php if (isset($_SESSION['message'])): ?> <div class="alert alert-<?php echo $_SESSION['message']['type']; ?> alert-dismissible fade show no-print" role="alert"> <?php echo $_SESSION['message']['text']; ?> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> </div> <?php unset($_SESSION['message']); ?> <?php endif; ?> <div class="order-header"> <div class="row align-items-center"> <div class="col-md-8"> <h1 class="mb-2"> <i class="fas fa-file-invoice me-2"></i> تفاصيل الطلب #<?php echo str_pad($order_id, 6, '0', STR_PAD_LEFT); ?> </h1> <p class="mb-0">عرض التفاصيل الكاملة للطلب</p> </div> <div class="col-md-4 text-start"> <div class="d-flex gap-2 justify-content-start no-print"> <button class="btn btn-light" onclick="window.print()"> <i class="fas fa-print me-2"></i> طباعة </button> <a href="orders.php" class="btn btn-outline-light"> <i class="fas fa-arrow-right me-2"></i> رجوع </a> </div> </div> </div> </div> <div class="print-only text-center mb-4"> <h2>فاتورة طلب #<?php echo str_pad($order_id, 6, '0', STR_PAD_LEFT); ?></h2> <p>تاريخ الطباعة: <?php echo date('Y-m-d H:i'); ?></p> </div> <div class="row"> <!-- معلومات العميل --> <div class="col-md-6 mb-4"> <div class="card info-card"> <div class="card-header bg-primary text-white"> <h5 class="card-title mb-0"> <i class="fas fa-user me-2"></i> معلومات العميل </h5> </div> <div class="card-body"> <table class="table table-borderless"> <tr> <td width="30%"><strong>الاسم الكامل:</strong></td> <td><?php echo htmlspecialchars($order['customer_name']); ?></td> </tr> <tr> <td><strong>البريد الإلكتروني:</strong></td> <td><?php echo htmlspecialchars($order['customer_email']); ?></td> </tr> <tr> <td><strong>رقم الهاتف:</strong></td> <td><?php echo htmlspecialchars($order['customer_phone']); ?></td> </tr> <tr> <td><strong>العنوان:</strong></td> <td><?php echo nl2br(htmlspecialchars($order['customer_address'])); ?></td> </tr> </table> </div> </div> </div> <!-- معلومات الطلب --> <div class="col-md-6 mb-4"> <div class="card info-card"> <div class="card-header bg-success text-white"> <h5 class="card-title mb-0"> <i class="fas fa-shopping-cart me-2"></i> معلومات الطلب </h5> </div> <div class="card-body"> <table class="table table-borderless"> <tr> <td width="40%"><strong>رقم الطلب:</strong></td> <td>#<?php echo str_pad($order_id, 6, '0', STR_PAD_LEFT); ?></td> </tr> <tr> <td><strong>تاريخ الطلب:</strong></td> <td><?php echo date('Y-m-d H:i', strtotime($order['created_at'])); ?></td> </tr> <tr> <td><strong>آخر تحديث:</strong></td> <td><?php echo date('Y-m-d H:i', strtotime($order['updated_at'])); ?></td> </tr> <tr> <td><strong>حالة الطلب:</strong></td> <td> <span class="badge bg-<?php echo $statuses[$order['status']]['color']; ?>"> <i class="fas fa-<?php echo $statuses[$order['status']]['icon']; ?> me-1"></i> <?php echo $statuses[$order['status']]['label']; ?> </span> </td> </tr> <tr> <td><strong>المبلغ الإجمالي:</strong></td> <td><span class="h5 text-success">$<?php echo number_format($order['total_amount'], 2); ?></span></td> </tr> </table> </div> </div> </div> </div> <!-- عناصر الطلب --> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header bg-info text-white"> <h5 class="card-title mb-0"> <i class="fas fa-list me-2"></i> عناصر الطلب </h5> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered"> <thead class="table-light"> <tr> <th width="5%">#</th> <th width="15%">الصورة</th> <th width="30%">المنتج</th> <th width="10%">الكمية</th> <th width="15%">سعر الوحدة</th> <th width="15%">المجموع</th> </tr> </thead> <tbody> <?php $total_amount = 0; if (empty($order_items)): ?> <tr> <td colspan="6" class="text-center text-muted py-4"> <i class="fas fa-exclamation-circle me-2"></i> لا توجد عناصر في هذا الطلب </td> </tr> <?php else: foreach ($order_items as $index => $item): $item_total = $item['price'] * $item['quantity']; $total_amount += $item_total; ?> <tr> <td class="text-center"><?php echo $index + 1; ?></td> <td class="text-center"> <?php if ($item['image_url']): ?> <img src="../<?php echo $item['image_url']; ?>" alt="<?php echo htmlspecialchars($item['product_name']); ?>" class="product-img"> <?php else: ?> <div class="product-img bg-light d-flex align-items-center justify-content-center"> <i class="fas fa-mobile-alt text-muted"></i> </div> <?php endif; ?> </td> <td> <strong><?php echo htmlspecialchars($item['product_name']); ?></strong> <?php if ($item['description']): ?> <br> <small class="text-muted"><?php echo substr($item['description'], 0, 50); ?>...</small> <?php endif; ?> </td> <td class="text-center"><?php echo $item['quantity']; ?></td> <td class="text-success">$<?php echo number_format($item['price'], 2); ?></td> <td class="text-success"><strong>$<?php echo number_format($item_total, 2); ?></strong></td> </tr> <?php endforeach; endif; ?> </tbody> <tfoot> <tr class="table-active"> <td colspan="5" class="text-end"><strong>المجموع النهائي:</strong></td> <td class="text-success"><strong class="h5">$<?php echo number_format($total_amount, 2); ?></strong></td> </tr> </tfoot> </table> </div> </div> </div> </div> </div> <!-- تحديث حالة الطلب --> <?php if ($order['status'] === 'pending' || $order['status'] === 'processing'): ?> <div class="row mt-4 no-print"> <div class="col-12"> <div class="card"> <div class="card-header bg-warning text-dark"> <h5 class="card-title mb-0"> <i class="fas fa-edit me-2"></i> تحديث حالة الطلب </h5> </div> <div class="card-body"> <form method="POST" action="orders.php" class="row g-3 align-items-center"> <input type="hidden" name="order_id" value="<?php echo $order['id']; ?>"> <div class="col-md-4"> <select name="status" class="form-select"> <?php foreach ($statuses as $key => $info): ?> <option value="<?php echo $key; ?>" <?php echo ($order['status'] == $key) ? 'selected' : ''; ?>> <?php echo $info['label']; ?> </option> <?php endforeach; ?> </select> </div> <div class="col-md-2"> <button type="submit" name="update_status" class="btn btn-primary w-100"> <i class="fas fa-save me-2"></i> تحديث </button> </div> <div class="col-md-6"> <small class="text-muted"> <i class="fas fa-info-circle me-1"></i> يمكنك تحديث حالة الطلب لتتبع تقدمه </small> </div> </form> </div> </div> </div> </div> <?php endif; ?> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> </body> </html>