-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
397 lines (342 loc) · 24.2 KB
/
index.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 "connect.php";
include "functions.php";
$user_data = check_login($conn);
// $userID = $_SESSION['user_id'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ADMIN PAGE</title>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0 auto;
}
body {
background: url("./img/simple.png") no-repeat fixed center ;
}
</style>
</head>
<body>
<div class="container">
<!---------- CARD FOR ADMIN ---------->
<div class="card mt-5 px-3 py-3 container align-items-center bg-dark text-white" >
<span class="card-header h3 text-center text-secondary fw-bold fs-2"> <?php echo $user_data['name']; ?></span>
<!---------- ADMIN NAME ---------->
<div class="card-body border-0">
<h5 class="card-title mt-4">
<?php echo $user_data['location']; ?>
</h5>
</div>
<!---------- LOGOUT ---------->
<a href="logout.php">
<button class="btn btn-dark btn-outline-light mt-3 mb-2" name="logout" id="logout">
Logout
</button>
</a>
<!---------- HR ---------->
<hr width="500px;" size="7">
<!---------- TABS ---------->
<ul class="nav nav-pills mt-2" id="myTab" role="tablist">
<!---------- CREATE EVENT TAB ---------->
<li class="nav-item" role="presentation">
<button class="nav-link active" id="event_tab" data-bs-toggle="tab" data-bs-target="#event" type="button" role="tab" aria-controls="home" aria-selected="true">Create Event</button>
</li>
<!---------- DISPLAY TAB ---------->
<li class="nav-item" role="presentation">
<button class="nav-link" id="display-tab" data-bs-toggle="tab" data-bs-target="#display" type="button" role="tab" aria-controls="display" aria-selected="false">Display</button>
</li>
<!---------- JOINED EVENT TAB ---------->
<li class="nav-item" role="presentation">
<button class="nav-link" id="joined-tab" data-bs-toggle="tab" data-bs-target="#joined" type="button" role="tab" aria-controls="joined" aria-selected="false">Joined Event</button>
</li>
</ul>
<!---------- HR ---------->
<hr width="305px;" size="6">
<!---------- TABS' CONTENT ---------->
<div class="tab-content" id="myTabContent">
<!---------- CREATE EVENT CONTENT ---------->
<div class="tab-pane fade show active" id="event" role="tabpanel" aria-labelledby="event_tab">
<!---------- FORM OF CREATE EVENT ---------->
<form action="insertEvent.php" method="POST">
<div class="mt-3">
<label class="form-label">Event Name</label>
<input type="hidden" name="id" value="<?php echo $user_data['user_id'];?>" required>
<input autocomplete="off" type="text" class="form-control bg-dark text-white" name="event_name" id="event_name">
<label class="form-label mt-3">Location</label>
<input tautocomplete="off" ype="text" class="form-control bg-dark text-white" name="event_loc" id="event_loc" required>
</div>
<!------------------ UPLOAD IMAGE ------------------>
<div class="mt-3">
<label class="form-label">Event Image</label>
<input type="file" class="form-control bg-dark text-white" name="event_image" id="event_image" accept="image/png, image/jpeg, image/jpg" required>
</div>
<!---------- HR ---------->
<hr size="5">
<!------------------SUBMIT ------------------------->
<div class="mt-4 text-center">
<button class="btn btn-dark btn-outline-primary" name="submitNewEvent" id="submitNewEvent">Submit</button>
</div>
</form>
</div>
<!---------- DISPLAY CONTENT ---------->
<div class="tab-pane fade" id="display" role="tabpanel" aria-labelledby="display-tab">
<!---------- EVENT WORD ---------->
<h3 class="text-white h3 text-center mt-3 fw-bold" style="font-family:'Fira Sans', sans-serif;">EVENTS</h3>
<!---------- TABLE---------->
<div class="container">
<div class="row">
<!-- COL 1 -->
<div class="col">
<?php
$location = $user_data['location'];
$displayAllEvent = "SELECT * FROM `events` WHERE event_loc = '$location'";
$displayAllEvent_res = $conn->query($displayAllEvent);
if($displayAllEvent_res->num_rows > 0){
while($AllEvent_row = $displayAllEvent_res->fetch_assoc()){
?>
<!---------- DISPLAY CARD ---------->
<div class="card mt-5 mb-5 px-3 py-3 bg-dark border border-outline-light">
<!---------- DISPLAY IMAGE ---------->
<img src="img/<?php echo $AllEvent_row['event_image']?>" class="card-img-top" style="width: 25rem; height: auto" alt="<?php echo $AllEvent_row['event_image']?>">
<!---------- EVENT NAME ---------->
<div class="card-body">
<h5 class="card-title text-light fw-bold fs-4 text-center" style="font-family:'Fira Sans', sans-serif;">
<?php echo $AllEvent_row['event_name']?>
</h5>
<h6 class="text-center">
<?php echo $AllEvent_row['event_loc'] ?>
</h6>
<p class="text-muted text-center">
<?php echo $AllEvent_row['status'] ?>
</p>
<?php
$id = $AllEvent_row['event_id'];
$eventDetails ="SELECT COUNT(users_detail.name) as total FROM bookings,events,users_detail WHERE bookings.event_id = events.event_id AND events.event_id = '$id' AND bookings.user_id = users_detail.user_id";
$qry = $conn->query($eventDetails);
$data = mysqli_fetch_array($qry);
?>
<p class="text-center">
<img src="./img/users.png" alt=""> <?php echo $data['total']?>
</p>
<?php
?>
</div>
<!---------- BUTTONS ---------->
<div class="container row">
<div class="col-sm-12 text-center">
<div class="row text-center">
<!---------- UPDATE BUTTON ---------->
<div class="col-md-3">
<?php
if($user_data['user_id'] == $AllEvent_row['user_id']) {
?>
<a href="update.php?edit=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-primary" name="edit" id="edit">Update</button>
</a>
<?php
}
?>
</div>
<!---------- JOIN BUTTON ---------->
<div class="col-md-3">
<form method="post"action="book.php">
<?php
$e_id =$AllEvent_row['event_id'];
$u_id = $user_data['user_id'];
$booking_j = "SELECT * FROM bookings WHERE event_id = '$e_id' AND user_id ='$u_id'";
$query_books = $conn->query($booking_j);
if(mysqli_num_rows($query_books) == 0){
?>
<button class="btn btn-dark btn-outline-success" name="submit_book" type="submit" id="join" value="<?php echo $AllEvent_row['event_id']?>" >
Join
</button>
<?php
}else{
?>
<button class="btn btn-dark btn-outline-success" name="submit_book" type="submit" id="join" value="" disabled>
Joined
</button>
<?php
}
?>
</form>
</div>
<!---------- VIEW BUTTON ---------->
<div class="col-md-3">
<a href="view.php?view=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-warning" name="view" id="view">View</button>
</a>
</div>
<!---------- DELETE BUTTON ---------->
<div class="col-md-3">
<?php
if($user_data['user_id'] == $AllEvent_row['user_id']) {
?>
<a href="delete.php?delete=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-danger" name="edit" id="edit">Delete</button>
</a>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<!-- COL 2 -->
<div class="col">
<?php
$location = $user_data['location'];
$displayAllEvent = "SELECT * FROM `events` WHERE NOT event_loc = '$location'";
$displayAllEvent_res = $conn->query($displayAllEvent);
if($displayAllEvent_res->num_rows > 0){
while($AllEvent_row = $displayAllEvent_res->fetch_assoc()){
?>
<!---------- DISPLAY CARD ---------->
<div class="card mt-5 mb-5 px-3 py-3 bg-dark border border-outline-light">
<!---------- DISPLAY IMAGE ---------->
<img src="img/<?php echo $AllEvent_row['event_image']?>" class="card-img-top" style="width: 25rem; height: auto" alt="<?php echo $AllEvent_row['event_image']?>">
<!---------- EVENT NAME ---------->
<div class="card-body">
<h5 class="card-title text-light fw-bold fs-4 text-center" style="font-family:'Fira Sans', sans-serif;">
<?php echo $AllEvent_row['event_name']?>
</h5>
<h6 class="text-center">
<?php echo $AllEvent_row['event_loc'] ?>
</h6>
<p class="text-center text-muted">
<?php echo $AllEvent_row['status'] ?>
</p>
<?php
$id = $AllEvent_row['event_id'];
$eventDetails ="SELECT COUNT(users_detail.name) as total FROM bookings,events,users_detail WHERE bookings.event_id = events.event_id AND events.event_id = '$id' AND bookings.user_id = users_detail.user_id";
$qry = $conn->query($eventDetails);
$data = mysqli_fetch_array($qry);
?>
<p class="text-center">
<img src="./img/users.png" alt=""> <?php echo $data['total']?>
</p>
<?php
?>
</div>
<!---------- BUTTONS ---------->
<div class="container row">
<div class="col-sm-12 text-center">
<div class="row text-center">
<!---------- UPDATE BUTTON ---------->
<div class="col-md-3">
<?php
if($user_data['user_id'] == $AllEvent_row['user_id']) {
?>
<a href="update.php?edit=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-primary" name="edit" id="edit">Update</button>
</a>
<?php
}
?>
</div>
<!---------- JOIN BUTTON ---------->
<div class="col-md-3">
<form method="post"action="book.php">
<?php
$e_id =$AllEvent_row['event_id'];
$u_id = $user_data['user_id'];
$booking_j = "SELECT * FROM bookings WHERE event_id = '$e_id' AND user_id ='$u_id'";
$query_books = $conn->query($booking_j);
if(mysqli_num_rows($query_books) == 0){
// echo "wala_ka_apil";
?>
<button class="btn btn-dark btn-outline-success" name="submit_book" type="submit" id="join" value="<?php echo $AllEvent_row['event_id']?>" >
Join
</button>
<?php
}else{
// echo "ka_apil";
?>
<button class="btn btn-dark btn-outline-success" name="submit_book" type="submit" id="join" value="" disabled>
Joined
</button>
<?php
}
?>
</form>
</div>
<!---------- VIEW BUTTON ---------->
<div class="col-md-3">
<a href="view.php?view=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-warning" name="view" id="view">View</button>
</a>
</div>
<!---------- DELETE BUTTON ---------->
<div class="col-md-3">
<?php
if($user_data['user_id'] == $AllEvent_row['user_id']) {
?>
<a href="delete.php?delete=<?php echo $AllEvent_row['event_id']; ?>">
<button class="btn btn-dark btn-outline-danger" name="edit" id="edit">Delete</button>
</a>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<!---------- JOINED TAB CONTENT ---------->
<div class="tab-pane fade mb-5" id="joined" role="tabpanel" aria-labelledby="booked-tab">
<div class="container">
<?php
$userID = $user_data['user_id'];
$Event = "SELECT * FROM bookings,events WHERE bookings.user_id = '$userID' AND bookings.event_id = events.event_id";
$Event_res = $conn->query($Event);
if($Event_res-> num_rows > 0){
while($Event_row = $Event_res->fetch_assoc()){
?>
<!---------- DISPLAY CARD ---------->
<div class="card mt-5 px-3 py-3 bg-dark border border-outline-light" style="width: 27rem;">
<img src="img/<?php echo $Event_row['event_image']?>" class="card-img-top" height="auto" width="auto" alt="<?php echo $Event_row['event_image']?>">
<div class="card-body">
<h5 class="card-title text-light fw-bold fs-4 text-center" style="font-family:'Fira Sans', sans-serif;"><?php echo $Event_row['event_name']?></h5>
</div>
<div class="container text-center">
<form method="post"action="book.php">
<button class="btn btn-dark btn-outline-danger" name="delete_book" type="submit" value="<?php echo $Event_row['booking_id']?>">CANCEL</button>
</form>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</div>
</div>
</div>
</body>
</html>