-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment.php
395 lines (356 loc) · 12.6 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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<?php
include("header.php");
//Insert statement starts here
if(isset($_POST['submit']))
{
if($_GET['paidfor'] == "LLR")
{
$curreentdatedate = strtotime($dt);
$testdatedate = strtotime("+7 day", $curreentdatedate);
$testdate = date('Y-m-d', $testdatedate);
$sqlupd = "UPDATE llr SET status='Paid',applicationdate='$dt',testdate='$testdate' WHERE llrid='$_POST[insid]'";
$qsql = mysqli_query($con,$sqlupd);
echo mysqli_error($con);
}
if($_GET['paidfor'] == "DL")
{
$curreentdatedate = strtotime($dt);
$testdatedate = strtotime("+1 day", $curreentdatedate);
$testdate = date('Y-m-d', $testdatedate);
$sqlupd = "UPDATE drivinglicense SET status='Paid',applicationdate='$dt',testdate='$testdate' WHERE drivinglicenseid='$_POST[insid]'";
$qsql = mysqli_query($con,$sqlupd);
echo mysqli_error($con);
}
if($_GET['paidfor'] == "Vehicle Registration")
{
$curreentdatedate = strtotime($dt);
$testdatedate = strtotime("+7 days", $curreentdatedate);
$testdate = date('Y-m-d', $testdatedate);
$sqlupd = "UPDATE vehicleregistration SET status='Paid',date='$testdate' WHERE vehicleregid='$_POST[insid]'";
$qsql = mysqli_query($con,$sqlupd);
echo mysqli_error($con);
}
if($_GET['paidfor'] == "Address Change")
{
$curreentdatedate = strtotime($dt);
$testdatedate = strtotime("+7 days", $curreentdatedate);
$testdate = date('Y-m-d', $testdatedate);
$sqlupd = "UPDATE drivinglicense SET status='Paid',applicationdate='$dt',testdate='$testdate' WHERE drivinglicenseid='$_POST[insid]'";
$qsql = mysqli_query($con,$sqlupd);
echo mysqli_error($con);
}
if($_GET['paidfor'] == "Renewal")
{
$curreentdatedate = strtotime($dt);
$testdatedate = strtotime("+1 day", $curreentdatedate);
$testdate = date('Y-m-d', $testdatedate);
$sqlupd = "UPDATE drivinglicense SET status='Paid',applicationdate='$dt',testdate='$testdate' WHERE drivinglicenseid='$_POST[insid]'";
$qsql = mysqli_query($con,$sqlupd);
echo mysqli_error($con);
}
// insid paiddate paidfor paymenttype cardholder cardnumber expireson cvvnumber paidamt
$paymentdetail= "<br>Payment type: " . $_POST['paymenttype'];
$paymentdetail= $paymentdetail . "<br>Card holder: " . $_POST['cardholder'];
$paymentdetail= $paymentdetail . "<br>Card number: " . $_POST['cardnumber'];
$paymentdetail= $paymentdetail . "<br>Expires on: " . $_POST['expireson'];
$paymentdetail= $paymentdetail . "<br>CVV Number: " . $_POST['cvvnumber'];
$sql="INSERT INTO payment (enrollerid,paymenttype, paidfor, paidid, paidamt,paiddate,description,status)VALUES ('$_SESSION[enrollerid]','$_POST[paymenttype]','$_POST[paidfor]','$_POST[insid]','$_POST[paidamt]','$_POST[paiddate]','$paymentdetail','Active')";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
if(mysqli_affected_rows($con) == 1)
{
echo "<script>alert('Payment done successfully');</script>";
if($_GET['paidfor'] == "LLR")
{
echo "<script>window.location='llreceipt.php?insid=$_POST[insid]';</script>";
}
if($_GET['paidfor'] == "DL")
{
echo "<script>window.location='dlreceipt.php?insid=$_POST[insid]';</script>";
}
if($_GET['paidfor'] == "Vehicle Registration")
{
echo "<script>window.location='vehicleregistrationreceipt.php?insid=$_POST[insid]';</script>";
}
if($_GET['paidfor'] == "Address Change")
{
echo "<script>window.location='addresschangereceipt.php?insid=$_POST[insid]';</script>";
}
if($_GET['paidfor'] == "Renewal")
{
echo "<script>window.location='drivinglicenserenewalreceipt.php?insid=$_POST[insid]';</script>";
}
}
}
//Insert statement ends here
//Edit statement starts here
if(isset($_GET['editid']))
{
$sqledit ="SELECT * FROM payment WHERE paymentid='$_GET[editid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
}
//Edit statement ends here
if($_GET['paidfor'] == "LLR")
{
$sqledit ="SELECT * FROM llr LEFT JOIN enroller ON llr.enrollerid=enroller.enrollerid WHERE llr.llrid='$_GET[insid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
$arrvehicletypes = unserialize($rsedit['vehicletypeid']);
}
if($_GET['paidfor'] == "DL")
{
$sqledit ="SELECT * FROM drivinglicense LEFT JOIN enroller ON drivinglicense.enrollerid=enroller.enrollerid WHERE drivinglicense.drivinglicenseid='$_GET[insid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
$arrvehicletypes = unserialize($rsedit['vehicletypeid']);
}
if($_GET['paidfor'] == "Vehicle Registration")
{
$sqledit ="SELECT * FROM vehicleregistration LEFT JOIN enroller ON vehicleregistration.enrollerid=enroller.enrollerid WHERE vehicleregistration.vehicleregid='$_GET[insid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
$arrvehicletypes[0] = $rsedit['vehicletypeid'];
}
if($_GET['paidfor'] == "Address Change")
{
$sqledit ="SELECT * FROM drivinglicense LEFT JOIN enroller ON drivinglicense.enrollerid=enroller.enrollerid WHERE drivinglicense.drivinglicenseid='$_GET[insid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
$arrvehicletypes = unserialize($rsedit['vehicletypeid']);
}
if($_GET['paidfor'] == "Renewal")
{
$sqledit ="SELECT * FROM drivinglicense LEFT JOIN enroller ON drivinglicense.enrollerid=enroller.enrollerid WHERE drivinglicense.drivinglicenseid='$_GET[insid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
echo $arrvehicletypes = unserialize($rsedit['vehicletypeid']);
}
?>
<div class="slider">
<div class="callbacks_container">
<ul class="rslides" id="slider4">
<li style="background-color:black;height:150px;">
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</div>
<!-- //banner -->
<!--about-->
<section class="about" id="about">
<div class="container py-lg-5 py-md-5 py-sm-4 py-3">
<!--Horizontal Tab-->
<div id="horizontalTab">
<ul class="resp-tabs-list justify-content-center">
<li data-blast="bgColor">Make Payment</li>
</ul>
<div class="resp-tabs-container">
<div class="tab1">
<div class="row mt-lg-4 mt-3">
<div class="col-md-5 about-txt-img">
<table class="table table-striped table-bordered">
<tr>
<th colspan="2" style="background-color: green;color:white;"><?php echo $_GET['paidfor']; ?> Application detail</th>
</tr>
<tr>
<td>Application No.</td><td><?php echo $_GET['insid']; ?></td>
</tr>
<tr>
<td>Name.</td><td><?php echo $rsedit['name']; ?></td>
</tr>
<tr>
<th colspan="2" style="background-color: green;color:white;">Total Cost</th>
</tr>
<?php
$tcost = 0;
$cost =0;
foreach($arrvehicletypes as $vtype)
{
$sqlvehicletype = "SELECT * FROM vehicletype WHERE vehicletypeid='$vtype'";
$qsqlvehicletype = mysqli_query($con,$sqlvehicletype);
$rsvehicletype = mysqli_fetch_array($qsqlvehicletype);
if($_GET['paidfor'] == "LLR")
{
?>
<tr>
<td><?php echo $rsvehicletype['vehicletype']; ?></td><td>₹<?php echo $rsvehicletype["llrcost"];
$cost=$rsvehicletype["llrcost"];
?></td>
</tr>
<?php
}
if($_GET['paidfor'] == "DL")
{
?>
<tr>
<td><?php echo $rsvehicletype['vehicletype']; ?></td><td>₹<?php echo $rsvehicletype["dlcost"];
$cost=$rsvehicletype["dlcost"];
?></td>
</tr>
<?php
}
if($_GET['paidfor'] == "Vehicle Registration")
{
?>
<tr>
<td><?php echo $rsvehicletype['vehicletype']; ?></td><td>₹<?php echo $rsvehicletype["vehicleregcost"];
$cost=$rsvehicletype["vehicleregcost"];
?></td>
</tr>
<?php
}
if($_GET['paidfor'] == "Address Change")
{
?>
<tr>
<td><?php echo $rsvehicletype['vehicletype']; ?></td><td>₹<?php echo $rsvehicletype["addresschangecost"];
$cost=$rsvehicletype["addresschangecost"];
?></td>
</tr>
<?php
}
if($_GET['paidfor'] == "Renewal")
{
?>
<tr>
<td><?php echo $rsvehicletype['vehicletype']; ?></td><td>₹<?php echo $rsvehicletype["dlrenewalcost"];
$cost=$rsvehicletype["dlrenewalcost"];
?></td>
</tr>
<?php
}
$tcost = $tcost +$cost;
}
?>
<tr>
<th>Total cost</th><th>₹<?php echo $tcost; ?></th>
</tr>
</table>
</div>
<div class="col-md-7 latest-list">
<div class="about-jewel-agile-left">
<p>
<form action="" method="post" onsubmit="return validateform()">
<input type="hidden" class="form-control" id="paidfor" name="paidfor" value="<?php echo $_GET['paidfor']; ?>">
<input type="hidden" class="form-control" id="paiddate" name="paiddate" value="<?php echo date("Y-m-d"); ?>">
<input type="hidden" class="form-control" id="insid" name="insid" value="<?php echo $_GET['insid']; ?>">
<div class="form-group">
<label for="email">Payment Type:<span class="classvalidate" id="idpaymenttype"></span></label>
<select class="form-control" id="paymenttype" placeholder="Enter Payment Type" name="paymenttype">
<option value="">Select card type</option>
<?php
$arr = array("VISA","Master Card","Rupay");
foreach($arr as $val)
{
echo "<option value='$val'>$val</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="email">Name on Card:<span class="classvalidate" id="idcardholder"></span></label>
<input type="text" class="form-control" id="cardholder" placeholder="Enter Card Holder" name="cardholder">
</div>
<div class="form-group">
<label for="email">16 digit Card number:<span class="classvalidate" id="idcardnumber"></span></label>
<input type="text" class="form-control" id="cardnumber" placeholder="Enter Card number" name="cardnumber">
</div>
<div class="form-group">
<label for="email">Card Valid till:<span class="classvalidate" id="idexpireson"></span></label>
<input type="month" min="<?php echo date("Y-m"); ?>" class="form-control" id="expireson" placeholder="Enter Expiry date" name="expireson">
</div>
<div class="form-group">
<label for="email">CVV:<span class="classvalidate" id="idcvvnumber"></span></label>
<input type="number" class="form-control" id="cvvnumber" placeholder="CVV Number" name="cvvnumber">
</div>
<div class="form-group">
<label for="email">Total Amount:</label>
<input type="text" readonly class="form-control" id="paidamt" placeholder="Enter Paid Amt" name="paidamt" value="<?php echo $tcost; ?>">
</div>
<button type="submit" name="submit" class="btn btn-info">Click here to Pay</button>
</form>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--//about-->
<?php
include("footer.php");
?>
<script>
$(document).ready( function () {
$('#myTable').DataTable();
} );
</script>
<script>
function confirmdel()
{
if(confirm("Are you sure want to delete this record?") == true)
{
return true;
}
else
{
return false;
}
}
</script>
<script>
function validateform()
{
var numericExpression = /^[0-9]+$/;
var alphaExp = /^[a-zA-Z]+$/;
var alphaspaceExp = /^[a-zA-Z\s]+$/;
var alphaNumericExp = /^[0-9a-zA-Z]+$/;
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
var validateform="true";
$( ".classvalidate" ).empty();
if(document.getElementById("paymenttype").value=="")
{
document.getElementById("idpaymenttype").innerHTML="Payment Type Should not be empty...";
validateform="false";
}
if(document.getElementById("cardholder").value=="")
{
document.getElementById("idcardholder").innerHTML="Card Holder Should not be empty...";
validateform="false";
}
if(document.getElementById("cardnumber").value=="")
{
document.getElementById("idcardnumber").innerHTML="Card Number Should not be empty...";
validateform="false";
}
if(document.getElementById("expireson").value=="")
{
document.getElementById("idexpireson").innerHTML="Expires on Should not be empty...";
validateform="false";
}
if(document.getElementById("cvvnumber").value.length >3 )
{
document.getElementById("idcvvnumber").innerHTML="cvvnumber Should Contains only 3 nos...";
validateform="false";
}
if(document.getElementById("cvvnumber").value=="")
{
document.getElementById("idcvvnumber").innerHTML="cvvnumber Should not be empty...";
validateform="false";
}
if(validateform=="true")
{
return true;
}
else
{
return false;
}
}
</script>