|
1
|
|
|
<?php |
|
2
|
|
|
/************************************************************************ |
|
3
|
|
|
* OVIDENTIA http://www.ovidentia.org * |
|
4
|
|
|
************************************************************************ |
|
5
|
|
|
* Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
|
6
|
|
|
* * |
|
7
|
|
|
* This file is part of Ovidentia. * |
|
8
|
|
|
* * |
|
9
|
|
|
* Ovidentia is free software; you can redistribute it and/or modify * |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by * |
|
11
|
|
|
* the Free Software Foundation; either version 2, or (at your option) * |
|
12
|
|
|
* any later version. * |
|
13
|
|
|
* * |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, but * |
|
15
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
|
17
|
|
|
* See the GNU General Public License for more details. * |
|
18
|
|
|
* * |
|
19
|
|
|
* You should have received a copy of the GNU General Public License * |
|
20
|
|
|
* along with this program; if not, write to the Free Software * |
|
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
|
22
|
|
|
* USA. * |
|
23
|
|
|
************************************************************************/ |
|
24
|
|
|
|
|
25
|
|
|
require_once dirname(__FILE__).'/agent_right.class.php'; |
|
26
|
|
|
require_once dirname(__FILE__).'/csv.class.php'; |
|
27
|
|
|
|
|
28
|
|
|
class exportAvailableBalancesCls extends absences_Csv |
|
29
|
|
|
{ |
|
30
|
|
|
private $resYears; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* |
|
34
|
|
|
* @var array |
|
35
|
|
|
*/ |
|
36
|
|
|
private $rights; |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
private $recoveries; |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string YYYY-MM-DD |
|
47
|
|
|
*/ |
|
48
|
|
|
private $date = null; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var array |
|
52
|
|
|
*/ |
|
53
|
|
|
private $dirfields; |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
public function getHtml() |
|
57
|
|
|
{ |
|
58
|
|
|
global $babDB; |
|
59
|
|
|
|
|
60
|
|
|
$this->separatortxt = absences_translate("Separator"); |
|
|
|
|
|
|
61
|
|
|
$this->other = absences_translate("Other"); |
|
|
|
|
|
|
62
|
|
|
$this->comma = absences_translate("Comma"); |
|
|
|
|
|
|
63
|
|
|
$this->tab = absences_translate("Tab"); |
|
|
|
|
|
|
64
|
|
|
$this->semicolon = absences_translate("Semicolon"); |
|
|
|
|
|
|
65
|
|
|
$this->export = absences_translate("Export"); |
|
|
|
|
|
|
66
|
|
|
$this->sepdectxt = absences_translate("Decimal separator"); |
|
|
|
|
|
|
67
|
|
|
$this->t_yes = absences_translate("Yes"); |
|
|
|
|
|
|
68
|
|
|
$this->t_no = absences_translate("No"); |
|
|
|
|
|
|
69
|
|
|
$this->t_date = absences_translate('Export day date'); |
|
|
|
|
|
|
70
|
|
|
$this->t_year = absences_translate('Year filter'); |
|
|
|
|
|
|
71
|
|
|
$this->t_organization = absences_translate('Organization'); |
|
|
|
|
|
|
72
|
|
|
$this->additional_fields = absences_translate("Additional fields to export:"); |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
$W = bab_Widgets(); |
|
75
|
|
|
$this->datePicker = $W->DatePicker()->setName('date')->display($W->HtmlCanvas()); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
$this->resYears = $babDB->db_query("SELECT YEAR(date_begin) year FROM absences_rights WHERE YEAR(date_begin)<>'0' GROUP BY year"); |
|
78
|
|
|
|
|
79
|
|
|
$this->resOrganization = $babDB->db_query("SELECT * FROM `absences_organization` ORDER BY name ASC"); |
|
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
$this->dirfields = bab_getDirEntry(BAB_REGISTERED_GROUP, BAB_DIR_ENTRY_ID_GROUP); |
|
83
|
|
|
|
|
84
|
|
|
unset($this->dirfields['sn']); |
|
85
|
|
|
unset($this->dirfields['givenname']); |
|
86
|
|
|
unset($this->dirfields['jpegphoto']); |
|
87
|
|
|
|
|
88
|
|
|
return bab_printTemplate($this, absences_addon()->getRelativePath()."vacadm.html", "abexport"); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* template method to list available years |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getnextyear() |
|
95
|
|
|
{ |
|
96
|
|
|
global $babDB; |
|
97
|
|
|
|
|
98
|
|
|
if ($arr = $babDB->db_fetch_assoc($this->resYears)) |
|
99
|
|
|
{ |
|
100
|
|
|
$this->year = bab_toHtml($arr['year']); |
|
|
|
|
|
|
101
|
|
|
return true; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
return false; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
View Code Duplication |
public function getnextfield() |
|
|
|
|
|
|
109
|
|
|
{ |
|
110
|
|
|
if (list($name,$arr) = each($this->dirfields)) |
|
111
|
|
|
{ |
|
112
|
|
|
$this->fieldname = bab_toHtml($name); |
|
|
|
|
|
|
113
|
|
|
$this->fieldlabel = bab_toHtml($arr['name']); |
|
|
|
|
|
|
114
|
|
|
return true; |
|
115
|
|
|
} |
|
116
|
|
|
return false; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* template method to list available organization |
|
121
|
|
|
*/ |
|
122
|
|
|
public function getnextorganization() |
|
123
|
|
|
{ |
|
124
|
|
|
global $babDB; |
|
125
|
|
|
|
|
126
|
|
|
if ($arr = $babDB->db_fetch_assoc($this->resOrganization)) |
|
127
|
|
|
{ |
|
128
|
|
|
$this->organization = bab_toHtml($arr['name']); |
|
|
|
|
|
|
129
|
|
|
$this->id_organization = bab_toHtml($arr['id']); |
|
|
|
|
|
|
130
|
|
|
return true; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
return false; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
private function query($year, $groupby = '', $organization = '', $user = '') |
|
139
|
|
|
{ |
|
140
|
|
|
global $babDB; |
|
141
|
|
|
|
|
142
|
|
|
if (!empty($year)) { |
|
143
|
|
|
$year = 'AND YEAR(r.date_begin)='.$babDB->quote($year); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
if ($organization) { |
|
147
|
|
|
$organization = 'AND p.id_organization='.$babDB->quote($organization); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
if ($user) { |
|
151
|
|
|
$user = ' AND p.id_user='.$babDB->quote($user); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
$query = " |
|
156
|
|
|
SELECT |
|
157
|
|
|
ur.* |
|
158
|
|
|
FROM |
|
159
|
|
|
absences_users_rights ur, |
|
160
|
|
|
absences_rights r, |
|
161
|
|
|
absences_personnel p, |
|
162
|
|
|
bab_users u |
|
163
|
|
|
WHERE |
|
164
|
|
|
ur.id_user=p.id_user |
|
165
|
|
|
AND p.id_user=u.id |
|
166
|
|
|
AND r.id = ur.id_right |
|
167
|
|
|
AND r.active = 'Y' |
|
168
|
|
|
$year |
|
169
|
|
|
$organization |
|
170
|
|
|
$user |
|
171
|
|
|
$groupby |
|
172
|
|
|
ORDER BY |
|
173
|
|
|
u.lastname, |
|
174
|
|
|
u.firstname, |
|
175
|
|
|
r.description |
|
176
|
|
|
"; |
|
177
|
|
|
|
|
178
|
|
|
return $babDB->db_query($query); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
|
|
182
|
|
|
|
|
183
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* New row for the user |
|
188
|
|
|
* |
|
189
|
|
|
* @param absences_AgentRight $agentRight |
|
190
|
|
|
* @param array $remain |
|
191
|
|
|
* |
|
192
|
|
|
* @return Array |
|
193
|
|
|
*/ |
|
194
|
|
|
private function getNewCurrentRow(absences_AgentRight $agentRight, Array $remain) |
|
195
|
|
|
{ |
|
196
|
|
|
$arr = bab_getUserName($agentRight->id_user, false); |
|
197
|
|
|
|
|
198
|
|
|
$currentRow = array( |
|
199
|
|
|
$this->csvEncode($arr['lastname']), |
|
200
|
|
|
$this->csvEncode($arr['firstname']), |
|
201
|
|
|
$remain['D'], // total days |
|
202
|
|
|
$remain['H'] // total hours |
|
203
|
|
|
); |
|
204
|
|
|
|
|
205
|
|
|
foreach($this->rights as $initcol) { |
|
206
|
|
|
$currentRow[$initcol] = 0.0; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
foreach($this->recoveries as $quantity_unit => $initcol) { |
|
210
|
|
|
if (isset($initcol)) { |
|
211
|
|
|
$currentRow[$initcol] = 0.0; |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
return $currentRow; |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Process one row |
|
221
|
|
|
* if user row exists, add remain to the correct right column |
|
222
|
|
|
* if the user row does not exists, create it |
|
223
|
|
|
* |
|
224
|
|
|
* return the row only if it is the first user row |
|
225
|
|
|
* else return null |
|
226
|
|
|
* |
|
227
|
|
|
* @return array | null |
|
228
|
|
|
*/ |
|
229
|
|
|
private function processRow($arr) |
|
230
|
|
|
{ |
|
231
|
|
|
static $currentUser = null; |
|
232
|
|
|
static $currentRow = null; |
|
233
|
|
|
|
|
234
|
|
|
$return = null; |
|
235
|
|
|
|
|
236
|
|
|
if (null === $arr) { |
|
237
|
|
|
|
|
238
|
|
|
if (!isset($currentRow)) { |
|
239
|
|
|
return array(); |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
$encoded = $this->encodeFloats($currentRow); |
|
243
|
|
|
$currentRow = null; |
|
244
|
|
|
$currentUser = null; |
|
245
|
|
|
return $encoded; |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
$agentRight = new absences_AgentRight(); |
|
249
|
|
|
$agentRight->setRow($arr); |
|
250
|
|
|
|
|
251
|
|
|
$right = $agentRight->getRight(); |
|
252
|
|
|
|
|
253
|
|
|
$remain = array('D' => 0.0, 'H' => 0.0); |
|
254
|
|
|
|
|
255
|
|
|
$remain_line = $remain[$right->quantity_unit] = $agentRight->getAvailableQuantity($this->date); |
|
256
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
if ($currentUser !== $agentRight->id_user) { |
|
259
|
|
|
$currentUser = $agentRight->id_user; |
|
260
|
|
|
|
|
261
|
|
|
if (null !== $currentRow && !$this->isRowEmpty($currentRow)) { |
|
|
|
|
|
|
262
|
|
|
$return = $this->encodeFloats($currentRow); |
|
|
|
|
|
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
$currentRow = $this->getNewCurrentRow($agentRight, $remain); |
|
266
|
|
|
|
|
267
|
|
|
$this->addDirValues($arr['id_user'], $currentRow); |
|
268
|
|
|
|
|
269
|
|
|
} else { |
|
270
|
|
|
|
|
271
|
|
|
$currentRow[2] += $remain['D']; // total days |
|
272
|
|
|
$currentRow[3] += $remain['H']; // total hours |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
|
|
276
|
|
|
$this->setRightColumn($right, $currentRow, $remain, $remain_line); |
|
277
|
|
|
|
|
278
|
|
|
|
|
279
|
|
|
return $return; |
|
280
|
|
|
} |
|
281
|
|
|
|
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* Complete current row with right value |
|
285
|
|
|
* @param absences_Right $right |
|
286
|
|
|
* @param array &$currentRow |
|
287
|
|
|
*/ |
|
288
|
|
|
private function setRightColumn(absences_Right $right, Array &$currentRow, Array $remain, $remain_line) |
|
289
|
|
|
{ |
|
290
|
|
|
|
|
291
|
|
|
if (absences_Right::RECOVERY === $right->getKind()) { |
|
292
|
|
|
|
|
293
|
|
|
// recovery right |
|
294
|
|
|
$col = $this->recoveries[$right->quantity_unit]; |
|
295
|
|
|
if ($col > 3) { |
|
296
|
|
|
$currentRow[$col] += $remain[$right->quantity_unit]; |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
|
|
300
|
|
|
} else { |
|
301
|
|
|
|
|
302
|
|
|
|
|
303
|
|
|
//regular right, add to specific column |
|
304
|
|
|
$col = $this->rights[$right->id]; |
|
305
|
|
|
|
|
306
|
|
|
if ($col > 3) { |
|
307
|
|
|
$currentRow[$col] = $remain_line; |
|
308
|
|
|
} |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* Complete current row with directory entry values |
|
314
|
|
|
* @param int $id_user |
|
315
|
|
|
* @param array &$currentRow |
|
316
|
|
|
*/ |
|
317
|
|
|
private function addDirValues($id_user, Array &$currentRow) |
|
318
|
|
|
{ |
|
319
|
|
|
$agent = absences_Agent::getFromIdUser($id_user); |
|
320
|
|
|
|
|
321
|
|
|
foreach ($this->dirfields as $name => $dummy) { |
|
322
|
|
|
$currentRow[] = $this->csvEncode($this->getAgentDirValue($agent, $name)); |
|
323
|
|
|
} |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
|
|
327
|
|
|
|
|
328
|
|
|
|
|
329
|
|
|
/** |
|
330
|
|
|
* @return string |
|
331
|
|
|
*/ |
|
332
|
|
|
private function getSeparator() |
|
333
|
|
|
{ |
|
334
|
|
|
switch((int) bab_pp('wsepar')) |
|
335
|
|
|
{ |
|
336
|
|
|
case 0: return bab_pp('separ'); |
|
337
|
|
|
case 1: return ','; |
|
338
|
|
|
case 2: return "\t"; |
|
339
|
|
|
case 3: return ';'; |
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
|
|
344
|
|
|
|
|
345
|
|
|
protected function getDate() |
|
346
|
|
|
{ |
|
347
|
|
|
$W = bab_Widgets(); |
|
348
|
|
|
return $W->DatePicker()->getISODate(bab_rp('date')); |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* @return array |
|
354
|
|
|
*/ |
|
355
|
|
|
private function getHeader($year = '', $organization = '') |
|
356
|
|
|
{ |
|
357
|
|
|
global $babDB; |
|
358
|
|
|
|
|
359
|
|
|
$columns = $this->query($year, 'GROUP BY r.id', $organization); |
|
360
|
|
|
$this->rights = array(); |
|
361
|
|
|
|
|
362
|
|
|
|
|
363
|
|
|
if ($this->dirfields && !empty($this->dirfields)) |
|
|
|
|
|
|
364
|
|
|
{ |
|
365
|
|
|
$ov_fields = bab_getDirEntry(BAB_REGISTERED_GROUP, BAB_DIR_ENTRY_ID_GROUP); |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
$header = array( |
|
369
|
|
|
$this->csvEncode(absences_translate('Lastname')), |
|
370
|
|
|
$this->csvEncode(absences_translate('Firstname')), |
|
371
|
|
|
$this->csvEncode(absences_translate('Total days')), |
|
372
|
|
|
$this->csvEncode(absences_translate('Total hours')) |
|
373
|
|
|
); |
|
374
|
|
|
|
|
375
|
|
|
|
|
376
|
|
|
$this->recoveries = array( |
|
377
|
|
|
'D' => null, |
|
378
|
|
|
'H' => null |
|
379
|
|
|
); |
|
380
|
|
|
|
|
381
|
|
|
$recovery = array( |
|
382
|
|
|
'D' => false, |
|
383
|
|
|
'H' => false |
|
384
|
|
|
); |
|
385
|
|
|
|
|
386
|
|
|
while ($arr = $babDB->db_fetch_assoc($columns)) |
|
387
|
|
|
{ |
|
388
|
|
|
$agentRight = new absences_AgentRight(); |
|
389
|
|
|
$agentRight->setRow($arr); |
|
390
|
|
|
|
|
391
|
|
|
$right = $agentRight->getRight(); |
|
392
|
|
|
|
|
393
|
|
|
if (absences_Right::RECOVERY === $right->getKind()) { |
|
394
|
|
|
$recovery[$right->quantity_unit] = true; |
|
395
|
|
|
continue; |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
$header[] = $this->csvEncode($right->description.' ('.$right->getUnitLabel().')'); |
|
399
|
|
|
$this->rights[$arr['id_right']] = (count($header) -1); |
|
400
|
|
|
} |
|
401
|
|
|
|
|
402
|
|
View Code Duplication |
if ($recovery['D']) { |
|
|
|
|
|
|
403
|
|
|
$header[] = $this->csvEncode(absences_translate('Recoveries (days)')); |
|
404
|
|
|
$this->recoveries['D'] = (count($header) -1); |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
View Code Duplication |
if ($recovery['H']) { |
|
|
|
|
|
|
408
|
|
|
$header[] = $this->csvEncode(absences_translate('Recoveries (hours)')); |
|
409
|
|
|
$this->recoveries['H'] = (count($header) -1); |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
foreach($this->dirfields as $name => $dummy) |
|
413
|
|
|
{ |
|
414
|
|
|
$header[] = $this->csvEncode($ov_fields[$name]['name']); |
|
|
|
|
|
|
415
|
|
|
} |
|
416
|
|
|
|
|
417
|
|
|
return $header; |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
|
|
421
|
|
|
|
|
422
|
|
|
public function csv() |
|
423
|
|
|
{ |
|
424
|
|
|
|
|
425
|
|
|
$W = bab_Widgets(); |
|
426
|
|
|
|
|
427
|
|
|
if ($date = $W->DatePicker()->getISODate(bab_rp('date'))) { |
|
428
|
|
|
if ('0000-00-00' !== $date) { |
|
429
|
|
|
$this->date = $date; |
|
430
|
|
|
} |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
$this->dirfields = bab_rp('dirfields', array()); |
|
|
|
|
|
|
434
|
|
|
|
|
435
|
|
|
|
|
436
|
|
|
|
|
437
|
|
|
$separator = $this->getSeparator(); |
|
438
|
|
|
$header = $this->getHeader(bab_rp('year'), bab_rp('organization')); |
|
439
|
|
|
|
|
440
|
|
|
|
|
441
|
|
|
$this->echoCsv($separator, $header); |
|
442
|
|
|
|
|
443
|
|
|
} |
|
444
|
|
|
|
|
445
|
|
|
|
|
446
|
|
|
|
|
447
|
|
|
|
|
448
|
|
|
|
|
449
|
|
|
private function echoCsv($separator, $header) |
|
450
|
|
|
{ |
|
451
|
|
|
global $babDB; |
|
452
|
|
|
|
|
453
|
|
|
$this->setHeaders(absences_translate("Vacation")); |
|
454
|
|
|
|
|
455
|
|
|
echo implode($separator, $header)."\n"; |
|
456
|
|
|
|
|
457
|
|
|
$rows = $this->query(bab_rp('year'), 'GROUP BY u.id, r.id', bab_rp('organization')); |
|
458
|
|
|
|
|
459
|
|
|
while ($arr = $babDB->db_fetch_assoc($rows)) |
|
460
|
|
|
{ |
|
461
|
|
|
if (null !== $line = $this->processRow($arr)) |
|
462
|
|
|
{ |
|
463
|
|
|
echo implode($separator, $line)."\n"; |
|
464
|
|
|
} |
|
465
|
|
|
} |
|
466
|
|
|
echo implode($separator, $this->processRow(null))."\n"; |
|
467
|
|
|
|
|
468
|
|
|
exit; |
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
|
|
472
|
|
|
/** |
|
473
|
|
|
* @return array |
|
474
|
|
|
*/ |
|
475
|
|
|
private function getUserRow($id_user) |
|
476
|
|
|
{ |
|
477
|
|
|
global $babDB; |
|
478
|
|
|
|
|
479
|
|
|
$rows = $this->query('', 'GROUP BY u.id, r.id', '', $id_user); |
|
480
|
|
|
|
|
481
|
|
|
while ($arr = $babDB->db_fetch_assoc($rows)) |
|
482
|
|
|
{ |
|
483
|
|
|
if (null !== $line = $this->processRow($arr)) |
|
484
|
|
|
{ |
|
485
|
|
|
return $line; |
|
486
|
|
|
} |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
return $this->processRow(null); |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
|
|
493
|
|
|
|
|
494
|
|
|
/** |
|
495
|
|
|
* @return Widget_Displayable_Interface |
|
496
|
|
|
*/ |
|
497
|
|
|
public function compareDateForOneUser($id_user) |
|
498
|
|
|
{ |
|
499
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/dateTime.php'; |
|
500
|
|
|
|
|
501
|
|
|
$this->dirfields = array(); |
|
502
|
|
|
|
|
503
|
|
|
$header = $this->getHeader(); |
|
504
|
|
|
|
|
505
|
|
|
|
|
506
|
|
|
$yesterday = BAB_DateTime::now(); |
|
507
|
|
|
$yesterday->less(1, BAB_DATETIME_DAY); |
|
508
|
|
|
|
|
509
|
|
|
$this->date = $yesterday->getIsoDate(); |
|
510
|
|
|
$arr0 = $this->getUserRow($id_user); |
|
511
|
|
|
|
|
512
|
|
|
$this->date = date('Y-m-d'); |
|
513
|
|
|
$arr1 = $this->getUserRow($id_user); |
|
514
|
|
|
|
|
515
|
|
|
$this->date = null; |
|
516
|
|
|
$arr2 = $this->getUserRow($id_user); |
|
517
|
|
|
|
|
518
|
|
|
|
|
519
|
|
|
$W = bab_Widgets(); |
|
520
|
|
|
$table = $W->TableView(); |
|
521
|
|
|
|
|
522
|
|
|
$row = 0; |
|
523
|
|
|
|
|
524
|
|
|
$table->addItem($W->Label(''), $row, 0 ); |
|
525
|
|
|
$table->addItem($W->Label('Yesterday'), $row, 1); |
|
526
|
|
|
$table->addItem($W->Label('Today'), $row, 2); |
|
527
|
|
|
$table->addItem($W->Label('No date'), $row, 3); |
|
528
|
|
|
$row++; |
|
529
|
|
|
|
|
530
|
|
|
foreach ($header as $k => $label) { |
|
531
|
|
|
|
|
532
|
|
|
if ('"0,0"' === $arr1[$k] && '"0,0"' === $arr2[$k]) { |
|
533
|
|
|
continue; |
|
534
|
|
|
} |
|
535
|
|
|
|
|
536
|
|
|
$table->addItem($W->Label($label), $row, 0 ); |
|
537
|
|
|
$table->addItem($l0 = $W->Label($arr0[$k]), $row, 1); |
|
538
|
|
|
$table->addItem($l1 = $W->Label($arr1[$k]), $row, 2); |
|
539
|
|
|
$table->addItem($l2 = $W->Label($arr2[$k]), $row, 3); |
|
540
|
|
|
|
|
541
|
|
|
$values = array_unique(array($arr0[$k], $arr1[$k], $arr2[$k])); |
|
542
|
|
|
|
|
543
|
|
|
if (1 !== count($values)) { |
|
544
|
|
|
$l0->addClass('widget-strong'); |
|
545
|
|
|
$l1->addClass('widget-strong'); |
|
546
|
|
|
$l2->addClass('widget-strong'); |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
$row++; |
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
return $table; |
|
553
|
|
|
} |
|
554
|
|
|
} |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: