-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.php
162 lines (126 loc) · 5.8 KB
/
payment.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
<html>
<head>
<title>Payment Gateway</title>
<link rel = "stylesheet" href = "Styles\payment.css">
</head>
<body>
<?php include 'menu.php'?>
<center><h1> Payment </h1></center>
<?php
$id = $_SESSION["id"];
$con = mysqli_connect("localhost", "root", "", "parkingsystem");
if (!$con)
{
die("Connection Failed!" . mysqli_connect_error());
}
$vtype = $_SESSION["vtype"];
$numberplate = $_SESSION["numplate"];
$sql1 = "select numberplate, timein, timeout,ticketid from tickets where numberplate = '$numberplate'";
$result1 = mysqli_query($con, $sql1);
if ($result1)
{
$row = mysqli_fetch_assoc($result1);
$ticid=$row['ticketid'];
$time1=$row['timein'];
$time2=$row['timeout'];
$numberplate = $row['numberplate'];
$vehicletype = [1 => 'Two Wheeler',2 => 'Four Wheeler',3 => 'Electric Two Wheeler',4 => 'Electric Two Wheeler'];
$vehicletype2 = $vehicletype[$vtype];
$ticketid = $_SESSION['ticketnum'];
$formattedtime1 = date("H:i:s", strtotime($time1));
$formattedtime2 = date("H:i:s", strtotime($time2));
echo "<div class='center'>";
echo "<div class='centerstyle'>";
echo "<label>Ticket Number:</label>";
echo "<input type='text' value='$ticketid' readonly>";
echo "<br><br>";
echo "<label>Username:</label>";
echo "<input type='text' value='$username' readonly>";
echo "<br><br>";
echo "<label>Vehicle Type:</label>";
echo "<input type='text' value='$vehicletype2' readonly>";
echo "<br><br>";
echo "<label>Time In: </label>";
echo "<input type='time' value='$formattedtime1' readonly>";
echo "<br><br>";
echo "<label>Time Out: </label>";
echo "<input type='time' value='$formattedtime2' readonly>";
$sql2 = "select slotnum from slot where ticketid = $ticid";
$result2=mysqli_query($con,$sql2);
$row=mysqli_fetch_assoc($result2);
$slot=$row['slotnum'];
echo "<br><br>";
echo "<label>Slot Number:</label>";
echo "<input type='text' value='$slot' readonly>";
if ($vtype == 1)
{
$price=10;
}
else if ($vtype == 2)
{
$price=20;
}
else if ($vtype == 3)
{
$price=5;
echo "Congrats on owning an Electric Two Wheeler";
}
else
{
$price=10;
echo "Congrats on owning an Electric Four Wheeler";
}
$sql3 = "SELECT
SEC_TO_TIME((TIME_TO_SEC(timeout) - TIME_TO_SEC(timein) + 86400) % 86400) AS td
FROM tickets where numberplate = '$numberplate'";
$result3 = mysqli_query($con,$sql3);
$row = mysqli_fetch_assoc($result3);
$timediff = $row['td'];
$timediff = date("H", strtotime($timediff));
// echo $timediff;
if($timediff!=0)
{
$price = $price * $timediff;
}
echo"<form action='' method='post'>";
echo "<br>";
echo "<label>Price of Ticket:</label>";
echo "<input type='text' value='$price' readonly>";
echo "<br><br>";
echo"<input type='submit' class = 'payment' name='pay' value='Buy Ticket'>";
echo"</form>";
echo "</div>";
echo "<div class='price-details'>";
echo "<h2>Price Details</h2>";
echo "<label> Two Wheeler: </label>";
echo "<label1> $10/hour </label1>";
echo "<br><br>";
echo "<label> Four Wheeler: </label>";
echo "<label1> $20/hour </label1>";
echo "<br><br>";
echo "<label> Electric Two Wheeler: </label>";
echo "<label1> $5/hour </label1>";
echo "<br><br>";
echo "<label> Electric Four Wheeler: </label>";
echo "<label1> $10/hour </label1>";
echo "</div>";
echo "</div>";
if(isset($_POST['pay']))
{
$sql4 = "insert into payment(price,slotnum) values('$price','$slot')";
$result4 = mysqli_query($con,$sql4);
if($result4)
{
echo "<script>alert('Payment Confirmed for $username\\nvehicle number $numberplate\\nslot number $slot');</script>";
echo "<script>window.location='order.php?slot=$slot';</script>";
}
else
{
echo"<script>alert('no')</script>";
}
}
}
?>
</body>
</html>
<!-- Duplication of same ticket not fixed yet! -->