-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshowCombineRooster.php
188 lines (163 loc) · 5.27 KB
/
showCombineRooster.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
<?php
include_once('include/functions.php');
include_once('include/config.php');
include_once('include/pdf/config.php');
include_once('include/pdf/3gk_table.php');
include_once('include/HTML_TopBottom.php');
$cfgProgDir = 'auth/';
include($cfgProgDir. "secure.php");
$db = connect_db();
$roosters = array();
if(isset($_REQUEST['rs'])) {
$roosters = explode('|', $_REQUEST['rs']);
} elseif(isset($_REQUEST['r'])) {
$roosters = $_REQUEST['r'];
}
if(count($roosters) > 0) {
$diensten = getAllKerkdiensten(true);
$text[] = "<table>";
$text[] = "<tr>";
$text[] = "<th> </th>";
$header[] = 'Datum';
foreach($roosters as $rooster) {
# Voorganger
if($rooster == 'v') {
$text[] = "<th>Voorganger</th>";
$header[] = 'Voorganger';
# Collecte
} elseif($rooster == 'c') {
$text[] = "<th>Collecte</th>";
$header[] = 'Collecte';
# de rest
} else {
$RoosterData = getRoosterDetails($rooster);
$text[] = "<th>". $RoosterData['naam'] ."</th>";
$header[] = $RoosterData['naam'];
}
}
$text[] = "</tr>";
foreach($diensten as $dienst) {
$dienstData = getKerkdienstDetails($dienst);
$gevuldeCel = false;
$cel = $rij = array();
foreach($roosters as $rooster) {
# Voorganger
if($rooster == 'v') {
if($dienstData['voorganger'] != '') {
$cel[] = "<td>". $dienstData['voorganger'] ."</td>";
$rij[] = $dienstData['voorganger'];
$gevuldeCel = true;
} else {
$cel[] = "<td> </td>";
$rij[] = '';
}
# Collecte
} elseif($rooster == 'c') {
if($dienstData['collecte_1'] != '') {
$cel[] = "<td>". $dienstData['collecte_1'] .'<br>'. $dienstData['collecte_2'] ."</td>";
$rij[] = $dienstData['collecte_1'] ."\n". $dienstData['collecte_2'];
$gevuldeCel = true;
} else {
$cel[] = "<td> </td>";
$rij[] = '';
}
# De rest
} else {
$vulling = getRoosterVulling($rooster, $dienst);
# Als er leden gevonden is voor het rooster
if(is_array($vulling) AND count($vulling) > 0) {
$team = array();
foreach($vulling as $lid) {
$team[] = makeName($lid, 5);
}
$cel[] = "<td>". implode("<br>", $team) ."</td>";
$rij[] = implode("\n", $team);
$gevuldeCel = true;
# Als er tekst gevonden is voor het rooster
} elseif(is_string($vulling) AND strlen($vulling) > 1) {
$cel[] = "<td>". $vulling ."</td>";
$rij[] = $vulling;
$gevuldeCel = true;
# Als er niks gevonden is voor het rooster
} else {
$cel[] = "<td> </td>";
$rij[] = '';
}
}
}
if($gevuldeCel) {
$text[] = "<tr>";
$text[] = "<td>".time2str("%a %d %b %H:%M", $dienstData['start'])."<br><i>".$dienstData['bijzonderheden'] ."</i></td>";
$text[] = implode("\n", $cel);
$text[] = "</tr>";
$rij = array_merge(array(time2str("%a %d %b %H:%M", $dienstData['start'])."\n".$dienstData['bijzonderheden']), $rij);
$data[] = $rij;
}
}
$text[] = "</table>";
$text[] = "<p>";
$text[] = "<a href='?rs=". implode('|', $roosters)."&pdf' class='button'>sla op als PDF</a>";
toLog('debug', '', 'Combi-rooster '. implode('|', $roosters) .' bekeken');
} else {
$roosters = getRoosters(0);
$first[] = "<form>";
$first[] = "<table id='combirooster_table'>";
foreach($roosters as $rooster) {
$data = getRoosterDetails($rooster);
$first[] = "<tr><td><input type='checkbox' name='r[]' value='$rooster'></td><td>". $data['naam']."</td></tr>";
}
$first[] = "<tr>";
$first[] = " <td><input type='checkbox' name='r[]' value='v'></td>";
$first[] = " <td>Voorganger</td>";
$first[] = "</tr>";
$first[] = "<tr>";
$first[] = " <td><input type='checkbox' name='r[]' value='c'></td>";
$first[] = " <td>Collecte</td>";
$first[] = "</tr>";
$first[] = "</table>";
#$first[] = "<tr>";
#$first[] = " <td colspan='2'> </td>";
#$first[] = "</tr>";
#$first[] = "<tr>";
#$first[] = " <td colspan='2'><input type='submit' name='show' value='Toon gezamenlijk'></td>";
#$first[] = "</tr>";
$first[] = "<p> </p>";
$first[] = "<input type='submit' name='show' value='Toon gezamenlijk'>";
$first[] = "</form>";
}
if(isset($_REQUEST['pdf'])) {
if(count($header) == 2) {
$RoosterData = getRoosterDetails(end($roosters));
$title = 'Rooster '. $RoosterData['naam'];
} else {
$title = 'Gecombineerd rooster';
}
if(count($header) < 6) {
$pdf = new PDF_3GK_Table();
} else {
$pdf = new PDF_3GK_Table('L');
}
$breedte = $pdf->GetPageWidth();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont($cfgLttrType,'',8);
$widths = array_fill(1, (count($header)-1), ($breedte-25-(2*$cfgMarge))/(count($header)-1));
$widths[0] = 25;
$pdf->SetWidths($widths);
$pdf->makeTable($header, $data);
$pdf->Output('I', $title.'_'.date('Y_m_d').'.pdf');
toLog('debug', '', 'Combi-rooster '. implode('|', $roosters) .' in PDF bekeken');
} else {
echo showCSSHeader(array('default', 'table_default'));
if(isset($first)) {
echo '<div class="content_vert_kolom">'.NL;
echo " <div class='content_block'>".NL. implode(NL, $first).NL."</div>".NL;
echo '</div> <!-- end \'content_vert_kolom\' -->'.NL;
} else {
echo '<div class="content_vert_kolom_full">'.NL;
echo " <div class='content_block'>".NL. implode(NL, $text).NL."</div>".NL;
echo '</div> <!-- end \'content_vert_kolom_full\' -->'.NL;
}
echo showCSSFooter();
}
?>