-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder-details.php
219 lines (206 loc) · 12.7 KB
/
order-details.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php include './conn/conn.php' ?>
<?php include './includes/Session.php' ?>
<?php include './includes/verifyUserSession.php' ?>
<?php
if (!isset($_GET['transaction_no'])) {
Session::redirectTo('orders.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Party Jungle Toys & Party Needs</title>
<?php $active_page = "orders" ?>
<?php include './includes/header.php' ?>
</head>
<body class="bg-light">
<?php include './includes/top_header.php' ?>
<main class="main">
<section class="">
<div class="container my-5">
<div class="d-flex flex-wrap">
<div>
<a href="orders.php" class="btn btn-sm btn-brown me-2 text-light rounded-circle">
<i class="bx bx-arrow-back"></i>
</a>
</div>
<h3 class="text-dark my-0 fw-light">
Track Order
</h3>
</div>
<hr class="mt-1">
<div>
<?php
$user_id = Session::getUser()['id'];
$transaction_no = $_GET['transaction_no'];
$query = mysqli_query($con, "SELECT orders.*, shipping.description,shipping.price FROM orders INNER JOIN shipping ON orders.shipping_id = shipping.id WHERE orders.transaction_no = '$transaction_no'");
$row = $query->fetch_assoc();
$transaction_no = $row['transaction_no'];
$description = $row['description'];
$total = $row['total'];
$status = $row['status'];
$order_id = $row['id'];
$subtotal = 0;
//get order details 2 products only
$get_details = mysqli_query($con, "SELECT * FROM order_details WHERE order_id = $order_id");
$num_of_products = mysqli_query($con, "SELECT COUNT(*) FROM order_details WHERE order_id = $order_id")->fetch_array()[0];
?>
<div class="row">
<div class="col-md">
<div class="card mb-3 rounded-3 shadow border-0">
<div class="card-body p-lg-4">
<div class="d-flex flex-wrap align-items-center">
<p class=" shadow-sm text-bg-light badge rounded-pill py-2 px-3 fw-bold text-secondary">
Order
<span class="text-brown">#</span>
<span class=" fw-normal text-dark"><?php echo $row['transaction_no'] ?></span>
</p>
</div>
<div class="px-3">
<?php $status = mysqli_query($con, "SELECT * FROM order_status WHERE status_code=" . $row['status'])->fetch_assoc(); ?>
<p class="my-1 text-secondary fw-light">Status</p>
<p class="my-1 text-dark fw-bold"><?php echo $status['status_label'] ?></p>
</div>
<ul class="list-group list-group-flush">
<?php
while ($details = $get_details->fetch_assoc()) :
$subtotal += $details['price'] * $details['quantity'];
$category = mysqli_query($con, "SELECT * FROM categories WHERE id=" . $details['category_id'])->fetch_assoc();
?>
<li class="list-group-item">
<div class="row mt-3 align-items-center">
<div class="col-sm-5 col-6 col-md-3 col-lg-3">
<img src="<?php echo $details['product_photo'] ?>" alt="" class="img-fluid img-thumbnail">
</div>
<div class="col">
<div class="row">
<div class="col-md">
<?php
if ($category['category_name'] == 'Balloons') {
?>
<a href="#instruction-modal" data-bs-toggle="modal" data-instruction="<?php echo $details['instruction'] ?>">
<i class="bx bx-info-circle"></i>
</a>
<?php
}
?>
<p class="my-1 fw-bold"><?php echo $details['product_name'] ?></p>
<p class="my-1 text-secondary">
<?php echo $details['variation'] ?>
</p>
<div class="text-secondary">
<p>Qty: <?php echo $details['quantity'] ?></p>
</div>
</div>
<div class="col-md">
<p class="text-orange my-1"><strong>₱</strong> <?php echo $details['price'] * $details['quantity'] ?></p>
</div>
</div>
</div>
</div>
</li>
<?php
endwhile;
?>
</ul>
<div class="px-4">
<hr>
<div class="row mt-3">
<div class="col-md">
<div class="">
<?php
$shipping = mysqli_query($con, "SELECT * FROM shipping WHERE id = " . $row['shipping_id'])->fetch_assoc();
?>
<p class="text-secondary fw-light">Shipping Type:</p>
<p class="my-1">
<?php echo $shipping['description'] ?>
<i class="bx bxs-truck bx-flip-horizontal text-orange"></i>
</p>
</div>
</div>
<div class="col-md">
<div class="row">
<div class="col">
<p class="my-1 text-secondary fw-light">Subtotal</p>
</div>
<div class="col">
<p class="my-1"><strong>₱</strong> <?php echo $subtotal ?></p>
</div>
</div>
<div class="row">
<div class="col">
<p class="my-1 text-secondary fw-light">Shipping fee</p>
</div>
<div class="col">
<p class="my-1"><strong>₱</strong> <?php echo $shipping['price'] ?></p>
</div>
</div>
<div class="row mt-3">
<div class="col">
<p class="my-1 text-secondary fw-light">Total</p>
</div>
<div class="col">
<p class="my-1 text-orange"><strong>₱</strong> <?php echo $total + $shipping['price'] ?></p>
</div>
</div>
</div>
</div>
</div>
<p class="mt-4 mb-1 text-end text-black-50">
<small>
Order was placed on
<?php echo date("M d, Y", strtotime($row['ordered_at'])) ?>
</small>
</p>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card border-0 rounded-1 shadow">
<div class="card-body">
<p class="p-3 text-bg-light badge shadow-sm fs-6">
<i class="bx bxs-circle"></i> Status
</p>
<ul class="status-list">
<?php
$query = mysqli_query($con, "SELECT * FROM order_status WHERE status_code != -1 AND status_code != 5 ORDER BY id ASC");
while ($status = $query->fetch_assoc()) {
?>
<li class="<?php echo $row['status'] == $status['status_code'] ? ($row['status'] == 4 ? 'checked' : 'active') : ($row['status'] > $status['status_code'] ? 'checked' : '') ?>">
<p class="title"><?php echo $status['status_label'] ?></p>
<p class="my-1">
<small>
<?php echo $status['description'] ?>
</small>
</p>
</li>
<?php
}
?>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
include './includes/featured-products.php';
?>
</main>
<?php include './includes/footer.php' ?>
<?php include './includes/details-modals.php' ?>
<?php include './includes/scripts.php' ?>
<script>
$("#instruction-modal").on("show.bs.modal", function(e) {
let text = $(e.relatedTarget).data("instruction");
$("#instructions-text").html(text)
})
</script>
</body>
</html>