-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_orders_completed.php
More file actions
65 lines (57 loc) · 2.21 KB
/
Copy pathadmin_orders_completed.php
File metadata and controls
65 lines (57 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
@include 'config.php';
session_start();
$admin_id = $_SESSION['admin_id'];
if (!isset($admin_id)){ header('location:login.php'); exit; }
$message = [];
if (isset($_GET['delete'])) {
$delete_id = $_GET['delete'];
$delete_orders = $conn->prepare("DELETE FROM `orders` WHERE id = ?");
$delete_orders->execute([$delete_id]);
header('location:admin_orders_completed.php');
exit;
}
$select_orders = $conn->prepare("SELECT * FROM `orders` WHERE payment_status='completed' ORDER BY placed_on DESC");
$select_orders->execute();
$summary = $conn->query("
SELECT
SUM(payment_status='pending') AS pending_total,
SUM(payment_status='completed') AS completed_total
FROM orders
")->fetch(PDO::FETCH_ASSOC);
$order_view_mode = 'completed';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Completed Orders</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/admin_style.css">
</head>
<body>
<?php include 'admin_header.php'; ?>
<div class="main-content container-fluid py-4">
<h1 class="text-center fw-bold mb-4">Completed Orders</h1>
<a href="admin_orders.php" class="btn btn-secondary mb-4"><i class="fas fa-arrow-left me-2"></i> Back to Active Orders</a>
<?php foreach($message as $msg): ?>
<div class="alert alert-info alert-dismissible fade show mb-3">
<i class="fas fa-info-circle me-2"></i><?= htmlspecialchars($msg); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
<?php endforeach; ?>
<div class="row g-4">
<?php if($select_orders->rowCount() > 0): ?>
<?php while($order = $select_orders->fetch(PDO::FETCH_ASSOC)): ?>
<?php include 'order_card.php'; ?>
<?php endwhile; ?>
<?php else: ?>
<p class="text-center p-5 bg-white shadow rounded">No completed orders!</p>
<?php endif; ?>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="js/admin_script.js"></script>
</body>
</html>