🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:order-details.php
<?php $page = 'orders'; $page_title = 'Order Details'; require_once '../includes/header.php'; $id = intval($_GET['id'] ?? 0); $stmt = $db->prepare("SELECT * FROM orders WHERE id = ?"); $stmt->execute([$id]); $order = $stmt->fetch(); if (!$order) { admin_set_flash('error', 'Order not found'); header('Location: ' . ADMIN_PATH . 'pages/orders.php'); exit; } $order_items = get_order_items($id); if ($_SERVER['REQUEST_METHOD'] == 'POST' && verify_csrf($_POST[CSRF_TOKEN_NAME] ?? '')) { $order_status = $_POST['order_status'] ?? $order['order_status']; $payment_status = $_POST['payment_status'] ?? $order['payment_status']; $stmt = $db->prepare("UPDATE orders SET order_status = ?, payment_status = ? WHERE id = ?"); $stmt->execute([$order_status, $payment_status, $id]); admin_set_flash('success', 'Order updated'); header('Location: ' . ADMIN_PATH . 'pages/order-details.php?id=' . $id); exit; } ?> <div class="row g-4"> <div class="col-lg-8"> <div class="admin-card"> <div class="admin-card-header"> <h3 class="admin-card-title">Order #<?= htmlspecialchars($order['order_number']) ?></h3> <span class="status-badge status-<?= $order['order_status'] ?>"> <?= ucfirst($order['order_status']) ?> </span> </div> <div class="row g-3 mb-4"> <div class="col-md-3"> <small class="text-muted d-block">Date</small> <strong><?= date('M d, Y h:i A', strtotime($order['created_at'])) ?></strong> </div> <div class="col-md-3"> <small class="text-muted d-block">Payment</small> <strong style="text-transform: uppercase;"><?= $order['payment_method'] ?></strong> </div> <div class="col-md-3"> <small class="text-muted d-block">Total Items</small> <strong><?= count($order_items) ?></strong> </div> <div class="col-md-3"> <small class="text-muted d-block">Total Amount</small> <strong style="color: var(--primary-rose-gold); font-size: 1.1rem;"><?= format_currency($order['total']) ?></strong> </div> </div> <h5>Order Items</h5> <div class="table-responsive"> <table class="admin-table"> <thead> <tr> <th>Product</th> <th>Qty</th> <th>Price</th> <th>Total</th> </tr> </thead> <tbody> <?php foreach ($order_items as $item): ?> <tr> <td> <div style="display: flex; gap: 10px; align-items: center;"> <?php if ($item['product_image']): ?> <img src="<?= UPLOADS_URL ?>products/<?= $item['product_image'] ?>" style="width: 40px; height: 40px; border-radius: 6px; object-fit: cover;"> <?php endif; ?> <strong><?= htmlspecialchars($item['product_name']) ?></strong> </div> </td> <td><?= $item['quantity'] ?></td> <td><?= format_currency($item['price']) ?></td> <td><strong><?= format_currency($item['total']) ?></strong></td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <div class="col-lg-4"> <!-- Update Status --> <div class="admin-card"> <div class="admin-card-header"> <h3 class="admin-card-title">Update Order</h3> </div> <form method="POST"> <?= csrf_field() ?> <div class="form-group-admin"> <label class="form-label-admin">Order Status</label> <select name="order_status" class="form-control-admin"> <option value="pending" <?= $order['order_status'] == 'pending' ? 'selected' : '' ?>>Pending</option> <option value="processing" <?= $order['order_status'] == 'processing' ? 'selected' : '' ?>>Processing</option> <option value="shipped" <?= $order['order_status'] == 'shipped' ? 'selected' : '' ?>>Shipped</option> <option value="delivered" <?= $order['order_status'] == 'delivered' ? 'selected' : '' ?>>Delivered</option> <option value="cancelled" <?= $order['order_status'] == 'cancelled' ? 'selected' : '' ?>>Cancelled</option> </select> </div> <div class="form-group-admin"> <label class="form-label-admin">Payment Status</label> <select name="payment_status" class="form-control-admin"> <option value="pending" <?= $order['payment_status'] == 'pending' ? 'selected' : '' ?>>Pending</option> <option value="completed" <?= $order['payment_status'] == 'completed' ? 'selected' : '' ?>>Completed</option> <option value="failed" <?= $order['payment_status'] == 'failed' ? 'selected' : '' ?>>Failed</option> <option value="refunded" <?= $order['payment_status'] == 'refunded' ? 'selected' : '' ?>>Refunded</option> </select> </div> <button type="submit" class="btn-admin btn-primary-admin w-100" style="justify-content: center;"> <i class="fas fa-save"></i> Update Order </button> </form> </div> <!-- Customer Info --> <div class="admin-card"> <div class="admin-card-header"> <h3 class="admin-card-title">Customer</h3> </div> <p style="margin-bottom: 8px;"><strong><?= htmlspecialchars($order['first_name'] . ' ' . $order['last_name']) ?></strong></p> <p style="margin-bottom: 8px;"><i class="fas fa-envelope"></i> <?= htmlspecialchars($order['email']) ?></p> <p style="margin-bottom: 0;"><i class="fas fa-phone"></i> <?= htmlspecialchars($order['phone']) ?></p> </div> <!-- Address --> <div class="admin-card"> <div class="admin-card-header"> <h3 class="admin-card-title">Shipping Address</h3> </div> <address style="margin: 0; color: var(--gray-700); line-height: 1.7;"> <?= htmlspecialchars($order['address_line1']) ?><br> <?php if ($order['address_line2']): ?><?= htmlspecialchars($order['address_line2']) ?><br><?php endif; ?> <?= htmlspecialchars($order['city']) ?>, <?= htmlspecialchars($order['state']) ?> <?= htmlspecialchars($order['zip_code']) ?><br> <?= htmlspecialchars($order['country']) ?> </address> </div> <!-- Order Summary --> <div class="admin-card"> <div class="admin-card-header"> <h3 class="admin-card-title">Summary</h3> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 8px;"> <span>Subtotal:</span> <strong><?= format_currency($order['subtotal']) ?></strong> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 8px;"> <span>Shipping:</span> <strong><?= $order['shipping_cost'] > 0 ? format_currency($order['shipping_cost']) : 'FREE' ?></strong> </div> <div style="display: flex; justify-content: space-between; margin-bottom: 8px;"> <span>Tax:</span> <strong><?= format_currency($order['tax']) ?></strong> </div> <?php if ($order['discount'] > 0): ?> <div style="display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--success);"> <span>Discount:</span> <strong>-<?= format_currency($order['discount']) ?></strong> </div> <?php endif; ?> <hr> <div style="display: flex; justify-content: space-between; font-size: 1.1rem;"> <strong>Total:</strong> <strong style="color: var(--primary-rose-gold);"><?= format_currency($order['total']) ?></strong> </div> </div> <a href="<?= ADMIN_PATH ?>pages/orders.php" class="btn-admin btn-secondary-admin w-100" style="justify-content: center;"> <i class="fas fa-arrow-left"></i> Back to Orders </a> </div> </div> <?php require_once '../includes/footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder