-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotelbookingpayment.php
481 lines (455 loc) · 21.3 KB
/
hotelbookingpayment.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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<?php
include("header.php");
$sql = "SELECT * FROM hotel LEFT JOIN tourism_location ON hotel.location_id = tourism_location.location_id WHERE hotel_id='$_GET[hotelid]'";
$qsql = mysqli_query($con, $sql);
echo mysqli_error($con);
$rs = mysqli_fetch_array($qsql);
//####
$sqlhotel_image = "SELECT * FROM hotel_image WHERE hotel_id='$_GET[hotelid]'";
$qsqlhotel_image = mysqli_query($con, $sqlhotel_image);
$rshotel_image = mysqli_fetch_array($qsqlhotel_image);
$checkin = strtotime($_GET['checkin']);
$checkout = strtotime($_GET['checkout']);
$datediff = $checkout - $checkin;
$nodays = round($datediff / (60 * 60 * 24));
$nodays = $nodays + 1;
?>
<!-- Sub Banner Start -->
<div class="mg_sub_banner">
<div class="container">
<h2>Hotel Booking Payment Panel</h2>
</div>
</div>
<!-- Sub Banner Start -->
<!-- Main Contnt Wrap Start -->
<div class="iqoniq_contant_wrapper">
<section>
<div class="container">
<div class="row">
<!-- iqoniq Blog Listing Start -->
<div class="col-md-6">
<!-- iqoniq Blog Listing Start -->
<div class="mg_blog_listing fancy-overlay">
<div class="text">
<?php
$i = 0;
$sqlroomtype = "SELECT * FROM room_type where room_type.status='Active' AND room_type.hotel_id='$_GET[hotelid]' ";
if ($_GET['room_type']) {
$sqlroomtype = $sqlroomtype . " AND room_typeid='$_GET[room_type]'";
}
$qsqlroomtype = mysqli_query($con, $sqlroomtype);
while ($rsroomtype = mysqli_fetch_array($qsqlroomtype)) {
$sqlroomtypeimg = "SELECT * FROM hotel_image where status='Active' AND room_typeid='$rsroomtype[0]'";
$qsqlroomtypeimg = mysqli_query($con, $sqlroomtypeimg);
$rsroomtypeimg = mysqli_fetch_array($qsqlroomtypeimg);
?>
<h5 class="blog_title"><?php echo $rs['hotel_name']; ?></h5>
<div class="clear"></div>
<p><?php echo $rs['hotel_address']; ?>,<br><?php echo $rs['location_name']; ?><br>PIN : <?php echo $rs['hotel_pincode']; ?></p>
<hr>
<p><b>Hotel policies:</b><br><?php echo $rs['hotel_policies']; ?></p>
<?php
}
?>
</div>
</div>
<!-- iqoniq Blog Listing End -->
</div>
<!-- iqoniq Blog Listing Start -->
<!-- iqoniq Blog Listing Start -->
<div class="col-md-6">
<!-- iqoniq Blog Listing Start -->
<div class="mg_blog_listing fancy-overlay">
<div class="text">
<h5 class="blog_title">Tariff details
<hr>
</h5>
<?php
$i = 0;
$sqlroomtype = "SELECT * FROM room_type where room_type.status='Active' AND room_type.hotel_id='$_GET[hotelid]' ";
if ($_GET['room_type']) {
$sqlroomtype = $sqlroomtype . " AND room_typeid='$_GET[room_type]'";
}
$qsqlroomtype = mysqli_query($con, $sqlroomtype);
while ($rsroomtype = mysqli_fetch_array($qsqlroomtype)) {
$sqlroomtypeimg = "SELECT * FROM hotel_image where status='Active' AND room_typeid='$rsroomtype[0]'";
$qsqlroomtypeimg = mysqli_query($con, $sqlroomtypeimg);
$rsroomtypeimg = mysqli_fetch_array($qsqlroomtypeimg);
?>
<b>Redeem Gift Coupon here:</b>
<input type="text" class="form-control" name="giftcoupon" id="giftcoupon">
<input type="button" class="btn btn-primary" name="btnredeem" id="btnredeem" value="Click here to Verify" onclick="funverifydiscount(giftcoupon.value)"> <label id="divgiftcoupondetail"></label>
<hr>
<Div id="idpaychart">
<table class="table table-striped table-bordered">
<tr>
<th>Cost per day</th>
<td>Rs. <?php echo $rsroomtype['cost']; ?></td>
</tr>
<tr>
<th>No. of days</th>
<td><?php
if ($nodays == 1) {
echo $nodays . " Day";
} else {
echo $nodays . " Days";
}
?></td>
</tr>
<tr>
<th>Total Cost</th>
<th>Rs. <?php echo $totcost = $rsroomtype['cost'] * $nodays; ?></th>
</tr>
</table>
</div>
<input type="hidden" name="nodays" id="nodays" value="<?php echo $nodays; ?>">
<input type="hidden" name="cost" id="cost" value="<?php echo $rsroomtype['cost']; ?>">
<input type="hidden" name="totcost" id="totcost" value="<?php echo $totcost; ?>">
<input type="hidden" name="discount_amt" id="discount_amt" value="0">
<input type="hidden" name="couponcode" id="couponcode" value="0">
<input type="hidden" name="expirydate" id="expirydate" value="0">
<input type="hidden" name="discount_percentage" id="discount_percentage" value="0">
<input type="hidden" name="max_limit" id="max_limit" value="0">
<input type="hidden" name="reason" id="reason" value="0">
<input type="hidden" name="status" id="status" value="0">
<?php
}
?>
</div>
</div>
<!-- iqoniq Blog Listing End -->
</div>
<!-- iqoniq Blog Listing Start -->
<!-- iqoniq Blog Listing Start -->
<?php
$i = 0;
$sqlroomtype = "SELECT * FROM room_type where room_type.status='Active' AND room_type.hotel_id='$_GET[hotelid]' ";
if ($_GET['room_type']) {
$sqlroomtype = $sqlroomtype . " AND room_typeid='$_GET[room_type]'";
}
$qsqlroomtype = mysqli_query($con, $sqlroomtype);
$rsroomtype = mysqli_fetch_array($qsqlroomtype); {
$sqlroomtypeimg = "SELECT * FROM hotel_image where status='Active' AND room_typeid='$rsroomtype[0]'";
$qsqlroomtypeimg = mysqli_query($con, $sqlroomtypeimg);
$rsroomtypeimg = mysqli_fetch_array($qsqlroomtypeimg);
if (mysqli_num_rows($qsqlroomtypeimg) == 0) {
$imgname = "images/noimage.png";
} else {
if (file_exists("imghotel/$rsroomtypeimg[hotel_image]")) {
$imgname = "imghotel/$rsroomtypeimg[hotel_image]";
} else {
$imgname = "images/noimage.png";
}
}
?>
<div class="col-md-12">
<!-- iqoniq Blog Listing Start -->
<div class="mg_blog_listing fancy-overlay">
<div class="text">
<a>
<div class="col-md-12">
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:blue;">
<p class="list-group-item-text" style="width:500px;"><?php echo $rsroomtype['room_type']; ?> -
<?php
if ($_GET['adults'] == 1) {
echo $_GET['adults'] . " Adult";
} else {
echo $_GET['adults'] . " Adults";
}
?>
<?php
if ($_GET['adults'] != 0) {
if ($_GET['adults'] == 1) {
echo " and " . $rsroomtype['max_children'] . " Child";
} else {
echo " and " . $rsroomtype['max_children'] . " Children";
}
}
?><br>
</p>
</button>
</div>
<div class="col-md-6 text-left">
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:grey;">Check In - <?php echo date("d-M-Y", strtotime($_GET['checkin'])); ?> <?php echo date("h:i A", strtotime($_GET['checkintime'])); ?></button>
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:grey;">Check Out - <?php echo date("d-M-Y", strtotime($_GET['checkout'])); ?> <?php echo date("h:i A", strtotime($_GET['checkouttime'])); ?></button>
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:green;"><?php
$checkin = strtotime($_GET['checkin']);
$checkout = strtotime($_GET['checkout']);
$datediff = $checkout - $checkin;
$nodays = round($datediff / (60 * 60 * 24));
$nodays = $nodays + 1;
if ($nodays == 1) {
echo $nodays . " Day";
} else {
echo $nodays . " Days";
}
?></button>
</div>
<div class="col-md-6">
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:violet;text-align:left;padding:5px;"><b>Name</b><br><?php echo $_POST['name']; ?></button>
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:violet;text-align:left;padding:5px;"><b>Mobile No.</b><br><?php echo $_POST['contactnumber']; ?></button>
<button type="button" class="btn btn-primary btn-lg btn-block" style="height:75px;background-color:violet;text-align:left;padding:5px;"><b>Note</b><br><?php echo $_POST['note']; ?></button>
</div>
</a>
</div>
</div>
<!-- iqoniq Blog Listing End -->
</div>
<?php
}
?>
<!-- iqoniq Blog Listing Start -->
<div class="col-md-12">
<!-- iqoniq Blog Listing Start -->
<div class="mg_blog_listing fancy-overlay">
<div class="text">
<div class="box ng-scope" ng-controller="productTravellerController" style="height: 350px;">
<div class="box-content">
<?php
if (isset($_SESSION['customer_id'])) {
?>
<input type='hidden' name='hotelid' id='hotelid' value='<?php echo $_GET['hotelid']; ?>'>
<input type='hidden' name='room_type' id='room_type' value='<?php echo $_GET['room_type']; ?>'>
<input type='hidden' name='adults' id='adults' value='<?php echo $_GET['adults']; ?>'>
<input type='hidden' name='children' id='children' value='<?php echo $_GET['children']; ?>'>
<input type='hidden' name='checkin' id='checkin' value='<?php echo $_GET['checkin']; ?>'>
<input type='hidden' name='checkout' id='checkout' value='<?php echo $_GET['checkout']; ?>'>
<input type='hidden' name='checkintime' id='checkintime' value='<?php echo $_GET['checkintime']; ?>'>
<input type='hidden' name='checkouttime' id='checkouttime' value='<?php echo $_GET['checkouttime']; ?>'>
<input type='hidden' name='name' id='name' value='<?php echo $_POST['name']; ?>'>
<input type='hidden' name='contactnumber' id='contactnumber' value='<?php echo $_POST['contactnumber']; ?>'>
<input type='hidden' name='note' id='note' value='<?php echo $_POST['note']; ?>'>
<h3>Enter payment details </h3>
<div class="row">
<div class="col-md-6">
<span><label>Payment Type</label></span>
<span>
<select name="payment_type" id="payment_type" class="form-control" style="height:40px;" onchange="loadcardtype(this.value)">
<option value=''>Select payment type</option>
<option value='VISA'>VISA</option>
<option value='MASTER CARD'>MASTER CARD</option>
<option value='CREDIT CARD'>CREDIT CARD</option>
<option value='DEBIT CARD'>DEBIT CARD</option>
</select><span id="errpayment_type" class="errmsg flash"></span>
</span>
</div>
<div class="col-md-6" id="divcardtype"> <br></div>
</div>
<hr>
<div class="col-md-6">
<span><label>Card holder</label></span>
<span><input name="card_holder" id="card_holder" type="text" class="form-control"><span id="errcard_holder" class="errmsg flash"></span></span>
</div>
<div class="col-md-6">
<span><label>Card No</label></span>
<span><input name="card_no" id="card_no" type="text" class="form-control" value="<?php echo $rsedit['card_no']; ?>"><span id="errcard_no" class="errmsg flash"></span></span>
</div>
<div class="col-md-6">
<span><label>CVV No</label></span>
<span><input name="cvv_no" id="cvv_no" type="text" class="form-control" value="<?php echo $rsedit['cvv_no']; ?>"><span id="errcvv_no" class="errmsg flash"></span></span>
</div>
<div class="col-md-6">
<span><label>Expiry Date</label></span>
<span><input name="exp_date" id="exp_date" type="month" class="form-control" value="<?php echo $rsedit['exp_date']; ?>" min="<?php echo date("Y-m"); ?>"><span id="errexp_date" class="errmsg flash"></span></span>
</div>
<div class="col-md-12">
<hr>
<center><input type="button" id="btnpayment" name="btnpayment" class="btn btn-success" style="width: 250px;" value="Make payment"> </center>
</div>
<?php
} else {
?>
<h3>Enter Traveller Details </h3>
<div class="col-md-12">
New Customer
<input type="submit" class="form-control" value="Click here to Register" style="width:200px;" onclick="window.location='customerregistration.php?hotelid=<?php echo $_GET['hotelid']; ?>&room_type=<?php echo $_GET['room_type']; ?>&adults=<?php echo $_GET['adults']; ?>&children=<?php echo $_GET['children']; ?>&checkin=<?php echo $_GET['checkin']; ?>&checkout=<?php echo $_GET['checkout']; ?>&btnsearch=<?php echo $_GET['btnsearch']; ?>';">
<hr>
</div>
<div class="col-md-12">
Existing customer
<input type="submit" class="form-control" value="Click here to Login" style="width:200px;" onclick="window.location='customerlogin.php?hotelid=<?php echo $_GET['hotelid']; ?>&room_type=<?php echo $_GET['room_type']; ?>&adults=<?php echo $_GET['adults']; ?>&children=<?php echo $_GET['children']; ?>&checkin=<?php echo $_GET['checkin']; ?>&checkout=<?php echo $_GET['checkout']; ?>&btnsearch=<?php echo $_GET['btnsearch']; ?>'">
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- Main Contnt Wrap End -->
<?php
include("footer.php");
?>
<style>
a.list-group-item {
height: auto;
min-height: 220px;
}
a.list-group-item.active small {
color: #fff;
}
.stars {
margin: 20px auto 1px;
}
</style>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script>
$('#btnpayment').bind('click', function(e) {
var alphaExp = /^[a-zA-Z]+$/; //Variable to validate only alphabets
var alphaspaceExp = /^[a-zA-Z\s]+$/; //Variable to validate only alphabets with space
var alphanumericExp = /^[a-zA-Z0-9]+$/; //Variable to validate only alphanumerics
var numericExpression = /^[0-9]+$/; //Variable to validate only numbers
var emailpattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; //For email id
var i = 0;
$(".errmsg").empty();
var payment_type = $('#payment_type').val();
var card_holder = $('#card_holder').val();
var card_no = $('#card_no').val();
var cvv_no = $('#cvv_no').val();
var exp_date = $('#exp_date').val();
var name = $('#name').val();
var contactnumber = $('#contactnumber').val();
var note = $('#note').val();
var discount_amt = $('#discount_amt').val();
var couponcode = $('#couponcode').val();
var expirydate = $('#expirydate').val();
var discount_percentage = $('#discount_percentage').val();
var max_limit = $('#max_limit').val();
var reason = $('#reason').val();
var status = $('#status').val();
var hotelid = $('#hotelid').val();
var room_type = $('#room_type').val();
var adults = $('#adults').val();
var children = $('#children').val();
var checkin = $('#checkin').val();
var checkout = $('#checkout').val();
var checkintime = $('#checkintime').val();
var checkouttime = $('#checkouttime').val();
var cost = $('#cost').val();
var totcost = $('#totcost').val();
//errpayment_type errcard_holder errcard_no errcvv_no errexp_date
if (payment_type == "") {
document.getElementById("errpayment_type").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Kindly select payment type..";
i = 1;
}
if (!card_holder.match(alphaspaceExp)) {
document.getElementById("errcard_holder").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Card holder entry not valid..";
i = 1;
}
if (card_holder == "") {
document.getElementById("errcard_holder").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Card holder name should not be empty..";
i = 1;
}
if (card_no.length != 16) {
document.getElementById("errcard_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Kindly enter 16 digit Card number..";
i = 1;
}
if (!card_no.match(numericExpression)) {
document.getElementById("errcard_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Card Number entry not valid..";
i = 1;
}
if (card_no == "") {
document.getElementById("errcard_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Kindly enter Card number..";
i = 1;
}
if (cvv_no.length != 3) {
document.getElementById("errcvv_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Kindly enter 3 digit CVV number..";
i = 1;
}
if (cvv_no == "") {
document.getElementById("errcvv_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>CVV Number should not be empty..";
i = 1;
}
if (!cvv_no.match(numericExpression)) {
document.getElementById("errcvv_no").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>CVV Number entry not valid..";
i = 1;
}
if (exp_date == "") {
document.getElementById("errexp_date").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Expiry date should not be empty..";
i = 1;
}
if (i == 0) {
$.post("payment.php", {
'hotelid': hotelid,
'room_type': room_type,
'adults': adults,
'children': children,
'checkin': checkin,
'checkout': checkout,
'checkintime': checkintime,
'checkouttime': checkouttime,
'payment_type': payment_type,
'card_holder': card_holder,
'card_no': card_no,
'cvv_no': cvv_no,
'exp_date': exp_date,
'name': name,
'contactnumber': contactnumber,
'note': note,
'cost': cost,
'totcost': totcost,
'discount_amt': discount_amt,
'discount_couponcode': couponcode,
'discount_expirydate': expirydate,
'discount_percentage': discount_percentage,
'discount_max_limit': max_limit,
'discount_reason': reason,
'discount_status': status,
'btnhotelbooking': "btnhotelbooking"
},
function(data, status) {
alert("Payment done successfully...");
window.location = 'hotelbookingreceipt.php?paymentid=' + data;
});
}
});
function loadcardtype(cardtype) {
if (cardtype == "") {
document.getElementById("divcardtype").innerHTML = "";
} else {
document.getElementById("divcardtype").innerHTML = '<label><i class="fa fa-picture-o" aria-hidden="true"></i> Select Card Type</label><br><input type="radio" name="cardtype" value="Visa" required>Visa <input type="radio" name="cardtype" value="Master Card" required>Master Card ';
}
}
</script>
<script>
function funverifydiscount(giftcoupon) {
$.post("jsgiftcouponverify.php", {
'giftcoupon': giftcoupon,
'btngiftcoupon': "btngiftcoupon"
},
function(data, status) {
parsed = $.parseJSON(data);
if (parsed[0]['couponcode'] == 0) {
document.getElementById("divgiftcoupondetail").innerHTML = "<b style='color: red'>This coupon not available..</b>";
} else {
var toatlcost = document.getElementById("cost").value * document.getElementById("nodays").value;
var ttoalcost = document.getElementById("cost").value * document.getElementById("nodays").value;
var discountamt = (parsed[0]['discount_percentage'] * ttoalcost) / 100;
if (discountamt > parsed[0]['max_limit']) {
discountamt = parsed[0]['max_limit'];
}
ttoalcost = parseFloat(ttoalcost) - parseFloat(discountamt);
document.getElementById("divgiftcoupondetail").innerHTML = "<b style='color: green'>" + parsed[0]['discount_percentage'] + "% Discount Applied. Max Limit Rs." + parsed[0]['max_limit'] + "</b>";
document.getElementById("idpaychart").innerHTML = "<table class='table table-striped table-bordered'><tr><th>Cost per day</th><td>Rs. " + document.getElementById("cost").value + "</td></tr><tr><th>No. of days</th><td><?php if ($nodays == 1) {
echo $nodays . ' Day';
} else {
echo $nodays . ' Days';
} ?></td> </tr> <tr> <th>Sub Total </th><th>Rs. " + toatlcost + "</th> </tr> <tr> <th>Discount Amount</th><th>Rs. " + discountamt + "</th> </tr> <tr><th>Total Cost</th><th>Rs. " + ttoalcost + "</th></tr></table>";
document.getElementById("discount_amt").value = discountamt;
//###
document.getElementById("couponcode").value = parsed[0]['couponcode'];
document.getElementById("expirydate").value = parsed[0]['expirydate'];
document.getElementById("discount_percentage").value = parsed[0]['discount_percentage'];
document.getElementById("max_limit").value = parsed[0]['max_limit'];
document.getElementById("reason").value = parsed[0]['reason'];
document.getElementById("status").value = parsed[0]['status'];
//###
}
});
}
</script>