-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderdetails.php
112 lines (91 loc) · 2.92 KB
/
orderdetails.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
<?php include("./inc/req_functions.php") ?>
<?php include("./inc/connection.php") ?>
<?php session_start() ?>
<?php
if (!isset($_GET['order_id'])) {
header("Location: manageorders.php?user=false");
}
if (!($_SESSION["usertype"] == "SystemAdmin" || $_SESSION["usertype"] == "operational")) {
header("Location: signin.php?access=false");
}
$order_id = $_GET['order_id'];
$query = "SELECT * FROM preorders WHERE order_id='{$order_id}' LIMIT 1";
$result = mysqli_query($conn, $query);
query_check($result);
$table = "";
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_assoc($result);
$userid = $row['userid'];
$query = "SELECT om.order_id, ml.meal_name,om.quantity,us.first_name FROM order_meals as om
INNER JOIN preorders as po ON om.order_id = po.order_id
INNER JOIN meals as ml ON om.mealid = ml.mealid
INNER JOIN users as us ON po.userid = us.userid
WHERE om.order_id='{$order_id}'";
$result = mysqli_query($conn, $query);
query_check($result);
if (mysqli_num_rows($result) >= 1) {
while ($row = mysqli_fetch_assoc($result)) {
$table .= "<tr>";
$table .= "<td>{$row['meal_name']}</td>";
$table .= "<td>{$row['quantity']}</td>";
$table .= "</td>";
$first_name = $row['first_name'];
}
} else {
header("Location?manageorders.php?orders=false");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Details</title>
</head>
<?php
if ($_SESSION['usertype'] == "normaluser") {
include("./inc/mainheader.php");
} else if ($_SESSION['usertype'] == "SystemAdmin") {
include("./inc/adminheader.php");
} else if ($_SESSION['usertype'] == "operational") {
include("./inc/opheader.php");
}
?>
<body>
<div class="container">
<h2>Order Details</h2>
<div class="mt-2">
<div class="d-flex mt-3 mb-3">
<div class="col-md-2">
<h5>User Name: <?php echo $first_name ?></h5>
</div>
<div class="col-md-1">
<h5>
User ID: <?php echo $userid ?>
</h5>
</div>
</div>
<!-- <div class="row"> -->
<div class="col-md-6">
<h4>Meals</h4>
<table class="table">
<thead>
<tr>
<th>Meal Name</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php
if (isset($table)) {
echo $table;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>