-
Notifications
You must be signed in to change notification settings - Fork 0
/
beo_list.php
236 lines (195 loc) · 7.56 KB
/
beo_list.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
<?php
//
$doPing = false;
require_once "classes/start.inc.php";
require_once "classes/beo.inc.php";
//
$oBeo = new Beo((isset($type_of_beo) ? $type_of_beo : ''), $label);
$oWebuser->checkLoggedIn();
// show page
echo createBeoListContent();
function createBeoListContent() {
global $twig, $oWebuser, $type_of_beo, $protect, $dbConn, $dateOutCriterium, $oBeo;
$items = array();
if ( !isset($_GET["m"]) ) {
$selectedMonth = date("m");
} else {
$selectedMonth = trim(substr($_GET["m"],0,2));
}
if ( $selectedMonth == '' ) {
$selectedMonth = date("m");
}
if ( !isset($_GET["y"]) ) {
$selectedYear = date("Y");
} else {
$selectedYear = trim(substr($_GET["y"], 0, 4));
}
if ( $selectedYear == '' ) {
$selectedYear = date("Y");
}
// allow only previous, current and next year
if ( $selectedYear < date("Y")-1 ) {
$selectedYear = date("Y")-1;
$selectedMonth = 1;
} elseif ( $selectedYear > date("Y")+1 ) {
$selectedYear = date("Y")+1;
$selectedMonth = 12;
}
$arrHolidays = getNationalHolidays($selectedYear, $selectedMonth );
$daysInCurrentMonth = cal_days_in_month(CAL_GREGORIAN, $selectedMonth, $selectedYear);
$cellWidth = 23;
$vakantieWidth = $daysInCurrentMonth * $cellWidth+($daysInCurrentMonth*2);
//
$layout = trim($protect->request('get', "l"));
if ($layout == '') {
$layout = $oWebuser->getUserSetting($type_of_beo . '_display_format', 'tabular');
}
if (!in_array($layout, array('tabular', 'tile'))) {
$layout = 'tabular';
}
// save setting
$query_update = "INSERT INTO staff_user_settings (`user_id`, `setting`, `value`) VALUES (" . $oWebuser->getId() . ", '" . $type_of_beo . "_display_format', '$layout') ON DUPLICATE KEY UPDATE `value`='$layout' ";
$stmt = $dbConn->getConnection()->prepare($query_update);
$stmt->execute();
//
$checkInOutIds = implode(',', $oWebuser->getFavourites('checkinout'));
//
$totaal["aanwezig"] = 0;
$totaal["afwezig"] = 0;
$ontruimersAanwezigOpVerdieping = array();
$nrOfLevels = Settings::get("number_of_levels");
if ($nrOfLevels == '') {
$nrOfLevels = 6;
}
for ($i = 0; $i <= $nrOfLevels; $i++) {
$ontruimersAanwezigOpVerdieping[$i] = 0;
}
//
$querySelect = "
SELECT DISTINCT protime_curric.PERSNR, protime_curric.FIRSTNAME, protime_curric.NAME, IFNULL(bhv_sortorder, 9999)
FROM protime_curric
LEFT JOIN staff_today_checkinout ON protime_curric.PERSNR = staff_today_checkinout.PERSNR AND staff_today_checkinout.BOOKDATE = '" . date("Ymd") . "'
WHERE " . $dateOutCriterium . "
AND " . $oBeo->getQuery() . Misc::getNeverShowPersonsCriterium() . "
ORDER BY " . $oBeo->getExtraOrderBy() . "protime_curric.FIRSTNAME, protime_curric.NAME ";
//preprintHidden( $querySelect );
$showFloors = 0;
if ($oBeo->getShowFloor()) {
$showFloors = 1;
}
$showTelephone = 0;
if ($oWebuser->hasAuthorisationBeoTelephone()) {
$showTelephone = 1;
}
//
$stmt = $dbConn->getConnection()->prepare($querySelect);
$stmt->execute();
$result = $stmt->fetchAll();
foreach ($result as $row) {
$item = array();
$oEmployee = new ProtimeUser($row["PERSNR"]);
$item['id'] = $oEmployee->getId();
$item['url'] = createUrl(array('url' => 'employee.php?id=' . $oEmployee->getId(), 'label' => $oEmployee->getNiceFirstLastname()));
$item['verdieping'] = $oEmployee->getOntruimerVerdieping();
$item['telephone'] = Telephone::getTelephonesHref($oEmployee->getTelephones());
//
if (strpos(',' . $checkInOutIds . ',', ',' . $oEmployee->getId() . ',') !== false) {
$alttitle = Translations::get('lbl_click_to_not_get_email_notification');
$item['checkinout'] = '<a href="#" onClick="return checkInOut(' . $oEmployee->getId() . ', \'r\');" title="' . $alttitle . '" class="nolink"><img src="images/misc/clock-red.png" border=0></a>';
} else {
$alttitle = Translations::get('lbl_click_to_get_email_notification');
$item['checkinout'] = '<a href="#" onClick="return checkInOut(' . $oEmployee->getId() . ', \'a\');" title="' . $alttitle . '" class="nolink"><img src="images/misc/clock-black.png" border=0></a>';
}
//
$status = getCurrentDayCheckInoutState($oEmployee->getId());
if ($status["aanwezig"] == 1) {
$totaal["aanwezig"]++;
$ontruimersAanwezigOpVerdieping[$oEmployee->getOntruimerVerdieping()] = 1;
} else {
$totaal["afwezig"]++;
}
//
$item['status_style'] = $status["status_color"];
$item['status_text'] = $status["status_text"];
$item['status_alt'] = $status["status_alt"];
//
if ( $type_of_beo == 'b' && ( $oWebuser->isBhv() || $oWebuser->isAdmin() ) ) {
$oAbsenceCalendar = new AbsenceCalendar($oEmployee->getId());
$arrVakantie = $oAbsenceCalendar->getAbsencesAndHolidaysMonth($selectedYear, $selectedMonth);
//
$currentSchedule = new ProtimeUserSchedule($oEmployee->getId(), date("Ymd"));
$vrijeWerkdagen = $currentSchedule->getFreeWorkingdays();
//
$vak = AbsenceCalendarFormat::inMonthListFormat($selectedYear, $selectedMonth, $arrVakantie, $arrHolidays, $vrijeWerkdagen);
$item['vakantie'] = $vak;
}
$items[] = $item;
// als niet rood en ook niet groen dan altijd tonen
}
// HEADERS
$headerDays = '';
if ( $type_of_beo == 'b' && ( $oWebuser->isBhv() || $oWebuser->isAdmin() ) ) {
for ( $i = 1; $i <= $daysInCurrentMonth; $i++ ) {
$extrastyle = "width:" . $cellWidth ."px;border: thin solid white;";
$celValue = $i;
$cellStyle = getStyle($selectedYear, $selectedMonth, $i, array(), $arrHolidays,1, null );
$extrastyle .= $cellStyle["tdStyle"];
if ( $cellStyle["alt"] != '' ) {
$celValue = '<a title="' . $cellStyle["alt"] . '" style="' . $cellStyle["hrefStyle"] . '" >' . $celValue . '</a>';
}
$headerDays .= "<TD style=\"" . $extrastyle . "\" align=center><font size=-2>" . $celValue . "</font></TD>";
}
}
//
// FLOORS
$floors = '';
if ($oBeo->getShowFloor()) {
$showFloors = 1;
for ($i = 0; $i <= $nrOfLevels; $i++) {
if ($ontruimersAanwezigOpVerdieping[$i] == 1) {
$style = " background-color:green;color:white; ";
} else {
$style = " background-color:#C62431;color:white; ";
}
$floors .= "<td align=\"center\" style=\"" . $style . "width:22px;\">" . $i . "</td>";
}
}
if ( $type_of_beo == 'b' ) {
$showBhvComment = 1;
} else {
$showBhvComment = 0;
}
//
if ( $type_of_beo == 'b' && ( $oWebuser->isBhv() || $oWebuser->isAdmin() ) ) {
$twigTemplate = 'beo_list_vakantie.twig';
} else {
$twigTemplate = 'beo_list.twig';
}
return $twig->render($twigTemplate, array(
'title' => $oBeo->getLabel()
, 'in_case_of_emergency_call' => Translations::get('in_case_of_emergency_call')
, 'emergency_number' => Settings::get('emergency_number')
, 'lbl_present' => Translations::get('lbl_present')
, 'lbl_not_present' => Translations::get('lbl_not_present')
, 'totaal_aanwezig' => $totaal["aanwezig"]
, 'totaal_afwezig' => $totaal["afwezig"]
, 'lbl_page_refreshes_every' => Translations::get('lbl_page_refreshes_every')
, 'date' => date("H:i:s")
, 'showBhvComment' => $showBhvComment
, 'showFloors' => $showFloors
, 'showTelephone' => $showTelephone
, 'floors' => $floors
, 'lbl_level' => Translations::get('lbl_level')
, 'lbl_name' => Translations::get('lbl_name')
, 'lbl_check_inout' => Translations::get('lbl_check_inout')
, 'lbl_telephone' => Translations::get('lbl_telephone')
, 'items' => $items
, 'vakantieWidth' => $vakantieWidth
, 'lbl_today' => Translations::get('lbl_today')
, 'lbl_holidayabsences' => Translations::get('lbl_holidayabsences')
, 'selectedMonth' => Translations::get('month' . ($selectedMonth+0))
, 'selectedYear' => $selectedYear
, 'headerDays' => $headerDays
, 'isBhv' => ( $type_of_beo == 'b' && ( $oWebuser->isBhv() || $oWebuser->isAdmin() ) ) ? 1 : 0
));
}