-
Notifications
You must be signed in to change notification settings - Fork 3
/
final_bill.php
112 lines (95 loc) · 3.61 KB
/
final_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
<!DOCTYPE html>
<html lang="en">
<head>
<title> Purchase | Farmex</title>
<meta charset ="utf-8"/>
<style type = "text/css">
td, th, table {
border: thin solid lightblue;
}
<? echo ‘<link href=”bill.css” media="" >’ ?>
</style>
</head>
<body>
<?php
//get form data values
$tomato = $_POST["tomato"];
$potato = $_POST["potato"];
$cauliflower = $_POST["cauliflower"];
$onion = $_POST["onion"];
$cabbage = $_POST["cabbage"];
$username = $_POST["username"];
$userhash = $_POST["userhash"];
//if any value is blank, set to zero
if ($tomato == "") $tomato =0;
if ($potato == "") $potato =0;
if ($cauliflower == "") $cauliflower =0;
if ($onion == "") $onion =0;
if ($cabbage == "") $cabbage =0;
//compute cost
$tomato_cost = 45 * $tomato;
$potato_cost = 35 * $potato;
$cauliflower_cost = 40 * $cauliflower;
$cabbage_cost = 19 * $cabbage;
$onion_cost = 49 * $onion;
$total_cost = $tomato_cost + $potato_cost + $cabbage_cost + $cauliflower_cost + $onion_cost;
$total_items = $tomato + $potato + $onion + $cauliflower + $cabbage;
$tax = 5/100 * $total_cost;
$costplustax = $total_cost + $tax;
?>
<h4> FARMEX - FRESH FROM THE FARM </h4>
<?php
print ("Customer Name: $username <br/>User Hash: $userhash ");
?>
<p/> <p/>
<table>
<caption>
ORDER INFORMATION
</caption>
<tr>
<th> Product </th>
<th> Unit Price </th>
<th> Quantity Ordered </th>
<th> Item Cost </th>
</tr>
<tr>
<td> Tomato </td>
<td> ₹45.00 </td>
<td> <?php print("$tomato"); ?> </td>
<td> <?php printf("₹ %4.2f", $tomato_cost); ?></td>
</tr>
<tr>
<td> Potato </td>
<td> ₹35.00 </td>
<td> <?php print("$potato"); ?> </td>
<td> <?php printf("₹ %4.2f", $potato_cost); ?></td>
</tr>
<tr>
<td> Onions </td>
<td> ₹49.00 </td>
<td> <?php print("$onion"); ?> </td>
<td> <?php printf("₹ %4.2f", $onion_cost); ?></td>
</tr>
<tr>
<td> Cauliflower </td>
<td> ₹40.00 </td>
<td> <?php print("$cauliflower"); ?> </td>
<td> <?php printf("₹ %4.2f", $cauliflower_cost); ?></td>
</tr>
<tr>
<td> Cabbage </td>
<td> ₹19.00 </td>
<td> <?php print("$cabbage"); ?> </td>
<td> <?php printf("₹ %4.2f", $cabbage_cost); ?></td>
</tr>
</table>
<p/> <p/>
<?php
print ("Total items: $total_items <br/>");
print ("Total Cost: ₹$total_cost <br/>");
printf ("GST on total (5%): ₹$tax <br/>");
printf ("Your total bill is:₹ %3.2f <br/>", $costplustax);
print ("THANK YOU, VISIT AGAIN");
?>
</body>
</html>