-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummary.php
265 lines (222 loc) · 11.1 KB
/
summary.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php session_start(); ?>
<?php
if (!isset($_SESSION['customer']))
{
$_SESSION['customer'] = array('firstName'=>'','email'=>'','phone'=>'','address'=>'','zip'=>'','notes'=>'');
}
?>
<?php
if (!isset($_SESSION['cart']))
{
$_SESSION['cart'] = array();
}
?>
<?php
if(!$_SESSION['paid'])
{
$message = "Payment Invalid";
echo "<script type='text/javascript'>alert('$message');
window.location.href='./menu.php';
</script>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Sushi Bar SG</title>
<link rel="shortcut icon" href="./assets/icon/favicon.ico" type="image/x-icon">
<link rel="icon" href="./assets/icon/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="./styles/sushi.css">
<meta charset="utf-8">
<style>
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: url('OpenSans-Regular.ttf') format('truetype');
}
</style>
<script type="text/javascript" src="./scripts/checkout.js"> </script>
</head>
<body>
<div class="container">
<section>
<div class="header">
<div class="header-box1"><img src="assets/nav/sushi_logo.png" alt="logo" class="logo" width="150px" height="50px"></div>
<div class="header-box2">
<nav class="main-nav">
<ul>
<li><a href="index.php"><b>home</b></a></li>
<li><a href="menu.php"><b>menu</b></a></li>
<li><a href="contact.php"><b>contact</b></a></li>
</ul>
</nav>
</div>
<div class="header-box3">
<nav class="main-nav">
<a id="cart" href="user.php"><img src="assets/nav/user-icon.jpg" width="50px" height="50px"></a>
<a id="cart" href="cart.php"><img src="assets/nav/cart.png" width="50px" height="50px"></a>
</nav>
</div>
</div>
</section>
<div class="confirmation-main">
<?php
include './php/credentials.php';
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<?php
$name=$_SESSION['customer']['firstName'];
$address= $_SESSION['customer']['address'];
$postalCode=$_SESSION['customer']['zip'];
$email=$_SESSION['customer']['email'];
$phone= $_SESSION['customer']['phone'];
$note=$_SESSION['customer']['notes'];
echo
'<div id="confirmation-contact">
<h1>Thank you, your order has been submitted.</h1><hr>
<div id="shipping-details">
<p><b>Name:</b></p>
<p>'.$name.'</p><br>
<p><b>Address:</b></p>
<p>'.$address.'</p>
<p>Singapore, '.$postalCode.'</p>
</div>
<div id="email-details">
<p><b>Email:</b></p>
<p>'.$email.'</p>
</div>
</div>'
?>
<div id="cart-summary">
<div id="cart-table" style="margin-top: 30px; float: none;">
<table id="cart-details">
<thead>
<tr>
<th></th>
<th>Item</th>
<th>Item Price</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
</thead>
<tbody>
<?php
$allPrice=0;
for ($i=0; $i<count($_SESSION['cart']); $i++)
{
if ($_SESSION['cart'][array_keys($_SESSION['cart'])[$i]]>0)
{
$sql = "SELECT * FROM menu where id=".array_keys($_SESSION['cart'])[$i];
$result = mysqli_query($conn, $sql);
$item=array();
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result))
{
$rowId ='ItemWithId' .array_keys($_SESSION['cart'])[$i];
$quantityId = 'quantity'.$rowId;
$priceId ='price'.$rowId;
$totalPriceId ='totalPrice'.$rowId;
$itemNoId = 'itemNo'.$rowId;
$deleteId ='delete'.$rowId;
$saveId ='save'.$rowId;
echo "<tr id='".$rowId."'>";
echo "<td class='td-center'><img src=".$row['imgURL']."><input type='number' class='input-number' value=".array_keys($_SESSION['cart'])[$i]." id='itemNoId' name='itemNoId'";
echo 'style="display:none"';
echo" ></td>";
echo "<td class='td-left'>" .$row['name']. "</td>";
echo "<td id='".$priceId."'>" .$row['price']. "</td>";
echo "<td>" .$_SESSION['cart'][array_keys($_SESSION['cart'])[$i]]. "</td>";
echo '</td>';
echo'</form>';
$totalPrice = $row['price']*$_SESSION['cart'][array_keys($_SESSION['cart'])[$i]];
echo "<td class='td-center' id='".$totalPriceId."'>".$totalPrice."</td>";
echo "<input type='number' value=".array_keys($_SESSION['cart'])[$i]." id='itemNoId' name='itemNoId'";
echo 'style="display:none"';
echo" >";
echo "</tr>";
$allPrice = $allPrice +$totalPrice;
}
}
}
else
{
$_SESSION['cart'][array_keys($_SESSION['cart'])[$i]]=0;
}
}
?>
</tbody>
</table>
</div>
<div id="order-summary2" style="float: none; margin-left: 550px;">
<table id="summary-details">
<thead>
<th style="border-bottom: 1px solid #ddd;"></th>
<th style="border-bottom: 1px solid #ddd;"></th>
<th style="border-bottom: 1px solid #ddd;"></th>
<th style="border-bottom: 1px solid #ddd;"></th>
</thead>
<tbody>
<tr>
<td style="text-align: left; margin-right: 190px;">subtotal</td>
<td></td>
<td></td>
<td style="text-align: left;"><?php echo $allPrice ?></td>
</tr>
<tr>
<td style="text-align: left; margin-right: 190px;">delivery</td>
<td></td>
<td></td>
<td style="text-align: left;">4</td>
</tr>
<tr>
<td style="text-align: left; margin-right: 190px;">gst (7%)</td>
<td></td>
<td></td>
<td style="text-align: left;"><?php $gstPrice = $allPrice * 0.07; echo $gstPrice; ?></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td style="text-align: left; margin-right: 190px; margin-top: 50px;"><h3>total</h3></td>
<td></td>
<td></td>
<td style="text-align: left; margin-top: 50px;"><h3><?php echo $allPrice + $gstPrice + 4; ?></h3></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<section>
<div class="footer">
<div id="icons">
<a href="#"><img src="assets/footer/fb_icon.jpg"></a>
<a href="#"><img src="assets/footer/pinterest_icon.jpg"></a>
<a href="#"><img src="assets/footer/snapchat_icon.jpg"></a>
<a href="#"><img src="assets/footer/spotify_icon.jpg"></a>
</div>
<div id="copyright">
<i>© The Sushi Bar All Rights Reserved</i>
</div>
</div>
</section>
</div>
</body>
<?php
unset($_SESSION['cart']);
unset($_SESSION['quantity']);
unset($_SESSION['customer']);
unset($_SESSION['paid']);
?>
</html>