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__).'/base.ui.php'; |
26
|
|
|
bab_Widgets()->includePhpClass('Widget_Form'); |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
class absences_AgentCardFrame extends absences_CardFrame |
30
|
|
|
{ |
31
|
|
|
protected $agent; |
32
|
|
|
|
33
|
|
|
public function __construct(absences_Agent $agent, $layout = null) |
34
|
|
|
{ |
35
|
|
|
parent::__construct(null, $layout); |
36
|
|
|
|
37
|
|
|
$this->agent = $agent; |
38
|
|
|
|
39
|
|
|
$this->loadPage(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function initClasses() |
43
|
|
|
{ |
44
|
|
|
$this->addClass('absences-agent-cardframe'); |
45
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_16); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function loadPage() |
49
|
|
|
{ |
50
|
|
|
$this->initClasses(); |
51
|
|
|
|
52
|
|
|
$W = bab_Widgets(); |
53
|
|
|
$cols = $W->HBoxItems( |
54
|
|
|
$col1 = $W->VBoxLayout(), // photo |
55
|
|
|
$W->Items( |
56
|
|
|
$W->Title($this->agent->getName(),3), |
57
|
|
|
$W->HBoxItems( |
58
|
|
|
$col2 = $W->VBoxLayout()->setVerticalSpacing(.2,'em'), // nom, regime, fonction, service |
59
|
|
|
$col3 = $W->VBoxLayout()->setVerticalSpacing(.2,'em') // positions dans l'organigramme / responsable hierarchique |
60
|
|
|
)->setHorizontalSpacing(3,'em') |
61
|
|
|
) |
62
|
|
|
)->setHorizontalSpacing(1,'em'); |
63
|
|
|
|
64
|
|
|
$this->addItem($cols); |
65
|
|
|
|
66
|
|
|
if ($photo = $this->getPhoto()) |
67
|
|
|
{ |
68
|
|
|
$col1->addItem($photo); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
if ($nickname = $this->getNickname()) |
73
|
|
|
{ |
74
|
|
|
$col2->addItem($nickname); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if ($disabled = $this->getDisabled()) |
78
|
|
|
{ |
79
|
|
|
$col2->addItem($disabled); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
if ($email = $this->getEmail()) |
83
|
|
|
{ |
84
|
|
|
$col2->addItem($email); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
if ($btel = $this->getDirField('btel')) |
88
|
|
|
{ |
89
|
|
|
$col2->addItem($btel); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$this->addPersonnelInfos($col2); |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
if ($direntry = $this->getDirEntry()) |
96
|
|
|
{ |
97
|
|
|
$col3->addItem($direntry); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
if ($planning = $this->getPlanning()) |
101
|
|
|
{ |
102
|
|
|
$col3->addItem($planning); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/* |
106
|
|
|
if ($workinghours = $this->getWorkingHours()) |
107
|
|
|
{ |
108
|
|
|
$col3->addItem($workinghours); |
109
|
|
|
} |
110
|
|
|
*/ |
111
|
|
|
|
112
|
|
|
$superior = absences_Agent::getCurrentUser()->isSuperiorOf($this->agent); |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
if (absences_Agent::getCurrentUser()->isManager()) |
116
|
|
|
{ |
117
|
|
View Code Duplication |
if ('rights' !== bab_rp('idx')) |
|
|
|
|
118
|
|
|
{ |
119
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Rights'), Func_Icons::APPS_VACATIONS), |
120
|
|
|
absences_addon()->getUrl().'vacadm&idx=rights&idu='.$this->agent->getIdUser())->setOpenMode(Widget_Link::OPEN_POPUP) |
121
|
|
|
); |
122
|
|
|
} |
123
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Export'), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET), absences_addon()->getUrl().'vacadm&idx=export&id_user='.$this->agent->getIdUser())); |
124
|
|
|
|
125
|
|
|
} |
126
|
|
|
else if ($superior && absences_getVacationOption('chart_superiors_set_rights')) |
127
|
|
|
{ |
128
|
|
|
$entity = $this->agent->getMainEntity(); |
129
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Rights'), Func_Icons::APPS_VACATIONS), |
130
|
|
|
absences_addon()->getUrl().'vacchart&idx=rights&idu='.$this->agent->getIdUser().'&ide='.$entity['id'].'&popup=1')->setOpenMode(Widget_Link::OPEN_POPUP) |
131
|
|
|
); |
132
|
|
|
} |
133
|
|
View Code Duplication |
else if ($superior) |
|
|
|
|
134
|
|
|
{ |
135
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Balance'), Func_Icons::APPS_VACATIONS), |
136
|
|
|
absences_addon()->getUrl().'vacuser&idx=viewrights&id_user='.$this->agent->getIdUser().'&popup=1')->setOpenMode(Widget_Link::OPEN_POPUP) |
137
|
|
|
); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
|
142
|
|
|
if ($superior = $this->agent->getSuperior()) |
143
|
|
|
{ |
144
|
|
|
//TRANSLATORS: Supervisor in organizational chart |
145
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Supervisor'), $superior['name'][0])); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
|
149
|
|
|
if ($organization = $this->agent->getOrganization()) |
150
|
|
|
{ |
151
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Organization'), $organization->name)); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
|
155
|
|
|
if ($entity = $this->agent->getMainEntity()) |
156
|
|
|
{ |
157
|
|
|
if (absences_Agent::getCurrentUser()->canViewEntityPlanning($entity['id'])) |
158
|
|
|
{ |
159
|
|
|
|
160
|
|
|
$col2->addItem( |
161
|
|
|
$W->FlowItems( |
162
|
|
|
$W->Label(absences_translate('Position'))->addClass('widget-strong')->colon(), |
163
|
|
|
$W->Items( |
164
|
|
|
$W->Label($entity['name']), |
165
|
|
|
$W->Label(' ('), |
166
|
|
|
$W->Link(absences_translate('planning'), absences_addon()->getUrl().'planning&idx=entity_cal&popup=1&ide='.$entity['id'])->setOpenMode(Widget_Link::OPEN_POPUP), |
167
|
|
|
$W->Label(')') |
168
|
|
|
) |
169
|
|
|
)->addClass('widget-small')->setSpacing(.2,'em', .3,'em') |
170
|
|
|
); |
171
|
|
|
|
172
|
|
|
|
173
|
|
|
} else { |
174
|
|
|
|
175
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Position'), $entity['name'])); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
|
179
|
|
|
//TRANSLATORS: Main role in organizational chart entity |
180
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Role'), $entity['role_name'])); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
|
184
|
|
|
if (!$superior && !$entity) |
185
|
|
|
{ |
186
|
|
|
// no organizational chart, replace with directory fields |
187
|
|
|
|
188
|
|
|
if ($departmentnumber = $this->getDirField('departmentnumber')) |
189
|
|
|
{ |
190
|
|
|
$col2->addItem($departmentnumber); |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* |
199
|
|
|
*/ |
200
|
|
|
protected function addPersonnelInfos($col2) |
201
|
|
|
{ |
202
|
|
|
if ($approbation = $this->agent->getApprobation()) |
203
|
|
|
{ |
204
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Approbation'), $approbation['name'].sprintf(' (%s)', $approbation['type']))); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
$collection = $this->agent->getCollection(); |
208
|
|
|
if (isset($collection) && $collection->getRow()) |
209
|
|
|
{ |
210
|
|
|
$col2->addItem($this->titledLabel(absences_translate('Collection'), $collection->name)); |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
|
215
|
|
|
|
216
|
|
|
protected function getPhoto() |
217
|
|
|
{ |
218
|
|
|
if ($photo = $this->agent->getPhoto()) |
219
|
|
|
{ |
220
|
|
|
$W = bab_Widgets(); |
221
|
|
|
return $W->Image($photo, $this->agent->getName()); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
return null; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* |
229
|
|
|
* @param string $fieldname |
230
|
|
|
*/ |
231
|
|
|
protected function getDirField($fieldname) |
232
|
|
|
{ |
233
|
|
|
$direntry = $this->agent->getDirEntry(); |
234
|
|
|
|
235
|
|
|
if (!isset($direntry[$fieldname])) |
236
|
|
|
{ |
237
|
|
|
return null; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
if (empty($direntry[$fieldname]['value'])) |
241
|
|
|
{ |
242
|
|
|
return null; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
return $this->titledLabel( |
246
|
|
|
$direntry[$fieldname]['name'], |
247
|
|
|
$direntry[$fieldname]['value'] |
248
|
|
|
); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
|
252
|
|
|
protected function getNickname() |
253
|
|
|
{ |
254
|
|
|
return $this->titledLabel( |
255
|
|
|
absences_translate('Login ID'), |
256
|
|
|
bab_getUserNickname($this->agent->id_user) |
257
|
|
|
); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
|
261
|
|
|
|
262
|
|
|
protected function getDisabled() |
263
|
|
|
{ |
264
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/userinfosincl.php'; |
265
|
|
|
|
266
|
|
|
if (bab_userInfos::isValid($this->agent->getIdUser())) |
267
|
|
|
{ |
268
|
|
|
return null; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
272
|
|
|
$W = bab_Widgets(); |
273
|
|
|
return $W->Icon(absences_translate('This account is disabled'), Func_Icons::STATUS_DIALOG_WARNING); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* |
279
|
|
|
* |
280
|
|
|
*/ |
281
|
|
|
protected function getEmail() |
282
|
|
|
{ |
283
|
|
|
$W = bab_Widgets(); |
284
|
|
|
$direntry = $this->agent->getDirEntry(); |
285
|
|
|
|
286
|
|
|
if (!isset($direntry['email'])) |
287
|
|
|
{ |
288
|
|
|
return null; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
if (empty($direntry['email']['value'])) |
292
|
|
|
{ |
293
|
|
|
return null; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
return $W->FlowItems( |
297
|
|
|
$W->Label($direntry['email']['name'])->addClass('widget-strong')->colon(), |
298
|
|
|
$W->Link($direntry['email']['value'], 'mailto:'.$direntry['email']['value']) |
299
|
|
|
)->addClass('widget-small')->setSpacing(.2,'em', .3,'em'); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
|
303
|
|
|
|
304
|
|
|
|
305
|
|
|
|
306
|
|
|
|
307
|
|
|
protected function getDirEntry() |
308
|
|
|
{ |
309
|
|
|
$W = bab_Widgets(); |
310
|
|
|
$link = bab_getUserDirEntryLink($this->agent->id_user, BAB_DIR_ENTRY_ID_USER); |
|
|
|
|
311
|
|
|
|
312
|
|
|
if (!$link) |
313
|
|
|
{ |
314
|
|
|
return null; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
return $W->Link($W->Icon(absences_translate('View directory entry'), Func_Icons::OBJECTS_CONTACT), $link)->setOpenMode(Widget_Link::OPEN_POPUP); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
|
321
|
|
|
|
322
|
|
|
|
323
|
|
|
protected function getPlanning() |
324
|
|
|
{ |
325
|
|
|
$W = bab_Widgets(); |
326
|
|
|
|
327
|
|
|
$addon = bab_getAddonInfosInstance('absences'); |
328
|
|
|
|
329
|
|
|
return $W->Link($W->Icon(absences_translate('View planning'), Func_Icons::APPS_CALENDAR), $addon->getUrl().'planning&idx=cal&popup=1&idu='.$this->agent->id_user)->setOpenMode(Widget_Link::OPEN_POPUP); |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
|
333
|
|
|
|
334
|
|
|
protected function getWorkingHours() |
335
|
|
|
{ |
336
|
|
|
$W = bab_Widgets(); |
337
|
|
|
|
338
|
|
|
$func = bab_functionality::get('WorkingHours'); |
339
|
|
|
|
340
|
|
|
if (false === $func) |
341
|
|
|
{ |
342
|
|
|
return null; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
$url = $func->getUserSettingsPopupUrl($this->agent->getIdUser()); |
346
|
|
|
|
347
|
|
|
if (null === $url) |
348
|
|
|
{ |
349
|
|
|
return null; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
return $W->Link($W->Icon(absences_translate('Working hours'), Func_Icons::APPS_CALENDAR), $url)->setOpenMode(Widget_Link::OPEN_POPUP); |
353
|
|
|
} |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
|
357
|
|
|
|
358
|
|
|
class absences_AgentFullFrame extends absences_AgentCardFrame |
359
|
|
|
{ |
360
|
|
|
/** |
361
|
|
|
* |
362
|
|
|
*/ |
363
|
|
|
protected function addPersonnelInfos($col2) |
364
|
|
|
{ |
365
|
|
|
// do not display personnel info because exists in edit form |
366
|
|
|
// show link to directory entry instead |
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
|
370
|
|
|
protected function initClasses() |
371
|
|
|
{ |
372
|
|
|
$this->addClass('absences-agent-fullframe'); |
373
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_16); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
|
379
|
|
|
|
380
|
|
|
|
381
|
|
|
|
382
|
|
|
|
383
|
|
|
|
384
|
|
|
class absences_AgentMovementList extends absences_Paginate |
385
|
|
|
{ |
386
|
|
|
const MAX = 20; |
387
|
|
|
|
388
|
|
|
public $altbg = true; |
389
|
|
|
|
390
|
|
|
public $t_date; |
391
|
|
|
public $date; |
392
|
|
|
|
393
|
|
|
public $t_author; |
394
|
|
|
public $author; |
395
|
|
|
|
396
|
|
|
public $t_message; |
397
|
|
|
public $message; |
398
|
|
|
|
399
|
|
|
public $t_comment; |
400
|
|
|
public $comment; |
401
|
|
|
|
402
|
|
|
private $res; |
403
|
|
|
|
404
|
|
|
public function __construct(absences_Agent $agent) |
405
|
|
|
{ |
406
|
|
|
$this->t_date = absences_translate('Date'); |
407
|
|
|
$this->t_author = absences_translate('Author'); |
408
|
|
|
$this->t_request = absences_translate('Object'); |
|
|
|
|
409
|
|
|
$this->t_message = absences_translate('Message'); |
410
|
|
|
$this->t_comment = absences_translate('Regularization or approval comment by the author'); |
411
|
|
|
|
412
|
|
|
|
413
|
|
|
$this->res = $agent->getMovementIterator(); |
414
|
|
|
$this->res->rewind(); |
415
|
|
|
|
416
|
|
|
$this->paginate($this->res->count(), self::MAX); |
417
|
|
|
$this->res->seek($this->pos); |
418
|
|
|
|
419
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
420
|
|
|
} |
421
|
|
|
|
422
|
|
View Code Duplication |
public function getnext() |
|
|
|
|
423
|
|
|
{ |
424
|
|
|
if (($this->res->key() - $this->pos) >= self::MAX) |
425
|
|
|
{ |
426
|
|
|
return false; |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
if ($this->res->valid()) |
430
|
|
|
{ |
431
|
|
|
$W = bab_Widgets(); |
432
|
|
|
$movement = $this->res->current(); |
433
|
|
|
/*@var $movement absences_Movement */ |
434
|
|
|
|
435
|
|
|
$this->altbg = !$this->altbg; |
436
|
|
|
|
437
|
|
|
$this->author = bab_toHtml(bab_getUserName($movement->id_author)); |
438
|
|
|
$this->date = bab_toHtml(bab_shortDate(bab_mktime($movement->createdOn))); |
439
|
|
|
if ($request = $movement->getRequest()) |
440
|
|
|
{ |
441
|
|
|
$this->request = $request->getManagerFrame()->addClass(Func_Icons::ICON_LEFT_16)->display($W->HtmlCanvas()); |
|
|
|
|
442
|
|
|
} else { |
443
|
|
|
$this->request = ''; |
|
|
|
|
444
|
|
|
} |
445
|
|
|
$this->message = bab_toHtml($movement->message); |
446
|
|
|
$this->comment = bab_toHtml($movement->comment); |
447
|
|
|
|
448
|
|
|
$this->res->next(); |
449
|
|
|
return true; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
return false; |
453
|
|
|
} |
454
|
|
|
|
455
|
|
View Code Duplication |
public function getHtml() |
|
|
|
|
456
|
|
|
{ |
457
|
|
|
$babBody = bab_getInstance('babBody'); |
458
|
|
|
|
459
|
|
|
if ($this->res->count() === 0) |
460
|
|
|
{ |
461
|
|
|
$babBody->addError(absences_translate('There are no records yet for this user')); |
462
|
|
|
return ''; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
return bab_printTemplate($this, absences_addon()->getRelativePath()."agent.html", "movement"); |
|
|
|
|
466
|
|
|
} |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
|
470
|
|
|
|
471
|
|
|
|
472
|
|
|
|
473
|
|
|
|
474
|
|
|
|
475
|
|
|
|
476
|
|
|
|
477
|
|
|
|
478
|
|
|
|
479
|
|
|
|
480
|
|
|
class absences_AgentRightsList |
481
|
|
|
{ |
482
|
|
|
public $nametxt; |
483
|
|
|
public $urlname; |
484
|
|
|
public $url; |
485
|
|
|
public $descriptiontxt; |
486
|
|
|
public $description; |
487
|
|
|
public $consumedtxt; |
488
|
|
|
public $consumed; |
489
|
|
|
public $fullname; |
490
|
|
|
public $titletxt; |
491
|
|
|
|
492
|
|
|
public $arr = array(); |
493
|
|
|
public $babDB; |
494
|
|
|
private $res; |
495
|
|
|
|
496
|
|
|
public $iduser; |
497
|
|
|
public $idcoll; |
498
|
|
|
public $bview; |
499
|
|
|
|
500
|
|
|
public $updatetxt; |
501
|
|
|
public $invalidentry; |
502
|
|
|
public $invalidentry1; |
503
|
|
|
public $invalidentry2; |
504
|
|
|
|
505
|
|
|
public function __construct($id) |
506
|
|
|
{ |
507
|
|
|
global $babDB; |
508
|
|
|
$this->iduser = $id; |
509
|
|
|
$this->idu = $id; |
|
|
|
|
510
|
|
|
$this->ide = bab_rp('ide'); |
|
|
|
|
511
|
|
|
$this->updatetxt = absences_translate("Update"); |
512
|
|
|
$this->desctxt = absences_translate("Description"); |
|
|
|
|
513
|
|
|
$this->typetxt = absences_translate("Type"); |
|
|
|
|
514
|
|
|
$this->consumedtxt = absences_translate("Consumed"); |
515
|
|
|
$this->waitingtxt = absences_translate("Waiting"); |
|
|
|
|
516
|
|
|
$this->datebtxt = absences_translate("Begin date"); |
|
|
|
|
517
|
|
|
$this->dateetxt = absences_translate("End date"); |
|
|
|
|
518
|
|
|
$this->quantitytxt = absences_translate("Rights"); |
|
|
|
|
519
|
|
|
$this->balancetxt = absences_translate("Balance"); |
|
|
|
|
520
|
|
|
$this->previsionaltxt = absences_translate("Previsional"); |
|
|
|
|
521
|
|
|
$this->previsionalbalancetxt = absences_translate("Previ. Bal."); |
|
|
|
|
522
|
|
|
$this->datetxt = absences_translate("Entry date"); |
|
|
|
|
523
|
|
|
$this->invalidentry = bab_toHtml(absences_translate("Invalid entry! Only numbers are accepted or . !"), BAB_HTML_JS); |
524
|
|
|
$this->invalidentry1 = absences_translate("Invalid entry"); |
525
|
|
|
$this->invalidentry2 = absences_translate("Days must be multiple of 0.5"); |
526
|
|
|
$this->t_comment = absences_translate("Comment on quantities modification for user history:"); |
|
|
|
|
527
|
|
|
$GLOBALS['babBody']->title = absences_translate("Vacation rights of:").' '.bab_getUserName($id); |
528
|
|
|
|
529
|
|
|
$infos = bab_getUserInfos($id); |
530
|
|
|
$this->currentUserLastname = $infos['sn']; |
|
|
|
|
531
|
|
|
$this->currentUserFirstname = $infos['givenname']; |
|
|
|
|
532
|
|
|
|
533
|
|
|
$this->tg = bab_rp('tg'); |
|
|
|
|
534
|
|
|
|
535
|
|
|
require_once dirname(__FILE__).'/agent.class.php'; |
536
|
|
|
require_once dirname(__FILE__).'/agent.ui.php'; |
537
|
|
|
$agent = absences_Agent::getFromIdUser($id); |
538
|
|
|
$cardframe = new absences_AgentCardFrame($agent); |
539
|
|
|
$this->header = $cardframe->display(bab_Widgets()->HtmlCanvas()); |
|
|
|
|
540
|
|
|
|
541
|
|
|
$this->res = $agent->getAgentRightManagerIterator(); |
542
|
|
|
$this->res->rewind(); |
543
|
|
|
|
544
|
|
|
$collectionName = absences_translate('Unknown'); |
545
|
|
|
if ($collection = $agent->getCollection()) { |
546
|
|
|
if ($collection->getRow()) { |
547
|
|
|
$collectionName = $collection->name; |
548
|
|
|
} |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
$this->not_in_collection = sprintf(absences_translate('This right is not in collection %s'), $collectionName); |
|
|
|
|
552
|
|
|
|
553
|
|
|
$this->agentRight = (absences_Agent::getCurrentUser()->isManager() && !bab_rp('ide')); |
|
|
|
|
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
public function getnextright(&$ignore) |
|
|
|
|
557
|
|
|
{ |
558
|
|
|
static $y = ''; |
559
|
|
|
static $label = ''; |
560
|
|
|
|
561
|
|
|
if( $this->res->valid()) |
562
|
|
|
{ |
563
|
|
|
|
564
|
|
|
$agentRight = $this->res->current(); |
565
|
|
|
/*@var $agentRight absences_AgentRight */ |
566
|
|
|
$right = $agentRight->getRight(); |
567
|
|
|
|
568
|
|
|
$right->monthlyQuantityUpdate(); |
569
|
|
|
|
570
|
|
|
$type = $right->getType(); |
571
|
|
|
|
572
|
|
|
$this->res->next(); |
573
|
|
|
|
574
|
|
|
|
575
|
|
|
$this->idright = $right->id; |
|
|
|
|
576
|
|
|
$this->description = bab_toHtml($right->description); |
577
|
|
|
$this->type = bab_toHtml($type->name); |
|
|
|
|
578
|
|
|
$this->color = bab_toHtml($type->color); |
|
|
|
|
579
|
|
|
$this->quantity = absences_editQuantity($agentRight->getQuantity(), $right->quantity_unit); |
|
|
|
|
580
|
|
|
|
581
|
|
|
$this->unit = bab_toHtml($right->getUnitLabel()); |
|
|
|
|
582
|
|
|
|
583
|
|
|
$this->dynamic_quantity = null; |
|
|
|
|
584
|
|
|
$dyn = $agentRight->getDynamicQuantity(); |
585
|
|
View Code Duplication |
if (abs($dyn) > 0.01) { |
|
|
|
|
586
|
|
|
$this->dynamic_quantity = bab_toHtml( |
587
|
|
|
sprintf( |
588
|
|
|
absences_translate( |
589
|
|
|
'The quantity include %s because of the balance modification according to the consumed amount rule', |
590
|
|
|
'The quantity include %s because of the balance modification according to the consumed amount rule', |
591
|
|
|
$dyn |
592
|
|
|
), |
593
|
|
|
absences_quantity($dyn, $right->quantity_unit) |
594
|
|
|
) |
595
|
|
|
); |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
|
599
|
|
|
$this->increment_quantity = null; |
|
|
|
|
600
|
|
|
$dyn = $agentRight->getIncrementQuantity(); |
601
|
|
View Code Duplication |
if (abs($dyn) > 0.01) { |
|
|
|
|
602
|
|
|
$this->increment_quantity = bab_toHtml( |
603
|
|
|
sprintf( |
604
|
|
|
absences_translate( |
605
|
|
|
'The quantity include %s because of the monthly modifications', |
606
|
|
|
'The quantity include %s because of the monthly modifications', |
607
|
|
|
$dyn |
608
|
|
|
), |
609
|
|
|
absences_quantity($dyn, $right->quantity_unit) |
610
|
|
|
) |
611
|
|
|
); |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
$this->disp_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit); |
|
|
|
|
615
|
|
|
|
616
|
|
|
if ($message = $agentRight->getQuantityAlert()) |
617
|
|
|
{ |
618
|
|
|
$this->alert = bab_toHtml($message); |
|
|
|
|
619
|
|
|
} else { |
620
|
|
|
$this->alert = null; |
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
|
624
|
|
|
if ($right->getYear() !== $y) |
625
|
|
|
{ |
626
|
|
|
$this->year = null === $right->getYear() ? absences_translate('No theoretical period') : $right->getYear(); |
|
|
|
|
627
|
|
|
} else { |
628
|
|
|
$this->year = ''; |
629
|
|
|
} |
630
|
|
|
$y = $right->getYear(); |
631
|
|
|
|
632
|
|
|
$rgrouplabel = $right->getRgroupLabel(); |
633
|
|
|
$this->rgroup = $rgrouplabel !== $label && !empty($rgrouplabel) ? $rgrouplabel : ''; |
|
|
|
|
634
|
|
|
$label = $rgrouplabel; |
635
|
|
|
|
636
|
|
|
$this->in_rgroup = null !== $right->getRgroup(); |
|
|
|
|
637
|
|
|
|
638
|
|
|
$this->dateb = bab_shortDate(bab_mktime($right->date_begin), false); |
|
|
|
|
639
|
|
|
$this->datee = bab_shortDate(bab_mktime($right->date_end), false); |
|
|
|
|
640
|
|
|
|
641
|
|
|
$this->consumed = absences_quantity($agentRight->getConfirmedQuantity(), $right->quantity_unit); |
642
|
|
|
$this->waiting = absences_quantity($agentRight->getWaitingQuantity(), $right->quantity_unit); |
|
|
|
|
643
|
|
|
$this->previsional = absences_quantity($agentRight->getPrevisionalQuantity(), $right->quantity_unit); |
|
|
|
|
644
|
|
|
|
645
|
|
|
$balance = $agentRight->getQuantity()-$agentRight->getWaitingQuantity()-$agentRight->getConfirmedQuantity(); |
646
|
|
|
$this->balance = absences_quantity($balance, $right->quantity_unit); |
|
|
|
|
647
|
|
|
$this->previsional_balance = absences_quantity($balance - $agentRight->getPrevisionalQuantity(), $right->quantity_unit); |
|
|
|
|
648
|
|
|
|
649
|
|
|
$this->readonly = ($right->getKind() === absences_Right::FIXED); |
|
|
|
|
650
|
|
|
$this->agent_right_url = bab_toHtml(absences_addon()->getUrl().'vacadm&idx=agentright&ar='.$agentRight->id); |
|
|
|
|
651
|
|
|
$this->in_collection = $agentRight->isRightInAgentCollection(); |
|
|
|
|
652
|
|
|
|
653
|
|
|
return true; |
654
|
|
|
} |
655
|
|
|
else |
656
|
|
|
return false; |
657
|
|
|
|
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
|
661
|
|
|
|
662
|
|
|
|
663
|
|
|
|
664
|
|
|
/** |
665
|
|
|
* get previous or next user in manager list |
666
|
|
|
* @param string $sign |
667
|
|
|
* @param string $sqlOrderType |
668
|
|
|
* @return int|false |
669
|
|
|
*/ |
670
|
|
|
private function getUserInManagerList($sign, $sqlOrderType) { |
671
|
|
|
|
672
|
|
|
|
673
|
|
|
global $babDB; |
674
|
|
|
|
675
|
|
|
|
676
|
|
|
$ide = bab_rp('ide'); |
677
|
|
|
|
678
|
|
|
// delegation administration list |
679
|
|
|
if ($ide && absences_isAccessibleEntityAsSuperior($ide)) { |
680
|
|
|
|
681
|
|
|
|
682
|
|
|
$users = bab_OCGetCollaborators($ide); |
683
|
|
|
$superior = bab_OCGetSuperior($ide); |
684
|
|
|
|
685
|
|
|
if (((int)$superior['id_user']) !== (int)$GLOBALS['BAB_SESS_USERID'] && false === absences_isAccessibleEntityAsCoManager($ide)) { |
686
|
|
|
$users[] = $superior; |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
|
690
|
|
|
$ordering = array(); |
691
|
|
|
foreach($users as $key => $user) { |
692
|
|
|
$ordering[$key] = $user['lastname'].' '.$user['firstname']; |
693
|
|
|
} |
694
|
|
|
|
695
|
|
|
bab_sort::natcasesort($ordering); |
696
|
|
|
|
697
|
|
|
|
698
|
|
|
$previous = false; |
699
|
|
|
$next = false; |
700
|
|
|
|
701
|
|
|
$next_prev_index = array(); |
702
|
|
|
|
703
|
|
|
foreach($ordering as $key => $dummy) { |
704
|
|
|
|
705
|
|
|
if (false !== $previous) { |
706
|
|
|
$next_prev_index[$previous]['next'] = $users[$key]['id_user']; |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
$next_prev_index[$users[$key]['id_user']] = array( |
710
|
|
|
'previous' => $previous, |
711
|
|
|
'next' => $next |
712
|
|
|
); |
713
|
|
|
|
714
|
|
|
$previous = $users[$key]['id_user']; |
715
|
|
|
} |
716
|
|
|
|
717
|
|
|
reset($ordering); |
718
|
|
|
$firstuser = $users[key($ordering)]['id_user']; |
719
|
|
|
next($ordering); |
720
|
|
|
$seconduser = $users[key($ordering)]['id_user']; |
721
|
|
|
|
722
|
|
|
$next_prev_index[$firstuser]['next'] = $seconduser; |
723
|
|
|
|
724
|
|
|
|
725
|
|
|
|
726
|
|
|
switch($sign) { |
727
|
|
|
case '<': |
728
|
|
|
return $next_prev_index[$this->iduser]['previous']; |
729
|
|
|
|
730
|
|
|
case '>': |
731
|
|
|
return $next_prev_index[$this->iduser]['next']; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
|
735
|
|
|
return false; |
736
|
|
|
} |
737
|
|
|
|
738
|
|
|
|
739
|
|
|
|
740
|
|
|
|
741
|
|
|
|
742
|
|
|
|
743
|
|
|
// manager list |
744
|
|
|
|
745
|
|
|
$acclevel = absences_vacationsAccess(); |
746
|
|
|
if( true === $acclevel['manager']) |
747
|
|
|
{ |
748
|
|
|
|
749
|
|
|
$res = $babDB->db_query(' |
750
|
|
|
SELECT |
751
|
|
|
p.id_user |
752
|
|
|
FROM |
753
|
|
|
'.ABSENCES_PERSONNEL_TBL.' p, '.BAB_USERS_TBL.' u |
754
|
|
|
|
755
|
|
|
WHERE |
756
|
|
|
u.id = p.id_user |
757
|
|
|
AND (u.lastname '.$sign.' '.$babDB->quote($this->currentUserLastname).' |
758
|
|
|
OR (u.lastname = '.$babDB->quote($this->currentUserLastname).' |
759
|
|
|
AND u.firstname '.$sign.' '.$babDB->quote($this->currentUserFirstname).') |
760
|
|
|
) |
761
|
|
|
|
762
|
|
|
ORDER BY u.lastname '.$sqlOrderType.', u.firstname '.$sqlOrderType.' |
763
|
|
|
|
764
|
|
|
LIMIT 0,2 |
765
|
|
|
'); |
766
|
|
|
|
767
|
|
|
|
768
|
|
|
|
769
|
|
|
if ($arr = $babDB->db_fetch_assoc($res)) { |
770
|
|
|
return (int) $arr['id_user']; |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
|
776
|
|
|
|
777
|
|
|
|
778
|
|
|
|
779
|
|
|
return false; |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
|
783
|
|
|
|
784
|
|
|
|
785
|
|
View Code Duplication |
public function previoususer() { |
|
|
|
|
786
|
|
|
|
787
|
|
|
static $i = 0; |
788
|
|
|
|
789
|
|
|
if (0 === $i) { |
790
|
|
|
|
791
|
|
|
$id_user = $this->getUserInManagerList('<','DESC'); |
792
|
|
|
if (!$id_user) { |
|
|
|
|
793
|
|
|
return false; |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
$this->previous = bab_toHtml(bab_getUserName($id_user)); |
|
|
|
|
797
|
|
|
|
798
|
|
|
require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php'; |
799
|
|
|
$url = bab_url::request_gp(); |
800
|
|
|
|
801
|
|
|
if (bab_rp('idu')) { |
802
|
|
|
$url = bab_url::mod($url, 'idu', $id_user); |
803
|
|
|
} |
804
|
|
|
|
805
|
|
|
if (bab_rp('id_user')) { |
806
|
|
|
$url = bab_url::mod($url, 'id_user', $id_user); |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
$this->previousurl = bab_toHtml($url); |
|
|
|
|
810
|
|
|
|
811
|
|
|
|
812
|
|
|
$i++; |
813
|
|
|
return true; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
return false; |
817
|
|
|
} |
818
|
|
|
|
819
|
|
View Code Duplication |
public function nextuser() { |
|
|
|
|
820
|
|
|
|
821
|
|
|
static $i = 0; |
822
|
|
|
|
823
|
|
|
if (0 === $i) { |
824
|
|
|
|
825
|
|
|
$id_user = $this->getUserInManagerList('>','ASC'); |
826
|
|
|
if (!$id_user) { |
|
|
|
|
827
|
|
|
return false; |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
$this->next = bab_toHtml(bab_getUserName($id_user)); |
|
|
|
|
831
|
|
|
|
832
|
|
|
require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php'; |
833
|
|
|
$url = bab_url::request_gp(); |
834
|
|
|
if (bab_rp('idu')) { |
835
|
|
|
$url = bab_url::mod($url, 'idu', $id_user); |
836
|
|
|
} |
837
|
|
|
|
838
|
|
|
if (bab_rp('id_user')) { |
839
|
|
|
$url = bab_url::mod($url, 'id_user', $id_user); |
840
|
|
|
} |
841
|
|
|
$this->nexturl = bab_toHtml($url); |
|
|
|
|
842
|
|
|
|
843
|
|
|
|
844
|
|
|
$i++; |
845
|
|
|
return true; |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
return false; |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
} |
852
|
|
|
|
853
|
|
|
|
854
|
|
|
|
855
|
|
|
|
856
|
|
|
|
857
|
|
|
|
858
|
|
|
|
859
|
|
|
|
860
|
|
|
|
861
|
|
|
|
862
|
|
|
class absences_PersonalOptionsEditor extends Widget_Form |
863
|
|
|
{ |
864
|
|
|
|
865
|
|
|
public function __construct() |
866
|
|
|
{ |
867
|
|
|
$W = bab_Widgets(); |
868
|
|
|
|
869
|
|
|
parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em')); |
870
|
|
|
|
871
|
|
|
|
872
|
|
|
$this->setName('options'); |
873
|
|
|
$this->addClass('widget-bordered'); |
874
|
|
|
$this->addClass('BabLoginMenuBackground'); |
875
|
|
|
$this->addClass('widget-centered'); |
876
|
|
|
$this->colon(); |
877
|
|
|
|
878
|
|
|
$this->setCanvasOptions($this->Options()->width(70,'em')); |
|
|
|
|
879
|
|
|
|
880
|
|
|
$this->addFields(); |
881
|
|
|
$this->loadFormValues(); |
882
|
|
|
|
883
|
|
|
$this->addButtons(); |
884
|
|
|
$this->setSelfPageHiddenFields(); |
885
|
|
|
} |
886
|
|
|
|
887
|
|
|
|
888
|
|
|
|
889
|
|
View Code Duplication |
protected function addFields() |
|
|
|
|
890
|
|
|
{ |
891
|
|
|
$W = bab_Widgets(); |
892
|
|
|
|
893
|
|
|
|
894
|
|
|
$this->addItem($W->LabelledWidget( |
895
|
|
|
absences_translate('Email to notify when a vacation request is accepted (other than me)'), |
896
|
|
|
$W->TextEdit()->setColumns(80)->setLines(2), |
897
|
|
|
'emails', |
898
|
|
|
absences_translate('Comma separated values') |
899
|
|
|
)); |
900
|
|
|
|
901
|
|
|
|
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
|
905
|
|
|
|
906
|
|
|
|
907
|
|
|
|
908
|
|
|
protected function loadFormValues() |
909
|
|
|
{ |
910
|
|
|
global $babDB; |
911
|
|
|
|
912
|
|
|
|
913
|
|
|
$values = array(); |
914
|
|
|
$agent = absences_Agent::getCurrentUser(); |
915
|
|
|
|
916
|
|
|
$values['emails'] = $agent->emails; |
917
|
|
|
|
918
|
|
|
$this->setValues($values, array('options')); |
919
|
|
|
} |
920
|
|
|
|
921
|
|
|
|
922
|
|
View Code Duplication |
protected function addButtons() |
|
|
|
|
923
|
|
|
{ |
924
|
|
|
$W = bab_Widgets(); |
925
|
|
|
|
926
|
|
|
$button = $W->FlowItems( |
927
|
|
|
$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save')) |
928
|
|
|
)->setSpacing(1,'em'); |
929
|
|
|
|
930
|
|
|
$this->addItem($button); |
931
|
|
|
} |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
|
935
|
|
|
|
936
|
|
|
|
937
|
|
|
|
938
|
|
|
|
939
|
|
|
|
940
|
|
|
|
941
|
|
|
|
942
|
|
|
|
943
|
|
|
|
944
|
|
|
|
945
|
|
|
|
946
|
|
|
|
947
|
|
|
|
948
|
|
|
|
949
|
|
|
|
950
|
|
|
|
951
|
|
|
|
952
|
|
|
|
953
|
|
|
class absences_AgentEdit |
954
|
|
|
{ |
955
|
|
|
public $usertext; |
956
|
|
|
public $grouptext; |
957
|
|
|
public $userval; |
958
|
|
|
public $userid; |
959
|
|
|
public $groupval; |
960
|
|
|
public $groupid; |
961
|
|
|
public $collection; |
962
|
|
|
public $idcollection; |
963
|
|
|
public $collname; |
964
|
|
|
public $appschema; |
965
|
|
|
public $idsapp; |
966
|
|
|
public $saname; |
967
|
|
|
public $selected; |
968
|
|
|
public $add; |
969
|
|
|
public $bdel; |
970
|
|
|
public $delete; |
971
|
|
|
public $groupsbrowurl; |
972
|
|
|
public $usersbrowurl; |
973
|
|
|
|
974
|
|
|
public $orand; |
975
|
|
|
public $reset; |
976
|
|
|
|
977
|
|
|
|
978
|
|
|
/** |
979
|
|
|
* @var bool |
980
|
|
|
*/ |
981
|
|
|
public $changeorganization = true; |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* @var int |
985
|
|
|
*/ |
986
|
|
|
private $id_organization; |
987
|
|
|
|
988
|
|
|
/** |
989
|
|
|
* @var absences_OrganizationIterator |
990
|
|
|
*/ |
991
|
|
|
private $organizations; |
992
|
|
|
|
993
|
|
|
|
994
|
|
|
/** |
995
|
|
|
* @var array |
996
|
|
|
*/ |
997
|
|
|
private $wsprofiles; |
998
|
|
|
|
999
|
|
|
/** |
1000
|
|
|
* @var ORM_Iterator |
1001
|
|
|
*/ |
1002
|
|
|
private $profiles; |
1003
|
|
|
|
1004
|
|
|
|
1005
|
|
|
/** |
1006
|
|
|
* @var int |
1007
|
|
|
*/ |
1008
|
|
|
private $loop_selectedProfile = 0; |
1009
|
|
|
|
1010
|
|
|
|
1011
|
|
|
public $canuseprofiles = false; |
1012
|
|
|
|
1013
|
|
|
|
1014
|
|
|
public function __construct($idp) |
1015
|
|
|
{ |
1016
|
|
|
require_once dirname(__FILE__).'/organization.class.php'; |
1017
|
|
|
|
1018
|
|
|
$this->usertext = absences_translate("User"); |
1019
|
|
|
$this->collection = absences_translate("Collection:"); |
1020
|
|
|
$this->appschema = absences_translate("Approbation schema for vacation requests:"); |
1021
|
|
|
$this->t_id_sa_cet = absences_translate("Approbation schema for deposit into the time savings account:"); |
|
|
|
|
1022
|
|
|
$this->t_id_sa_recover = absences_translate("Approbation schema for declaration of worked days entitling recovery:"); |
|
|
|
|
1023
|
|
|
$this->t_use_vr = absences_translate("Use schema for vacation requests"); |
|
|
|
|
1024
|
|
|
$this->t_list_request = absences_translate("List absence requests"); |
|
|
|
|
1025
|
|
|
$this->t_create_request = absences_translate("Create a vacation request"); |
|
|
|
|
1026
|
|
|
$this->t_emails = absences_translate('Email to notify when a vacation request is accepted, comma separated'); |
|
|
|
|
1027
|
|
|
$this->t_organization = absences_translate('Organization:'); |
|
|
|
|
1028
|
|
|
$this->t_workschedule = absences_translate('Work schedule profile'); |
|
|
|
|
1029
|
|
|
$this->t_from = absences_translate('From'); |
|
|
|
|
1030
|
|
|
$this->t_to = absences_translate('To'); |
|
|
|
|
1031
|
|
|
|
1032
|
|
|
$this->listrequesturl = bab_toHtml(absences_addon()->getUrl()."vacadmb&idx=lreq&userid=".urlencode($idp)); |
|
|
|
|
1033
|
|
|
$this->createrequesturl = bab_toHtml(absences_addon()->getUrl()."vacuser&idx=period&rfrom=1&id_user=".urlencode($idp)); |
|
|
|
|
1034
|
|
|
|
1035
|
|
|
$this->delete = absences_translate("Delete"); |
1036
|
|
|
$this->usersbrowurl = absences_addon()->getUrl()."vacadm&idx=browu&cb="; |
1037
|
|
|
$this->tg = bab_rp('tg'); |
|
|
|
|
1038
|
|
|
$this->ide = isset($_REQUEST['ide']) ? $_REQUEST['ide'] : false; |
|
|
|
|
1039
|
|
|
|
1040
|
|
|
global $babDB; |
1041
|
|
|
$W = bab_Widgets(); |
1042
|
|
|
$this->idp = $idp; |
|
|
|
|
1043
|
|
|
|
1044
|
|
|
$userpicker = $W->UserPicker()->setName('userid'); |
1045
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
1046
|
|
|
$this->userpicker = $W->Frame()->addClass(Func_Icons::ICON_LEFT_16)->addItem($userpicker)->display($W->HtmlCanvas()); |
|
|
|
|
1047
|
|
|
|
1048
|
|
|
|
1049
|
|
|
list($n) = $babDB->db_fetch_array($babDB->db_query("SELECT COUNT(*) FROM ".ABSENCES_ENTRIES_TBL." WHERE id_user='".$babDB->db_escape_string($this->idp)."' AND status=''")); |
1050
|
|
|
|
1051
|
|
|
if ($n > 0) { |
1052
|
|
|
$waiting = absences_translate( |
1053
|
|
|
'Modification are disabled, the user have %d waiting request' , |
1054
|
|
|
'Modification are disabled, the user have %d waiting requests', |
1055
|
|
|
$n); |
1056
|
|
|
$this->waiting = sprintf($waiting, $n); |
|
|
|
|
1057
|
|
|
} |
1058
|
|
|
|
1059
|
|
|
if (isset($_POST['action']) && $_POST['action'] == 'changeuser') |
1060
|
|
|
{ |
1061
|
|
|
$this->userid = $_POST['userid']; |
1062
|
|
|
$this->idsa = $_POST['idsa']; |
|
|
|
|
1063
|
|
|
$this->id_sa_cet = $_POST['id_sa_cet']; |
|
|
|
|
1064
|
|
|
$this->id_sa_recover = $_POST['id_sa_recover']; |
|
|
|
|
1065
|
|
|
$this->idcol = $_POST['idcol']; |
|
|
|
|
1066
|
|
|
$this->idp = $_POST['idp']; |
1067
|
|
|
$this->id_organization = bab_pp('id_organization'); |
1068
|
|
|
} |
1069
|
|
|
|
1070
|
|
|
if( !empty($this->idp)) |
1071
|
|
|
{ |
1072
|
|
|
require_once dirname(__FILE__).'/agent.class.php'; |
1073
|
|
|
require_once dirname(__FILE__).'/agent.ui.php'; |
1074
|
|
|
$this->add = absences_translate("Modify"); |
1075
|
|
|
$agent = absences_Agent::getFromIdUser($this->idp); |
1076
|
|
|
|
1077
|
|
|
if (!$agent->exists()) |
1078
|
|
|
{ |
1079
|
|
|
// T7680 apres suppression d'une fiche d'annuaire |
1080
|
|
|
$url = bab_url::get_request('tg'); |
1081
|
|
|
$url->idx = 'lper'; |
1082
|
|
|
$url->location(); |
1083
|
|
|
} |
1084
|
|
|
|
1085
|
|
|
$this->userid = $agent->getIdUser(); |
1086
|
|
|
|
1087
|
|
|
|
1088
|
|
|
$frame = new absences_AgentFullFrame($agent); |
1089
|
|
|
|
1090
|
|
|
$this->userval = $frame->display($W->HtmlCanvas()); |
1091
|
|
|
$this->idcol = $agent->id_coll; |
1092
|
|
|
$this->idsa = $agent->id_sa; |
1093
|
|
|
$this->id_sa_cet = $agent->id_sa_cet; |
|
|
|
|
1094
|
|
|
$this->id_sa_recover = $agent->id_sa_recover; |
|
|
|
|
1095
|
|
|
$this->emails = bab_toHtml($agent->emails); |
|
|
|
|
1096
|
|
|
$this->id_organization = $agent->id_organization; |
1097
|
|
|
} |
1098
|
|
|
else |
1099
|
|
|
{ |
1100
|
|
|
$this->add = absences_translate("Add"); |
1101
|
|
|
$this->idcol = ''; |
1102
|
|
|
$this->idsa = ''; |
1103
|
|
|
$this->id_sa_cet = ''; |
|
|
|
|
1104
|
|
|
$this->id_sa_recover = ''; |
|
|
|
|
1105
|
|
|
$this->userval = ''; |
1106
|
|
|
$this->userid = ''; |
1107
|
|
|
$this->emails = ''; |
|
|
|
|
1108
|
|
|
$this->id_organization = 0; |
1109
|
|
|
} |
1110
|
|
|
|
1111
|
|
|
$this->groupval = ""; |
1112
|
|
|
$this->groupid = ""; |
1113
|
|
|
|
1114
|
|
|
$this->sares = bab_WFGetApprobationsList(); |
|
|
|
|
1115
|
|
|
|
1116
|
|
|
|
1117
|
|
|
$this->colres = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc"); |
|
|
|
|
1118
|
|
|
$this->countcol = $babDB->db_num_rows($this->colres); |
|
|
|
|
1119
|
|
|
|
1120
|
|
|
$this->organizations = new absences_OrganizationIterator(); |
1121
|
|
|
$this->organizations->rewind(); |
1122
|
|
|
|
1123
|
|
|
$this->changeorganization = !(bool) absences_getVacationOption('organization_sync'); |
1124
|
|
|
|
1125
|
|
|
$defaultWh = bab_functionality::get('WorkingHours'); |
1126
|
|
|
|
1127
|
|
|
if ($workschedules = bab_functionality::get('WorkingHours/Workschedules')) { |
1128
|
|
|
/*@var $workschedules Func_WorkingHours_Workschedules */ |
1129
|
|
|
$this->wsprofiles = $workschedules->getProfiles($this->idp); |
1130
|
|
|
|
1131
|
|
|
if (count($this->wsprofiles) > 0 && $workschedules instanceof $defaultWh) { |
1132
|
|
|
$this->canuseprofiles = true; |
1133
|
|
|
} |
1134
|
|
|
|
1135
|
|
|
|
1136
|
|
|
$this->profiles = $workschedules->getUserProfiles($this->idp); |
1137
|
|
|
$this->profiles->rewind(); |
1138
|
|
|
} |
1139
|
|
|
} |
1140
|
|
|
|
1141
|
|
|
|
1142
|
|
|
public function getnextorganization() |
1143
|
|
|
{ |
1144
|
|
|
if ($this->organizations->valid()) { |
1145
|
|
|
$organization = $this->organizations->current(); |
1146
|
|
|
$this->organizations->next(); |
1147
|
|
|
|
1148
|
|
|
$this->value = bab_toHtml($organization->id); |
|
|
|
|
1149
|
|
|
$this->name = bab_toHtml($organization->name); |
|
|
|
|
1150
|
|
|
$this->selected = ($this->id_organization == $organization->id); |
1151
|
|
|
|
1152
|
|
|
return true; |
1153
|
|
|
} |
1154
|
|
|
} |
1155
|
|
|
|
1156
|
|
|
public function getnextsa() |
1157
|
|
|
{ |
1158
|
|
|
|
1159
|
|
|
if( list(,$arr) = each($this->sares) ) |
1160
|
|
|
{ |
1161
|
|
|
$this->saname = $arr['name']; |
1162
|
|
|
$this->idsapp = $arr['id']; |
1163
|
|
|
$this->selected = ( $this->idsa == $this->idsapp ) ? "selected" : ''; |
1164
|
|
|
$this->selected_cet = ( $this->id_sa_cet == $this->idsapp ) ? "selected" : ''; |
|
|
|
|
1165
|
|
|
$this->selected_recover = ( $this->id_sa_recover == $this->idsapp ) ? "selected" : ''; |
|
|
|
|
1166
|
|
|
|
1167
|
|
|
return true; |
1168
|
|
|
} |
1169
|
|
|
reset($this->sares); |
1170
|
|
|
return false; |
1171
|
|
|
|
1172
|
|
|
} |
1173
|
|
|
|
1174
|
|
View Code Duplication |
public function getnextcol() |
|
|
|
|
1175
|
|
|
{ |
1176
|
|
|
static $j= 0; |
1177
|
|
|
if( $j < $this->countcol ) |
1178
|
|
|
{ |
1179
|
|
|
global $babDB; |
1180
|
|
|
$arr = $babDB->db_fetch_array($this->colres); |
1181
|
|
|
$this->collname = $arr['name']; |
1182
|
|
|
$this->idcollection = $arr['id']; |
1183
|
|
|
if( $this->idcol == $this->idcollection ) |
1184
|
|
|
$this->selected = "selected"; |
1185
|
|
|
else |
1186
|
|
|
$this->selected = ""; |
1187
|
|
|
$j++; |
1188
|
|
|
return true; |
1189
|
|
|
} |
1190
|
|
|
else |
1191
|
|
|
return false; |
1192
|
|
|
} |
1193
|
|
|
|
1194
|
|
|
|
1195
|
|
|
public function getnextwsprofile() |
1196
|
|
|
{ |
1197
|
|
|
if (list($id, $name) = each($this->wsprofiles)) { |
1198
|
|
|
$this->id = bab_toHtml($id); |
|
|
|
|
1199
|
|
|
$this->name = bab_toHtml($name); |
1200
|
|
|
$this->selected = ($this->loop_selectedProfile === $id); |
1201
|
|
|
|
1202
|
|
|
return true; |
1203
|
|
|
} |
1204
|
|
|
|
1205
|
|
|
reset($this->wsprofiles); |
1206
|
|
|
return false; |
1207
|
|
|
} |
1208
|
|
|
|
1209
|
|
|
|
1210
|
|
|
public function getnextprofile() |
1211
|
|
|
{ |
1212
|
|
|
static $firstRow = null; |
1213
|
|
|
|
1214
|
|
|
if (!isset($firstRow) && 0 === $this->profiles->count()) { |
1215
|
|
|
$firstRow = true; |
1216
|
|
|
$this->profileRow(); |
1217
|
|
|
return true; |
1218
|
|
|
} |
1219
|
|
|
|
1220
|
|
|
|
1221
|
|
|
if ($this->profiles->valid()) { |
1222
|
|
|
$userProfile = $this->profiles->current(); |
1223
|
|
|
$this->profileRow($userProfile); |
1224
|
|
|
|
1225
|
|
|
|
1226
|
|
|
$this->profiles->next(); |
1227
|
|
|
return true; |
1228
|
|
|
} |
1229
|
|
|
|
1230
|
|
|
return false; |
1231
|
|
|
} |
1232
|
|
|
|
1233
|
|
|
|
1234
|
|
|
private function profileRow(workschedules_UserProfile $userProfile = null) |
1235
|
|
|
{ |
1236
|
|
|
$W = bab_Widgets(); |
1237
|
|
|
$canvas = $W->HtmlCanvas(); |
1238
|
|
|
|
1239
|
|
|
$this->userProfileId = '0'; |
|
|
|
|
1240
|
|
|
|
1241
|
|
|
$from = $W->DatePicker()->setName(array('profiles', 'from', '')); |
1242
|
|
|
$to = $W->DatePicker()->setName(array('profiles', 'to', '')); |
1243
|
|
|
|
1244
|
|
|
if (isset($userProfile)) { |
1245
|
|
|
$this->userProfileId = $userProfile->id; |
1246
|
|
|
$this->loop_selectedProfile = (int) $userProfile->profile->id; |
1247
|
|
|
|
1248
|
|
|
$from->setValue($userProfile->from); |
1249
|
|
|
$to->setValue($userProfile->to); |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
$this->datepicker_from = $from->display($canvas); |
|
|
|
|
1253
|
|
|
$this->datepicker_to = $to->display($canvas); |
|
|
|
|
1254
|
|
|
|
1255
|
|
|
$this->userProfileId = isset($userProfile) ? $userProfile->id : '0'; |
1256
|
|
|
} |
1257
|
|
|
|
1258
|
|
|
|
1259
|
|
|
public function printhtml() |
1260
|
|
|
{ |
1261
|
|
|
$babBody = bab_getBody(); |
1262
|
|
|
|
1263
|
|
|
$babBody->addJavascriptFile(absences_addon()->getTemplatePath().'workschedules.js', true); |
1264
|
|
|
|
1265
|
|
|
$babBody->addStyleSheet(absences_addon()->getStylePath().'vacation.css'); |
1266
|
|
|
$babBody->babecho(bab_printTemplate($this, absences_addon()->getRelativePath()."vacadm.html", "personnelcreate")); |
|
|
|
|
1267
|
|
|
} |
1268
|
|
|
} |
1269
|
|
|
|
1270
|
|
|
|
1271
|
|
|
|
1272
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.