Output.php
11.4 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
<?php
/**
* This file is part of ncfilters by netz.coop eG.
*
* Ncfilters is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Ncfilters is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ncfilters. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von ncfilters by netz.coop eG.
*
* Ncfilters ist Freie Software: Sie können es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
* veröffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Ncfilters wird in der Hoffnung, dass es nützlich sein wird, aber
* OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License für weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*
*/
/**
* Output
* Main html Output for project
*
* @author kontakt@nc
*/
class Output {
public function printhead() {
$string = '<!DOCTYPE html>';
$string .= '<html lang="en">';
$string .= '<head>';
$string .= '<!-- Required meta tags -->';
$string .= '<meta charset="utf-8">';
$string .= '<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">';
$string .= '<!-- Bootstrap CSS -->';
$string .= '<link rel="stylesheet" href="include/libs/bootstrap-4.0.0/css/bootstrap.min.css" >';
$string .= '<link rel="stylesheet" href="include/css/basic.css" >';
$string .= '<script src="include/libs/jquery/js/jquery-3.2.1.slim.min.js" ></script>';
$string .= '<script src="include/libs/tether/js/tether.min.js" ></script>';
$string .= '<script src="include/libs/bootstrap-4.0.0/js/bootstrap.min.js" ></script>';
$string .= '<script src="include/js/basic.js" ></script>';
$string .= '</head>';
return $string;
}
public function printlogo($name) {
$string = '<div class="header">';
$string .= ' <a href="https://netz.coop"><img class="logo" src="include/images/logo.png" alt="logo" /></a>';
$string .= '<h1>' . $name . '</h1>';
$string .= ' </div>';
return $string;
}
public function printfoter() {
$string = '<div class="footer">
<small>ncfilters powered by netz.coop eG</small>
</div>';
return $string;
}
public function printcollapsebtn($btnname = 'Erweitert', $id = 'collapseId', $type = 'warning') {
$string .= '<button class="btn btn-' . $type . '" type="button" data-toggle="collapse" data-target="#' . $id . '" aria-expanded="false" aria-controls="' . $id . '"> ' . $btnname . ' </button>';
return $string;
}
public function printcollapsecontent($input, $btnname = 'Erweitert', $id = 'collapseId', $type = 'warning') {
$string = '<div class="collapse" id="' . $id . '">';
$string .= '<div class="card card-block">';
$string .= $input;
$string .= '</div>';
$string .= '</div>';
return $string;
}
public function printstartbody() {
$string = '<body>';
$string .= '<div class="container">';
return $string;
}
public function printpagename($name = 'ncfilters') {
$string = '<h1>' . $name . '</h1>';
$string .= '';
return $string;
}
public function printformstart($name = 'domain', $value = 'print') {
$string .= '<form class="form-horizontal" method="POST" role="form" >';
$string .= '<input type="hidden" name="' . $name . '" value="' . $value . '">';
return $string;
}
public function printformend() {
$string .= '</form>';
return $string;
}
public function printbutton($name = 'Submit',$type='primary',$title='submit',$class='') {
$string .= '<input class="btn btn-'.$type.' '.$class.'" type="submit" value="' . $name . '" title="'.$title.'">';
return $string;
}
public function printmsg($text = 'Submit', $type = 'success') {
$string .= '<div class="alert alert-' . $type . '" role="alert">' . $text . '</div>';
return $string;
}
public function printendbody() {
$string .= '</div>';
$string .= '</body>';
return $string;
}
public function printmintablestart() {
$string .= '<table class="table">';
$string .= '<tbody>';
$string .= '<tr>';
return $string;
}
public function printmintableend() {
$string .= '</tr>';
$string .= '</tbody>';
$string .= '</table>';
return $string;
}
public function printmintablecell($content) {
$string .= '<th>' . $content . '</th>';
return $string;
}
public function printdropdown($array,$name,$fieldlabel='name',$fieldvalue='group_id') {
$string .= '<select name="'.$name.'">';
foreach ($array as $key => $value) {
$string .= ' <option value="'.$value[$fieldvalue].'" label="'.$value[$fieldlabel].'">'.$value[$fieldlabel].' ('.$value[$fieldvalue] .')</option>';
}
$string .= ' </select>';
return $string;
}
public function printtable($ary_head, $ary_content, $controlls = false, $ary_controll = array(), $user = 0) {
$string = '<table class="table table-responsive">';
$string .= '<thead class="thead-inverse">';
$string .= '<tr>';
$string .= '<th>#</th>';
if($ary_controll['table']==='pclist'){
$db = new Connectdb();
$arraygroups=$db->getgroupids();
// echo '<pre>';
// print_r($arraygroups);
// echo '</pre>';
}
foreach ($ary_head as $key => $value) {
if ($value === 'updated' || $value === 'updatedby' || $value === 'intern') {
} else {
$string .= '<th>' . $value . '</th>';
}
}
$string .= '</tr>';
$string .= '</thead>';
$string .= '<tbody>';
if (key_exists('fastinput', $ary_controll)) {
$string .= '<form class="form-horizontal" method="POST" role="form" >';
$string .= '<input type="hidden" name="table" value="' . $ary_controll['table'] . '">';
$string .= '<input type="hidden" name="action" value="fastinput">';
$i = 0;
foreach ($ary_content as $key => $value) {
if ($i === 0) {
$string .= '<tr>';
$string .= '<td>' . $this->printbutton('Eintragen') . '</td>';
foreach ($value as $skey => $svalue) {
if ($skey === 'updated') {
$string .= '<input type="hidden" name="updated" value="' . date("Y-m-d H:i:s") . '">';
} elseif ($skey === 'updatedby') {
$string .= '<input type="hidden" name="updatedby" value="' . $user . '">';
} else {
if($ary_controll['table']==='pclist' && $skey === 'group_id'){
// $string .= '<td>' . $arraygroups[$svalue]['name'].' ('. $svalue .') </td>';
$string .='<td>';
$string .= $this->printdropdown($arraygroups,'group_id',$fieldlabel='name',$fieldvalue='group_id');
$string .= '</td>';
}elseif ($skey === 'id' && $ary_controll['table'] !== 'groups') {
$string .= '<td></td>';
} elseif ($skey === 'childlvl') {
$string .= '<td><input type="number" name="' . $skey . '" value="1"></td>';
} elseif ($skey === 'enable' || $skey === 'open') {
$string .= '<input type="hidden" name="' . $skey . '" value="0" />';
$string .= '<td><input type="CHECKBOX" name="' . $skey . '"></td>';
} elseif ($skey === 'intern') {
$string .= '<input type="hidden" name="' . $skey . '" value="0">';
} elseif ($skey === 'priority') {
$string .= '<td><input type="number" name="' . $skey . '" value="0"></td>';
} else {
$string .= '<td><input type="text" name="' . $skey . '" placeholder="' . $skey . '"></td>';
}
}
}
$string .= '</tr>';
}
$i++;
}
$string .= '</form>';
}
$i = 0;
foreach ($ary_content as $key => $value) {
$string .= '<tr>';
if (key_exists('delete', $ary_controll)) {
$string .= '<td><form class="form-horizontal" method="POST" role="form" >';
$string .= '<input type="hidden" name="table" value="' . $ary_controll['table'] . '">';
$string .= '<input type="hidden" name="action" value="delete">';
if($ary_controll['table']==='groups'){
$string .= '<input type="hidden" name="group_id" value="' . $value['group_id'] . '">';
}else{
$string .= '<input type="hidden" name="id" value="' . $value['id'] . '">';
}
$string .= '' . $this->printbutton('löschen','danger btn-sm') . '';
$string .= '</form></td>';
} else {
$string .= '<td>' . $i . '</td>';
}
foreach ($value as $skey => $svalue) {
if ($skey === 'updated' || $skey === 'updatedby' || $skey === 'intern') {
}elseif ($skey === 'enable' || $skey === 'open') {
if($value[$skey] ==='0'){
$string .= '<td><form class="form-horizontal" method="POST" role="form" >';
$string .= '<input type="hidden" name="table" value="' . $ary_controll['table'] . '">';
$string .= '<input type="hidden" name="action" value="activate">';
$string .= '<input type="hidden" name="field" value="'.$skey.'">';
if($ary_controll['table']==='groups'){
$string .= '<input type="hidden" name="group_id" value="' . $value['group_id'] . '">';
}else{
$string .= '<input type="hidden" name="id" value="' . $value['id'] . '">';
}
$string .= '' . $this->printbutton('✔','danger btn-sm','Aktivieren') . '';
$string .= '</form></td>';
}else{
$string .= '<td><form class="form-horizontal" method="POST" role="form" >';
$string .= '<input type="hidden" name="table" value="' . $ary_controll['table'] . '">';
$string .= '<input type="hidden" name="action" value="deactivate">';
$string .= '<input type="hidden" name="field" value="'.$skey.'">';
if($ary_controll['table']==='groups'){
$string .= '<input type="hidden" name="group_id" value="' . $value['group_id'] . '">';
}else{
$string .= '<input type="hidden" name="id" value="' . $value['id'] . '">';
}
$string .= '' . $this->printbutton('✖','success btn-sm','Deaktivieren') . '';
$string .= '</form></td>';
}
$string .= '<input type="hidden" name="updatedby" value="' . $user . '">';
} else {
if($ary_controll['table']==='pclist' && $skey === 'group_id'){
$string .= '<td>' . $arraygroups[$svalue]['name'].' ('. $svalue .') </td>';
}else{
$string .= '<td>' . $svalue . '</td>';
}
}
}
$string .= '</tr>';
$i++;
}
$string .= '</tbody>';
$string .= '</table>';
return $string;
}
public function printlogin(){
$string = '
<div id="loginbox">
<div class="wrapper">
<form class="form-signin" action="./" method="post">
<fieldset>
<p>
<input type="text" id="username" name="username" placeholder="Name" value="" maxlength="20" />
</p>
<p>
<input type="password" id="password" name="password" placeholder="Passwort" value="" maxlength="20" />
</p>
<p>
<input type="hidden" name="form_token" value="<?php echo $form_token; ?>" />';
$string .= $this->printbutton('➥ Login','primary btn-sm','Login') ;
$string .=' </p>
</fieldset>
</form>
</div>
</div>';
echo $string;
}
}