-
Notifications
You must be signed in to change notification settings - Fork 4
/
order_view.php
136 lines (126 loc) · 6.63 KB
/
order_view.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
<?php
include "./config/connect.php";
$statusVie = ["Đang xử lý", "Đang giao hàng", "Đã giao hàng", "Đã hủy"];
$id_order = $_GET['id'];
?>
<div id="content">
<!-- Shopping Cart Section Start -->
<div class="section section-margin">
<div class="container">
<div class="row" data-aos="fade-down">
<div class="col-12">
<!-- Cart Table Start -->
<div class="cart-table table-responsive">
<table class="table table-bordered">
<h3 class="text-center">Chi tiết đơn hàng <?php echo $id_order ?></h3>
<!-- Table Head Start -->
<thead>
<tr>
<th scope="col" class="pro-thumbnail">Ảnh</th>
<th scope="col" class="pro-title">Sản Phẩm</th>
<th scope="col" class="pro-price">Giá</th>
<th scope="col" class="pro-subtotal">Tổng tiền</th>
</tr>
</thead>
<!-- Table Head End -->
<!-- Table Body Start -->
<tbody>
<?php
$user = $_SESSION['user'];
$sql = "SELECT *
FROM `tb_user` as u, `tb_order` as o, `tb_order_details` as od, `tb_product` as p
WHERE u.username = o.username
AND o.id_order = od.id_order
AND od.id_product = p.id_product
AND u.username = '$user'
AND o.id_order = '$id_order'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if ($count > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$id_product = $row['id_product'];
$name = $row['name'];
$price = (float)$row['price'];
$image = $row['image'];
$amount = (int)$row['amount'];
$total_price = $price * $amount;
$total_money = (float)$row['total_money'];
$order_date = $row['order_date'];
$status = $row['status'];
?>
<tr>
<td class="pro-thumbnail">
<a href="#">
<img class="fit-image rounded" src="./assets/images/products/<?php echo $image ?>" alt="Product<?php echo $id_product ?>" style="width:80%" />
</a>
</td>
<td class="pro-title">
<a href="#"><?php echo $name ?></a>
</td>
<td class="pro-price">
<span><?php echo $price ?>$ x <?php echo $amount?></span>
</td>
<td class="pro-subtotal"><span><?php echo $total_price ?>$</span></td>
</tr>
<?php
}
}
?>
</tbody>
<!-- Table Body End -->
</table>
</div>
<!-- Cart Table End -->
</div>
</div>
<div class="row m-t-50" data-aos="fade-up">
<div class="col-lg-6 me-0 ms-auto">
<!-- Cart Calculation Area Start -->
<div class="cart-calculator-wrapper">
<div class="cart-calculate-items">
<h3 class="title text-center">Thông tin đơn hàng</h3>
<div class="table-responsive">
<table class="table">
<tr>
<td>Ngày đặt hàng</td>
<td><?php echo $order_date ?></td>
</tr>
<tr>
<td>Trạng thái</td>
<td><?php
if($status == 'pending'){
echo $statusVie[0];
}
else if($status == 'shipping'){
echo $statusVie[1] . ' (không thể huỷ hàng)';
}
else if($status == 'delivered'){
echo $statusVie[2] . ' (không thể huỷ hàng)';
}
else if($status == 'canceled'){
echo $statusVie[3] . ' (không thể huỷ hàng)';
}
?></td>
</tr>
<tr class="total">
<td>Tổng tiền</td>
<td class="total-amount"><?php echo $total_money ?>$</td>
</tr>
</table>
</div>
<!-- Responsive Table End -->
</div>
<?php if($status == 'pending'){
?>
<a id="cancelOrder" class="btn btn btn-gray-deep btn-hover-primary m-t-30" id_order="<?php echo $id_order?>">Huỷ Hàng</a>
<?php
}
?>
</div>
<!-- Cart Calculation Area End -->
</div>
</div>
</div>
</div>
<!-- Shopping Cart Section End -->
</div>