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__).'/right.ui.php'; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
bab_Widgets()->includePhpClass('Widget_Form'); |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
|
32
|
|
|
class absences_AgentRightEditor extends absences_RightBaseEditor |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* |
36
|
|
|
* @var absences_AgentRight |
37
|
|
|
*/ |
38
|
|
|
protected $agentRight; |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var Widget_RadioSet |
43
|
|
|
*/ |
44
|
|
|
protected $quantity_type; |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public function __construct(absences_AgentRight $agentright) |
48
|
|
|
{ |
49
|
|
|
$W = bab_Widgets(); |
50
|
|
|
|
51
|
|
|
parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em')); |
52
|
|
|
|
53
|
|
|
$this->agentRight = $agentright; |
54
|
|
|
|
55
|
|
|
bab_functionality::includefile('Icons'); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$this->setName('agent_right'); |
58
|
|
|
$this->addClass('widget-bordered'); |
59
|
|
|
$this->addClass('BabLoginMenuBackground'); |
60
|
|
|
$this->addClass('widget-centered'); |
61
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_24); |
62
|
|
|
$this->colon(); |
63
|
|
|
|
64
|
|
|
$this->setCanvasOptions($this->Options()->width(70,'em')); |
|
|
|
|
65
|
|
|
|
66
|
|
|
$this->addFields(); |
67
|
|
|
$this->loadFormValues(); |
68
|
|
|
|
69
|
|
|
$this->addButtons(); |
70
|
|
|
$this->setSelfPageHiddenFields(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
protected function addFields() |
75
|
|
|
{ |
76
|
|
|
$this |
77
|
|
|
->addItem($this->quantity_type()) |
78
|
|
|
->addItem($this->quantity()) |
79
|
|
|
->addItem($this->availability_rules()) |
80
|
|
|
->addItem($this->renewal()) |
81
|
|
|
; |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
|
85
|
|
|
$right = $this->agentRight->getRight(); |
86
|
|
|
$rightCet = $right->getRightCet(); |
87
|
|
|
if ($rightCet->getRow()) |
88
|
|
|
{ |
89
|
|
|
$this->addItem($this->saving()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$this->addItem($this->movement_comment()); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* |
98
|
|
|
*/ |
99
|
|
View Code Duplication |
protected function movement_comment() |
|
|
|
|
100
|
|
|
{ |
101
|
|
|
$W = bab_Widgets(); |
102
|
|
|
|
103
|
|
|
return $W->LabelledWidget( |
104
|
|
|
absences_translate('Comment on modification for history'), |
105
|
|
|
$W->TextEdit()->setLines(2)->setMandatory(true, absences_translate('The comment is mandatory'))->addClass('widget-fullwidth'), |
106
|
|
|
__FUNCTION__ |
107
|
|
|
); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
|
112
|
|
|
|
113
|
|
|
protected function loadFormValues() |
114
|
|
|
{ |
115
|
|
|
|
116
|
|
|
$this->setHiddenValue('agent_right[id]', $this->agentRight->id); |
117
|
|
|
|
118
|
|
|
if (isset($_POST['agent_right'])) |
119
|
|
|
{ |
120
|
|
|
$values = $_POST['agent_right']; |
121
|
|
|
} else if (isset($this->agentRight)) |
122
|
|
|
{ |
123
|
|
|
$values = $this->agentRight->getRow(); |
124
|
|
|
$right = $this->agentRight->getRight(); |
125
|
|
|
$values['quantity'] = absences_editQuantity($this->agentRight->getQuantity(), $right->quantity_unit); |
126
|
|
|
|
127
|
|
|
$values['quantity_type'] = 'right'; |
128
|
|
|
|
129
|
|
|
if ('' !== (string) $this->agentRight->quantity) { |
130
|
|
|
$values['quantity_type'] = 'agent'; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
|
134
|
|
|
} else { |
135
|
|
|
return; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
$this->setValues(array('agent_right' => $values)); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
|
143
|
|
View Code Duplication |
protected function addButtons() |
|
|
|
|
144
|
|
|
{ |
145
|
|
|
$W = bab_Widgets(); |
146
|
|
|
|
147
|
|
|
$button = $W->FlowItems( |
148
|
|
|
$W->SubmitButton()->setName('cancel')->setLabel(absences_translate('Cancel')), |
149
|
|
|
$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save')) |
150
|
|
|
)->setSpacing(1,'em'); |
151
|
|
|
|
152
|
|
|
$this->addItem($button); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Criteres de disponibilite d'un droit |
158
|
|
|
*/ |
159
|
|
|
protected function availability_rules() |
160
|
|
|
{ |
161
|
|
|
$W = bab_Widgets(); |
162
|
|
|
|
163
|
|
|
|
164
|
|
|
|
165
|
|
|
$input_date = $this->by_request_input_date(); |
166
|
|
|
|
167
|
|
|
$accordions = $W->Accordions() |
168
|
|
|
->addPanel(absences_translate('Availability depends on the date of the vacation request input'), $input_date) |
169
|
|
|
->addPanel(absences_translate('Availability depends on the requested period dates'), $this->by_requested_period()) |
170
|
|
|
; |
171
|
|
|
|
172
|
|
|
// $accordions->setOpenPanel($input_date->getId()); |
173
|
|
|
|
174
|
|
|
return $accordions; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Availability depends on the requested period dates |
181
|
|
|
*/ |
182
|
|
|
protected function by_requested_period() |
183
|
|
|
{ |
184
|
|
|
$W = bab_Widgets(); |
185
|
|
|
$period = $W->PeriodPicker()->setNames('inperiod_start', 'inperiod_end'); |
186
|
|
|
|
187
|
|
|
$validoverlap = $W->LabelledWidget( |
188
|
|
|
absences_translate('Allow overlap between the request period and the test periods'), |
189
|
|
|
$W->CheckBox(), |
190
|
|
|
'validoverlap' |
191
|
|
|
); |
192
|
|
|
|
193
|
|
|
return $W->VBoxItems( |
194
|
|
|
$W->Label(absences_translate('The right is available if the vacation request is in the period')), |
195
|
|
|
$period, |
196
|
|
|
$validoverlap |
197
|
|
|
)->setVerticalSpacing(1,'em'); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
|
201
|
|
|
|
202
|
|
|
protected function getSign($value) |
203
|
|
|
{ |
204
|
|
|
if ($value >= 0) { |
205
|
|
|
return '+'; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
return '-'; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
|
212
|
|
|
protected function quantity_type() |
213
|
|
|
{ |
214
|
|
|
$W = bab_Widgets(); |
215
|
|
|
|
216
|
|
|
$right = $this->agentRight->getRight(); |
217
|
|
|
$q = absences_quantity($right->quantity, $right->quantity_unit); |
218
|
|
|
$nb = 1; |
219
|
|
|
|
220
|
|
View Code Duplication |
if ($increment = $right->getIncrementQuantity()) { |
|
|
|
|
221
|
|
|
if (0 !== (int) round(100 * $increment)) { |
222
|
|
|
$q .= sprintf(absences_translate(' %s %s by monthly update'), $this->getSign($increment), absences_quantity(abs($increment), $right->quantity_unit)); |
223
|
|
|
$nb++; |
224
|
|
|
} |
225
|
|
|
} |
226
|
|
|
|
227
|
|
View Code Duplication |
if ($dynamic = $this->agentRight->getDynamicQuantity()) { |
|
|
|
|
228
|
|
|
if (0 !== (int) round(100 * $dynamic)) { |
229
|
|
|
$q .= sprintf(absences_translate(' %s %s by consumption'), $this->getSign($increment), absences_quantity(abs($dynamic), $right->quantity_unit)); |
230
|
|
|
$nb++; |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
if ($nb > 1) { |
235
|
|
|
$q .= ' = '.absences_quantity($this->agentRight->getRightQuantity(), $right->quantity_unit); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
|
239
|
|
|
$this->quantity_type = $W->RadioSet() |
240
|
|
|
->setName('quantity_type') |
241
|
|
|
->addOption('right', sprintf(absences_translate('Use the quantity provided by the right (%s)'), $q)) |
242
|
|
|
->addOption('agent', absences_translate('Use a specific value')); |
243
|
|
|
|
244
|
|
|
return $this->quantity_type; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
|
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* quantity |
251
|
|
|
* quantite initiale + les ajustement dynamiques du droits (variables par mois + droits dynamiques) |
252
|
|
|
* |
253
|
|
|
* @return Widget_FlowLayout |
254
|
|
|
*/ |
255
|
|
|
protected function quantity() |
256
|
|
|
{ |
257
|
|
|
$W = bab_Widgets(); |
258
|
|
|
|
259
|
|
|
$lineedit = $W->LineEdit()->setSize(4)->setMaxSize(5)->setName('quantity'); |
260
|
|
|
|
261
|
|
|
|
262
|
|
|
$right = $this->agentRight->getRight(); |
263
|
|
|
$q = array(); |
264
|
|
|
|
265
|
|
|
$increment = $this->agentRight->getAgentIncrementQuantity(); |
266
|
|
|
if ($increment || $right->getIncrementQuantity()) { |
267
|
|
|
$q[] = sprintf(absences_translate('%s by monthly update'), absences_quantity($increment, $right->quantity_unit)); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
if ($dynamic = $this->agentRight->getDynamicQuantity()) { |
271
|
|
|
if (0 !== (int) round(100 * $dynamic)) { |
272
|
|
|
$q[] = sprintf(absences_translate('%s by consumption'), absences_quantity($dynamic, $right->quantity_unit)); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
$description = null; |
277
|
|
|
if ($q) { |
|
|
|
|
278
|
|
|
$description = sprintf(absences_translate('The input quantity include %s'), implode(', ', $q)); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
|
282
|
|
|
$quantity = $W->LabelledWidget( |
283
|
|
|
absences_translate('Quantity available for the user'), |
284
|
|
|
$lineedit, |
285
|
|
|
'quantity', |
286
|
|
|
$description, |
287
|
|
|
$this->agentRight->getRight()->getUnitLabel() |
288
|
|
|
); |
289
|
|
|
|
290
|
|
|
|
291
|
|
|
$this->quantity_type->setAssociatedDisplayable($quantity, array('agent')); |
292
|
|
|
|
293
|
|
|
return $quantity; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
|
297
|
|
|
|
298
|
|
|
protected function renewal() |
299
|
|
|
{ |
300
|
|
|
$W = bab_Widgets(); |
301
|
|
|
|
302
|
|
|
return $W->LabelledWidget(absences_translate('Include this right in the next yearly renewal'), $W->CheckBox(), __FUNCTION__); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
|
308
|
|
|
|
309
|
|
|
|
310
|
|
|
|
311
|
|
|
class absences_QuantityModificationCardFrame extends absences_CardFrame |
312
|
|
|
{ |
313
|
|
|
protected function createTable() |
314
|
|
|
{ |
315
|
|
|
$W = bab_Widgets(); |
316
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
317
|
|
|
|
318
|
|
|
$table = $W->BabTableView(); |
319
|
|
|
$table->addClass('absences-quantity-modification-table'); |
320
|
|
|
$table->addClass(Func_Icons::ICON_LEFT_16); |
321
|
|
|
|
322
|
|
|
$table->addColumnClass(0, 'date'); |
323
|
|
|
|
324
|
|
|
return $table; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
|
328
|
|
|
protected function quantityLabel($quantity, $unit) |
329
|
|
|
{ |
330
|
|
|
$W = bab_Widgets(); |
331
|
|
|
|
332
|
|
|
$sign = '+'; |
333
|
|
|
if ($quantity < 0) { |
334
|
|
|
$sign = '-'; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
return $W->Label($sign.absences_quantity(abs($quantity), $unit)); |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
|
342
|
|
|
|
343
|
|
|
|
344
|
|
|
|
345
|
|
|
|
346
|
|
|
|
347
|
|
|
|
348
|
|
|
class absences_IncrementCardFrame extends absences_QuantityModificationCardFrame |
349
|
|
|
{ |
350
|
|
|
protected $agentright; |
351
|
|
|
|
352
|
|
|
public $contain_rows = false; |
353
|
|
|
|
354
|
|
View Code Duplication |
public function __construct(absences_AgentRight $agentright, $layout = null) |
|
|
|
|
355
|
|
|
{ |
356
|
|
|
parent::__construct(null, $layout); |
357
|
|
|
|
358
|
|
|
$this->agentright = $agentright; |
359
|
|
|
|
360
|
|
|
|
361
|
|
|
$this->addClass('absences-dynamicright-cardframe'); |
362
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_16); |
363
|
|
|
|
364
|
|
|
$this->loadPage(); |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
|
368
|
|
|
|
369
|
|
|
protected function loadPage() |
370
|
|
|
{ |
371
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
372
|
|
|
$W = bab_Widgets(); |
373
|
|
|
|
374
|
|
|
|
375
|
|
|
$this->addItem($W->Title(absences_translate('Quantity modifications by monthly right modification'))); |
376
|
|
|
|
377
|
|
|
|
378
|
|
|
$addon = bab_getAddonInfosInstance('absences'); |
|
|
|
|
379
|
|
|
$right = $this->agentright->getRight(); |
380
|
|
|
$table = $this->createTable(); |
381
|
|
|
|
382
|
|
|
$row = 0; |
383
|
|
|
|
384
|
|
|
$table->addItem($W->Label(absences_translate('Initial quantity'))->addClass('right')->colon(), $row, 0); |
385
|
|
|
$table->addItem($W->Label(absences_quantity($this->agentright->getInitialQuantity(), $right->quantity_unit)), $row, 1); |
386
|
|
|
$row++; |
387
|
|
|
|
388
|
|
|
|
389
|
|
|
$table->addHeadRow($row); |
390
|
|
|
|
391
|
|
|
$table->addItem($W->Label(absences_translate('Modification date')), $row, 0); |
392
|
|
|
$table->addItem($W->Label(absences_translate('Quantity added to the right')), $row, 1); |
393
|
|
|
$row++; |
394
|
|
|
|
395
|
|
|
$I = $this->agentright->getIncrementIterator(); |
396
|
|
|
|
397
|
|
|
if ($I->count() > 0) |
|
|
|
|
398
|
|
|
{ |
399
|
|
|
$this->contain_rows = true; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
|
403
|
|
|
if ($I instanceof absences_IncrementAgentRightIterator) { |
404
|
|
|
$this->addItem($W->Icon( |
405
|
|
|
absences_translate('The montly update are added each month from the specific user quantity because the user quantity has been modified. To get back to the default value, the quantity field must be set empty'), |
406
|
|
|
Func_Icons::STATUS_DIALOG_INFORMATION |
407
|
|
|
)); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
if ($I instanceof absences_IncrementRightIterator) { |
411
|
|
|
$this->addItem($W->Icon( |
412
|
|
|
absences_translate('The montly update are added each month from the right quantity, if a specific quantity is set for the user, such changes will no longer be used'), |
413
|
|
|
Func_Icons::STATUS_DIALOG_INFORMATION |
414
|
|
|
)); |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
|
418
|
|
|
|
419
|
|
|
|
420
|
|
|
foreach($I as $increment) |
421
|
|
|
{ |
422
|
|
|
$table->addItem($W->Label(bab_shortDate(bab_mktime($increment->createdOn))), $row, 0); |
423
|
|
|
$table->addItem($this->quantityLabel($increment->quantity, $right->quantity_unit), $row, 1); |
424
|
|
|
|
425
|
|
|
$row++; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
|
429
|
|
|
|
430
|
|
|
|
431
|
|
|
$this->addItem($table); |
432
|
|
|
} |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
|
436
|
|
|
|
437
|
|
|
|
438
|
|
|
|
439
|
|
|
|
440
|
|
|
|
441
|
|
|
|
442
|
|
|
|
443
|
|
|
|
444
|
|
|
|
445
|
|
|
|
446
|
|
|
|
447
|
|
|
|
448
|
|
|
|
449
|
|
|
|
450
|
|
|
class absences_DynamicRightCardFrame extends absences_QuantityModificationCardFrame |
451
|
|
|
{ |
452
|
|
|
protected $agentright; |
453
|
|
|
|
454
|
|
|
public $contain_rows = false; |
455
|
|
|
|
456
|
|
View Code Duplication |
public function __construct(absences_AgentRight $agentright, $layout = null) |
|
|
|
|
457
|
|
|
{ |
458
|
|
|
parent::__construct(null, $layout); |
459
|
|
|
|
460
|
|
|
$this->agentright = $agentright; |
461
|
|
|
|
462
|
|
|
|
463
|
|
|
$this->addClass('absences-dynamicright-cardframe'); |
464
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_16); |
465
|
|
|
|
466
|
|
|
$this->loadPage(); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
|
470
|
|
|
|
471
|
|
|
protected function loadPage() |
472
|
|
|
{ |
473
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
474
|
|
|
$W = bab_Widgets(); |
475
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
476
|
|
|
|
477
|
|
|
|
478
|
|
|
$this->addItem($W->Title(absences_translate('Quantity modifications depending on the consumed quantity'))); |
479
|
|
|
|
480
|
|
|
$right = $this->agentright->getRight(); |
481
|
|
|
$t = $right->getDynamicTypes(); |
482
|
|
|
|
483
|
|
|
$this->addItem($W->Label(sprintf(absences_translate('%s has consumed %s of %s beetween the %s and the %s'), |
484
|
|
|
$this->agentright->getAgent()->getName(), |
485
|
|
|
absences_quantity(round($this->agentright->getDynamicTotalConfirmedDays(), 2), 'D'), |
486
|
|
|
implode(', ', $t), |
487
|
|
|
bab_shortDate(bab_mktime($right->dynconf_begin), false), |
488
|
|
|
bab_shortDate(bab_mktime($right->dynconf_end), false) |
489
|
|
|
))); |
490
|
|
|
|
491
|
|
|
|
492
|
|
|
$table = $this->createTable(); |
493
|
|
|
|
494
|
|
|
|
495
|
|
|
$row = 0; |
496
|
|
|
|
497
|
|
|
$increment_quantity = $this->agentright->getIncrementQuantity(); |
498
|
|
|
$initial_title = 0 === (int) round(100*$increment_quantity) ? absences_translate('Initial quantity') : absences_translate('Initial quantity + monthly updates'); |
499
|
|
|
$table->addItem($W->Label($initial_title)->addClass('right')->colon(), $row, 0); |
500
|
|
|
$initial = $this->agentright->getInitialQuantity(); |
501
|
|
|
$initial += $increment_quantity; |
502
|
|
|
$table->addItem($W->Label(absences_quantity($initial, $right->quantity_unit)), $row, 1, 1, 2); |
503
|
|
|
$row++; |
504
|
|
|
|
505
|
|
|
|
506
|
|
|
$table->addHeadRow($row); |
507
|
|
|
|
508
|
|
|
$table->addItem($W->Label(absences_translate('Modification date')), $row, 0); |
509
|
|
|
$table->addItem($W->Label(absences_translate('Quantity added to the right')), $row, 1); |
510
|
|
|
$table->addItem($W->Label(absences_translate('Vacation request that caused the change')), $row, 2); |
511
|
|
|
$row++; |
512
|
|
|
|
513
|
|
|
$right = $this->agentright->getRight(); |
514
|
|
|
|
515
|
|
|
$I = $this->agentright->getDynamicRightIterator(); |
516
|
|
|
|
517
|
|
|
if ($I->count() > 0) |
518
|
|
|
{ |
519
|
|
|
$this->contain_rows = true; |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
$addon = bab_getAddonInfosInstance('absences'); |
523
|
|
|
|
524
|
|
|
foreach($I as $dynamicRight) |
525
|
|
|
{ |
526
|
|
|
/* @var $dynamicRight absences_DynamicRight */ |
527
|
|
|
|
528
|
|
|
$request_url = new bab_url($addon->getUrl().'vacadmb'); |
529
|
|
|
$request_url->idx = 'morvw'; |
530
|
|
|
$request_url->id = $dynamicRight->id_entry; |
531
|
|
|
$request_url->popup = 1; |
532
|
|
|
|
533
|
|
|
$table->addItem($W->Label(bab_shortDate(bab_mktime($dynamicRight->createdOn))), $row, 0); |
534
|
|
|
$table->addItem($this->quantityLabel($dynamicRight->quantity, $right->quantity_unit), $row, 1); |
535
|
|
|
$table->addItem($W->Link($W->Icon('', Func_Icons::ACTIONS_DOCUMENT_PROPERTIES), $request_url->toString())->setOpenMode(Widget_Link::OPEN_POPUP), $row, 2); |
536
|
|
|
|
537
|
|
|
$row++; |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
|
541
|
|
|
$this->addItem($table); |
542
|
|
|
} |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
|
546
|
|
|
|
547
|
|
|
|
548
|
|
|
|
549
|
|
|
class absences_AgentRightMovementFrame extends absences_CardFrame |
550
|
|
|
{ |
551
|
|
|
public $count; |
552
|
|
|
|
553
|
|
|
public function __construct(absences_AgentRight $agentRight) |
554
|
|
|
{ |
555
|
|
|
$W = bab_Widgets(); |
556
|
|
|
parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(.5, 'em')); |
557
|
|
|
|
558
|
|
|
|
559
|
|
|
|
560
|
|
|
$this->addClass('widget-bordered'); |
561
|
|
|
$this->addClass('widget-centered'); |
562
|
|
|
$this->addClass(Func_Icons::ICON_LEFT_24); |
563
|
|
|
|
564
|
|
|
$this->setCanvasOptions($this->Options()->width(70,'em')); |
|
|
|
|
565
|
|
|
|
566
|
|
|
$this->addItem($W->Title(absences_translate('History'))); |
567
|
|
|
|
568
|
|
|
$res = $agentRight->getMovementIterator(); |
569
|
|
|
$this->count = $res->count(); |
570
|
|
|
|
571
|
|
|
foreach ($res as $movement) { |
572
|
|
|
|
573
|
|
|
$this->addMovement($movement); |
574
|
|
|
} |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
|
578
|
|
|
protected function addMovement(absences_Movement $movement) |
579
|
|
|
{ |
580
|
|
|
$W = bab_Widgets(); |
581
|
|
|
|
582
|
|
|
$date = $W->Label(bab_shortDate(bab_mktime($movement->createdOn))); |
583
|
|
|
$message = $W->RichText($movement->message)->setRenderingOptions(BAB_HTML_ALL ^ BAB_HTML_P); |
584
|
|
|
|
585
|
|
|
$date->setTitle(bab_getUserName($movement->id_author)); |
586
|
|
|
|
587
|
|
|
if ($movement->comment) { |
588
|
|
|
$message = $W->VBoxItems( |
589
|
|
|
$message, |
590
|
|
|
$W->FlowItems( |
591
|
|
|
$W->Label(absences_translate('Comment'))->colon(), |
592
|
|
|
$W->RichText($movement->comment)->setRenderingOptions(BAB_HTML_ALL ^ BAB_HTML_P) |
593
|
|
|
)->setSpacing(.8, 'em') |
594
|
|
|
)->setSpacing(.5, 'em'); |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
|
598
|
|
|
$this->addItem($W->HBoxItems($date, $message)); |
599
|
|
|
} |
600
|
|
|
} |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: