-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorderuser.php
212 lines (181 loc) · 7.49 KB
/
orderuser.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
<?php
include ('components/header.php');
include ('components/sidebaruser.php');
$products= query("SELECT * FROM product");
$conn = connection();
$id = $_SESSION['id'];
$Get = isset($_GET['discountCode']) ? $_GET['discountCode'] : '';
$getDiscount = query("SELECT * FROM discount WHERE discountCode = '$Get'");
?>
<!DOCTYPE html>
<html lang="en">
<body>
<!-- ======= Header ======= -->
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
<a href="index.html" class="logo d-flex align-items-center">
<img src="assets/img/logo.png" alt="" />
<span class="d-none d-lg-block">PRES U Caffe</span>
</a>
<i class="bi bi-list toggle-sidebar-btn"></i>
</div>
<!-- End Search Bar -->
<nav class="header-nav ms-auto">
<ul class="d-flex align-items-center">
<li class="nav-item d-block d-lg-none">
<a class="nav-link nav-icon search-bar-toggle" href="#">
<i class="bi bi-search"></i>
</a>
</li>
<!--End Search Icon-->
<!-- End Profile Nav -->
</ul>
</nav>
<!-- End Icons Navigation -->
</header>
<!-- End Header -->
<!-- ======= Sidebar ======= -->
<?php
?>
<!-- End Sidebar-->
<main id="main" class="main">
<div class="pagetitle">
<h3>My Order</h3>
</div>
<div style="clear:both"></div>
<br />
<h3>Order Details</h3>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="40%">Item Name</th>
<th width="10%">Quantity</th>
<th width="20%">Price</th>
<th width="15%">Total</th>
<th width="5%">Action</th>
</tr>
<?php
if(!empty($_SESSION["shopping_cart"]))
{
$total = 0;
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
?>
<tr>
<td><?php echo $values["item_name"]; ?></td>
<td><?php echo $values["item_quantity"]; ?></td>
<td>Rp. <?php echo $values["item_price"]; ?></td>
<td>Rp. <?php echo number_format($values["item_quantity"] * $values["item_price"], 2);?></td>
<td><a href="dashboarduser.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">Remove</span></a></td>
</tr>
<?php
$total = $total + ($values["item_quantity"] * $values["item_price"]);
}
?>
<tr>
<td colspan="3" align="right">Total</td>
<td align="right">Rp. <?php echo number_format($total, 2); ?></td>
<td></td>
</tr>
<?php
}
?>
</table>
</div>
<div >
<form method="post" action="">
<label for="Voucher" class="col-form-label">Discount Code</label>
<div class="col-sm-10 d-flex">
<input type="text" name="voucher" class="form-control mx-2" id="Voucher">
<input type="submit" class="btn btn-success"></input>
</div>
</form>
</div>
<div>
<label for="Method" class="col-form-label">Payment Method</label>
<div class="col-sm-10">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1">
<label class="form-check-label" for="inlineRadio1">OVO</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2">
<label class="form-check-label" for="inlineRadio2">ShopeePay</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3">
<label class="form-check-label" for="inlineRadio2">Cash</label>
</div>
</div>
</div>
<div>
<?php
if(isset($_POST['voucher'])){
$voucher = $_POST['voucher'];
$query = mysqli_query($conn, "SELECT * FROM discount WHERE discountCode = '$voucher'");
if(mysqli_num_rows($query) == 0){
echo "<script>alert('Voucher not found!')</script>";
echo "<script>window.location.href='orderuser.php'</script>";
}
$getDiscount = mysqli_fetch_assoc($query);
$total = $total - $total / 100 * $getDiscount['discountAmount'];
?>
<div class="form-group
row">
<div class="col-sm-10">
<label for="Total" class="col-form-label">Total</label>
<p>Discount Code: <?php echo $voucher ?> </p>
<p>Discount Amount: <?php echo $getDiscount['discountAmount'] ?>%</p>
<p class='h4'>Total: Rp. <?php echo number_format($total, 2); ?> </p>
<p></p>
</div>
</div>
<?php } ?>
</input>
</form>
<form method="post" action="orderlist.php">
<input type="hidden" name="price" value="<?php echo $total; ?>"></input>
<input type="hidden" name="name" value="<?php echo $_SESSION['name']; ?>"></input>
<?php
$totalQuantity = 0;
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
$totalQuantity += $values["item_quantity"];
}
?>
<input type="hidden" name="quantity" value="<?php echo $totalQuantity; ?>"></input>
<?php
$itemName = "";
foreach($_SESSION["shopping_cart"] as $keys => $values)
{
$itemName .= $values["item_name"] . ", ";
}
?>
<input type="hidden" name="item" value="<?php echo $itemName; ?>"></input>
<input type="submit" name="submit" class="btn btn-primary" value="Order"></input>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- ======= Footer ======= -->
<!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/chart.js/chart.min.js"></script>
<script src="assets/vendor/echarts/echarts.min.js"></script>
<script src="assets/vendor/quill/quill.min.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>