-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathveranstaltung.php
193 lines (158 loc) · 5.82 KB
/
veranstaltung.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
<?php
/*
* Created on 23.11.2015
*
*/
function veranstaltung() {
global $func;
$id = 0;
$titel = "";
$untertitel = "";
$datum = "";
$sonderwertung = "";
# display Form
if (isset($_GET['id'])) {
if($_GET['id'] != "new") {
$sql = "select * from veranstaltung where ID = ".$_GET['id'];
$result = dbRequest($sql, 'SELECT');
foreach ($result[0] as $row) {
$titel = $row['titel'];
$untertitel = $row['untertitel'];
$sonderwertung = $row['sonderwertung'];
$datum = $row['datum'];
$id = $row['ID'];
}
}
?>
<script>
$( document ).ready( function() {
$('.datepicker').datepicker({
format: 'yyyy-mm-dd',
autoclose: true,
language: 'de',
orientation: 'bottom'
})
$("#editVeranstaltung").submit(function(event){
// cancels the form submission
event.preventDefault();
var msg = '';
if( $('#title').val().length < 2 ) { msg = msg + '<strong>Titel</strong> darf nicht leer sein<br>'; }
if( $('#date').val().length != 10 ) { msg = msg + '<strong>Datum</strong> ist nicht im richtigen Format, oder leer<br>'; }
if( msg == '' ) {
submitForm('#editVeranstaltung', 'index.php?func=veranstaltung');
} else {
$(".alert").html(msg);
$(".alert").removeClass('hidden');
}
});
});
</script>
<div class="alert alert-danger hidden col-sm-offset-3 col-sm-6" role="alert"></div>
<form role="form" class="form-horizontal" id="editVeranstaltung" name="editVeranstaltung">
<div class="form-group">
<input type="hidden" name="form" value="saveVeranstaltung">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
</div>
<div class="form-group">
<label for="title" class="col-sm-4 control-label">Titel:</label>
<div class="col-sm-5">
<input name="title" maxlength="200" type="text" class="form-control" id="title" placeholder="Titel" value="<?php echo $titel; ?>">
</div>
</div>
<div class="form-group">
<label for="subTitle" class="col-sm-4 control-label">Untertitel:</label>
<div class="col-sm-5">
<input name="subTitle" maxlength="200" type="text" class="form-control" id="subTitle" placeholder="Untertitel" value="<?php echo $untertitel; ?>">
</div>
</div>
<div class="form-group">
<label for="date" class="col-sm-4 control-label">Datum:</label>
<div class="col-sm-5">
<div class="input-group datepicker date">
<input name="datum" type="text" class="form-control" id="date" placeholder="Datum" value="<?php echo $datum; ?>">
<span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label for="subTitle" class="col-sm-4 control-label">Sonderwertung:</label>
<div class="col-sm-5">
<input name="sonderwertung" maxlength="200" type="text" class="form-control" id="sonderwertung" placeholder="Sonderwertung" value="<?php echo $sonderwertung; ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-5">
<button type="submit" id="submit" class="btn btn-success">save</button>
<a type="button" class="btn btn-default" href="index.php?func=veranstaltung">cancel</a>
</div>
</div>
</form>
<?php
} else {
# Display Veranstaltungen
?>
<h3>Veranstaltungen</h3>
<a type="button" href="index.php?func=veranstaltung&id=new" class="btn btn-success pull-right btn-new-top">neue Veranstaltung</a>
<div class="table-responsive">
<table class="table table-striped table-vcenter">
<thead>
<tr>
<th>ID</th>
<th>Titel</th>
<th>Untertitel</th>
<th>Datum</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = "select * from veranstaltung order by datum desc;";
$result = dbRequest($sql, 'SELECT');
foreach ($result[0] as $row) {
if(isset($_SESSION['vID']) && $_SESSION['vID'] == $row['ID']) {
$b = "bold";
} else {
$b = "";
}
?>
<tr>
<td><?php echo $row['ID'] ?></td>
<td><a class="veranstaltung-<?php echo $row['ID']." ".$b; ?>" href="#" onclick="javascript:selectVeranstaltung(<?php echo $row['ID']?>); return false;"><?php echo $row['titel']; ?></a></td>
<td><?php echo $row['untertitel']; ?></td>
<td><?php echo $row['datum']; ?></td>
<td><a type="button" class="btn btn-default btn-small-border" href="<?php echo $_SERVER["REQUEST_URI"]."&id=".$row['ID']; ?>"><i class="fa fa-wrench"></i></a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php
}
}
function saveVeranstaltung() {
if($_POST['id'] == "new") {
$sql = "insert into veranstaltung (titel, untertitel, sonderwertung, datum) values ( '".htmlspecialchars($_POST['title'], ENT_QUOTES, 'UTF-8')."', '".htmlspecialchars($_POST['subTitle'], ENT_QUOTES, 'UTF-8')."', '".htmlspecialchars($_POST['sonderwertung'], ENT_QUOTES, 'UTF-8')."','".htmlspecialchars($_POST['datum'], ENT_QUOTES, 'UTF-8')."')";
} else {
$sql = "update veranstaltung set titel = '".htmlspecialchars($_POST['title'], ENT_QUOTES, 'UTF-8')."', untertitel = '".htmlspecialchars($_POST['subTitle'], ENT_QUOTES, 'UTF-8')."', sonderwertung = '".htmlspecialchars($_POST['sonderwertung'], ENT_QUOTES, 'UTF-8')."', datum = '".htmlspecialchars($_POST['datum'], ENT_QUOTES, 'UTF-8')."' where ID = ".$_POST['id'].";";
}
$result = dbRequest($sql, 'INSERT');
if($result[2] == "") {
echo 'ok';
} else {
echo $result[2];
}
}
function selectVeranstaltung( $id ) {
$_SESSION['vID'] = $id;
$_SESSION['rID'] = 0;
$sql = "select * from veranstaltung where id = $id";
$result = dbRequest($sql, 'SELECT');
foreach ($result[0] as $row) {
$_SESSION['vTitel'] = $row['titel'];
$_SESSION['vUntertitel'] = $row['untertitel'];
$_SESSION['vDatum'] = $row['datum'];
$_SESSION['vSpecial'] = $row['sonderwertung'];
}
echo $_SESSION['vTitel'];
}
?>