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
/
buy_tickets.php
397 lines (324 loc) · 14.6 KB
/
buy_tickets.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
<?php
session_start();
include_once ('db_config.php');
date_default_timezone_set("Asia/Colombo");
$sql_temp = "SELECT movie_id FROM tbl_movies WHERE `status` = 1 ORDER BY movie_id";
$result_temp=mysqli_query($db,$sql_temp);
if(mysqli_num_rows($result_temp)>0){
$row_temp = mysqli_fetch_array($result_temp);
if(isset($_GET['movieID'])){
$movieID = mysqli_real_escape_string($db, $_GET['movieID']);
$sql_movie = "SELECT * FROM tbl_movies WHERE movie_id='$movieID'";
$result=mysqli_query($db,$sql_movie);
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_array($result);
$startingDate=$row['starting_date'];
$endingDate=$row['ending_date'];
}
else{
header('location: buy_tickets.php?movieID='.$row_temp['movie_id']);
}
}
else{
header('location: buy_tickets.php?movieID='.$row_temp['movie_id']);
}
}
else{
header('location:index.php');
}
$sql_temp = "SELECT * FROM tbl_bookings_temporary";
$query_temp=mysqli_query($db,$sql_temp);
$rowCount_temp = mysqli_num_rows($query_temp);
if($rowCount_temp > 0){
while($row_temp=mysqli_fetch_array($query_temp)){
$temp_datetime = strtotime($row_temp['timestamp']);
$curr_datetime = time();
$timeDiff_temp = $temp_datetime - $curr_datetime;
if($timeDiff_temp < 30*60)
$sql_temp_delete = "DELETE FROM tbl_bookings_temporary WHERE `timestamp` = '{$row_temp['timestamp']}'";
$db->query($sql_temp_delete);
}
}
?>
<!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">
<!--Bootstrap Fullscreen Modal CSS-->
<link rel="stylesheet" type="text/css" href="css/bootstrap4-modal-fullscreen.min.css">
<!--JQuery Toast Plugin CSS-->
<link rel="stylesheet" type="text/css" href="css/jquery.toast.min.css">
<!--Font Awesome CSS-->
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<!--Glyphicons CSS-->
<link rel="stylesheet" type="text/css" href="css/glyphicon.css">
<!--JQuery-UI CSS-->
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
<!--Owl Carousel CSS-->
<link rel="stylesheet" type="text/css" href="css/owl.carousel.css">
<link rel="stylesheet" type="text/css" href="css/owl.theme.default.css">
<!--Custom Style CSS-->
<link rel="stylesheet" type="text/css" href="css/style.css?v=<?php echo time(); ?>">
<link rel="stylesheet" type="text/css" href="css/movies_slider.css">
<!--Favicon Image-->
<link rel="shortcut icon" type="image/png" href="images/icon.png">
<title>InstaMovies</title>
</head>
<body id="itemid-7">
<!--Navbar Code - Start-->
<?php include('header.php'); ?>
<!--Navbar Code - End-->
<!--Buy Tickets Body - Start-->
<div class="buy-tickets">
<!--Movie Banner-->
<div class="movie_banner" id="movie_banner">
<?php
if($movieID!=''){
echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['banner'] ).'"/>';
}else{
echo '<img src="images/banner.jpg?v='.time().'"/>';
}
?>
</div>
<!--Select Movie-->
<div class="movie-name">
<div class="container">
<div class="row">
<div class="movie_selection_list col-xs-12 col-sm-12 col-md-12 col-lg-12">
<form>
<div class="form-group" id="now-showing-list">
<select class="form-control form-control-lg" id="selectMovie" onChange="SelectRedirect();">
<?php
$select_movie = "SELECT * FROM tbl_movies WHERE `status` = 1";
$query_movie=mysqli_query($db,$select_movie);
$rowCount_movie = mysqli_num_rows($query_movie);
if($movieID!=''){
if($rowCount_movie > 0){
while($row = $query_movie->fetch_assoc()){
echo '<option value="'.$row['movie_id'].'">'.$row['movie_name'].'</option>';
}
}
}else{
echo '<option value="">Select Movie</option>';
if($rowCount_movie > 0){
while($row = $query_movie->fetch_assoc()){
echo '<option value="'.$row['movie_id'].'">'.$row['movie_name'].'</option>';
}
}
}
?>
</select>
</div>
</form>
</div>
</div>
</div>
</div>
<!--Show-Datepicker-->
<div class="show-date" id="show_date">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="date-container">
<ul class="list-inline">
<?php
if($startingDate>date("Y-m-d")){
$date = $startingDate;
}
else{
$startingDate = date("Y-m-d");
$date = date("Y-m-d");
}
$i = 0;
while (strtotime($date) <= strtotime("+6 days", strtotime($startingDate))) {
echo '<li class="datepicker" id = "date-'.$i.'" dateValue = "'.$date.'" onclick="selectDate(this.id)">';
echo '<div class="month">'.date('M', strtotime($date)).'</div>';
echo '<div class="date">'.date('d', strtotime($date)).'</div>';
echo '<div class="day">'.date('D', strtotime($date)).'</div>';
echo '</li>';
if($date==$endingDate){
break;
}
$date = date ("Y-m-d", strtotime("+1 days", strtotime($date)));
}
?>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- <div class="show-date" id="show_date">
<div class="container">
<div class="row">
<div class="date_selection col-xs-4 col-sm-4 col-md-4 col-lg-4">
<form >
<div class="form-group" >
<div class="input-group">
<input type='text' class="form-control" id='datepicker' readonly="true">
</div>
</div>
</form>
</div>
</div>
</div>
</div> -->
<!--Display Show-Time-Table-->
<div class="show-time-table" id="time_table">
<div class="container">
<div class="row" style="margin:-1px 0px">
<table class="table table-responsive" id=table_details>
<!--table link-->
</table>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade modal-fullscreen" id="myModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<!--Link to Modal Content-->
</div>
</div>
</div>
</div>
<!--Buy Tickets Body - End-->
<!--Footer Code - Start-->
<?php include('footer.php') ?>
<!--Footer Code - End-->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js,then Owl_Carousel, then Bootstrap JS -->
<script src="js/jquery.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/owl.carousel.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery.toast.min.js"></script>
<!--Page Redirecting-->
<script>
//Redirecting to selected movie
function SelectRedirect(){
var $valueid = document.getElementById('selectMovie').value;
window.location="buy_tickets.php?movieID="+$valueid;
}
//Setting the select option to current movieID
$("#selectMovie > [value=" + "<?php echo $movieID ?>" + "]").attr("selected", "true");
</script>
<!--Date Picker Script-->
<script>
$(document).ready(function(){
//Set first date as default and fetch showtimes for that date
$("#date-0").addClass('active');
var sel_Date = $('#date-0').attr('dateValue');
var movieID = jQuery('#selectMovie').val();
if(sel_Date){
$.ajax({
type:'POST',
url:'assets/buy_tickets.inc.php',
data:'sel_date=' + sel_Date + '&movie_id=' + movieID,
success:function(html){
$('#table_details').html(html);
}
});
}
//Change active class to selected date and fetch showtimes for that date
$(".date-container ul[class*=list-inline] li").click(function () {
$(".date-container ul[class*=list-inline] .active").removeClass('active');
$(this).addClass('active');
var sel_Date = $(this).attr('dateValue');
var movieID = jQuery('#selectMovie').val();
if(sel_Date){
$.ajax({
type:'POST',
url:'assets/buy_tickets.inc.php',
data:'sel_date=' + sel_Date + '&movie_id=' + movieID,
success:function(html){
$('#table_details').html(html);
}
});
}
});
});
</script>
<!--------------------- Usual Date Picker Calendar - Start ------------------------->
<!--Date Picker Script-->
<!-- <script>
$( function() {
$( "#datepicker" ).datepicker({
dateFormat: 'yy-mm-dd',
showOn: "button",
buttonImage: "images/calendar.png",
buttonText: "Select Date",
beforeShowDay: enableAvailableDays
});
});
</script> -->
<!--Enabling Dates between Two Dates fetched from database-->
<!-- <script>
//Converting any number to two digits (for example: (9 -> 09))
function pad2(number) {
return (number < 10 ? '0' : '') + number;
}
//Fetching an array of dates between two dates
var getDateArray = function(start, end) {
var array_dates = new Array();
var cur_date = new Date(start);
for(var l=0;l<7;l++) {
var current_date=new Date(cur_date);
var formatted_date = current_date.getFullYear() + "-" + pad2(current_date.getMonth() + 1) + "-" + pad2(current_date.getDate());
array_dates.push(formatted_date);
cur_date.setDate(cur_date.getDate() + 1);
}
return array_dates;
}
var startDate = new Date("<?php //echo $startingDate?>"); //YYYY-MM-DD
if(startDate<new Date()){
startDate = new Date();
}
var endDate = new Date("<?php //echo $endingDate?>"); //YYYY-MM-DD
$("#datepicker").datepicker('option','minDate',startDate);
$("#datepicker").datepicker('option','maxDate',endDate);
//Enabling an array of dates
var availableDates = getDateArray(startDate, endDate); //desired Dates
function enableAvailableDays(date) {
var sdate = $.datepicker.formatDate('yy-mm-dd', date)
if($.inArray(sdate, availableDates) != -1){
return [true];
}
return[false];
}
</script> -->
<!-- <script>
$('#datepicker').on('change',function(){
var sel_Date = $(this).val();
var movieID = jQuery('#selectMovie').val();
if(sel_Date){
$.ajax({
type:'POST',
url:'assets/buy_tickets.inc.php',
data:'sel_date=' + sel_Date + '&movie_id=' + movieID,
success:function(html){
$('#table_details').html(html);
}
});
}
})
</script> -->
<!--------------------- Usual Date Picker Calendar - End ------------------------->
<script>
$('#myModal').on('show.bs.modal', function () {
$('body').css('overflow', 'hidden');
})
$('#myModal').on('hidden.bs.modal', function (e) {
$('body').css('overflow', 'auto');
})
</script>
<script>
$(".header_wrapper .main_menu_wrapper .item-7").addClass("active");
</script>
</body>
</html>