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
/
Copy pathuser.dashboard.php
377 lines (326 loc) · 17 KB
/
user.dashboard.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
<?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'];?> | Dashboard</title>
<style>
.navbar {
background:black !important;
}
@media (max-width: 575px){
#ticketIDForm .form-control {
margin-bottom: 15px;
}
#ticketIDForm .row {
margin-left: 0;
}
#ticketIDForm .col-sm-7, .col-sm-3 {
padding-left: 0;
padding-right: 0;
}
}
</style>
</head>
<body id="itemid-3">
<!--Navbar Code - Start-->
<?php include('header.php'); ?>
<!--Navbar Code - End-->
<div style="padding-top:85px;padding-bottom:25px;background-color:#ebebeb">
<div class="container mt-3" style="background:#FFF;">
<div style="padding:15px 15px 10px"><h1 style="text-align:center; font-size:50px; font-weight:normal; color:#001c8e; font-family:Arial, Helvetica, sans-serif">Welcome <?php echo $user_row['first_name']?>!</h1></div>
</div>
<div class="container mt-3" style="background:#FFF;padding-bottom:15px">
<div style="padding:15px 15px 10px"><h1 style="font-size: 35px; font-weight: normal;">Tickets On Sale</h1></div>
<div style="margin:0px 0 30px; text-align:center">
<button class="btn btn-danger btn-lg" style="padding:5px 10px" data-toggle="modal" data-target="#buyTicketModal">Buy Ticket</button>
</div>
<div class="table-responsive" style="min-height:121px; padding:0 15px">
<table class="table table-striped table-bordered table-sm">
<thead style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</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 FROM tbl_bookings A, tbl_movies B, tbl_theatres C, tbl_shows D, tbl_showtimes E WHERE DATE_ADD(NOW(), INTERVAL 1 HOUR) < CONCAT(A.show_date, ' ', E.starting_time) 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 AND A.status = '1' 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++;
echo "<tr>";
echo "<td>{$i}</td>";
echo "<td>{$row['ticket_id']}</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='12' style='padding-left:7px'>No tickets available.</td></tr>";
}
?>
</tbody>
<tfoot style="text-align:center">
<tr>
<th>#</th>
<th>Ticket ID</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="buyTicketModal" 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">Buy 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="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="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="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-4 col-form-label">Customer Name:</label>
<div class="col-sm-8">
<input id="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="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="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="confirm" type="button" class="btn btn-primary">Confirm</button>
<button id="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 -->
<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(){
$('#buyTicketModal').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.dashboard.buyTicket.view_ticket.php',
type:'POST',
data:'ticketID=' + ticketID,
success:function(html){
if(html!=""){
$("#ticketDetails").html(html);
}else{
$("#invalid").show();
}
}
});
}
});
$('#buyTicketModal').on('hidden.bs.modal', function () {
$("#ticket_id").val("");
$("#ticketDetails").html("");
$("#invalid").hide();
$("#customerDetails").hide();
$("#customerDetailsForm")[0].reset();
$("#ticketIDForm").show();
$("#confirm").show();
$("#pay").hide();
$("#ticketDetails").show();
$("#errorForm").hide();
$(".error_code").hide();
});
$("#confirm").on("click", function(){
if($("#ticketDetails").html()!=""){
var ticketID = $("#ticket_id").val();
$.ajax({
url:'assets/user.dashboard.buyTicket.check.php',
type:'POST',
data:'ticketID=' + ticketID,
success:function(success){
if(success=="success"){
$("#ticketIDForm").hide();
$("#confirm").hide();
$("#pay").show();
$("#ticketDetails").hide();
$("#customerDetails").show();
$('#customer_name').focus();
var remaining_time = 200;
document.getElementById("timer").innerHTML = remaining_time;
var Timer = setInterval(function(){
remaining_time -= 1;
document.getElementById("timer").innerHTML = remaining_time;
if(remaining_time <= 0){
remaining_time = 0;
clearInterval(Timer);
$("#buyTicketModal").modal("hide");
}
$('#buyTicketModal').on('hidden.bs.modal', function () {
clearInterval(Timer);
});
}, 1000);
}else{
$.toast({
text: "Ticket is unavailable.",
icon: 'error',
position: 'top-center',
hideAfter: 4000,
stack: false,
loader: false
});
}
}
});
}
});
$("#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("#errorForm").show();
jQuery("#errorForm").html("Invalid phone number !");
}else{
if(!emailfilter.test(customeremail)){
jQuery("#errorForm").show();
jQuery("#errorForm").html("Invalid email !");
}else{
jQuery("#errorForm").hide();
saveUserData();
}
}
}else{
jQuery("#errorForm").show();
jQuery("#errorForm").html("Fields can not be empty !");
}
});
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.dashboard.buyTicket.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
);
}
);
});
</script>
</body>
</html>
<?php
}else{
header('location: index.php');
}
?>