This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
user.bookings.php
734 lines (651 loc) · 37.2 KB
/
user.bookings.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
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
<?php
session_start();
include_once ('db_config.php');
if(isset($_SESSION['userID']) && !empty($_SESSION['userID']) && !($_SESSION['userID']=='0')) {
$user = "SELECT * FROM tbl_users WHERE `user_id` = '{$_SESSION['userID']}'";
$user_result = $db->query($user);
$user_row = $user_result->fetch_assoc();
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<!--JQuery Toast CSS-->
<link rel="stylesheet" type="text/css" href="css/jquery.toast.min.css">
<!--Custom Style CSS-->
<link rel="stylesheet" type="text/css" href="css/style.css?v=<?php echo time(); ?>">
<link rel="shortcut icon" type="image/png" href="images/icon.png">
<title>InstaMovies - <?php echo $user_row['first_name'];?> | Bookings</title>
<style>
.navbar {
background:black !important;
}
@media (max-width: 575px){
#ticketIDForm .form-control {
margin-bottom: 15px;
}
#ticketIDForm .row {
margin-left: 0;
}
#ticketIDForm .col-sm-8, .col-sm-2 {
padding-left: 0;
padding-right: 0;
}
#publishTicket_ticketIDForm .form-control {
margin-bottom: 15px;
}
#publishTicket_ticketIDForm .row {
margin-left: 0;
}
#publishTicket_ticketIDForm .col-sm-7, .col-sm-3 {
padding-left: 0;
padding-right: 0;
}
}
</style>
</head>
<body id="itemid-3" style="background-color:#ebebeb">
<!--Navbar Code - Start-->
<?php include('header.php'); ?>
<!--Navbar Code - End-->
<div style="margin-top:100px; margin-bottom:25px">
<div class="container mt-3" style="background:#FFF;padding-bottom:15px">
<div style="padding:15px"><h1 style="font-size:35px; font-weight:normal;">Bookings</h1></div>
<div style="margin:10px 0 30px; text-align:center">
<button class="btn btn-info" style="margin:0 2px" data-toggle="modal" data-target="#changeSeatModal">Change Seat</button>
<button class="btn btn-success" style="margin:0 2px" data-toggle="modal" data-target="#publishTicketModal">Publish Ticket</button>
</div>
<div class="table-responsive" style="padding:0 15px">
<table id="bookings_table" class="table table-striped table-bordered table-sm">
<thead style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</th>
<th>Booking Time</th>
<th>Movie</th>
<th>Theater</th>
<th>Show Date</th>
<th>Show Time</th>
<th>Category</th>
<th>Ticket Count</th>
<th>Seat(s)</th>
<th>Total Amount</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT A.*, GROUP_CONCAT(A.seat_number ORDER BY A.seat_id ASC) AS seat_number, B.movie_name, C.theatre_name, C.city, E.starting_time FROM tbl_bookings A, tbl_movies B, tbl_theatres C, tbl_shows D, tbl_showtimes E WHERE A.user_id = '{$_SESSION['userID']}' AND A.show_id = D.show_id AND B.movie_id = D.movie_id AND C.theatre_id = D.theatre_id AND A.showtime_id = E.showtime_id GROUP BY A.ticket_id ORDER BY booking_id DESC";
$result = $db->query($sql);
if($result->num_rows>0){
$i=0;
while($row=$result->fetch_assoc()){
$i++;
$show_datetime = strtotime($row['show_date']." ".$row['starting_time']);
$current_datetime = time();
$timeDiff = $show_datetime - $current_datetime;
echo "<tr>";
echo "<td>{$i}</td>";
echo "<td>{$row['ticket_id']}</td>";
echo "<td>{$row['booking_time']}</td>";
echo "<td>{$row['movie_name']}</td>";
echo "<td>{$row['theatre_name']} - {$row['city']}</td>";
echo "<td>{$row['show_date']}</td>";
echo "<td>".date('h:i A', strtotime($row['starting_time']))."</td>";
echo "<td>{$row['ticket_category']}</td>";
echo "<td>"."Full: {$row['full_seat_count']}"."<br>"."Kids: {$row['kids_seat_count']}"."</td>";
echo "<td>{$row['seat_number']}</td>";
echo "<td>Rs. ".number_format((float)$row['total_amount'], 2, '.', '')."</td>";
echo "<td style='text-align:center'>";
if($row['status'] == '2'){
echo "<span style='font-weight:bold;color:#c40099'>Sold<br>(✓)</span>";
}else if($row['status'] == '1'){
if ($timeDiff > 3600){
echo "<span style='font-weight:bold;color:#017ec6'>Published</span>";
}else{
echo "<span style='font-weight:bold;color:#ce0000'>Not sold<br>(✗)</span>";
}
}else{
if ($timeDiff > 0){
echo "<span style='font-weight:bold;color:green'>Booked</span>";
}else{
echo "<span style='font-weight:bold;font-size:20px;color:green'>✓</span>";
}
}
echo "</td>";
echo "</tr>";
}
}else{
echo "<tr><td colspan='12' style='padding-left:7px'>No bookings found.</td></tr>";
}
?>
</tbody>
<tfoot style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</th>
<th>Booking Time</th>
<th>Movie</th>
<th>Theater</th>
<th>Show Date</th>
<th>Show Time</th>
<th>Category</th>
<th>Ticket Count</th>
<th>Seat(s)</th>
<th>Total Amount</th>
<th>Status</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div style="margin-top:25px; margin-bottom:25px">
<div class="container mt-3" style="background:#FFF;padding-bottom:15px">
<div style="padding:15px"><h1 style="font-size:35px; font-weight:normal">Purchased Tickets</h1></div>
<div class="table-responsive" style="padding:0 15px">
<table id="bookings_table" class="table table-striped table-bordered table-sm">
<thead style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</th>
<th>Booking Time</th>
<th>Movie</th>
<th>Theater</th>
<th>Show Date</th>
<th>Show Time</th>
<th>Category</th>
<th>Ticket Count</th>
<th>Seat(s)</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT A.*, GROUP_CONCAT(A.seat_number ORDER BY A.seat_id ASC) AS seat_number, B.movie_name, C.theatre_name, C.city, E.starting_time, F.timestamp FROM tbl_bookings A, tbl_movies B, tbl_theatres C, tbl_shows D, tbl_showtimes E, tbl_bookings_purchase F WHERE F.user_id = '{$_SESSION['userID']}' AND F.ticket_id = A.ticket_id AND A.show_id = D.show_id AND B.movie_id = D.movie_id AND C.theatre_id = D.theatre_id AND A.showtime_id = E.showtime_id GROUP BY A.ticket_id ORDER BY booking_id DESC";
$result = $db->query($sql);
if($result->num_rows>0){
$i=0;
while($row=$result->fetch_assoc()){
$i++;
$show_datetime = strtotime($row['show_date']." ".$row['starting_time']);
$current_datetime = time();
$timeDiff = $show_datetime - $current_datetime;
echo "<tr>";
echo "<td>{$i}</td>";
echo "<td>{$row['ticket_id']}</td>";
echo "<td>{$row['timestamp']}</td>";
echo "<td>{$row['movie_name']}</td>";
echo "<td>{$row['theatre_name']} - {$row['city']}</td>";
echo "<td>{$row['show_date']}</td>";
echo "<td>".date('h:i A', strtotime($row['starting_time']))."</td>";
echo "<td>{$row['ticket_category']}</td>";
echo "<td>"."Full: {$row['full_seat_count']}"."<br>"."Kids: {$row['kids_seat_count']}"."</td>";
echo "<td>{$row['seat_number']}</td>";
echo "<td>Rs. ".number_format((float)$row['total_amount'], 2, '.', '')."</td>";
echo "</tr>";
}
}else{
echo "<tr><td colspan='11' style='padding-left:7px'>No purchased tickets found.</td></tr>";
}
?>
</tbody>
<tfoot style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</th>
<th>Booking Time</th>
<th>Movie</th>
<th>Theater</th>
<th>Show Date</th>
<th>Show Time</th>
<th>Category</th>
<th>Ticket Count</th>
<th>Seat(s)</th>
<th>Total Amount</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="modal fade" id="changeSeatModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" style="background:white">
<div class="modal-header">
<h5 class="modal-title">Change Seat</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="outline:none">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="ticketIDForm">
<div class="form-group row" style="margin-bottom:0;margin-right:0">
<label class="col-sm-2 col-form-label">Ticket ID:</label>
<div class="col-sm-8">
<input id="changeSeat_ticket_id" type="text" class="form-control" maxlength="15" style="text-transform:uppercase">
</div>
<button id="changeSeat_viewTicket" type="button" class="btn btn-danger col-sm-2">View</button>
</div>
</form>
<div id="changeSeat_details">
</div>
<div id="changeSeat_invalid" class="alert alert-danger" style="margin:20px 0 0;padding:8px;text-align:center;display:none" role="alert">
Ticket ID is invalid!
</div>
<div id="customerDetails" style="display:none">
<div style="background:#000; color:#FFF; padding:5px 10px; margin:0 0 20px; font-size:20px; text-align:center">You have <span id="timer">200</span> seconds to complete this process.</div>
<div id="changeSeat_errorForm" class="alert alert-danger" style="margin:0 0 15px;padding:8px;text-align:center;display:none" role="alert">
</div>
<form id="customerDetailsForm">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Customer Name:</label>
<div class="col-sm-9">
<input id="customer_name" name="customer_name" type="text" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Customer Mobile:</label>
<div class="col-sm-9">
<input id="customer_mobile" name="customer_mobile" type="text" maxlength="10" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Customer Email:</label>
<div class="col-sm-9">
<input id="customer_email" name="customer_email" type="text" class="form-control">
</div>
</div>
<div class="terms" style="margin:20px 0 0">
<input style="margin: 0 10px 15px 0" type="checkbox" name="terms" id="terms"/>I Agree to <a href="terms_and_conditions.php">Terms & Conditions</a>.
<div class="error_code" style="color:red; font-size:11px; display: none;">Please Agree to Terms & Conditions!</div>
</div>
</form>
<div class="payment_options" align="center" style="margin-top: 20px">
<form id="payment_options_form">
<table>
<tr><td><input class="pay_method" type="radio" name="payment_type" id="payment_type" value="visa_mastercard" checked = "checked"></td><td>Pay by Credit Card, Visa / Master</td><td style="padding-left:10px;"><img src="images/pp_master.jpg" /></td></tr>
<tr><td><input disabled class="pay_method" type="radio" name="payment_type" id="payment_type" value="union"></td><td>Pay by Union Bank Credit</td><td style="padding-left:10px;"><img src="images/pp_union.png" /></td></tr>
<tr><td><input disabled class="pay_method" type="radio" name="payment_type" id="payment_type" value="dfcc"></td><td>Pay by DFCC Bank Credit</td><td style="padding-left:10px;"><img src="images/pp_dfcc.png" /></td></tr>
</table>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button id="changeSeat_confirm" type="button" class="btn btn-primary">Confirm</button>
<button id="changeSeat_pay" type="button" class="btn btn-primary" style="display:none">Pay Now</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="publishTicketModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content" style="background:white">
<div class="modal-header">
<h5 class="modal-title">Cancel & Publish Ticket</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="outline:none">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="publishTicket_ticketIDForm">
<div class="form-group row" style="margin-bottom:0;margin-right:0">
<label class="col-sm-3 col-form-label">Ticket ID:</label>
<div class="col-sm-7">
<input id="ticket_id" type="text" class="form-control" maxlength="15" style="text-transform:uppercase">
</div>
<button id="viewTicket" type="button" class="btn btn-danger col-sm-2">View</button>
</div>
</form>
<div id="ticketDetails">
</div>
<div id="invalid" class="alert alert-danger" style="margin:20px 0 0;padding:8px;text-align:center;display:none" role="alert">
Ticket ID is invalid!
</div>
<div id="publishTicket_customerDetails" style="display:none">
<div style="background:#000; color:#FFF; padding:5px 10px; margin:0 0 20px; font-size:20px; text-align:center">You have <span id="publishTicket_timer">200</span> seconds to complete this process.</div>
<div id="publishTicket_errorForm" class="alert alert-danger" style="margin:0 0 15px;padding:8px;text-align:center;display:none" role="alert">
</div>
<form id="publishTicket_customerDetailsForm">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Customer Name:</label>
<div class="col-sm-8">
<input id="publishTicket_customer_name" name="customer_name" type="text" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Customer Mobile:</label>
<div class="col-sm-8">
<input id="publishTicket_customer_mobile" name="customer_mobile" type="text" maxlength="10" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Customer Email:</label>
<div class="col-sm-8">
<input id="publishTicket_customer_email" name="customer_email" type="text" class="form-control">
</div>
</div>
<div class="terms" style="margin:20px 0 0">
<input style="margin: 0 10px 15px 0" type="checkbox" name="publishTicket_terms" id="publishTicket_terms"/>I Agree to <a href="terms_and_conditions.php">Terms & Conditions</a>.
<div class="publishTicket_error_code" style="color:red; font-size:11px; display: none;">Please Agree to Terms & Conditions!</div>
</div>
</form>
<div class="payment_options" align="center" style="margin-top: 20px">
<form id="publishTicket_payment_options_form">
<table>
<tr><td><input class="pay_method" type="radio" name="publishTicket_payment_type" id="publishTicket_payment_type" value="visa_mastercard" checked = "checked"></td><td>Pay by Credit Card, Visa / Master</td><td style="padding-left:10px;"><img src="images/pp_master.jpg" /></td></tr>
<tr><td><input disabled class="pay_method" type="radio" name="publishTicket_payment_type" id="publishTicket_payment_type" value="union"></td><td>Pay by Union Bank Credit</td><td style="padding-left:10px;"><img src="images/pp_union.png" /></td></tr>
<tr><td><input disabled class="pay_method" type="radio" name="publishTicket_payment_type" id="publishTicket_payment_type" value="dfcc"></td><td>Pay by DFCC Bank Credit</td><td style="padding-left:10px;"><img src="images/pp_dfcc.png" /></td></tr>
</table>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button id="publishTicket_confirm" type="button" class="btn btn-primary">Confirm</button>
<button id="publishTicket_pay" type="button" class="btn btn-primary" style="display:none">Pay Now</button>
</div>
</div>
</div>
</div>
<!--Footer Code - Start-->
<?php include('footer.php') ?>
<!--Footer Code - End-->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.toast.min.js"></script>
<script>
jQuery(document).ready(function(){
//Publish Ticket -start
$('#publishTicketModal').on('shown.bs.modal', function () {
$('#ticket_id').focus();
});
$("#ticketDetails").html("");
$("#ticket_id").on("input", function(){
$("#ticketDetails").html("");
$("#invalid").hide();
})
$("#viewTicket").on("click", function(){
var ticketID = $("#ticket_id").val();
if(ticketID != ""){
$.ajax({
url:'assets/user.bookings.publishTicket.view_ticket.php',
type:'POST',
data:'ticketID=' + ticketID,
success:function(html){
if(html!=""){
$("#ticketDetails").html(html);
}else{
$("#invalid").show();
}
}
});
}
});
$('#publishTicketModal').on('hidden.bs.modal', function () {
$("#ticket_id").val("");
$("#ticketDetails").html("");
$("#invalid").hide();
$("#publishTicket_customerDetails").hide();
$("#publishTicket_customerDetailsForm")[0].reset();
$("#publishTicket_ticketIDForm").show();
$("#publishTicket_confirm").show();
$("#publishTicket_pay").hide();
$("#ticketDetails").show();
$("#publishTicket_errorForm").hide();
$(".publishTicket_error_code").hide();
});
$("#publishTicket_confirm").on("click", function(){
if($("#ticketDetails").html()!=""){
var ticketID = $("#ticket_id").val();
$.ajax({
url:'assets/user.bookings.publishTicket.check.php',
type:'POST',
data:'ticketID=' + ticketID,
success:function(success){
if(success=="success"){
$("#publishTicket_ticketIDForm").hide();
$("#publishTicket_confirm").hide();
$("#publishTicket_pay").show();
$("#ticketDetails").hide();
$("#publishTicket_customerDetails").show();
$('#publishTicket_customer_name').focus();
var remaining_time = 200;
document.getElementById("publishTicket_timer").innerHTML = remaining_time;
var publishTicket_Timer = setInterval(function(){
remaining_time -= 1;
document.getElementById("publishTicket_timer").innerHTML = remaining_time;
if(remaining_time <= 0){
remaining_time = 0;
clearInterval(publishTicket_Timer);
$("#publishTicketModal").modal("hide");
}
$('#publishTicketModal').on('hidden.bs.modal', function () {
clearInterval(publishTicket_Timer);
});
}, 1000);
}else{
$.toast({
text: "Ticket was already published.",
icon: 'error',
position: 'top-center',
hideAfter: 4000,
stack: false,
loader: false
});
}
}
});
}
});
$("#publishTicket_pay").on("click", function(){
var customername = jQuery("#publishTicket_customer_name").val();
var customerphone = jQuery("#publishTicket_customer_mobile").val();
var customeremail = jQuery("#publishTicket_customer_email").val();
var numberfilter = /^((\+[1-9]{1,10}[ \-]*)|(\([0-9]{2,10}\)[ \-]*)|([0-9]{2,10})[ \-]*)*?[0-9]{3,10}?[ \-]*[0-9]{0,10}?$/;
var emailfilter = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
if(customername!="" && customerphone!="" && customeremail!=""){
if (!numberfilter.test(customerphone) || customerphone.length!=10) {
jQuery("#publishTicket_errorForm").show();
jQuery("#publishTicket_errorForm").html("Invalid phone number !");
}else{
if(!emailfilter.test(customeremail)){
jQuery("#publishTicket_errorForm").show();
jQuery("#publishTicket_errorForm").html("Invalid email !");
}else{
jQuery("#publishTicket_errorForm").hide();
publishTicket_saveUserData();
}
}
}else{
jQuery("#publishTicket_errorForm").show();
jQuery("#publishTicket_errorForm").html("Fields can not be empty !");
}
});
function publishTicket_saveUserData() {
if(jQuery('#publishTicket_terms').prop('checked')){
jQuery(".publishTicket_error_code").hide();
var user_data = $("#publishTicket_customerDetailsForm").serialize();
var paymentType = $("input[name='publishTicket_payment_type']:checked").val();
window.location = "assets/user.bookings.publishTicket.payment.php?" + user_data + "&paymentType=" + paymentType;
}else{
jQuery(".publishTicket_error_code").show();
}
}
$('#publishTicket_customer_mobile').keyup(function() {
$(this).val(
$(this).val()
.replace(/^[^0]*/, '') // Remove starting non-zero characters
.replace(/[^\d]*/g, '') // Remove non-digit characters
);
}
);
//Publish Ticket - end
//Change Seat - start
$('#changeSeatModal').on('shown.bs.modal', function () {
$('#changeSeat_ticket_id').focus();
});
$("#changeSeat_details").html("");
$("#changeSeat_seats").html("");
$("#changeSeat_ticket_id").on("input", function(){
$("#changeSeat_details").html("");
$("#changeSeat_invalid").hide();
});
$("#changeSeat_viewTicket").on("click", function(){
var ticketID = $("#changeSeat_ticket_id").val();
if(ticketID != ""){
$.ajax({
url:'assets/user.bookings.changeSeat.view_details.php',
type:'POST',
data:'ticketID=' + ticketID,
success:function(html1){
if(html1!=""){
$("#changeSeat_details").html(html1);
}else{
$("#changeSeat_invalid").show();
}
}
});
}
});
$('#changeSeatModal').on('hidden.bs.modal', function () {
$("#changeSeat_ticket_id").val("");
$("#changeSeat_details").html("");
$("#changeSeat_invalid").hide();
$("#customerDetails").hide();
$("#customerDetailsForm")[0].reset();
$("#ticketIDForm").show();
$("#changeSeat_details").show();
$("#changeSeat_confirm").show();
$("#changeSeat_pay").hide();
$("#errorForm").hide();
$(".error_code").hide();
});
$("#changeSeat_confirm").on("click", function(){
if($("#changeSeat_details").html()!=""){
var ticketID = $("#changeSeat_ticket_id").val();
var seatsChanged = $("#changeSeatsForm").serializeArray();
var changedSeatsArray = new Array();
var pass = "";
$.each(seatsChanged, function(seatsChanged, field){
changedSeatsArray.push(field.value);
if(field.value != "") {
pass = "success";
}
});
if(pass == "success") {
$.ajax({
url:'assets/user.bookings.changeSeat.check.php',
type:'POST',
data:'changedSeats=' + JSON.stringify(changedSeatsArray),
success:function(html2){
if(html2==changedSeatsArray.length){
$("#ticketIDForm").hide();
$("#changeSeat_confirm").hide();
$("#changeSeat_pay").show();
$("#changeSeat_details").hide();
$("#customerDetails").show();
$('#customer_name').focus();
var timeleft = 200;
document.getElementById("timer").innerHTML = timeleft;
var Timer = setInterval(function(){
timeleft -= 1;
document.getElementById("timer").innerHTML = timeleft;
if(timeleft <= 0){
timeleft = 0;
clearInterval(Timer);
$("#changeSeatModal").modal("hide");
}
$('#changeSeatModal').on('hidden.bs.modal', function () {
clearInterval(Timer);
});
}, 1000);
}else{
$.toast({
text: "Some seats were entered incorrectly!",
icon: 'error',
position: 'top-center',
hideAfter: 5000,
stack: false,
loader: false
});
}
}
});
}else{
$.toast({
text: "No seats were entered.",
icon: 'error',
position: 'top-center',
hideAfter: 5000,
stack: false,
loader: false
});
}
}
});
$("#changeSeat_pay").on("click", function() {
var customername = jQuery("#customer_name").val();
var customerphone = jQuery("#customer_mobile").val();
var customeremail = jQuery("#customer_email").val();
var numberfilter = /^((\+[1-9]{1,10}[ \-]*)|(\([0-9]{2,10}\)[ \-]*)|([0-9]{2,10})[ \-]*)*?[0-9]{3,10}?[ \-]*[0-9]{0,10}?$/;
var emailfilter = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
if(customername!="" && customerphone!="" && customeremail!=""){
if (!numberfilter.test(customerphone) || customerphone.length!=10) {
jQuery("#changeSeat_errorForm").show();
jQuery("#changeSeat_errorForm").html("Invalid phone number !");
}else{
if(!emailfilter.test(customeremail)){
jQuery("#changeSeat_errorForm").show();
jQuery("#changeSeat_errorForm").html("Invalid email !");
}else{
jQuery("#changeSeat_errorForm").hide();
saveUserData();
}
}
}else{
jQuery("#changeSeat_errorForm").show();
jQuery("#changeSeat_errorForm").html("Fields can not be empty !");
}
});
if(performance.navigation.type == performance.navigation.TYPE_BACK_FORWARD) {
window.location = "user.bookings.php";
}
function saveUserData() {
if(jQuery('#terms').prop('checked')){
jQuery(".error_code").hide();
var user_data = $("#customerDetailsForm").serialize();
var paymentType = $("input[name='payment_type']:checked").val();
window.location = "assets/user.bookings.changeSeat.payment.php?" + user_data + "&paymentType=" + paymentType;
}else{
jQuery(".error_code").show();
}
}
$('#customer_mobile').keyup(function() {
$(this).val(
$(this).val()
.replace(/^[^0]*/, '') // Remove starting non-zero characters
.replace(/[^\d]*/g, '') // Remove non-digit characters
);
}
);
//Change Seat - end
});
</script>
</body>
</html>
<?php
}else{
header('location: index.php');
}
?>