-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbill.php
122 lines (95 loc) · 4.07 KB
/
bill.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
<?php include('partials-front/menu.php'); ?>
<section class="food-menu">
<div class="container">
<h2 class="text-center b">Bill</h2>
<h3 class="text-center b">Cake My Day Bakery</h2>
<style>
table,
td,
th {
border: 1px solid #ddd;
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
th,
td {
padding: 15px;
}
</style>
<table>
<tr>
<th>S.No</th>
<th>Product</th>
<th>Dietary Restrictions</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<?php
$customer_id = $_SESSION['cust1'];
if (!$customer_id) {
$customer_id = $_SESSION['cust2'];
}
//Query to Get all CAtegories from Database
$sql = "SELECT * FROM tbl_cart WHERE customer_id=$customer_id and cart_status='active'";
$total_amount = 0;
//Execute Query
$res = mysqli_query($conn, $sql);
//Count Rows
$count = mysqli_num_rows($res);
//Create Serial Number Variable and assign value as 1
$sn = 1;
//Check whether we have data in database or not
if ($count > 0) {
//We have data in database
//get the data and display
while ($row = mysqli_fetch_assoc($res)) {
$name = $row['product_name'];
$quantity = $row['product_quantity'];
$diet = $row['diet'];
$tprice = $row['product_totalprice'];
$total_amount = $total_amount + $tprice;
?>
<tr>
<td><?php echo $sn++; ?>. </td>
<td><?php echo $name; ?></td>
<td><?php echo $diet; ?></td>
<td><?php echo $quantity; ?></td>
<td><?php echo $tprice; ?></td>
</tr>
<?php
}
} else {
//WE do not have data
//We'll display the message inside table
?>
<h3 class="text-center b">Error in generating bill!</h2>
<?php header('location:' . SITEURL . 'manage-cart.php');
} ?>
</table>
<br><br><br>
<h3 class="text-center b">Total Amount : <?php echo 'Rs. ', $total_amount ?></h2>
<br><br><br>
<form action="" method="POST" class="payment">
<fieldset>
<div class="order-label">Do you want to continue payment with your pre-existing personal information?</div>
<input type="radio" name="choice" value="yes"> Yes <br><br>
<input type="radio" name="choice" value="no"> No<br><br>
<input type="submit" name="submit" value="Submit" class="btn btn-primary">
</fieldset>
</form>
<?php
if (isset($_POST['submit'])) {
if ($_POST['choice'] == 'yes') {
$_SESSION['total_amount'] = $total_amount;
header('location:' . SITEURL . 'payment1.php');
} else if ($_POST['choice'] == 'no') {
$_SESSION['total_amount'] = $total_amount;
header('location:' . SITEURL . 'payment.php');
}
}
?>
<br><br><br>
<?php include('partials-front/footer.php'); ?>