-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.php
More file actions
574 lines (506 loc) · 16.3 KB
/
views.php
File metadata and controls
574 lines (506 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
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
<?php
include "utils.php";
//Klasse erbt von utils (Logik)
class views extends utils{
//Print den Head und den Anfang des Bodys (Menubar) der HTML
function views_head(){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>App2night Adminpanel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<style>
.alert {
padding: 20px;
background-color: #f44336;
color: white;
opacity: 1;
transition: opacity 0.6s;
margin-bottom: 15px;
}
.alert.success {background-color: #4CAF50;}
.alert.info {background-color: #2196F3;}
.alert.warning {background-color: #ff9800;}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
</style>
</head>
<body>
<?php
//Menübar wird bei Login (default) nicht geprintet
if($_SESSION['type']) { ?>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Admin Panel" src="/img/a2n_app_color_20.png">
</a>
</div>
<form class="navbar-form navbar-left" action="index.php" method="POST">
<input type="submit" class='btn btn-info' name='partysview' value="Party Liste">
<input type="submit" class='btn btn-info' name='partysallview' value="Party Liste (Alle)">
<input type="submit" class='btn btn-info' name="partycreateview" value="Party anlegen">
<input type="submit" class='btn btn-info' name="usersview" value="User Liste">
<input type="submit" class='btn btn-info' name="usercreateview" value="User anlegen">
</form>
</div>
</nav>
<?php
}
}
//Print Footer der HTML
function views_footer(){
?>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
}
//Print die Loginseite
function views_login(){
?>
<br/>
<br/>
<br/>
<div clas="container">
<img alt="" src="/img/a2n_app_color_300.png" class="img-responsive center-block">
<div class="col-md-12">
<div class="modal-dialog" style="margin-bottom:0">
<div class="modal-content">
<div class="panel-heading">
<h3 class="panel-title">Login</h3>
</div>
<div class="panel-body">
<form role="form" name="login" action="index.php" method="POST">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Username" name="username" type="text" autofocus="">
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password">
</div>
<input class="btn btn-sm btn-info" type="submit" value=" Login " name="logbutton"/>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
}
//Print Party Tabelle
function views_partys_view(){
//Success Alert, wenn Party erfolgreich bearbeitet
if($_SESSION['alert'] == "suc_edit"){
?>
<div class="alert success">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
Party erfolgreich bearbeitet.
</div>
<?php }
//Success Alert wenn Party erfolgreich gelöscht
if($_SESSION['alert'] == "suc_delete"){
?>
<div class="alert success">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
Party erfolgreich gelöscht.
</div>
<?php }
//Success Alert wenn Party erfolgreich erstellt
if($_SESSION['alert'] == "suc_create"){
?>
<div class="alert success">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
Party erfolgreich erstellt.
</div>
<?php } ?>
<!-- Erstelle Headline mit festen Werten -->
<div class="container-fluid">
<form action="index.php" method="POST">
<table class="table table-bordered">
<thead class="thead-default">
<tr>
<th>Party ID</th>
<th>Name</th>
<th>Datum</th>
<th>Beschreibung</th>
<th>Preis</th>
<th>Up-Votings</th>
<th>Down-Votings</th>
<th>Musikgenre</th>
<th>Partytyp</th>
<th>Location</th>
<th>Host</th>
</tr>
</thead>
<tbody>
<?php
$today = date("Y-m-d");
//iteriere über Array mit Parties
foreach($_SESSION['pw'] as $keys => $partyobject)
{
$pdate = substr($partyobject['PartyDate'],0,10);
$pdate_date = date("Y-m-d", strtotime($pdate));
//erstelle Zeile für jeden key
//färbe Datensatz nach Datum
if($pdate_date < $today)
{
echo "<tr class=\"info\">";
} else if($pdate_date == $today){
echo "<tr class=\"success\">";
}
else {
echo "<tr>";
}
//iteriere über Partyarray
foreach($partyobject as $inner_key => $wert)
{
//erstelle eine Spalte mit den Werten der Party für jeden inner_key
echo "<td>$wert</td>";
if($inner_key == "PartyId") $id = $wert;
}
//erstelle "Bearbeiten" und "Löschen" Button in jeder Zeile
echo "<td><button type='submit' class='btn btn-info' name='partyeditview' value='$id'>Bearbeiten</button></td>";
echo "<td><button type='submit' class='btn btn-danger' name='partydelete' value='$id'>Löschen</button></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table></form>";
echo "</div>";
}
//Print Bearbeiten Formular
function views_party_edit(){
//erstelle Formular mit den Werten der aufgewählten Party
//Session Variable "pe" wird von Funktion partyeditview() geliefert
?>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h1>Party "<?php echo $_SESSION['pe']['PartyName']; ?>" ändern</h1>
<br/>
<form name="partyedit" action="index.php" method="POST">
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Name</label>
<div class="col-xs-10">
<input class="form-control" name="pname" type="text" value="<?php echo $_SESSION['pe']['PartyName']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Datum</label>
<div class="col-xs-10">
<input class="form-control" name="pdate" type="date" value="<?php echo $_SESSION['pe']['PartyDate']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Land</label>
<div class="col-xs-10">
<input class="form-control" name="pcountry" type="text" value="<?php echo $_SESSION['pe']['Location']['CountryName']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Stadt</label>
<div class="col-xs-10">
<input class="form-control" name="pcity" type="text" value="<?php echo $_SESSION['pe']['Location']['CityName']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Postleitzahl</label>
<div class="col-xs-10">
<input class="form-control" name="pzip" type="text" value="<?php echo $_SESSION['pe']['Location']['Zipcode']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Straße</label>
<div class="col-xs-10">
<input class="form-control" name="pstreet" type="text" value="<?php echo $_SESSION['pe']['Location']['StreetName']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Hausnummer</label>
<div class="col-xs-10">
<input class="form-control" name="phnumber" type="text" value="<?php echo $_SESSION['pe']['Location']['HouseNumber']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Musik Genre</label>
<div class="col-xs-10">
<select class="form-control" name="pgenre">
<option value="0" <?php if($_SESSION['pe']['MusicGenre'] == 0) echo "selected"; ?>>Alle</option>
<option value="1" <?php if($_SESSION['pe']['MusicGenre'] == 1) echo "selected"; ?>>Rock</option>
<option value="2" <?php if($_SESSION['pe']['MusicGenre'] == 2) echo "selected"; ?>>Pop</option>
<option value="3" <?php if($_SESSION['pe']['MusicGenre'] == 3) echo "selected"; ?>>HipHop</option>
<option value="4" <?php if($_SESSION['pe']['MusicGenre'] == 4) echo "selected"; ?>>Rap</option>
<option value="5" <?php if($_SESSION['pe']['MusicGenre'] == 5) echo "selected"; ?>>Elektro</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Typ</label>
<div class="col-xs-10">
<select class="form-control" name="ptype">
<option value="0" <?php if($_SESSION['pe']['PartyType'] == 0) echo "selected"; ?>>Bar</option>
<option value="1" <?php if($_SESSION['pe']['PartyType'] == 1) echo "selected"; ?>>Disco</option>
<option value="2" <?php if($_SESSION['pe']['PartyType'] == 2) echo "selected"; ?>>Wald</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Preis</label>
<div class="col-xs-10">
<input class="form-control" name="pprice" type="text" value="<?php echo $_SESSION['pe']['Price']; ?>">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Description</label>
<div class="col-xs-10">
<input class="form-control" name="pdesc" type="text" value="<?php echo $_SESSION['pe']['Description']; ?>">
</div>
</div>
<button type='submit' class="btn btn-success" name='partyedit' value='<?php echo $_SESSION['pe']['PartyId']; ?>'>Speichern</button> <button type='submit' class="btn btn-info" name='editcancel' value='$id'>Abbrechen</button>
</form>
</div>
</div>
</div>
<?php
}
//erstelle Formular zur Erstellung einer Party
function views_party_create(){
//Error Alert wenn die Party nicht erstellt werden konnte
if($_SESSION['alert'] == "fail"){
?>
<div class="alert">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
Etwas ist schlief gelaufen, bitte überprüfen Sie Ihre Eingabe.
</div>
<?php } ?>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h1>Party anlegen</h1>
<br/>
<form action="index.php" method="POST">
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Name</label>
<div class="col-xs-10">
<input class="form-control" name="pname" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Datum</label>
<div class="col-xs-10">
<input class="form-control" name="pdate" type="date" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Land</label>
<div class="col-xs-10">
<input class="form-control" name="pcountry" type="text" value="Deutschland">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Stadt</label>
<div class="col-xs-10">
<input class="form-control" name="pcity" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Postleitzahl</label>
<div class="col-xs-10">
<input class="form-control" name="pzip" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Straße</label>
<div class="col-xs-10">
<input class="form-control" name="pstreet" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Hausnummer</label>
<div class="col-xs-10">
<input class="form-control" name="phnumber" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Musik Genre</label>
<div class="col-xs-10">
<select class="form-control" name="pgenre">
<option value="0">Alle</option>
<option value="1">Rock</option>
<option value="2">Pop</option>
<option value="3">HipHop</option>
<option value="4">Rap</option>
<option value="5">Elektro</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Party Typ</label>
<div class="col-xs-10">
<select class="form-control" name="ptype">
<option value="0">Bar</option>
<option value="1">Disco</option>
<option value="2">Wald</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Preis</label>
<div class="col-xs-10">
<input class="form-control" name="pprice" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Description</label>
<div class="col-xs-10">
<input class="form-control" name="pdesc" type="text" value="">
</div>
</div>
<input type='submit' class="btn btn-success" name='partycreate' value="Speichern"> <input type='submit' class="btn btn-info" name='editcancel' value="Abbrechen">
</form>
</div>
</div>
</div>
<?php
}
//erstelle Formular zur Erstellung eines Users
function views_user_create(){
?>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h1>User anlegen</h1>
<br/>
<form action="index.php" method="POST">
<div class="form-group row">
<label class="col-xs-2 col-form-label">Userame</label>
<div class="col-xs-10">
<input class="form-control" name="uname" type="text" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Passwort</label>
<div class="col-xs-10">
<input class="form-control" name="upassword" type="password" value="">
</div>
</div>
<div class="form-group row">
<label class="col-xs-2 col-form-label">Email</label>
<div class="col-xs-10">
<input class="form-control" name="uemail" type="date" value="">
</div>
</div>
<input type='submit' class="btn btn-success" name='usercreate' value="Speichern"> <input type='submit' class="btn btn-info" name='usercreatecancel' value="Abbrechen">
</form>
</div>
</div>
</div>
<?php
}
//Erstelle User Tabelle
function views_user_view(){
//Success Alert wenn User Erstellen erfolgreich
//Warning Alert wenn User Erstellen erfolgreich
if($_SESSION['alert'] == "suc_usercreate"){
?>
<div class="alert success">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
User erfolgreich erstellt.
</div>
<div class="alert warning">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
Der User wird erst nach seiner ersten Aktivität in der User Liste angezeigt.
</div>
<?php } ?>
<div class="container-fluid">
<form action="index.php" method="POST">
<table class="table table-bordered">
<thead class="thead-default">
<tr>
<th>UserID</th>
<th>UserName</th>
<th>E-Mail</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
//iteriere über den äußeren Array mit Usern
foreach($_SESSION['uw'] as $keys => $userobject)
{
//iteriere über den inneren Userarray
foreach($userobject as $inner_key => $wert)
{
//Erstelle Spalte falls inner_key != location, da location immer null
if($inner_key != "location")
{
echo "<td>$wert</td>";
}
if($inner_key == "userId") $id = $wert;
}
//erstelle in jeder Zeile einen "Parties" Button
echo "<td><button type='submit' class='btn btn-info' name='userpartyview' value='$id'>Parties</button></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table></form>";
echo "</div>";
}
//Erstelle Tabelle mit den Parties vom User
function views_userparty_view(){
?>
<div class="container-fluid">
<form action="index.php" method="POST">
<table class="table table-bordered">
<thead class="thead-default">
<tr>
<th>UserID</th>
<th>User</th>
<th>PartyID</th>
<th>Party Name</th>
<th>Party Datum</th>
<th>Location</th>
<th>Host</th>
<th>Commitment State</th>
<th>General Rating</th>
<th>Price Rating</th>
<th>Location Rating</th>
<th>Mood Rating</th>
</tr>
</thead>
<tbody>
<?php
//iteriere über den äußeren Array mit den UserParties
foreach($_SESSION['up'] as $keys => $userobject)
{
//iteriere über den inneren UserPartyArray
foreach($userobject as $inner_key => $wert)
{
//Erstelle für jeden Wert eine Spalte
echo "<td>$wert</td>";
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<td><button type='submit' class='btn btn-info' name='userpartycancel' value='back'>Zurück</button></td>";
echo "</form>";
echo "</div>";
}
}
?>