-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderSuccess.php
177 lines (145 loc) · 7.88 KB
/
orderSuccess.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
<?php
$href = '';
include 'header.php';
if (isset($_GET['idOrderDetail'])) {
$total = 0;
$totalPay = 0;
$idOrder = $_GET['idOrderDetail'];
$notDelete = '';
if (isset($_GET['notDelete'])) {
$notDelete = "Không thể xóa sản phẩm đã được giao cho khách hàng";
}
if (isset($_GET['idProduct'])) {
$idProduct = $_GET['idProduct'];
if (isset($_POST['updateQuantity'])) {
if (isset($_POST['quantity'])) {
$quantityEdit = $_POST['quantity'];
$sqlUpdate = "update product_order set quantity = $quantityEdit where id_product = $idProduct and id_order = $idOrder";
$resUpdate = mysql_query($sqlUpdate);
}
}
}
// $sql = 'SELECT Orders.id as IdOrder, Users.fullname, Users.phone as phone, Users.email as email,
// Users.address as address, Orders.dateOrder
// FROM Orders
// INNER JOIN Users
// ON Orders.idUser= Users.id
// and Orders.id =' . $idOrder .
// ' group by IdOrder';
$sql = " SELECT * FROM v_order_list where idOrder =" . $idOrder . ' group by idOrder';
// echo $sql;
$res = mysql_query($sql);
if ($res) {
while ($row = mysql_fetch_assoc($res)) {
?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<h1 style="color:red";>Chúc mừng bạn đã đặt hàng thành công</h1>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h2 class="page-header">Chi tiết đơn hàng</h2>
<div class ="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<h3>Thông tin người nhận</h3>
<table class="table table-responsive">
<tr>
<th>Tên khách hàng</th>
<td><?php echo $row['fullname']; ?></td>
</tr>
<tr>
<th>Số điện thoại</th>
<td><?php echo $row['phone']; ?></td>
</tr>
<tr>
<th>Email</th>
<td><?php echo $row['email']; ?></td>
</tr>
<tr>
<th>Địa chỉ</th>
<td><?php echo $row['address']; ?></td>
</tr>
<tr>
<th>Ngày đặt hàng</th>
<td><?php echo $row['dateOrder']; ?></td>
</tr>
</table>
</div>
</div>
<?php
}
}
?>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3>Thông tin chi tiết sản phẩm</h3>
<p style="color: #009999"><?php echo $notDelete; ?>
<table class="table table-striped table-bordered table-hover table-responsive">
<thead>
<tr align="center">
<th>Tên sản phẩm</th>
<th>Giá</th>
<th>Giảm giá</th>
<th>Số lượng</th>
<th>Tổng cộng</th>
</tr>
</thead>
<tbody>
<?php
// $sqlOrderProduct = ' SELECT Orders.id as IdOrder,products.id as idProduct,
// products.name as nameProduct , products.price as price, products.saleprice as saleprice,
// product_order.quantity
// FROM Orders
// INNER JOIN product_order
// ON product_order.id_Order = orders.id
// INNER JOIN products
// ON product_order.id_Product = products.id
// and Orders.id =' . $idOrder;
$sqlOrderProduct = "SELECT * FROM v_order_list where idOrder =" . $idOrder;
$resOrderPr = mysql_query($sqlOrderProduct);
if ($resOrderPr) {
$totalAllSale = 0;
// $totalPay = 0;
while ($rowOP = mysql_fetch_assoc($resOrderPr)) {
$salePrice = $rowOP['saleprice'] * $rowOP['price'] / 100;
$totalSalePrice = $salePrice * $rowOP['quantity'];
$totalPriceProduct = $rowOP['quantity'] * $rowOP['price'] - $totalSalePrice;
$totalAllSale = $totalAllSale + $totalSalePrice;
$total = $total + $rowOP['quantity'] * $rowOP['price'];
$totalPay = $total - $totalAllSale;
?>
<tr class="odd gradeX" align="center">
<td><?php echo $rowOP['nameProduct']; ?></td>
<td><?php echo number_format($rowOP['price']); ?></td>
<td>
<?php echo number_format($salePrice); ?>
</td>
<td>
<?php echo $rowOP['quantity']; ?>
</td>
<td><?php echo number_format($totalPriceProduct); ?></td>
</tr>
<?php
}
}
?>
<tr>
<td colspan="6">
<h4 style="float: right; padding-right: 4px;">Tổng tiền chưa giảm: <?php echo number_format($total); ?><sup>đ</sup> <br/> <br/>
Số tiền được giảm: -<?php echo number_format($totalAllSale); ?><sup>đ</sup><br/> <br/>
Tổng tiền phải thanh toán:<?php echo number_format($totalPay) ?><sup>đ</sup></h4>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</body>
</html>