/
functions.php
3095 lines (2624 loc) · 118 KB
/
functions.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
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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
require("config.php");
/* Alle dingen die terug komen op pagina's, zoals headers, navigatie balken en footers */
function head() {
?>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title><?php retrieveTitle(); ?></title>
<!-- Bootstrap -->
<link href="<?php
if (!is_dir('admin')) {
print '../';
}
?>core/css/bootstrap.css" rel="stylesheet">
<link href="<?php
if (!is_dir('admin')) {
print '../';
}
?>core/css/style.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="http://code.jquery.com/jquery-1.6.3.min.js"></script>
<script src="<?php
if (!is_dir('admin')) {
print '../';
}
?>core/js/jquery.js"/></script>
<script type="text/javascript">
$(document).ready(function () {
$("#myTab a:first").tab('show');
});
$(function () {
// for bootstrap 3 use 'shown.bs.tab', for bootstrap 2 use 'shown' in the next line
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// save the latest tab; use cookies if you like 'em better:
localStorage.setItem('lastTab', $(this).attr('href'));
});
// go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('[href="' + lastTab + '"]').tab('show');
}
;
$(function () {
$("#editor").wysibb();
});
});
</script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<?php
}
function retrieveTitle() {
global $pdo;
$stmt = $pdo->prepare("SELECT * FROM SiteGegevens;");
$stmt->execute();
while ($row = $stmt->fetch()) {
$sitenaam = $row['sitenaam'];
print ($sitenaam);
}
}
function static_navbar() {
?>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-brand-centered">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand navbar-brand-centered">LaserGameBox</div>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-brand-centered">
<ul class="nav navbar-nav">
<li><a href="<?php
if (!is_dir('admin')) {
print '../';
}
?>index.php">Home</a></li>
<li><a href="<?php
if (!is_dir('admin')) {
print '../';
}
?>over-ons.php">Over ons</a></li>
<li><a href="<?php
if (!is_dir('admin')) {
print '../';
}
?>pakketten.php">Pakketten</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="<?php
if (!is_dir('admin')) {
print '../';
}
?>contact.php">Contact</a></li>
<li><a href="<?php
if (!is_dir('admin')) {
print '../';
}
?>reservering.php">Mijn reservering</a></li>
<li><a target="_blank" href="http://facebook.com"><i class="fa fa-facebook-square"></i></a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<?php
}
function adminnav() {
if ($_SESSION['login'] == TRUE) {
?>
<div class="adminnav col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 col-sm-10 col-sm-offset-1">
<li class="dropdown pull-right"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Hallo, <?php print $_SESSION['naam'] . " "; ?><b class="caret"></b></a>
<ul class="dropdown-menu list-inline">
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>index.php"><span class="glyphicon glyphicon-stats"></span>Dashboard</a></li>
<?php if ($_SESSION['functie'] == "Administrator") { ?>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_reserveringen.php"><span class="glyphicon glyphicon-tasks"></span>Reserveringen</a></li>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_medewerkers.php"><span class="glyphicon glyphicon-user"></span>Accounts</a></li>
<?php } ?>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_paginas.php"><span class="glyphicon glyphicon-book"></span>Pages</a></li>
<li class="divider col-xs-12"></li>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>account.php"><span class="glyphicon glyphicon-user"></span>Mijn Account</a></li>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>instellingen.php"><span class="glyphicon glyphicon-cog"></span>Instellingen</a></li>
<li class="col-xs-12"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>logout.php"><span class="glyphicon glyphicon-off"></span>Uitloggen</a></li>
</ul>
</li>
</div>
<?php
}
}
function headerwrap() {
?>
<header>
<div class="header-content">
<div class="header-content-inner">
<h1>Lasergamebox</h1>
<p>Lasergamen in je eigen omgeving!</p>
<hr class="light">
<a href="tel:0652654053" class="btn btn-primary hidden-lg hidden-md hidden"><span class="glyphicon glyphicon-phone-alt"></span> Bel ons.</a>
<a href="/reserveren.php" class="btn btn-primary">Reserveer direct!</a>
</div>
</div>
</header>
<?php
}
function carousel() {
?>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="core/img/slide1.jpg" alt="First slide">
<div class="container">
<div class="carousel-caption">
<h2>Lasergamen in je eigen omgeving.</h2>
<p></p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Reserveer nu!</a></p>
</div>
</div>
</div>
<div class="item">
<img class="second-slide" src="core/img/slide1.jpg" alt="Second slide">
<div class="container">
<div class="carousel-caption">
<h2>Vrijgezellenfeest?</h2>
<p>Ga gezellig met zijn allen lasergamen in een leuke of spannende omgeving. Voor jong en oud!</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Reserveer nu!</a></p>
</div>
</div>
</div>
<div class="item">
<img class="third-slide" src="core/img/slide1.jpg" alt="Third slide">
<div class="container">
<div class="carousel-caption">
<h2>Geen inspiratie voor een kinderfeestje?</h2>
<p>Ga gezellig met zijn allen lasergamen in een leuke of spannende omgeving. Neem de kinderen mee naar het bos! Laat ze daar elkaar beschieten!</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Reserveer nu!</a></p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div><!-- /.carousel -->
<?php
}
function reservation_bar() {
?>
<div class="reservation hidden-xs">
<div class="row">
<div class="col-lg-12 col-md-10 col-md-offset-1 col-sm-12 col-sm-offset-0">
<div class="input-group">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6">
<div class="input-group reserveerbar">
<span class="input-group-addon" id="sizing-addon2">Van: </span>
<input type="text" class="form-control" placeholder="" aria-describedby="sizing-addon2">
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6">
<div class="input-group reserveerbar">
<span class="input-group-addon" id="sizing-addon2">Tot:</span>
<input type="text" class="form-control" placeholder="" aria-describedby="sizing-addon2">
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-6">
<div class="input-group spinner reserveerbar">
<span class="input-group-addon" id="sizing-addon2">Aantal Pistolen:</span>
<input type="text" class="form-control" value="6" min="6" max="<?php onzichtbareVoorraad(); ?>">
<div class="input-group-btn-vertical">
<button class="btn btn-default" type="button"><i class="fa fa-caret-up"></i></button>
<button class="btn btn-default" type="button"><i class="fa fa-caret-down"></i></button>
</div>
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-6 col-xs-6 reserveerbar">
<a class="btn btn-primary reserveerknop" href="#" role="button">Reserveer</a>
</div>
</div>
</div>
</div>
</div>
<?php
}
function footer() {
?>
<footer>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<p class="text-right">© <?php echo date("Y"); ?> Lasergamebox.nl. Lasergamebox.nl is een onderdeel van GFretail.</p>
</div>
</footer>
<?php
}
/* Account overzicht op de website */
function overzicht_medewerkers() {
?>
<div class="col-md-10 col-md-offset-1">
<div class="bs-example">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a data-toggle="tab" href="#overzicht">Account overzicht</a></li>
<li><a data-toggle="tab" href="#toevoegen">Account toevoegen</a></li>
<!-- <li class="pull-right"><input type="text" class="form-control search-form" placeholder="Zoeken" ></li> -->
</ul>
<div class="tab-content">
<div id="overzicht" class="tab-pane fade in active ">
<p><table class = "table table-hover"><thead>
<tr>
<th>Naam</th>
<th>Achternaam</th>
<th>E-mail</th>
<th>Rechten</th>
<th> </th>
</tr>
</thead>
<?php account_overzicht(); ?>
</table></p>
</div>
<div id="toevoegen" class="tab-pane fade">
<div class="balk"><b>Gegevens account</b></div>
<script>
$('#form-content').on('show.bs.modal', function (e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
});
</script>
<form role="form" class="form-horizontal" method="post" action="overzicht_medewerkers.php">
<fieldset>
<!-- Text input-->
<div class="form-group">
<label class="col-sm-2 control-label" for="textinput">Voornaam</label>
<div class="col-sm-4">
<input type="text" placeholder="Voornaam" name="voornaam" class="form-control">
</div>
<label class="col-sm-2 control-label" for="textinput">Achternaam</label>
<div class="col-sm-4">
<input type="text" placeholder="Achternaam" name="achternaam" class="form-control">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-sm-2 control-label" for="textinput">Email</label>
<div class="col-sm-10">
<input type="text" placeholder="Email" name="email" class="form-control">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-sm-2 control-label" for="textinput">Wachtwoord</label>
<div class="col-sm-10">
<input type="text" placeholder="Wachtwoord" name="pass" class="form-control">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-sm-2 control-label" for="textinput">Functie</label>
<div class="col-sm-10">
<select class="form-control" id="functie" name="functie">
<option>Administrator</option>
<option>Web-administrator</option>
</select>
</div>
</div>
<div class="balk"><b>Na het aanmaken van een account word er een email verstuurd naar opgegeven emailadres met daarin de inlog gegevens.</b></div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="pull-right">
<input type="submit" class="btn btn-primary" name="toevoegen" value="Toevoegen">
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div> <!-- einde van tab-content -->
<?php
}
function account_overzicht() {
//Global gebruiken anders vindt die de gegevens(PDO string) niet en moet je keer op keer de connectie opnieuw invullen.
global $pdo;
$stmt = $pdo->prepare("SELECT * FROM medewerker");
$stmt->execute();
$medewerkers = $stmt->fetchAll();
foreach ($medewerkers as $medewerker) {
print("<tr class=\"active\">");
print("<td>" . $medewerker["naam"] . "</td>");
print("<td>" . $medewerker["achternaam"] . "</td>");
print("<td>" . $medewerker["email"] . "</td>");
print("<td>" . $medewerker["functie"] . "</td>");
if ($medewerker["mnr"] != $_SESSION['mnr']) {
print("<td>
<div class=\"btn-group\">
<a class=\"btn btn-default\" href=\"account_wijzig.php?mnr=" . $medewerker['mnr'] . "\">
<i class=\"fa fa-pencil-square-o\"></i>
</a>
<a class=\"btn btn-default\" onclick=\"return confirm('Weet u zeker dat u deze medewerker wilt verwijderen?')\" name=\"delete\" href=\"overzicht_medewerkers.php?delete=true&mnr=" . $medewerker['mnr'] . "\">
<i class=\"fa fa-times\"></i>
</a>
</div>
</td>");
} else {
print("<td></td>");
}
print("</tr>");
}
}
/* Aanmaken reservering voor de klant, door de admin */
function aanmaak_reservering() {
global $pdo;
$reserveringnr = "";
if (isset($_POST["reserveringnr"])) {
$reserverinsnr = $_POST["reserverinsnr"];
}
$klantnr = "";
if (isset($_POST["klantnr"])) {
$klantnr = $_POST["klantnr"];
}
$status = "";
if (isset($_POST["status"])) {
$status = $_POST["status"];
}
$naam = "";
if (isset($_POST["naam"])) {
$naam = $_POST["naam"];
}
$achternaam = "";
if (isset($_POST["achternaam"])) {
$achternaam = $_POST["achternaam"];
}
$telnummer = "";
if (isset($_POST["telnummer"])) {
$telnummer = $_POST["telnummer"];
}
$email = "";
if (isset($_POST["email"])) {
$email = $_POST["email"];
}
$postcode = "";
if (isset($_POST["postcode"])) {
$postcode = $_POST["postcode"];
}
$huisnummer = "";
if (isset($_POST["huisnummer"])) {
$huisnummer = $_POST["huisnummer"];
}
$straat = "";
if (isset($_POST["straat"])) {
$straat = $_POST["straat"];
}
$woonplaats = "";
if (isset($_POST["woonplaats"])) {
$woonplaats = $_POST["woonplaats"];
}
//datum moet nog andersom!!
$van = "";
if (isset($_POST["van"])) {
$van = $_POST["van"];
}
$tot = "";
if (isset($_POST["tot"])) {
$tot = $_POST["tot"];
}
$aantal_pistolen = "";
if (isset($_POST["aantal_pistolen"])) {
$aantal_pistolen = $_POST["aantal_pistolen"];
}
$aanbetaling = "";
if (isset($_POST["aanbetaling"])) {
$aanbetaling = $_POST["aanbetaling"];
}
$pakket_kosten = "";
if (isset($_POST["pakket_kosten"])) {
$pakket_kosten = $_POST["pakket_kosten"];
}
$borg = "";
if (isset($_POST["borg"])) {
$borg = $_POST["borg"];
}
$totaal = "";
if (isset($_POST["totaal"])) {
$totaal = $_POST["totaal"];
}
$array = array();
try {
print ('<br>');
//hier is gekozen voor het controleren op empty en niet voor isset - op moment dat er een spatie is ingevuld is de string al niet meer empty dus wordt de isset functie TRUE
if (isset($_POST["opslaan"]) && (empty($_POST["checkbox"])) && (empty($_POST["reserveringnr"]) || empty($_POST["klantnr"]) || empty($_POST["status"]) || empty($_POST["naam"]) || empty($_POST["achternaam"]) || empty($_POST["telnummer"]) || empty($_POST["postcode"]) || empty($_POST["huisnummer"]) || empty($_POST["straat"]) || empty($_POST["woonplaats"]) || empty($_POST["van"]) || empty($_POST["tot"]) || empty($_POST["aantal_pistolen"]) || empty($_POST["aanbetaling"]) || empty($_POST["pakket_kosten"]) || empty($_POST["borg"]) || empty($_POST["totaal"]) || empty($_POST["email"]) )) {
$controler = array('Voornaam' => $_POST["naam"], 'Achternaam' => $_POST["achternaam"], 'Email' => $_POST["email"], 'Reserveringnr' => $_POST["reserveringnr"], 'Klantnr' => $_POST["status"], 'Telefoonnummer' => $_POST["telnummer"],
'Postcode' => $_POST["postcode"], 'Huisnummer' => $_POST["huisnummer"], 'Straat' => $_POST["straat"], 'Plaats' => $_POST["plaats"], 'Van welke datum?' => $_POST["van"],
'Tot welke datum?' => $_POST["tot"], 'Aantal pistolen' => $_POST["aantal_pistolen"], 'Aanbetaling' => $_POST["aanbetaling"], 'Pakket kosten' => $_POST["pakket_kosten"],
'Borg' => $_POST["borg"], 'Totaal' => $_POST["totaal"]);
foreach ($controler as $key => $waarde) {
if (empty($waarde)) {
print('<div class="alert alert-danger" role="alert">' . $key . ' is leeg.</div>');
}
}
} else {
$stmt = $pdo->prepare("INSERT INTO klant (klantnr, naam, achternaam, email, telnummer, straat, huisnummer, woonplaats, postcode) VALUES(?,?,?,?,?,?,?,?,?)");
$stmt->execute(array($_POST["klantnr"], $_POST["naam"], $_POST["achternaam"], $_POST["email"], $_POST["telnummer"], $_POST["straat"], $_POST["huisnummer"], $_POST["woonplaats"], $_POST["postcode"]));
$stmt = $pdo->prepare("INSERT INTO reservering (reserveringnr, klantnr, aantal_pistolen, van, tot, status) VALUES(?, ?, ?, ?, ?, ?)");
$stmt->execute(array($_POST["reserveringnr"], $_POST["klantnr"], $_POST["aantal_pistolen"], $_POST["van"], $_POST["tot"], $_POST["status"]));
if ($stmt->rowCount() == 1) {
// als de klant is toegevoegd worden de ingevoerde waarden niet opnieuw getoond
$naam = $_POST["naam"];
$achternaam = $_POST["achternaam"];
$email = $_POST["email"];
$klantnr = $_POST["klantnr"];
$telnummer = $_POST["telnummer"];
$straat = $_POST["straat"];
$huisnummer = $_POST["huisnummer"];
$woonplaats = $_POST["woonplaats"];
$postcode = $_POST["postcode"];
$reserveringnr = $_POST["reserveringnr"];
$aantal_pistolen = $_POST["aantal_pistolen"];
$van = $_POST["van"];
$tot = $_POST["tot"];
$status = $_POST["status"];
print("<div class=\"alert alert-success\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Gelukt!</strong>
Reservering aangemaakt.
</div>");
$to = $email;
$subject = 'Reservering van lasergamepistolen';
$headers = "From: info@stomic.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<img src="http://project.stomic.com/core/img/slide1.jpg" height="200" width="700" alt="lasergamebox.nl" />';
$message .= '<h1>Lasergamebox.nl</h1>';
$message .= '<h3>Inlog gegevens</h3>';
$message .= '<p>Beste ' . $naam . '</p>';
$message .= 'Wij hebben succesvol een reservering voor u kunnen plaatsen.<br>';
$message .= 'Je kunt inloggen met de volgende gegevens:<br>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Email:</strong> </td><td>" . $email . "</td></tr>";
$message .= "<tr><td><strong>Reserveringsnummer:</strong> </td><td>" . $reserveringnr . "</td></tr>";
$message .= '<tr><td><strong>Login:</strong> </td><td><a href="http://project.stomic.com/reservering.php">Mijn reservering</a></td></tr>';
$message .= "</table>";
$message .= '<p></p>';
$message .= "</body></html>";
mail($to, $subject, $message, $headers);
}
}
} catch (PDOException $e) {
print "<div class=\"alert alert-danger\" role=\"alert\">Het aanmaken is mislukt. <a href=\"javascript: window.history.go(-1)\">Ga terug</a> </div>";
}
$pdo = NULL;
}
/* Account toevoegen op de website */
function account_toevoegen() {
//Global gebruiken anders vindt die de gegevens(PDO string) niet en moet je keer op keer de connectie opnieuw invullen.
global $pdo;
/*
$naam = "";
if (isset($_POST["voornaam"])) {
$naam = $_POST["voornaam"];
}
$achternaam = "";
if (isset($_POST["achternaam"])) {
$achternaam = $_POST["achternaam"];
}
$email = "";
if (isset($_POST["email"])) {
$achternaam = $_POST["email"];
}
$functie = "";
if (isset($_POST["functie"])) {
$functie = $_POST["functie"];
}
$pass = "";
if (isset($_POST["pass"])) {
$pass = $_POST["pass"];
}
$medewerker = array();
*/
//hier is gekozen voor het controleren op empty en niet voor isset - op moment dat er een spatie is ingevuld is de string al niet meer empty dus wordt de isset functie TRUE
if (empty($_POST["voornaam"]) OR empty($_POST["achternaam"]) OR empty($_POST["email"]) OR empty($_POST["pass"])) {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-danger\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Mislukt!</strong> Vul a.u.b alle gegevens in.
</div>";
} else {
$stmt = $pdo->prepare("SELECT * FROM medewerker WHERE email=?");
$stmt->execute(array($_POST["email"]));
if ($stmt->rowCount() == 1) {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-danger\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Mislukt!</strong> Een medewerker met dit e-mail adres staat al in het systeem geregistreerd.
</div>";
} else {
$salt = hash('sha256', $pass);
$stmt = $pdo->prepare("INSERT INTO medewerker (naam,achternaam,wachtwoord,email,functie) VALUES(?,?,?,?,?)");
$stmt->execute(array($_POST["voornaam"], $_POST["achternaam"], $salt, $_POST["email"], $_POST["functie"]));
if ($stmt->rowCount() == 1) {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-success\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Gelukt!</strong>
Medewerker toegevoegd.
</div>";
// als de medewerker is toegevoegd worden de ingevoerde waarden niet opnieuw getoond
$naam = $_POST["voornaam"];
$achternaam = $_POST["achternaam"];
$email = $_POST["email"];
$pass = $_POST["pass"];
$to = $email;
$subject = 'Account registratie';
$headers = "From: info@stomic.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<img src="http://project.stomic.com/core/img/slide1.jpg" height="200" width="700" alt="lasergamebox.nl" />';
$message .= '<h1>Lasergamebox.nl</h1>';
$message .= '<h3>Inlog gegevens</h3>';
$message .= '<p>Beste ' . $naam . '</p>';
$message .= 'Je bent succesvol geregistreerd op de website.<br>';
$message .= 'Je kunt inloggen met de volgende gegevens:<br>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Email:</strong> </td><td>" . $email . "</td></tr>";
$message .= "<tr><td><strong>Wachtwoord:</strong> </td><td>" . $pass . "</td></tr>";
$message .= '<tr><td><strong>Login:</strong> </td><td><a href="http://project.stomic.com/admin">admin paneel</a></td></tr>';
$message .= "</table>";
$message .= '<p></p>';
$message .= "</body></html>";
mail($to, $subject, $message, $headers);
}
}
}
$pdo = NULL;
}
/* Account wijzigen op de website */
function account_wijzig() {
//Global gebruiken anders vindt die de gegevens(PDO string) niet en moet je keer op keer de connectie opnieuw invullen.
global $pdo;
try {
if (isset($_POST["opslaan"])) {
if (!empty($_POST['pass'])) {
$pass = $_POST['pass'];
$salted = hash('sha256', $pass);
$stmt = $pdo->prepare("UPDATE medewerker SET naam=?,achternaam=?,email=?,functie=?,wachtwoord=? WHERE mnr=?");
$stmt->execute(array($_POST["voornaam"], $_POST["achternaam"], $_POST["email"], $_POST["functie"], $salted, $_GET["mnr"]));
print("<div class=\"alert alert-success\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Gelukt!</strong>
Medewerker bewerkt
</div>");
} elseif (empty($_POST["voornaam"]) || empty($_POST["achternaam"]) || empty($_POST["email"])) {
$controler = array('Voornaam' => $_POST["voornaam"], 'Achternaam' => $_POST["achternaam"], 'Email' => $_POST["email"]);
foreach ($controler as $key => $waarde) {
if (empty($waarde)) {
print('<div class="alert alert-danger" role="alert">' . $key . ' mag niet leeg zijn</div>');
}
}
} else {
$stmt = $pdo->prepare("UPDATE medewerker SET naam=?,achternaam=?,email=?,functie=? WHERE mnr=?");
$stmt->execute(array($_POST["voornaam"], $_POST["achternaam"], $_POST["email"], $_POST["functie"], $_GET["mnr"]));
print("<div class=\"alert alert-success\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Gelukt!</strong>
Medewerker bewerkt
</div>");
}
}
if ($_GET["mnr"] != "") {
$stmt = $pdo->prepare("SELECT * FROM medewerker WHERE mnr=?");
$stmt->execute(array($_GET["mnr"]));
$medewerker = $stmt->fetch();
$mnr = $medewerker["mnr"];
$naam = $medewerker["naam"];
$achternaam = $medewerker["achternaam"];
$email = $medewerker["email"];
$functie = $medewerker["functie"];
print " <form role=\"form\" class=\"form-horizontal\" method=\"post\" action=\"account_wijzig.php?mnr=$mnr\">";
print "<fieldset>";
print "<!-- Text input-->";
print "<div class=\"form-group\">";
print "<label class=\"col-sm-2 control-label\" for=\"textinput\">Voornaam</label>";
print "<div class=\"col-sm-4\">";
print "<input type=\"text\" placeholder=\"Voornaam\" name=\"voornaam\" class=\"form-control\" value=\"$naam\">";
print "</div>";
print "<label class=\"col-sm-2 control-label\" for=\"textinput\">Achternaam</label>";
print "<div class=\"col-sm-4\">";
print "<input type=\"text\" placeholder=\"Achternaam\" name=\"achternaam\" class=\"form-control\" value=\"$achternaam\">";
print "</div>";
print "</div>";
print "<!-- Text input-->";
print "<div class=\"form-group\">";
print "<label class=\"col-sm-2 control-label\" for=\"textinput\">Email</label>";
print "<div class=\"col-sm-10\">";
print "<input type=\"text\" placeholder=\"Email\" name=\"email\" class=\"form-control\" value=\"$email\">";
print "</div>";
print "</div>";
print "<!-- Text input-->";
print "<div class=\"form-group\">";
print "<label class=\"col-sm-2 control-label\" for=\"textinput\">Wachtwoord</label>";
print "<div class=\"col-sm-10\">";
print "<input type=\"text\" placeholder=\"Wachtwoord\" name=\"pass\" class=\"form-control\">";
print "</div>";
print "</div>";
print "<!-- Text input-->";
print "<div class=\"form-group\">";
print "<label class=\"col-sm-2 control-label\" for=\"textinput\">Functie</label>";
print "<div class=\"col-sm-10\">";
print "<select class=\"form-control\" id=\"functie\" name=\"functie\">";
print '<option value="Administrator" ' . (($functie == 'Administrator') ? 'selected="selected"' : "") . '>Administrator</option>';
print '<option value="Web-administrator" ' . (($functie == 'Web-administrator') ? 'selected="selected"' : "") . '>Web-administrator</option>';
print "</select>";
print "</div>";
print "</div>";
print "<div class=\"form-group\">";
print "<div class=\"col-sm-offset-2 col-sm-10\">";
print "<div class=\"pull-right\">";
print "<input type=\"submit\" class=\"btn btn-danger\" name=\"terug\" value=\"Ga Terug\">";
print "<span>     </span>";
print "<input type=\"submit\" class=\"btn btn-success\" name=\"opslaan\" value=\"Opslaan\">";
print "</div>";
print "</div>";
print "</div>";
print "</fieldset>";
print "</form> ";
} else {
print "<div class=\"alert alert-danger\" role=\"alert\">Het medewerker nummer mist. <a href=\"javascript: window.history.go(-1)\">Ga terug</a> </div>";
}
} catch (PDOException $e) {
print "<div class=\"alert alert-danger\" role=\"alert\">Het bewerken is mislukt, probeer het opnieuw. <a href=\"javascript: window.history.go(-1)\">Ga terug</a> </div>";
}
$pdo = NULL;
}
/* Account verwijderen op de website */
function verwijderMedewerker() {
//Global gebruiken anders vindt die de gegevens(PDO string) niet en moet je keer op keer de connectie opnieuw invullen.
global $pdo;
if ($_GET['mnr'] != $_SESSION['mnr']) {
if (isset($_GET['mnr'])) {
try {
$stmt = $pdo->prepare("DELETE FROM medewerker WHERE mnr=?");
$stmt->execute(array($_GET['mnr']));
if ($stmt->rowCount() == 1) {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-success\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Gelukt!</strong>
Medewerker verwijderd.
</div>";
} else {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-danger\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Mislukt!</strong>
Het verwijderen van de mederwerker is mislukt. Probeer het later opnieuw.
</div>";
}
} catch (PDOException $e) {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-danger\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Mislukt!</strong>
Er ging iets mis met de prepare statement. Neem contact met een IT boy.
</div>";
}
$pdo = NULL;
}
} else {
$_SESSION['AccountStatus'] = TRUE;
$_SESSION['AccountMessage'] = "<div class=\"alert alert-danger\" id=\"success-alert\">
<button type=\"button\" class=\"close\" data-dismiss=\"alert\">x</button>
<strong>Mislukt!</strong>
U kunt uw eigen account niet verwijderen. Duh!
</div>";
}
}
/* Login systeem voor het CMS */
function login_form() {
?>
<div class="col-md-6 col-md-offset-5"><h2><b>Admin Paneel</b></h2> </div>
<div class="col-md-5 col-md-offset-3"
<div class="panel panel-default">
<div class="panel-body">
<form action="index.php" class="form-horizontal" method="POST">
<fieldset>
<div class="form-group">
<label class="col-sm-4 control-label" for="textinput">Email</label>
<div class="col-sm-8">
<input class="form-control" placeholder="E-mail" name="email" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="textinput">Wachtwoord</label>
<div class="col-sm-8">
<input class="form-control" placeholder="Wachtwoord" name="wachtwoord" type="password">
</div>
</div>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<a href="wachtwoord_vergeten.php">Wachtwoord vergeten?</a>
</div>
</div>
<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<input class="btn btn-md btn-success btn-block" type="submit" name="submit" value="Inloggen">
</div>
</div>
</fieldset>
</form>
</div>
</div>
<?php
}
function login_check() {
if (isset($_POST['submit'])) {
global $pdo;
$email = $_POST['email'];
$pass = $_POST['wachtwoord'];
$sha256 = hash('sha256', $pass);
if (isset($_POST) && $email != '' && $pass != '') {
$stmt = $pdo->prepare("SELECT mnr, naam, email, wachtwoord,functie FROM medewerker WHERE email =?");
$stmt->execute(array($email));
while ($result = $stmt->fetch()) {
$p = $result['wachtwoord'];
$naam = $result['naam'];
$rechten = $result['functie'];
$mnr = $result['mnr'];
}
if ($p == $sha256) {
$_SESSION['naam'] = $naam;
$_SESSION['mnr'] = $mnr;
$_SESSION['login'] = TRUE;
$_SESSION['functie'] = $rechten;
print '<script>window.location.assign("index.php")</script>';
} else {
print "<br><div class=\"alert alert-danger\" role=\"alert\">De combinatie van e-mail en wachtwoord is onjuist. </div>";
}
} else {
print "<br><div class=\"alert alert-danger\" role=\"alert\">Vul een e-mail en wachtwoord in. </div>";
}
}
}
function adminDashboard() {
if ($_SESSION['functie'] == "Administrator") {
?>
<div class="col-lg-10 col-md-12 col-sm-12 col-xs-12 col-lg-offset-1 col-md-offset-0 col-sm-offset-0">
<h2>Admin Dashboard</h2>
<ul class="list-group">
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_reserveringen.php"><span class="glyphicon glyphicon-tasks"></span>Reserveringen</a></li>
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_medewerkers.php"><span class="glyphicon glyphicon-user"></span>Accounts</a></li>
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_paginas.php"><span class="glyphicon glyphicon-book"></span>Pages</a></li>
<li></li>
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>account.php"><span class="glyphicon glyphicon-user"></span>Mijn Account</a></li>
<li class="list-group-item"><a href="instellingen.php"><span class="glyphicon glyphicon-cog"></span>Instellingen</a></li>
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>logout.php"><span class="glyphicon glyphicon-off"></span>Uitloggen</a></li>
</ul>
</div> <?php
} else {
?>
<div class="col-lg-10 col-md-12 col-sm-12 col-xs-12 col-lg-offset-1 col-md-offset-0 col-sm-offset-0">
<h2>ADMIN DASHBOARD</h2>
<ul class="list-group">
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}
?>overzicht_paginas.php"><span class="glyphicon glyphicon-book"></span>Pages</a></li>
<li class="divider"></li>
<li class="list-group-item"><a href="<?php
if (is_dir('admin')) {
print 'admin/';
}