forked from Karwann/Online-Grocery-shopping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder_success.php
214 lines (187 loc) · 5.71 KB
/
order_success.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
<?php
session_start();
include("connection.php");
error_reporting(0);
if(!isset($_SESSION['customer']))
{
header("location:index.php");
}
$cust= $_SESSION['customer'];
?>
<!DOCTYPE html>
<html>
<head>
<title>AK Grocery - Order Placed</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<style>
#loader {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}
@-webkit-keyframes animatebottom {
from { bottom:-100px; opacity:0 }
to { bottom:0px; opacity:1 }
}
@keyframes animatebottom {
from{ bottom:-100px; opacity:0 }
to{ bottom:0; opacity:1 }
}
#myDiv {
display: none;
text-align: center;
}
</style>
</head>
<body onload="myFunction()" style="margin:0;">
<?php
$q2= "SELECT * FROM customers WHERE email= '$cust'";
$data2= mysqli_query($conn, $q2);
while($res2= mysqli_fetch_assoc($data2)){
$address= $res2['street'].", ".$res2['city'].", ".$res2['pincode'];
}
?>
<div id="loader"></div>
<div id= "myDiv" class="container" style="display:none;">
<div class="row justify-content-center">
<div class="table-responsive">
<?php
$somerand= "COD".mt_rand(100000000,999999999);
$q2= "SELECT * FROM customers WHERE email='$cust'";
$data2= mysqli_query($conn, $q2);
$res2= mysqli_fetch_assoc($data2);
?>
<h2 class="text-center text-black mb-5" style="margin-top: 20px;"> Order Placed </h2>
<table class="table table-bordered" style="margin-top: 40px;">
<tr>
<th>Purchased from</th>
<td>AK Grocery </td>
</tr>
<tr>
<th>Payment ID</th>
<td><?php echo $somerand; ?></td>
</tr>
<tr>
<th>Buyer Name</th>
<td><?= $res2['username']; ?></td>
</tr>
<tr>
<th>Buyer Phone No.</th>
<td><?= $res2['phone']; ?></td>
</tr>
<tr>
<th>Buyer Email</th>
<td><?= $res2['email']; ?></td>
</tr>
<tr>
<th>Buyer Address</th>
<td><?= $address; ?></td>
</tr>
<tr>
<th>Payment Status</th>
<td>Pending</td>
</tr>
<tr>
<th>Order Date</th>
<td><?php
date_default_timezone_set('Asia/Baghdad');
$date = date('d/m/Y H:i:s', time());
echo $date;?></td>
</tr>
</table>
<div class="text-center text-danger mb-2">
<button name="order" class="btn btn-danger" onclick='window.location.href = "order.php"'>Track your Order</button>
<button name="shopping" class="btn btn-success" onclick='window.location.href = "index.php"'>Continue Shoppping</button>
</div>
<?php
$spay_id= $somerand;
$sbuyer_name= $res2['username'];
$sbuyer_email= $res2['email'];
$sbuyer_phone= $res2['phone'];
$sstatus= "Cod";
$allvalues= $_SESSION['karo'];
$delivery= $_SESSION['del'];
if($delivery ==1 )
{
$shipping= "Normal";
}
else{
$shipping= "Express";
}
$some= json_decode($allvalues);
$items = array();
foreach($some as $arr) {
foreach($arr as $key => $value) {
$items[$key] = $value;
}
$sid= $items['id'];
$stitle= $items['name'];
$sprice= $items['price'];
$sqty= $items['quantity'];
$simage= $items['image'];
$sadmin='';
$q2= "SELECT * FROM products WHERE product_id= $sid ";
$data2= mysqli_query($conn, $q2);
while($res2= mysqli_fetch_assoc($data2)){
$sadmin= $res2['admin_name'];
$q3= "SELECT * FROM admin WHERE email= '$sadmin' ";
$data3= mysqli_query($conn, $q3);
while($resource= mysqli_fetch_assoc($data3)){
$sadmin_name= $resource['username'];
$sadmin_address= $resource['street'].", ".$resource['city'];
$sadmin_phone= $resource['phone'];
}
}
$q3= "INSERT INTO `orders`(`product_title`, `product_price`, `product_qty`, `product_image`, `admin_name`, `payment_id`, `payment_status`, `buyer_email`, `buyer_phone`, `buyer_name`,`order_date`,`delivery_status`,`shipping_method`, `buyer_address`) VALUES ('$stitle', '$sprice', '$sqty', '$simage', '$sadmin', '$spay_id', '$sstatus', '$sbuyer_email', '$sbuyer_phone', '$sbuyer_name','$date','ND','$shipping','$address')";
if(mysqli_query($conn, $q3)){
}else {
echo "Error: " . $q3 . "<br>" . mysqli_error($conn);
}
}
?>
</div>
</div>
</div>
<script>
var myVar;
function myFunction() {
myVar = setTimeout(showPage, 3000);
}
function showPage() {
document.getElementById("loader").style.display = "none";
document.getElementById("myDiv").style.display = "block";
}
</script>
</body>
</html>