-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-order.php
183 lines (160 loc) · 7.89 KB
/
list-order.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
session_start();
if (isset($_SESSION['id']) && isset($_SESSION['user_name'])) {
?>
<!DOCTYPE html>
<html>
<?php
include_once './partials/head.php';
?>
<body>
<div class="sidebar">
<div class="logo-details">
<i></i>
<a href="manager-home.php" class="logo_name">Stop One</a>
</div>
<ul class="nav-links">
<li>
<a href="manager-home.php">
<i class='bx bx-grid-alt'></i>
<span class="links_name">Dashboard</span>
</a>
</li>
<li>
<a href="list-product.php">
<i class='bx bx-box'></i>
<span class="links_name">List product</span>
</a>
</li>
<li>
<a href="list-order.php" class="active">
<i class='bx bx-box'></i>
<span class="links_name">List order</span>
</a>
</li>
<li class="log_out">
<a href="logout.php">
<i class='bx bx-log-out'></i>
<span class="links_name">Log out</span>
</a>
</li>
</ul>
</div>
<section class="home-section">
<nav>
<div class="sidebar-button">
<i class='bx bx-menu sidebarBtn'></i>
<span class="dashboard">Dashboard</span>
<span class="dashboard">
<div class="container">
<div class="row">
<div class="col">
</div>
<div class="col-6">
</div>
<div class="col">
<b>
<h5 style="font-family: 'Kanit', sans-serif;"> { Hello, <?php echo $_SESSION['name']; ?> }</h5>
</b>
</div>
</div>
</div>
</span>
</div>
</nav>
<div class="home-content">
<div class="overview-boxes">
<div class="cardMod">
<h4>List of Orders </h4>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Bill ID</th>
<th scope="col">Seller ID</th>
<th scope="col">Customer_id</th>
<th scope="col">Date & Time</th>
<th scope="col">Product Name</th>
<th scope="col">Unit Price</th>
<th scope="col">Quantity</th>
</tr>
</thead>
<tbody>
<?php
include_once './model/db_conn.php';
$sql = "SELECT * FROM bill";
$i = 1;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<th scope='row'>$i</th>";
echo "<td>" . $row["bill_id"] . "</td>";
echo "<td>" . $row["seller_id"] . "</td>";
echo "<td>" . $row["customer_id"] . "</td>";
echo "<td>" . $row["date_time"] . "</td>";
echo "<td>";
$sql2 = "SELECT product_id FROM bill_products WHERE bill_id='" . $row["bill_id"] . "'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while ($row2 = $result2->fetch_assoc()) {
$sql3 = "SELECT `name` AS `productname` FROM product WHERE product_id='" . $row2["product_id"] . "'";
$result3 = $conn->query($sql3);
$row3 = $result3->fetch_assoc();
echo $row3["productname"] . "<br>";
}
}
echo "</td>";
echo "<td>";
$sql2 = "SELECT product_id FROM bill_products WHERE bill_id='" . $row["bill_id"] . "'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while ($row2 = $result2->fetch_assoc()) {
$sql3 = "SELECT `price` AS `productprice` FROM product WHERE product_id='" . $row2["product_id"] . "'";
$result3 = $conn->query($sql3);
$row3 = $result3->fetch_assoc();
echo $row3["productprice"] . "<br>";
}
}
echo "</td>";
echo "<td>";
$sql4 = "SELECT product_id FROM bill_products WHERE bill_id='" . $row["bill_id"] . "'";
$result4 = $conn->query($sql4);
if ($result4->num_rows > 0) {
while ($row4 = $result4->fetch_assoc()) {
$sql5 = "SELECT quantity FROM bill_products WHERE bill_id='" . $row["bill_id"] . "' AND product_id='" . $row4["product_id"] . "'";
$result5 = $conn->query($sql5);
$row5 = $result5->fetch_assoc();
echo $row5["quantity"] . "<br>";
}
}
echo "</td>";
echo "</tr>";
$i++;
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<script>
let sidebar = document.querySelector(".sidebar");
let sidebarBtn = document.querySelector(".sidebarBtn");
sidebarBtn.onclick = function() {
sidebar.classList.toggle("active");
if (sidebar.classList.contains("active")) {
sidebarBtn.classList.replace("bx-menu", "bx-menu-alt-right");
} else
sidebarBtn.classList.replace("bx-menu-alt-right", "bx-menu");
}
</script>
</body>
</html>
<?php
} else {
header("Location: index.php");
exit();
}
?>