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__).'/request.class.php'; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* CET deposit request |
31
|
|
|
* |
32
|
|
|
* @property int $id_user |
33
|
|
|
* @property int $id_agent_right_cet |
34
|
|
|
* @property int $id_agent_right_source |
35
|
|
|
* @property float $quantity |
36
|
|
|
* @property int $idfai |
37
|
|
|
* @property string $comment |
38
|
|
|
* @property string $createdOn |
39
|
|
|
* @property string $modifiedOn |
40
|
|
|
* @property string $status |
41
|
|
|
* @property int $id_approver |
42
|
|
|
* @property int $archived |
43
|
|
|
* |
44
|
|
|
*/ |
45
|
|
|
class absences_CetDepositRequest extends absences_Request |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* |
49
|
|
|
* @var absences_AgentRight |
50
|
|
|
*/ |
51
|
|
|
private $agentRightSource; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* |
55
|
|
|
* @var absences_AgentRight |
56
|
|
|
*/ |
57
|
|
|
private $agentRightCet; |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param int $id |
62
|
|
|
* @return absences_CetDepositRequest |
63
|
|
|
*/ |
64
|
|
|
public static function getById($id) |
65
|
|
|
{ |
66
|
|
|
$request = new absences_CetDepositRequest(); |
67
|
|
|
$request->id = $id; |
68
|
|
|
|
69
|
|
|
return $request; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* |
76
|
|
|
* @return array |
77
|
|
|
*/ |
78
|
5 |
View Code Duplication |
public function getRow() |
|
|
|
|
79
|
|
|
{ |
80
|
5 |
|
if (null === $this->row) |
81
|
5 |
|
{ |
82
|
|
|
global $babDB; |
83
|
|
|
$query = 'SELECT * FROM absences_cet_deposit_request WHERE '; |
84
|
|
|
|
85
|
|
|
if (isset($this->id)) |
86
|
|
|
{ |
87
|
|
|
$query .= 'id='.$babDB->quote($this->id); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
$res = $babDB->db_query($query); |
91
|
|
|
$this->setRow($babDB->db_fetch_assoc($res)); |
92
|
|
|
} |
93
|
|
|
|
94
|
5 |
|
return $this->row; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
|
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return absences_AgentRight |
103
|
|
|
*/ |
104
|
|
|
public function getAgentRightSource() |
105
|
|
|
{ |
106
|
|
|
if (!isset($this->agentRightSource)) |
107
|
|
|
{ |
108
|
|
|
require_once dirname(__FILE__).'/agent_right.class.php'; |
109
|
|
|
$this->agentRightSource = absences_AgentRight::getById($this->id_agent_right_source); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $this->agentRightSource; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return absences_AgentRight |
119
|
|
|
*/ |
120
|
|
|
public function getAgentRightCet() |
121
|
|
|
{ |
122
|
|
|
if (!isset($this->agentRightCet)) |
123
|
|
|
{ |
124
|
|
|
require_once dirname(__FILE__).'/agent_right.class.php'; |
125
|
|
|
$this->agentRightCet = absences_AgentRight::getById($this->id_agent_right_cet); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
return $this->agentRightCet; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* (non-PHPdoc) |
134
|
|
|
* @see absences_Request::getRequestType() |
135
|
|
|
* |
136
|
|
|
* @return string |
137
|
|
|
*/ |
138
|
|
|
public function getRequestType() |
139
|
|
|
{ |
140
|
|
|
return absences_translate('Time saving account deposit'); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
|
144
|
5 |
|
public function save() |
145
|
|
|
{ |
146
|
5 |
|
global $babDB; |
147
|
|
|
|
148
|
5 |
|
if (!isset($this->createdOn)) { |
149
|
|
|
$this->createdOn = date('Y-m-d H:i:s'); |
150
|
|
|
} |
151
|
|
|
|
152
|
5 |
|
if (!isset($this->modifiedOn)) { |
153
|
5 |
|
$this->modifiedOn = date('Y-m-d H:i:s'); |
154
|
5 |
|
} |
155
|
|
|
|
156
|
|
|
|
157
|
5 |
|
if (isset($this->id) && !empty($this->id)) |
158
|
5 |
|
{ |
159
|
|
|
$query = ' |
160
|
|
|
UPDATE absences_cet_deposit_request |
161
|
|
|
SET |
162
|
2 |
|
id_agent_right_source='.$babDB->quote($this->id_agent_right_source).', |
163
|
2 |
|
quantity='.$babDB->quote($this->quantity).', |
164
|
2 |
|
modifiedOn='.$babDB->quote($this->modifiedOn).', |
165
|
2 |
|
idfai='.$babDB->quote($this->idfai).', |
166
|
2 |
|
status='.$babDB->quote($this->status).', |
167
|
2 |
|
quantity='.$babDB->quote($this->quantity).', |
168
|
2 |
|
comment='.$babDB->quote($this->comment).', |
169
|
2 |
|
comment2='.$babDB->quote($this->comment2).', |
170
|
2 |
|
id_approver='.$babDB->quote($this->id_approver).' |
171
|
2 |
|
'; |
172
|
|
|
|
173
|
2 |
|
if (isset($this->todelete)) { |
174
|
|
|
$query .= ', todelete='.$babDB->quote($this->todelete); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
$query .= ' WHERE |
178
|
2 |
|
id='.$babDB->quote($this->id).' '; |
179
|
|
|
|
180
|
2 |
|
$babDB->db_query($query); |
181
|
2 |
|
} else { |
182
|
|
|
|
183
|
|
|
|
184
|
5 |
|
$babDB->db_query('INSERT INTO |
185
|
|
|
absences_cet_deposit_request |
186
|
|
|
( |
187
|
|
|
id_user, |
188
|
|
|
id_agent_right_cet, |
189
|
|
|
id_agent_right_source, |
190
|
|
|
quantity, |
191
|
|
|
comment, |
192
|
|
|
createdOn, |
193
|
|
|
modifiedOn, |
194
|
|
|
idfai, |
195
|
|
|
status |
196
|
|
|
) |
197
|
|
|
VALUES |
198
|
|
|
( |
199
|
5 |
|
'.$babDB->quote($this->id_user).', |
200
|
5 |
|
'.$babDB->quote($this->id_agent_right_cet).', |
201
|
5 |
|
'.$babDB->quote($this->id_agent_right_source).', |
202
|
5 |
|
'.$babDB->quote($this->quantity).', |
203
|
5 |
|
'.$babDB->quote($this->comment).', |
204
|
5 |
|
'.$babDB->quote($this->createdOn).', |
205
|
5 |
|
'.$babDB->quote($this->modifiedOn).', |
206
|
5 |
|
'.$babDB->quote($this->idfai).', |
207
|
5 |
|
'.$babDB->quote($this->status).' |
208
|
|
|
) |
209
|
5 |
|
'); |
210
|
|
|
|
211
|
5 |
|
$this->id = $babDB->db_insert_id(); |
212
|
|
|
|
213
|
|
|
} |
214
|
5 |
|
} |
215
|
|
|
|
216
|
|
|
|
217
|
|
|
|
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* (non-PHPdoc) |
221
|
|
|
* @see absences_Request::getApprobationId() |
222
|
|
|
* |
223
|
|
|
* @return int |
224
|
|
|
*/ |
225
|
|
|
public function getApprobationId() |
226
|
|
|
{ |
227
|
|
|
if ($agent = $this->getAgent()) |
228
|
|
|
{ |
229
|
|
|
return $agent->getCetApprobationId(); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
return null; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Process specific code when the request is rejected |
237
|
|
|
* |
238
|
|
|
*/ |
239
|
|
|
protected function onReject() |
240
|
|
|
{ |
241
|
|
|
|
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Process specific code when the request is confirmed |
246
|
|
|
* |
247
|
|
|
*/ |
248
|
|
|
public function onConfirm() |
249
|
|
|
{ |
250
|
|
|
// the quantity in source right is removed dynamically |
251
|
|
|
|
252
|
|
|
$source = $this->getAgentRightSource()->getRight(); |
253
|
|
|
$cet = $this->getAgentRightCet()->getRight(); |
254
|
|
|
|
255
|
|
|
|
256
|
|
|
|
257
|
|
|
// add quantity to the CET |
258
|
|
|
|
259
|
|
|
$agentCet = $this->getAgentRightCet(); |
260
|
|
|
|
261
|
|
|
if (!$agentCet->getRow()) |
262
|
|
|
{ |
263
|
|
|
bab_debug('No agentRight found, agent deleted?'); |
264
|
|
|
return; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
|
268
|
|
|
$agentCet->quantity += $this->quantity; |
269
|
|
|
$agentCet->save(); |
270
|
|
|
|
271
|
|
|
$qte_text = absences_quantity($this->quantity, $source->quantity_unit); |
272
|
|
|
|
273
|
|
|
// ajout d'un message dans l'historique de chaque droit et dans l'historique de l'utilisateur |
274
|
|
|
|
275
|
|
|
$source->addMovement(sprintf(absences_translate('%s has saved %s to his time saving account'), $this->getAgent()->getName(), $qte_text)); |
276
|
|
|
$cet->addMovement(sprintf(absences_translate('The time saving account of %s has received %s'), $this->getAgent()->getName(), $qte_text)); |
277
|
|
|
$this->addMovement(sprintf(absences_translate('%s of right "%s" saved to "%s"'), $qte_text, $source->description, $cet->description)); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
|
281
|
|
|
public function getTitle() |
282
|
|
|
{ |
283
|
|
|
if (isset($this->todelete) && $this->todelete) { |
284
|
|
|
return absences_translate('time saving account deposit request to delete'); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
return absences_translate('time saving account deposit request'); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
|
291
|
|
|
public function getNotifyFields() |
292
|
|
|
{ |
293
|
|
|
$source = $this->getAgentRightSource()->getRight(); |
294
|
|
|
|
295
|
|
|
if (!$source->getRow()) |
296
|
|
|
{ |
297
|
|
|
return array(); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
return array( |
301
|
|
|
absences_translate('From right') => $source->description, |
302
|
|
|
absences_translate('Quantity') => absences_quantity($this->quantity, $source->quantity_unit) |
303
|
|
|
); |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* (non-PHPdoc) |
309
|
|
|
* @see absences_Request::getYear() |
310
|
|
|
* |
311
|
|
|
* @return int |
312
|
|
|
*/ |
313
|
|
|
public function getYear() |
314
|
|
|
{ |
315
|
|
|
$year = (int) substr($this->createdOn, 0, 4); |
316
|
|
|
|
317
|
|
|
if (0 === $year) |
318
|
|
|
{ |
319
|
|
|
return null; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
return $year; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
|
326
|
|
View Code Duplication |
public function getArchiveYear() |
|
|
|
|
327
|
|
|
{ |
328
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/dateTime.php'; |
329
|
|
|
$year = (int) substr($this->createdOn, 0, 4); |
330
|
|
|
|
331
|
|
|
if (0 === $year) |
332
|
|
|
{ |
333
|
|
|
return null; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
$day = absences_getVacationOption('archivage_day'); |
337
|
|
|
$month = absences_getVacationOption('archivage_month'); |
338
|
|
|
|
339
|
|
|
$currentYear = new BAB_DateTime($year, $month, $day); |
340
|
|
|
if($this->createdOn < $currentYear->getIsoDate()){ |
341
|
|
|
$year = $year-1; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
return $year; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
|
348
|
|
|
|
349
|
|
View Code Duplication |
public function archive() |
|
|
|
|
350
|
|
|
{ |
351
|
|
|
global $babDB; |
352
|
|
|
|
353
|
|
|
$babDB->db_query(" |
354
|
|
|
UPDATE absences_cet_deposit_request |
355
|
|
|
SET |
356
|
|
|
archived=".$babDB->quote(1)." |
357
|
|
|
WHERE |
358
|
|
|
id=".$babDB->quote($this->id)." |
359
|
|
|
"); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
|
363
|
|
|
|
364
|
|
View Code Duplication |
public function setNotified() |
|
|
|
|
365
|
|
|
{ |
366
|
|
|
global $babDB; |
367
|
|
|
|
368
|
|
|
$babDB->db_query(" |
369
|
|
|
UPDATE absences_cet_deposit_request |
370
|
|
|
SET |
371
|
|
|
appr_notified=".$babDB->quote(1)." |
372
|
|
|
WHERE |
373
|
|
|
id=".$babDB->quote($this->id)." |
374
|
|
|
"); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
|
378
|
|
|
public function getManagerEditUrl() |
379
|
|
|
{ |
380
|
|
|
$addon = bab_getAddonInfosInstance('absences'); |
381
|
|
|
return $addon->getUrl().'vacadmcet&idx=edit&id='.$this->id; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
public function getManagerDeleteUrl() |
385
|
|
|
{ |
386
|
|
|
$addon = bab_getAddonInfosInstance('absences'); |
387
|
|
|
return $addon->getUrl().'vacadmcet&idx=delete&id='.$this->id; |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
|
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* @return string |
394
|
|
|
*/ |
395
|
|
View Code Duplication |
public function getEditUrl($rfrom, $ide = null) |
|
|
|
|
396
|
|
|
{ |
397
|
|
|
$url = absences_addon()->getUrl()."vacuser&idx=cet&id=".$this->id; |
398
|
|
|
|
399
|
|
|
if (isset($rfrom)) |
400
|
|
|
{ |
401
|
|
|
$url .= '&rfrom='.$rfrom; |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
if (isset($ide)) |
405
|
|
|
{ |
406
|
|
|
$url .= '&ide='.$ide; |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
return $url; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
|
413
|
|
|
public function getManagerFrame() |
414
|
|
|
{ |
415
|
|
|
$W = bab_Widgets(); |
416
|
|
|
|
417
|
|
|
return $W->Link($W->Icon(absences_translate('Deposit on the time saving account'), Func_Icons::MIMETYPES_UNKNOWN), absences_addon()->getUrl()."vacadmcet&idx=edit&id=".$this->id ); |
|
|
|
|
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
|
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Get request card frame to display in requests list |
424
|
|
|
* @param bool $display_username Affiche le nom du demandeur dans la card frame ou non, utile pour les listes contenant plusieurs demandeurs possibles |
425
|
|
|
* @param int $rfrom si les demandes de la liste sont modifiee par un gestionnaire ou gestionnaire delegue |
426
|
|
|
* @param int $ide id entite de l'organigramme >0 si gestionnaire delegue seulement |
427
|
|
|
* @return Widget_Frame |
428
|
|
|
*/ |
429
|
|
|
public function getCardFrame($display_username, $rfrom, $ide) |
430
|
|
|
{ |
431
|
|
|
bab_functionality::includeOriginal('Icons'); |
|
|
|
|
432
|
|
|
$W = bab_Widgets(); |
433
|
|
|
|
434
|
|
|
|
435
|
|
|
$layout = $W->HBoxLayout()->setHorizontalSpacing(2,'em')->addClass('widget-full-width'); |
436
|
|
|
$frame = $W->Frame(null, $layout); |
437
|
|
|
$frame->addClass(Func_Icons::ICON_LEFT_16); |
438
|
|
|
|
439
|
|
|
if (!$this->getRow()) |
440
|
|
|
{ |
441
|
|
|
return $frame; |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
$layout->addItem($col1 = $W->VBoxLayout()->setVerticalSpacing(.5,'em')); |
445
|
|
|
$layout->addItem($col2 = $W->VBoxLayout()->setVerticalSpacing(.5,'em')); |
446
|
|
|
$layout->addItem($col3 = $W->VBoxLayout()->setVerticalSpacing(.5,'em')); |
447
|
|
|
|
448
|
|
|
$col1->addItem($W->Link($W->Icon(absences_translate('Deposit on the time saving account'), Func_Icons::MIMETYPES_UNKNOWN), absences_addon()->getUrl()."vacuser&idx=view_cet_deposit&id=".$this->id )); |
449
|
|
|
$col1->setCanvasOptions($col1->Options()->width(25,'em')); |
|
|
|
|
450
|
|
|
$col2->setCanvasOptions($col1->Options()->width(25,'em')); |
|
|
|
|
451
|
|
|
$layout->addItem($col3 = $W->VBoxLayout()->setVerticalSpacing(.5,'em')); |
452
|
|
|
$col2->setSizePolicy(Widget_SizePolicy::MAXIMUM); |
453
|
|
|
|
454
|
|
|
$col1->addItem($this->getStatusIcon()); |
455
|
|
|
|
456
|
|
|
|
457
|
|
|
|
458
|
|
|
if ($display_username) |
459
|
|
|
{ |
460
|
|
|
$col2->addItem($this->labelledValue(absences_translate('Owner'), $this->getUserName())); |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
$source = $this->getAgentRightSource()->getRight(); |
464
|
|
|
|
465
|
|
|
if ($source && $source->getRow()) |
466
|
|
|
{ |
467
|
|
|
$col2->addItem($this->labelledValue(absences_translate('From right'), $source->description)); |
468
|
|
|
$col2->addItem($this->labelledValue(absences_translate('Quantity'), absences_quantity($this->quantity, $source->quantity_unit))); |
469
|
|
|
} else { |
470
|
|
|
$col2->addItem($this->labelledValue(absences_translate('Quantity'), $this->quantity)); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
|
474
|
|
View Code Duplication |
if ($this->canModify()) |
|
|
|
|
475
|
|
|
{ |
476
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Modify'), Func_Icons::ACTIONS_DOCUMENT_EDIT), $this->getEditUrl($rfrom, $ide))); |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
if ($this->canDelete()) |
480
|
|
|
{ |
481
|
|
|
$urldelete = absences_addon()->getUrl()."vacuser&idx=delete&id_cetdeposit=".$this->id; |
482
|
|
|
$col3->addItem($W->Link($W->Icon(absences_translate('Delete'), Func_Icons::ACTIONS_EDIT_DELETE), $urldelete)); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
$frame->setTitle(sprintf(absences_translate('Created the %s'), bab_shortDate(bab_mktime($this->createdOn())))); |
486
|
|
|
|
487
|
|
|
return $frame; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
|
491
|
|
|
|
492
|
|
|
/** |
493
|
|
|
* Delete request |
494
|
|
|
*/ |
495
|
|
|
public function delete() |
496
|
|
|
{ |
497
|
|
|
|
498
|
|
|
parent::delete(); |
499
|
|
|
|
500
|
|
|
global $babDB; |
501
|
|
|
$babDB->db_query("delete from absences_cet_deposit_request where id=".$babDB->quote($this->id)); |
502
|
|
|
|
503
|
|
|
$this->addMovement( |
504
|
|
|
absences_translate('The time saving account deposit request has been deleted') |
505
|
|
|
); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Notify request owner about the approval or reject of the request |
511
|
|
|
*/ |
512
|
|
|
public function notifyOwner() |
513
|
|
|
{ |
514
|
|
|
require_once dirname(__FILE__).'/request.notify.php'; |
515
|
|
|
|
516
|
|
|
switch($this->status) |
517
|
|
|
{ |
518
|
|
|
case 'N': |
519
|
|
|
$subject = absences_translate("Your time saving account deposit request has been refused"); |
520
|
|
|
break; |
521
|
|
|
|
522
|
|
|
case 'Y': |
523
|
|
|
$subject = absences_translate("Your time saving account deposit request has been accepted"); |
524
|
|
|
break; |
525
|
|
|
|
526
|
|
|
default: |
527
|
|
|
return; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
absences_notifyRequestAuthor(array($this), $subject, $subject, $this->id_user); |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
|
535
|
|
|
|
536
|
|
|
|
537
|
|
|
|
538
|
|
|
|
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Vacation requests |
542
|
|
|
* |
543
|
|
|
*/ |
544
|
|
|
class absences_CetDepositRequestIterator extends absences_Iterator |
545
|
|
|
{ |
546
|
|
|
|
547
|
|
|
/** |
548
|
|
|
* |
549
|
|
|
* @var array |
550
|
|
|
*/ |
551
|
|
|
public $users; |
552
|
|
|
|
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* Filter by organization |
556
|
|
|
* @var int |
557
|
|
|
*/ |
558
|
|
|
public $organization; |
559
|
|
|
|
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* Filtrer les demandes necessitant ou pas un email aux approbateurs |
563
|
|
|
* @var int |
564
|
|
|
*/ |
565
|
|
|
public $appr_notified; |
566
|
|
|
|
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* Filtrer les demandes avec unes instance d'approbation |
570
|
|
|
* @var bool |
571
|
|
|
*/ |
572
|
|
|
public $idfai_set; |
573
|
|
|
|
574
|
|
|
/** |
575
|
|
|
* |
576
|
|
|
* @var string |
577
|
|
|
*/ |
578
|
|
|
public $status; |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Search all request created before this datetime |
582
|
|
|
* @var string |
583
|
|
|
*/ |
584
|
|
|
public $createdOn; |
585
|
|
|
|
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Search all request modified before this date |
589
|
|
|
* @var string |
590
|
|
|
*/ |
591
|
|
|
public $modifiedOn; |
592
|
|
|
|
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* Filtrer les demandes par annee |
596
|
|
|
* @var int |
597
|
|
|
*/ |
598
|
|
|
public $year; |
599
|
|
|
|
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* Filtrer les demandes par statut d'archivage |
603
|
|
|
* @var int |
604
|
|
|
*/ |
605
|
|
|
public $archived = 0; |
606
|
|
|
|
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* @var int |
610
|
|
|
*/ |
611
|
|
|
public $id_agent_right_source; |
612
|
|
|
|
613
|
|
|
|
614
|
4 |
|
public function getObject($data) |
615
|
|
|
{ |
616
|
|
|
|
617
|
4 |
|
$entry = new absences_CetDepositRequest; |
618
|
4 |
|
$entry->setRow($data); |
619
|
4 |
|
return $entry; |
620
|
|
|
|
621
|
|
|
} |
622
|
|
|
|
623
|
|
|
|
624
|
|
|
|
625
|
21 |
|
public function executeQuery() |
626
|
|
|
{ |
627
|
21 |
|
if(is_null($this->_oResult)) |
628
|
21 |
|
{ |
629
|
21 |
|
global $babDB; |
630
|
|
|
$req = 'SELECT r.* |
631
|
|
|
FROM |
632
|
|
|
absences_cet_deposit_request r |
633
|
|
|
LEFT JOIN absences_personnel p ON p.id_user=r.id_user |
634
|
21 |
|
'; |
635
|
|
|
|
636
|
|
|
|
637
|
21 |
|
$where = array(); |
638
|
|
|
|
639
|
21 |
|
if (isset($this->users)) |
640
|
21 |
|
{ |
641
|
21 |
|
$where[] = 'r.id_user IN('.$babDB->quote($this->users).')'; |
642
|
21 |
|
} |
643
|
|
|
|
644
|
21 |
|
if (isset($this->organization)) |
645
|
21 |
|
{ |
646
|
|
|
$where[] = 'p.id_organization='.$babDB->quote($this->organization); |
647
|
|
|
} |
648
|
|
|
|
649
|
21 |
|
if (isset($this->appr_notified)) |
650
|
21 |
|
{ |
651
|
|
|
$where[] = 'r.appr_notified='.$babDB->quote($this->appr_notified); |
652
|
|
|
} |
653
|
|
|
|
654
|
21 |
|
if (isset($this->idfai_set) && $this->idfai_set) |
655
|
21 |
|
{ |
656
|
|
|
$where[] = 'r.idfai>'.$babDB->quote(0); |
657
|
|
|
} |
658
|
|
|
|
659
|
21 |
|
if (isset($this->status)) |
660
|
21 |
|
{ |
661
|
7 |
|
$where[] = 'r.status='.$babDB->quote($this->status); |
662
|
7 |
|
} |
663
|
|
|
|
664
|
21 |
|
if (isset($this->createdOn)) |
665
|
21 |
|
{ |
666
|
15 |
|
$where[] = 'r.createdOn<='.$babDB->quote($this->createdOn); |
667
|
15 |
|
} |
668
|
|
|
|
669
|
21 |
|
if (isset($this->modifiedOn)) |
670
|
21 |
|
{ |
671
|
|
|
$where[] = 'r.modifiedOn<='.$babDB->quote($this->modifiedOn); |
672
|
|
|
} |
673
|
|
|
|
674
|
21 |
|
if (isset($this->year)) |
675
|
21 |
|
{ |
676
|
|
|
$where[] = 'YEAR(r.createdOn)='.$babDB->quote($this->year); |
677
|
|
|
} |
678
|
|
|
|
679
|
21 |
|
if (isset($this->startTo) && $this->startTo != '0000-00-00') |
680
|
21 |
|
{ |
681
|
|
|
$where[] = 'r.createdOn <='.$babDB->quote($this->startTo); |
|
|
|
|
682
|
|
|
} |
683
|
|
|
|
684
|
21 |
|
if (isset($this->startFrom) && $this->startFrom != '0000-00-00') |
685
|
21 |
|
{ |
686
|
|
|
$where[] = 'r.createdOn >='.$babDB->quote($this->startFrom); |
|
|
|
|
687
|
|
|
} |
688
|
|
|
|
689
|
21 |
|
if (isset($this->archived)) |
690
|
21 |
|
{ |
691
|
|
|
$where[] = 'r.archived='.$babDB->quote($this->archived); |
692
|
|
|
} |
693
|
|
|
|
694
|
21 |
|
if (isset($this->id_agent_right_source)) { |
695
|
21 |
|
$where[] = 'r.id_agent_right_source='.$babDB->quote($this->id_agent_right_source); |
696
|
21 |
|
} |
697
|
|
|
|
698
|
|
|
if ($where) |
|
|
|
|
699
|
21 |
|
{ |
700
|
21 |
|
$req .= ' WHERE '.implode(' AND ', $where); |
701
|
21 |
|
} |
702
|
|
|
|
703
|
21 |
|
$this->setMySqlResult($this->getDataBaseAdapter()->db_query($req)); |
704
|
21 |
|
} |
705
|
21 |
|
} |
706
|
|
|
} |
707
|
|
|
|
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.