-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.php
More file actions
381 lines (342 loc) · 16.3 KB
/
event.php
File metadata and controls
381 lines (342 loc) · 16.3 KB
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
<?php
session_start();
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
}
if (isset($_GET["event_id"])) {
$event_id = $_GET["event_id"];
} else {
$_SESSION['event_id'] = "";
session_abort();
}
require("php/database.php");
$user_email = '';
$is_customer = false;
$is_organizer = false;
if(isset($username)) {
$customer_query = sendQuery("select email from customer where username = '$username'");
if($customer_query) {
$user_email = $customer_query->fetch_assoc()['email'];
$is_customer = true;
$is_organizer = false;
} else {
$organizer_query = sendQuery("select * from organizer where username = '$username'");
$is_organizer = boolval($organizer_query);
}
}
sendQuery("UPDATE events SET view=view+1 WHERE event_id=$event_id;");
$event = sendQuery("select * from events where event_id = '$event_id'")->fetch_assoc();
$name = $event['name'];
$organizer_username = $event['organizer'];
$description = $event['description'];
$event_date = $event['date'];
$venue = $event['venue'];
$latitude = $event['latitude'];
$longitude = $event['longitude'];
$type = $event['type'];
$primary_image = $event['image'];
$facebook = $event['facebook'];
$twitter = $event['twitter'];
$viewed = $event['view'];
$organizer = sendQuery("select * from organizer where username = '$organizer_username'");
if ($organizer) {
$organizer = $organizer->fetch_assoc();
if ($organizer['status'] != 'approved') {
http_response_code(404);
header("Location: 404NotFound.php");
die();
}
$organizer_company_name = $organizer['company_name'];
};
$images = sendQuery("select image from event_image where event_id = '$event_id'");
$tickets_raw = sendQuery("select * from event_ticket where event_id = '$event_id'");
$tickets = array();
while($tickets_raw && $ticket = $tickets_raw->fetch_assoc()) {
array_push($tickets, $ticket);
}
$coupon_raw = sendQuery("select * from coupon");
$coupons = array();
$discounts = array();
while ($coupon_raw && $coupon = $coupon_raw->fetch_assoc()) {
array_push($coupons, $coupon['coupon']);
array_push($discounts, $coupon['discount']);
}
$coupons = json_encode($coupons);
$discounts = json_encode($discounts);
?>
<html>
<head>
<title>It's Happening!</title>
<link href="css/font-awesome.css" rel="stylesheet">
<link href="css/event.css" rel="stylesheet">
<link href="css/global-header.css" rel="stylesheet">
<link href="css/slides.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/slides.js"></script>
<script src="js/map.js"></script>
<script src="js/event_controller.js"></script>
<script src="js/image_resize.js"> </script>
</head>
<body>
<script type="text/javascript">
var username = <?php echo json_encode($username); ?>;
var event_id = <?php echo json_encode($event_id); ?>;
var lat = <?php echo json_encode($latitude); ?>;
var lng = <?php echo json_encode($longitude); ?>;
var name = <?php echo json_encode($name); ?>;
var type = <?php echo json_encode($type); ?>;
var user_email = <?php echo json_encode($user_email); ?>;
var tickets = <?php echo json_encode($tickets) ?>;
var viewd = <?php echo json_encode($view) ?>;
var coupons = JSON.parse(<?php echo json_encode($coupons); ?>);
var discounts = JSON.parse(<?php echo json_encode($discounts); ?>).map(parseFloat);
var is_organizer = <?php echo json_encode($is_organizer); ?>;
var is_customer = <?php echo json_encode($is_customer); ?>;
</script>
<!-- global header -->
<ul class='global-header'>
<?php
if (isset($_SESSION['username'])) {
echo "<li class='global-header-list'><a href='logout.php?'>Sign Out</a></li>";
if (sendQuery("select * from customer where username = '$username'")) {
echo "<li class='global-header-list'><a href='profile.php'>Profile</a></li>";
} else if (sendQuery("select * from organizer where username = '$username'")) {
echo "<li class='global-header-list'><a href='index.php'>Organizer</a></li>";
}
} else {
echo "<li class='global-header-list'><a href='login.php'>Sign In / Sign Up</a></li>";
}
?>
<li class='global-header-list'><a href="browse.php">Browse</a></li>
<li class='global-header-list'><a href="home.php">Home</a></li>
<li class='global-header-list'><a href="home.php#aboutUs">About Us</a></li>
<li class='global-header-list-left' style = "color: white; margin-top: 1.2%; margin-right: 15%;" align = center>
<?php if (isset($_SESSION['username'])) {
$user_query = sendQuery("SELECT first_name FROM organizer WHERE username='$username' UNION SELECT first_name FROM customer WHERE username='$username'");
if($user_query) {
$first_name = $user_query->fetch_assoc()['first_name'];
}
echo "Welcome! ".ucfirst($first_name);
}?>
</li>
</ul>
<!-- global header end -->
<!-- <div class="banner-map-container"> -->
<!-- banner -->
<div id="banner-container">
<?php
echo "
<div class='slides slides-fade'>
<img src='" . $primary_image . "'/>
<script> resizeImage('banner-container', 0); </script>
</div>
";
if ($images) {
$counter = 1;
while($images && $image = $images->fetch_assoc()['image']) {
echo "<div class='slides slides-fade'>
<img src='" . $image . "'/>
<script> resizeImage('banner-container', $counter); </script>
</div>";
$counter++;
}
if ($counter>1) {
echo "<div class='slides-dot-container'>";
for($i = 0; $i != $counter; $i++) {
echo "<span class='slides-dot' onclick='slideSet(" . $i . ")'></span>";
}
echo "</div>";
}
}
?>
<script>showSlides();</script>
</div>
<!-- banner end -->
<div class="event-info-container">
<div class='bookTickets-btn' onclick="showBookTickets()"> Book Tickets</div>
<div class="viewed"> Views: <?php echo $viewed; ?> </div>
<div class="event-info" style="padding-top:5px; width: auto;">
<?php echo "<h4>$name</h4>"; ?>
</div>
<div class="event-info" style="width:80%;">
<i class="fa fa-calendar" aria-hidden="true"></i>
<?php
$formatted_date = date("D • M jS Y • g:i A", strtotime($event_date));
echo " $formatted_date ";
?>
</div>
<div class="event-info">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<?php echo " $venue "; ?>
</div>
<div class="event-info">
<h6>
<span style="padding-right: 30px;">
<?php echo "Created by: $organizer_company_name "; ?>
</span>
<?php
if ($facebook != null) {
echo "<span> <a href='$facebook' target='_blank'><i class='fa fa-facebook' style='padding-left: 4px; line-height:20px; background: #3B5998;'></i></a></span>";
}
if ($twitter != null) {
echo "<span> <a href='$twitter' target='_blank'><i class='fa fa-twitter' style='padding-left: 3px; line-height:20px; background: #55ACEE;'></i></a></span>";
}
?>
</h6>
</div>
<div class="event-info">
<?php echo "<p>$description</p>"; ?>
</div>
<!-- map -->
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDuMrO8-BJdTVOPdTA_uxS5tlIsW3alQX0&callback=initMap">
</script>
<!-- map end -->
<div style="height:13px"></div>
</div>
<div id='bookTicketsPopup' class="overlay">
<div class='popup-container'>
<a class="popup-close" href="#">×</a>
<h5 class="popup-title"> Tickets </h5>
<table class='ticket-table'>
<tr>
<th>Section</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<?php
for ($i = 0; $i != count($tickets); ++$i) {
$ticket_type = $tickets[$i]['type'];
$ticket_price = "$" . $tickets[$i]['price'];
echo "<tr>
<td id='ticket-type$i'>$ticket_type</td>
<td id='ticket-price$i'>$ticket_price</td>
<td class=>
<p>
<span class='ticket-quantity-setter ticket-quantity-setter-left' onclick='updateTicketQuantity($i, -1)'> − </span>
<span class='ticket-quantity' id='ticket-quantity$i'> 0 </span>
<span class='ticket-quantity-setter ticket-quantity-setter-right' onclick='updateTicketQuantity($i, 1)'> + </span>
</p>
</td>
";
}
?>
</table>
<div class='coupon-container'>
<input id='coupon' class='coupon' type='text' placeholder='Coupon ' required=''/>
</div>
<div class='price-container'>
<p> Subtotal: $ <span id='subtotal'>0.00 </span></p>
</div>
<div class='checkout-btn' onclick='getOrderDetailsPopUp()'> Check Out </div>
</div>
</div>
<div id="checkoutPopup" class="overlay">
<div class="popup-container checkoutPopup-container">
<a class="popup-back" onclick="removeOrderDetails()" href="#bookTicketsPopup"> ← </a>
<a class="popup-close" onclick="removeOrderDetails()" href="#">×</a>
<h5 class="popup-title"> Your Order </h5>
<div class="popup-line"></div>
<div id="checkoutPopup-content"></div>
<div class="checkoutPopup-line"></div>
<p id="checkout-subtotal"> Subtotal: </p>
<p id="checkout-coupon" style="display:none"> Coupon: </p>
<p id="checkout-discount" style="display:none"> Discount: </p>
<p id="checkout-tax"> Tax: </p>
<p id="checkout-total"> Total: </p>
<div class="paypal-button-container">
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script> paypalCheckout(); </script>
</div>
</div>
</div>
<div id='guestPopup' class="overlay">
<div class="popup-container">
<a class="popup-back" href="#bookTicketsPopup"> ← </a>
<a class="popup-close" href="#">×</a>
<div class="guestPopup-container">
<?php
if ($is_organizer) {
echo "<p> Your organizer account doesn't have access to booking tickets, please </p>";
}
?>
<div class="guest-btn" onclick="window.open('login.php', '_blank')"> Sign In / Sign Up </div>
<p> OR </p>
<div>
<input id='guestEmail' type='text' placeholder="Email: " required=''/>
<div class="guest-btn" onclick="setGuestEmail();"> Guest Checkout </div>
</div>
</div>
</div>
</div>
<div class="related-events-container">
<h5 style="padding-left:50px"> Events You May Like ... </h5>
<?php
$related_events = array();
$today = date('Y-m-d h:i:s');
/* retrieve events hosted by this organizer */
$org_events = sendQuery("select * from events where organizer='$organizer_username' and event_id!='$event_id' and date(date)>date('$today') ORDER BY date ASC");
while (sizeof($related_events)<4 && $org_events && $org_event=$org_events->fetch_assoc()) {
array_push($related_events, $org_event);
}
$categ_events = sendQuery("select * from events where type='$type' and event_id!='$event_id' and date(date)>date($today) ORDER BY date ASC");
while (sizeof($related_events)<4 && $categ_events && $categ_event=$categ_events->fetch_assoc()) {
array_push($related_events, $categ_event);
}
for($i = 0; $i != sizeof($related_events); $i++) {
$rel_id = $related_events[$i]['event_id'];
$rel_image = $related_events[$i]['image'];
$rel_name = $related_events[$i]['name'];
$rel_date = $related_events[$i]['date'];
// echo "<script> console.log($rel_date); </script>";
$rel_day = date("j", strtotime($rel_date));
$rel_month = date("M", strtotime($rel_date));
$rel_year = date("Y", strtotime($rel_date));
echo "
<div class='related_events card'>
<div class='wrapper'>
<div class='date'>
<span class='day'>$rel_day</span>
<span class='month'>$rel_month</span>
<span class='year'>$rel_year</span>
</div>
<div class='img' id='related-event-img$i'>
<img src = '$rel_image'/>
<script> resizeImage('related-event-img$i', 0) </script>
</div>
<div class='data'>
<div class='content'>
<span class='author'><a href='event.php?event_id=$rel_id'>$rel_name</a></span>
</div>
<input type='checkbox' id='show-menu' />
</div>
</div>
</div>
";
}
?>
</div>
<!-- LiveChat (www.livechatinc.com) -->
<script type="text/javascript">
window.__lc = window.__lc || {};
window.__lc.license = 10377037;
(function () {
var lc = document.createElement('script');
lc.type = 'text/javascript';
lc.async = true;
lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(lc, s);
})();
</script>
<noscript>
<a href="https://www.livechatinc.com/chat-with/10377037/">Chat with us</a>,
powered by <a href="https://www.livechatinc.com/?welcome" rel="noopener" target="_blank">LiveChat</a>
</noscript>
<!-- LiveChat End -->
</body>
</html>