This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | |||
26 | |||
27 | |||
28 | include_once dirname(__FILE__).'/functions.php'; |
||
29 | include_once $babInstallPath."utilit/afincl.php"; |
||
30 | include_once $babInstallPath."utilit/mailincl.php"; |
||
31 | include_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
32 | include_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
33 | include_once dirname(__FILE__).'/utilit/right.class.php'; |
||
34 | |||
35 | function addVacationType($vtid, $what, $tname, $description, $tcolor, $cbalance) |
||
36 | { |
||
37 | global $babBody, $babDB; |
||
38 | class temp |
||
39 | { |
||
40 | var $name; |
||
41 | var $description; |
||
42 | var $quantity; |
||
43 | var $tnameval; |
||
44 | var $descriptionval; |
||
45 | var $quantityval; |
||
46 | var $vtid; |
||
47 | var $what; |
||
48 | |||
49 | var $invalidentry1; |
||
50 | |||
51 | var $add; |
||
52 | |||
53 | function temp($vtid, $what, $tname, $description, $tcolor, $cbalance) |
||
54 | { |
||
55 | global $babDB; |
||
56 | $this->what = $what; |
||
57 | $this->vtid = $vtid; |
||
58 | $this->name = absences_translate("Name"); |
||
59 | $this->description = absences_translate("Description"); |
||
60 | $this->colortxt = absences_translate("Color"); |
||
61 | $this->yestxt = absences_translate("Yes"); |
||
62 | $this->notxt = absences_translate("No"); |
||
63 | $this->t_recover = absences_translate("Use this right type to store the created recovery rights"); |
||
64 | |||
65 | $this->selctorurl = bab_toHtml($GLOBALS['babUrlScript']."?tg=selectcolor&idx=popup&callback=setColor"); |
||
66 | $this->tcolor = $tcolor; |
||
67 | |||
68 | if( $what == "modvt" && empty($tname)) |
||
69 | { |
||
70 | $arr = $babDB->db_fetch_array($babDB->db_query("select * from ".ABSENCES_TYPES_TBL." where id=".$babDB->quote($vtid))); |
||
71 | $this->tnameval = bab_toHtml($arr['name']); |
||
72 | $this->descriptionval = bab_toHtml($arr['description']); |
||
73 | $this->tcolorval = bab_toHtml($arr['color']); |
||
74 | $this->recover = (bool) $arr['recover']; |
||
75 | |||
76 | View Code Duplication | if( $arr['cbalance'] == 'Y') |
|
77 | { |
||
78 | $this->yselected = 'selected'; |
||
79 | $this->nselected = ''; |
||
80 | } |
||
81 | else |
||
82 | { |
||
83 | $this->yselected = ''; |
||
84 | $this->nselected = 'selected'; |
||
85 | } |
||
86 | } |
||
87 | else |
||
88 | { |
||
89 | $this->tnameval = bab_toHtml($tname); |
||
90 | $this->descriptionval = bab_toHtml($description); |
||
91 | $this->tcolorval = bab_toHtml($tcolor); |
||
92 | $this->recover = false; |
||
93 | |||
94 | View Code Duplication | if( $cbalance == 'N') |
|
95 | { |
||
96 | $this->nselected = 'selected'; |
||
97 | $this->yselected = ''; |
||
98 | } |
||
99 | else |
||
100 | { |
||
101 | $this->nselected = ''; |
||
102 | $this->yselected = 'selected'; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | View Code Duplication | if( $what == "modvt" ) |
|
107 | { |
||
108 | $this->bdel = true; |
||
109 | $this->del = absences_translate("Delete"); |
||
110 | $this->add = absences_translate("Modify"); |
||
111 | } |
||
112 | else |
||
113 | { |
||
114 | $this->bdel = false; |
||
115 | $this->add = absences_translate("Add"); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | |||
120 | list($count) = $babDB->db_fetch_row($babDB->db_query("select count(*) as total from ".ABSENCES_TYPES_TBL)); |
||
121 | $temp = new temp($vtid, $what, $tname, $description, $tcolor, $cbalance); |
||
122 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vtypecreate")); |
||
123 | return $count; |
||
124 | } |
||
125 | |||
126 | function listVacationCollections() |
||
127 | { |
||
128 | global $babBody; |
||
129 | |||
130 | class temp |
||
131 | { |
||
132 | var $nametxt; |
||
133 | var $urlname; |
||
134 | var $url; |
||
135 | var $descriptiontxt; |
||
136 | var $description; |
||
137 | |||
138 | var $arr = array(); |
||
139 | var $count; |
||
140 | var $res; |
||
141 | |||
142 | public $altbg = true; |
||
143 | |||
144 | View Code Duplication | function temp() |
|
145 | { |
||
146 | $this->nametxt = absences_translate("Name"); |
||
147 | $this->descriptiontxt = absences_translate("Description"); |
||
148 | $this->t_rights = absences_translate('Rights'); |
||
149 | $babDB = $GLOBALS['babDB']; |
||
150 | $req = "select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc"; |
||
151 | $this->res = $babDB->db_query($req); |
||
152 | $this->count = $babDB->db_num_rows($this->res); |
||
153 | } |
||
154 | |||
155 | function getnext() |
||
156 | { |
||
157 | static $i = 0; |
||
158 | if( $i < $this->count) |
||
159 | { |
||
160 | global $babDB; |
||
161 | $this->altbg = !$this->altbg; |
||
162 | $arr = $babDB->db_fetch_array($this->res); |
||
163 | $this->url = absences_addon()->getUrl()."vacadm&idx=modvc&id=".$arr['id']; |
||
164 | $this->urlname = bab_toHtml($arr['name']); |
||
165 | $this->description = bab_toHtml($arr['description']); |
||
166 | $this->righturl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=lrig&idcoll=".$arr['id']); |
||
167 | $i++; |
||
168 | return true; |
||
169 | } |
||
170 | else |
||
171 | return false; |
||
172 | |||
173 | } |
||
174 | } |
||
175 | |||
176 | $temp = new temp(); |
||
177 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vcollist")); |
||
178 | return $temp->count; |
||
179 | |||
180 | } |
||
181 | |||
182 | function listVacationTypes() |
||
183 | { |
||
184 | global $babBody; |
||
185 | |||
186 | class temp |
||
187 | { |
||
188 | var $nametxt; |
||
189 | var $urlname; |
||
190 | var $url; |
||
191 | var $descriptiontxt; |
||
192 | var $quantitytxt; |
||
193 | var $description; |
||
194 | var $quantity; |
||
195 | var $altaddvr; |
||
196 | public $altbg = true; |
||
197 | var $arr = array(); |
||
198 | var $count; |
||
199 | var $res; |
||
200 | |||
201 | View Code Duplication | function temp() |
|
202 | { |
||
203 | $this->nametxt = absences_translate("Name"); |
||
204 | $this->descriptiontxt = absences_translate("Description"); |
||
205 | $this->colortxt = absences_translate("Color"); |
||
206 | $this->altaddvr = absences_translate("Allocate vacation rights"); |
||
207 | $babDB = $GLOBALS['babDB']; |
||
208 | $req = "select * from ".ABSENCES_TYPES_TBL." order by name asc"; |
||
209 | $this->res = $babDB->db_query($req); |
||
210 | $this->count = $babDB->db_num_rows($this->res); |
||
211 | } |
||
212 | |||
213 | function getnext() |
||
214 | { |
||
215 | static $i = 0; |
||
216 | if( $i < $this->count) |
||
217 | { |
||
218 | global $babDB; |
||
219 | $arr = $babDB->db_fetch_array($this->res); |
||
220 | $this->altbg = !$this->altbg; |
||
221 | $this->url = bab_toHtml(absences_addon()->getUrl()."vacadm&idx=modvt&id=".$arr['id']); |
||
222 | $this->urlname = bab_toHtml($arr['name']); |
||
223 | $this->description = bab_toHtml($arr['description']); |
||
224 | $this->tcolor = bab_toHtml($arr['color']); |
||
225 | $this->addurl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=addvr&idtype=".$arr['id']); |
||
226 | $i++; |
||
227 | return true; |
||
228 | } |
||
229 | else |
||
230 | return false; |
||
231 | |||
232 | } |
||
233 | } |
||
234 | |||
235 | $temp = new temp(); |
||
236 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vtypelist")); |
||
237 | return $temp->count; |
||
238 | |||
239 | } |
||
240 | |||
241 | function addVacationCollection($vcid, $what, $tname, $description, $vtypeids, $category) |
||
242 | { |
||
243 | global $babBody; |
||
244 | class temp |
||
245 | { |
||
246 | var $name; |
||
247 | var $description; |
||
248 | var $vactypes; |
||
249 | var $tnameval; |
||
250 | var $descriptionval; |
||
251 | var $add; |
||
252 | var $vtypename; |
||
253 | var $vtcheck; |
||
254 | var $vcid; |
||
255 | var $vtids = array(); |
||
256 | |||
257 | var $arr = array(); |
||
258 | var $count; |
||
259 | var $res; |
||
260 | function temp($vcid, $what, $tname, $description, $vtypeids, $category) |
||
261 | { |
||
262 | global $babDB; |
||
263 | $this->name = absences_translate("Name"); |
||
264 | $this->description = absences_translate("Description"); |
||
265 | $this->vactypes = absences_translate("Vacations types"); |
||
266 | $this->category = absences_translate("Category to use in calendar"); |
||
267 | $this->t_checkall = absences_translate("Check/Uncheck all types"); |
||
268 | $this->vcid = $vcid; |
||
269 | $this->what = $what; |
||
270 | |||
271 | View Code Duplication | if( $what == "modvc") |
|
272 | { |
||
273 | $this->bdel = true; |
||
274 | $this->del = absences_translate("Delete"); |
||
275 | $this->add = absences_translate("Modify"); |
||
276 | } |
||
277 | else |
||
278 | { |
||
279 | $this->bdel = false; |
||
280 | $this->add = absences_translate("Add"); |
||
281 | } |
||
282 | |||
283 | if( $what == "modvc" && empty($tname)) |
||
284 | { |
||
285 | $arr = $babDB->db_fetch_array($babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." where id=".$babDB->quote($vcid))); |
||
286 | $this->tnameval = bab_toHtml($arr['name']); |
||
287 | $this->descriptionval = bab_toHtml($arr['description']); |
||
288 | $this->categoryval = bab_toHtml($arr['id_cat']); |
||
289 | |||
290 | } |
||
291 | else |
||
292 | { |
||
293 | $this->tnameval = bab_toHtml($tname); |
||
294 | $this->descriptionval = bab_toHtml($description); |
||
295 | $this->categoryval = bab_toHtml($category); |
||
296 | } |
||
297 | |||
298 | |||
299 | include_once $GLOBALS['babInstallPath']."utilit/calapi.php"; |
||
300 | $this->categs = bab_calGetCategories(); |
||
301 | |||
302 | $this->catcount = count($this->categs); |
||
303 | } |
||
304 | |||
305 | |||
306 | |||
307 | function getnextcat() |
||
308 | { |
||
309 | static $i = 0; |
||
310 | if( $i < $this->catcount) |
||
311 | { |
||
312 | $this->categid = $this->categs[$i]['id']; |
||
313 | $this->categname = bab_toHtml($this->categs[$i]['name']); |
||
314 | if( $this->categid == $this->categoryval ) |
||
315 | { |
||
316 | $this->selected = 'selected'; |
||
317 | } |
||
318 | else |
||
319 | { |
||
320 | $this->selected = ''; |
||
321 | } |
||
322 | $i++; |
||
323 | return true; |
||
324 | } |
||
325 | else |
||
326 | return false; |
||
327 | |||
328 | } |
||
329 | } |
||
330 | |||
331 | $temp = new temp($vcid, $what, $tname, $description, $vtypeids, $category); |
||
332 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vcolcreate")); |
||
333 | } |
||
334 | |||
335 | |||
336 | /** |
||
337 | * Tester l'export pour 1 utilisateur, valeurs avec date et sans date |
||
338 | */ |
||
339 | function testExportBalances() |
||
340 | { |
||
341 | require_once dirname(__FILE__).'/utilit/exportbalance.php'; |
||
342 | |||
343 | $W = bab_Widgets(); |
||
344 | $export = new exportAvailableBalancesCls(); |
||
345 | |||
346 | $page = $W->BabPage(); |
||
347 | $page->addItem($export->compareDateForOneUser(bab_rp('id_user'))); |
||
348 | $page->displayHtml(); |
||
349 | } |
||
350 | |||
351 | |||
352 | // available balances export |
||
353 | function exportAvailableBalances() |
||
354 | { |
||
355 | global $babBody; |
||
356 | require_once dirname(__FILE__).'/utilit/exportbalance.php'; |
||
357 | |||
358 | |||
359 | $export = new exportAvailableBalancesCls(); |
||
360 | |||
361 | if (!empty($_POST)) { |
||
362 | $export->csv(); |
||
363 | } |
||
364 | |||
365 | $babBody->babecho($export->getHtml()); |
||
366 | } |
||
367 | |||
368 | |||
369 | View Code Duplication | function listVacationPersonnel() |
|
370 | { |
||
371 | require_once dirname(__FILE__).'/utilit/agentlist.ui.php'; |
||
372 | $babBody = bab_getBody(); |
||
373 | |||
374 | $babBody->babecho(absences_agentListMenu()); |
||
375 | |||
376 | $addon = bab_getAddonInfosInstance('absences'); |
||
377 | $babBody->addStyleSheet($addon->getStylePath().'vacation.css'); |
||
378 | |||
379 | $temp = new absences_AgentList((array) bab_rp('filter', array())); |
||
380 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vpersonnellist")); |
||
381 | return $temp->count; |
||
382 | } |
||
383 | |||
384 | |||
385 | |||
386 | |||
387 | function addGroupVacationPersonnel() |
||
388 | { |
||
389 | global $babBody; |
||
390 | class temp |
||
391 | { |
||
392 | |||
393 | function temp() |
||
394 | { |
||
395 | $this->grouptext = absences_translate("Group"); |
||
396 | $this->collection = absences_translate("Collection"); |
||
397 | $this->appschema = absences_translate("Approbation schema for vacation requests:"); |
||
398 | $this->cetschema = absences_translate("Approbation schema for deposit into the time savings account:"); |
||
399 | $this->recoverschema = absences_translate("Approbation schema for declaration of worked days entitling recovery:"); |
||
400 | $this->t_use_vr = absences_translate("Use schema for vacation requests"); |
||
401 | $this->groupsbrowurl = absences_addon()->getUrl()."vacadm&idx=browg&cb="; |
||
402 | $this->t_add = absences_translate("Add"); |
||
403 | $this->t_modify = absences_translate("Modify"); |
||
404 | $this->t_record = absences_translate("Record"); |
||
405 | $this->t_add_modify = absences_translate("Add or modify users by group"); |
||
406 | $this->t_modify_alert = absences_translate("Users with waiting requests will not be modified"); |
||
407 | |||
408 | global $babDB; |
||
409 | |||
410 | $this->idsa = bab_rp('idsa', 0); |
||
411 | $this->idcol = isset($_REQUEST['idcol']) ? $_REQUEST['idcol'] : ''; |
||
412 | |||
413 | |||
414 | $this->groupval = ""; |
||
415 | $this->groupid = ""; |
||
416 | |||
417 | $W = bab_Widgets(); |
||
418 | |||
419 | $this->grouppicker = $W->GroupPicker()->setName('groupid')->display($W->HtmlCanvas()); |
||
420 | |||
421 | $this->sares = $babDB->db_query("select * from ".BAB_FLOW_APPROVERS_TBL." order by name asc"); |
||
422 | if( !$this->sares ) |
||
423 | $this->countsa = 0; |
||
424 | else |
||
425 | $this->countsa = $babDB->db_num_rows($this->sares); |
||
426 | |||
427 | $this->colres = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc"); |
||
428 | $this->countcol = $babDB->db_num_rows($this->colres); |
||
429 | } |
||
430 | |||
431 | function getnextsa() |
||
432 | { |
||
433 | global $babDB; |
||
434 | static $j= 0; |
||
435 | if( $j < $this->countsa ) |
||
436 | { |
||
437 | |||
438 | $arr = $babDB->db_fetch_array($this->sares); |
||
439 | $this->saname = bab_toHtml($arr['name']); |
||
440 | $this->idsapp = bab_toHtml($arr['id']); |
||
441 | if( $this->idsa == $this->idsapp ) |
||
442 | $this->selected = "selected"; |
||
443 | else |
||
444 | $this->selected = ""; |
||
445 | $j++; |
||
446 | return true; |
||
447 | } |
||
448 | else |
||
449 | { |
||
450 | $j = 0; |
||
451 | if ($this->countsa > 0) |
||
452 | $babDB->db_data_seek($this->sares,0); |
||
453 | return false; |
||
454 | } |
||
455 | } |
||
456 | |||
457 | View Code Duplication | function getnextcol() |
|
458 | { |
||
459 | static $j= 0; |
||
460 | if( $j < $this->countcol ) |
||
461 | { |
||
462 | global $babDB; |
||
463 | $arr = $babDB->db_fetch_array($this->colres); |
||
464 | $this->collname = bab_toHtml($arr['name']); |
||
465 | $this->idcollection = bab_toHtml($arr['id']); |
||
466 | if( $this->idcol == $this->idcollection ) |
||
467 | $this->selected = "selected"; |
||
468 | else |
||
469 | $this->selected = ""; |
||
470 | $j++; |
||
471 | return true; |
||
472 | } |
||
473 | else |
||
474 | return false; |
||
475 | } |
||
476 | |||
477 | function printhtml() |
||
478 | { |
||
479 | $GLOBALS['babBody']->babecho( bab_printTemplate($this, absences_addon()->getRelativePath()."vacadm.html", "grouppersonnelcreate")); |
||
480 | } |
||
481 | |||
482 | |||
483 | public function displaySaveProgress() |
||
484 | { |
||
485 | $W = bab_Widgets(); |
||
486 | $page = $W->BabPage(); |
||
487 | |||
488 | |||
489 | $groupid = (int) bab_pp('groupid'); |
||
490 | |||
491 | |||
492 | $page->setTitle(sprintf(absences_translate('Add users of group %s into personel members'), bab_getGroupName($groupid))); |
||
493 | |||
494 | $nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next'))); |
||
495 | |||
496 | |||
497 | $page->addItem( |
||
498 | $W->Frame() |
||
499 | ->setCanvasOptions($page->Options()->width(70,'em')) |
||
500 | ->addClass('widget-bordered') |
||
501 | ->addClass('BabLoginMenuBackground') |
||
502 | ->addClass('widget-centered') |
||
503 | ->addItem( |
||
504 | $W->ProgressBar() |
||
505 | ->setProgress(0) |
||
506 | ->setTitle(absences_translate('Process users list')) |
||
507 | ->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'addg_progress')) |
||
508 | ->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lper'), $nextbutton) |
||
509 | ) |
||
510 | ->addItem($nextbutton) |
||
511 | ); |
||
512 | |||
513 | |||
514 | $page->displayHtml(); |
||
515 | } |
||
516 | |||
517 | } |
||
518 | |||
519 | $temp = new temp(); |
||
520 | |||
521 | if (!empty($_POST)) |
||
522 | { |
||
523 | $temp->displaySaveProgress(); |
||
524 | return; |
||
525 | } |
||
526 | |||
527 | $temp->printhtml(); |
||
528 | } |
||
529 | |||
530 | |||
531 | |||
532 | |||
533 | |||
534 | |||
535 | |||
536 | |||
537 | |||
538 | |||
539 | function deleteVacationPersonnel($pos, $idcol, $idsa, $userids) |
||
540 | { |
||
541 | global $babBody, $idx; |
||
542 | |||
543 | class tempa |
||
544 | { |
||
545 | var $warning; |
||
546 | var $message; |
||
547 | var $title; |
||
548 | var $urlyes; |
||
549 | var $urlno; |
||
550 | var $yes; |
||
551 | var $no; |
||
552 | |||
553 | function tempa($pos, $idcol, $idsa, $userids) |
||
554 | { |
||
555 | global $BAB_SESS_USERID, $babDB; |
||
556 | $this->message = absences_translate("Are you sure you want to remove those personnel members"); |
||
557 | $this->title = ""; |
||
558 | $items = ""; |
||
559 | |||
560 | for($i = 0; $i < count($userids); $i++) |
||
561 | { |
||
562 | $req = "select * from ".BAB_USERS_TBL." where id='".$babDB->db_escape_string($userids[$i])."'"; |
||
563 | $res = $babDB->db_query($req); |
||
564 | if( $babDB->db_num_rows($res) > 0) |
||
565 | { |
||
566 | $arr = $babDB->db_fetch_array($res); |
||
567 | $this->title .= "<br>". bab_composeUserName($arr['firstname'], $arr['lastname']); |
||
568 | $items .= $arr['id']; |
||
569 | } |
||
570 | if( $i < count($userids) -1) |
||
571 | $items .= ","; |
||
572 | } |
||
573 | $this->warning = absences_translate("WARNING: This operation will remove personnel members, all the vacations parameters and the users vacation requests, the ovidentia users will remain"). "!"; |
||
574 | $this->urlyes = absences_addon()->getUrl()."vacadm&idx=lper&pos=".$pos."&idcol=".$idcol."&idsa=".$idsa."&action=Yes&items=".$items; |
||
575 | $this->yes = absences_translate("Yes"); |
||
576 | $this->urlno = absences_addon()->getUrl()."vacadm&idx=lper&pos=".$pos."&idcol=".$idcol."&idsa=".$idsa; |
||
577 | $this->no = absences_translate("No"); |
||
578 | } |
||
579 | } |
||
580 | |||
581 | if( count($userids) <= 0) |
||
582 | { |
||
583 | $babBody->msgerror = absences_translate("Please select at least one item"); |
||
584 | listVacationPersonnel(); |
||
585 | $idx = "lper"; |
||
586 | return; |
||
587 | } |
||
588 | $tempa = new tempa($pos, $idcol, $idsa, $userids); |
||
589 | $babBody->babecho( bab_printTemplate($tempa, absences_addon()->getRelativePath()."warning.html", "warningyesno")); |
||
590 | } |
||
591 | |||
592 | |||
593 | function admmenu() |
||
594 | { |
||
595 | require_once dirname(__FILE__).'/utilit/menu.ui.php'; |
||
596 | |||
597 | $W = bab_Widgets(); |
||
598 | $page = $W->BabPage(); |
||
599 | |||
600 | $menu = new absences_ManagerMenu(); |
||
601 | |||
602 | $page->setTitle(absences_translate('Vacation management')); |
||
603 | $page->addItem($menu->getFrame()); |
||
604 | $page->displayHtml(); |
||
605 | } |
||
606 | |||
607 | |||
608 | function saveVacationType($tname, $description, $tcolor, $maxdays=0, $mindays=0, $default=0) |
||
609 | { |
||
610 | global $babBody; |
||
611 | if( empty($tname)) { |
||
612 | $babBody->msgerror = absences_translate("ERROR: You must provide a name")." !"; |
||
613 | return false; |
||
614 | } |
||
615 | |||
616 | $babDB = $GLOBALS['babDB']; |
||
617 | |||
618 | $req = "select id from ".ABSENCES_TYPES_TBL." where name='".$babDB->db_escape_string($tname)."'"; |
||
619 | $res = $babDB->db_query($req); |
||
620 | View Code Duplication | if( $res && $babDB->db_num_rows($res) > 0 ) |
|
621 | { |
||
622 | $babBody->msgerror = absences_translate("This vacation type already exists") ." !"; |
||
623 | return false; |
||
624 | } |
||
625 | |||
626 | $req = "insert into ".ABSENCES_TYPES_TBL." ( name, description, quantity, maxdays, mindays, defaultdays, color, recover)"; |
||
627 | $req .= " values ( |
||
628 | '".$babDB->db_escape_string($tname)."', |
||
629 | '" .$babDB->db_escape_string($description). "', |
||
630 | '" .$babDB->db_escape_string(0). "', |
||
631 | '" .$babDB->db_escape_string($maxdays). "', |
||
632 | '" .$babDB->db_escape_string($mindays). "', |
||
633 | '" .$babDB->db_escape_string($default). "', |
||
634 | '" .$babDB->db_escape_string($tcolor). "', |
||
635 | ".$babDB->quote(bab_pp('recover', 0))." |
||
636 | )"; |
||
637 | $res = $babDB->db_query($req); |
||
638 | return true; |
||
639 | } |
||
640 | |||
641 | function updateVacationType($vtid, $tname, $description, $tcolor, $maxdays=0, $mindays=0, $default=0) |
||
642 | { |
||
643 | global $babBody; |
||
644 | if( empty($tname)) |
||
645 | { |
||
646 | $babBody->msgerror = absences_translate("ERROR: You must provide a name")." !"; |
||
647 | return false; |
||
648 | } |
||
649 | |||
650 | $babDB = $GLOBALS['babDB']; |
||
651 | |||
652 | $req = "SELECT id from ".ABSENCES_TYPES_TBL." WHERE name='".$babDB->db_escape_string($tname)."' AND id!='".$babDB->db_escape_string($vtid)."'"; |
||
653 | $res = $babDB->db_query($req); |
||
654 | View Code Duplication | if( $res && $babDB->db_num_rows($res) > 0 ) |
|
655 | { |
||
656 | $babBody->msgerror = absences_translate("This vacation type already exists") ." !"; |
||
657 | return false; |
||
658 | } |
||
659 | |||
660 | $req = "UPDATE ".ABSENCES_TYPES_TBL." |
||
661 | SET |
||
662 | name='".$babDB->db_escape_string($tname)."', |
||
663 | description='".$babDB->db_escape_string($description)."', |
||
664 | quantity='0', |
||
665 | maxdays='".$babDB->db_escape_string($maxdays)."', |
||
666 | mindays='".$babDB->db_escape_string($mindays)."', |
||
667 | defaultdays='".$babDB->db_escape_string($default)."', |
||
668 | color='".$babDB->db_escape_string($tcolor)."', |
||
669 | recover=".$babDB->quote(bab_pp('recover', 0))." |
||
670 | WHERE |
||
671 | id='".$babDB->db_escape_string($vtid)."'"; |
||
672 | $res = $babDB->db_query($req); |
||
673 | |||
674 | |||
675 | // clear planning cache |
||
676 | $babDB->db_query("DELETE FROM ".ABSENCES_CALENDAR_TBL.""); |
||
677 | |||
678 | return true; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * |
||
683 | * @param int $vtid |
||
684 | */ |
||
685 | View Code Duplication | function deleteVacationType($vtid) |
|
686 | { |
||
687 | global $babBody, $babDB; |
||
688 | $bdel = true; |
||
689 | |||
690 | list($total) = $babDB->db_fetch_array($babDB->db_query("select count(id) as total from ".ABSENCES_RIGHTS_TBL." where id_type='".$babDB->db_escape_string($vtid)."'")); |
||
691 | if( $total > 0 ) |
||
692 | { |
||
693 | $bdel = false; |
||
694 | } |
||
695 | |||
696 | if( $bdel ) |
||
697 | { |
||
698 | $babDB->db_query("delete from ".ABSENCES_TYPES_TBL." where id='".$babDB->db_escape_string($vtid)."'"); |
||
699 | $babDB->db_query("delete from ".ABSENCES_COLL_TYPES_TBL." where id_type='".$babDB->db_escape_string($vtid)."'"); |
||
700 | } |
||
701 | else |
||
702 | $babBody->msgerror = absences_translate("This vacation type is used and can't be deleted") ." !"; |
||
703 | } |
||
704 | |||
705 | |||
706 | /** |
||
707 | * |
||
708 | * @param unknown_type $tname |
||
709 | * @param unknown_type $description |
||
710 | * @param unknown_type $category |
||
711 | * @return boolean |
||
712 | */ |
||
713 | function absences_saveVacationCollection($tname, $description, $category) |
||
714 | { |
||
715 | global $babBody; |
||
716 | if( empty($tname)) |
||
717 | { |
||
718 | $babBody->msgerror = absences_translate("ERROR: You must provide a name")." !"; |
||
719 | return false; |
||
720 | } |
||
721 | |||
722 | $babDB = $GLOBALS['babDB']; |
||
723 | |||
724 | $req = "select id from ".ABSENCES_COLLECTIONS_TBL." where name='".$babDB->db_escape_string($tname)."'"; |
||
725 | $res = $babDB->db_query($req); |
||
726 | View Code Duplication | if( $res && $babDB->db_num_rows($res) > 0 ) |
|
727 | { |
||
728 | $babBody->msgerror = absences_translate("This collection already exists") ." !"; |
||
729 | return false; |
||
730 | } |
||
731 | |||
732 | $req = "insert into ".ABSENCES_COLLECTIONS_TBL." ( name, description, id_cat )"; |
||
733 | $req .= " values ('".$babDB->db_escape_string($tname)."', '" .$babDB->db_escape_string($description)."', '" .$babDB->db_escape_string($category). "')"; |
||
734 | $res = $babDB->db_query($req); |
||
735 | $id = $babDB->db_insert_id(); |
||
736 | |||
737 | return true; |
||
738 | } |
||
739 | |||
740 | |||
741 | /** |
||
742 | * |
||
743 | * @param int $vcid |
||
744 | * @param string $tname |
||
745 | * @param string $description |
||
746 | * @param int $category |
||
747 | */ |
||
748 | function absences_updateVacationCollection($vcid, $tname, $description, $category) |
||
749 | { |
||
750 | global $babBody, $babDB; |
||
751 | if( empty($tname)) |
||
752 | { |
||
753 | $babBody->msgerror = absences_translate("ERROR: You must provide a name")." !"; |
||
754 | return false; |
||
755 | } |
||
756 | |||
757 | |||
758 | $req = "select id from ".ABSENCES_COLLECTIONS_TBL." where name='".$babDB->db_escape_string($tname)."' and id!='".$babDB->db_escape_string($vcid)."'"; |
||
759 | $res = $babDB->db_query($req); |
||
760 | View Code Duplication | if( $res && $babDB->db_num_rows($res) > 0 ) |
|
761 | { |
||
762 | $babBody->msgerror = absences_translate("This collection already exists") ." !"; |
||
763 | return false; |
||
764 | } |
||
765 | |||
766 | $res = $babDB->db_query("update ".ABSENCES_COLLECTIONS_TBL." set name='".$babDB->db_escape_string($tname)."', description='".$babDB->db_escape_string($description)."', id_cat='".$babDB->db_escape_string($category)."' where id='".$babDB->db_escape_string($vcid)."'"); |
||
767 | |||
768 | return true; |
||
769 | } |
||
770 | |||
771 | |||
772 | View Code Duplication | function absences_beneficiariesUpdateProgress($id) |
|
773 | { |
||
774 | require_once dirname(__FILE__).'/utilit/right.ui.php'; |
||
775 | require_once dirname(__FILE__).'/utilit/right.act.php'; |
||
776 | |||
777 | $W = bab_Widgets(); |
||
778 | |||
779 | $right = new absences_Right($id); |
||
780 | |||
781 | $progress = $W->ProgressBar(); |
||
782 | |||
783 | absences_RightAct::updateCollectionsBeneficiaries($right, $progress, (array) bab_gp('collection', array())); |
||
784 | die(); |
||
785 | } |
||
786 | |||
787 | |||
788 | function absences_updateVacationPersonnelGroup() |
||
789 | { |
||
790 | global $babDB, $babBody; |
||
791 | |||
792 | $W = bab_Widgets(); |
||
793 | $progress = $W->ProgressBar(); |
||
794 | |||
795 | |||
796 | $groupid = bab_rp('groupid'); |
||
797 | $addmodify = bab_rp('addmodify'); |
||
798 | $idcol = bab_rp('idcol'); |
||
799 | $idsa = bab_rp('idsa'); |
||
800 | $id_sa_cet = bab_rp('id_sa_cet'); |
||
801 | $id_sa_recover = bab_rp('id_sa_recover'); |
||
802 | |||
803 | |||
804 | if( empty($groupid) ) |
||
805 | { |
||
806 | echo bab_toHtml(absences_translate("You must specify a group"), BAB_HTML_ALL); |
||
807 | return false; |
||
808 | } |
||
809 | |||
810 | if( !in_array($addmodify, array('add','modify')) ) |
||
811 | { |
||
812 | echo bab_toHtml(absences_translate("error"), BAB_HTML_ALL); |
||
813 | return false; |
||
814 | } |
||
815 | |||
816 | if( empty($idcol) && $addmodify == 'add' ) |
||
817 | { |
||
818 | echo bab_toHtml(absences_translate("You must specify a vacation collection"), BAB_HTML_ALL); |
||
819 | return false; |
||
820 | } |
||
821 | |||
822 | if( empty($idsa) ) |
||
823 | { |
||
824 | echo bab_toHtml(absences_translate("You must specify an approbation schema") , BAB_HTML_ALL); |
||
825 | return false; |
||
826 | } |
||
827 | |||
828 | |||
829 | $users = (array) bab_getGroupsMembers($groupid); |
||
830 | $total = count($users); |
||
831 | $pos = 1; |
||
832 | |||
833 | foreach($users as $user) |
||
834 | { |
||
835 | $agent = absences_Agent::getFromIdUser($user['id']); |
||
836 | |||
837 | if( $agent->exists() && $addmodify == 'modify') |
||
838 | { |
||
839 | if ($agent->id_sa != $idsa || $agent->id_sa_cet != $id_sa_cet || $agent->id_sa_recover != $id_sa_recover) |
||
840 | { |
||
841 | $wr = $agent->getRequestIterator()->count(); |
||
842 | |||
843 | if ($wr > 0) |
||
844 | { |
||
845 | // modification d'un membre du personnel avec des demandes en attente |
||
846 | // absences_updateVacationUser($arr['id_user'], $idsa); |
||
847 | |||
848 | echo bab_toHtml(sprintf(absences_translate( |
||
849 | '%s has not been modified because of %d waiting request', |
||
850 | '%s has not been modified because of %d waiting requests', $wr ), $agent->getName(), $wr) , BAB_HTML_ALL); |
||
851 | |||
852 | View Code Duplication | } else { |
|
853 | |||
854 | // modification d'un membre du personnel qui n'a pas de demande en attente |
||
855 | $babDB->db_query("update ".ABSENCES_PERSONNEL_TBL." set |
||
856 | id_sa='".$babDB->db_escape_string($idsa)."', |
||
857 | id_sa_cet=".$babDB->quote($id_sa_cet).", |
||
858 | id_sa_recover=".$babDB->quote($id_sa_recover)." |
||
859 | WHERE id_user=".$babDB->quote($user['id'])); |
||
860 | } |
||
861 | } |
||
862 | } |
||
863 | else if (!$agent->exists() && $addmodify == 'add') |
||
864 | { |
||
865 | // creation du nouveau membre du personnel |
||
866 | try { |
||
867 | $messages = array(); |
||
868 | absences_saveVacationPersonnel($user['id'], $idcol, $idsa, $id_sa_cet, $id_sa_recover, null, $messages); |
||
869 | |||
870 | foreach($messages as $m) |
||
871 | { |
||
872 | echo bab_toHtml($user['name'].' : '.$m, BAB_HTML_ALL); |
||
873 | } |
||
874 | |||
875 | |||
876 | } catch (Exception $e) |
||
877 | { |
||
878 | echo bab_toHtml($e->getMessage() , BAB_HTML_ALL); |
||
879 | } |
||
880 | } |
||
881 | |||
882 | |||
883 | $progress->updateProgress(($pos * 100) / $total, $agent->getName()); |
||
884 | $pos++; |
||
885 | } |
||
886 | |||
887 | $progress->updateProgress(100, absences_translate('Finished')); |
||
888 | die(); |
||
889 | } |
||
890 | |||
891 | |||
892 | /** |
||
893 | * |
||
894 | * @param int $vcid |
||
895 | */ |
||
896 | View Code Duplication | function absences_deleteVacationCollection($vcid) |
|
897 | { |
||
898 | global $babDB; |
||
899 | $bdel = true; |
||
900 | |||
901 | list($total) = $babDB->db_fetch_array($babDB->db_query("select count(id) as total from ".ABSENCES_PERSONNEL_TBL." where id_coll='".$babDB->db_escape_string($vcid)."'")); |
||
902 | if( $total > 0 ) |
||
903 | { |
||
904 | $bdel = false; |
||
905 | } |
||
906 | |||
907 | if( $bdel ) |
||
908 | { |
||
909 | $babDB->db_query("delete from ".ABSENCES_COLLECTIONS_TBL." where id='".$babDB->db_escape_string($vcid)."'"); |
||
910 | $babDB->db_query("delete from ".ABSENCES_COLL_TYPES_TBL." where id_coll='".$babDB->db_escape_string($vcid)."'"); |
||
911 | } |
||
912 | else |
||
913 | $babBody->msgerror = absences_translate("This vacation collection is used and can't be deleted") ." !"; |
||
914 | } |
||
915 | |||
916 | |||
917 | /** |
||
918 | * Remove vacation personnel |
||
919 | * @param unknown_type $items |
||
920 | */ |
||
921 | function confirmDeletePersonnel($items) |
||
922 | { |
||
923 | |||
924 | global $babDB; |
||
925 | |||
926 | $arr = explode(",", $items); |
||
927 | $cnt = count($arr); |
||
928 | for($i = 0; $i < $cnt; $i++) |
||
929 | { |
||
930 | $agent = absences_Agent::getFromIdUser($arr[$i]); |
||
931 | $agent->delete(); |
||
932 | bab_siteMap::clear($arr[$i]); |
||
933 | } |
||
934 | |||
935 | require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
||
936 | $url = bab_url::get_request('tg', 'idx'); |
||
937 | $url->location(); |
||
938 | } |
||
939 | |||
940 | |||
941 | |||
942 | |||
943 | /** |
||
944 | * Edit the agent-right link |
||
945 | * @param int $agent_right |
||
946 | */ |
||
947 | function absences_editAgentRight($agent_right) |
||
948 | { |
||
949 | $W = bab_Widgets(); |
||
950 | require_once dirname(__FILE__).'/utilit/agent_right.class.php'; |
||
951 | require_once dirname(__FILE__).'/utilit/agent.ui.php'; |
||
952 | require_once dirname(__FILE__).'/utilit/right.ui.php'; |
||
953 | require_once dirname(__FILE__).'/utilit/agent_right.ui.php'; |
||
954 | require_once dirname(__FILE__).'/utilit/changes.class.php'; |
||
955 | require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
||
956 | |||
957 | |||
958 | $agentRight = absences_AgentRight::getById($agent_right); |
||
959 | $agent = $agentRight->getAgent(); |
||
960 | $right = $agentRight->getRight(); |
||
961 | |||
962 | |||
963 | |||
964 | if (isset($_POST['agent_right'])) |
||
965 | { |
||
966 | $changes = new absences_Changes(); |
||
967 | $ar = $_POST['agent_right']; |
||
968 | |||
969 | if ( isset($ar['cancel']) ) |
||
970 | { |
||
971 | $url = bab_url::get_request('tg'); |
||
972 | $url->idx = 'rights'; |
||
973 | $url->idu = $agentRight->id_user; |
||
974 | $url->location(); |
||
975 | } |
||
976 | |||
977 | |||
978 | if( isset($ar['save'] )) |
||
979 | { |
||
980 | $date = $W->DatePicker(); |
||
981 | |||
982 | if ('right' === $ar['quantity_type']) { |
||
983 | $ar['quantity'] = ''; |
||
984 | } |
||
985 | |||
986 | $agentRightQuantity = $agentRight->getQuantityFromInput($ar['quantity']); |
||
987 | |||
988 | if (isset($agentRightQuantity)) { |
||
989 | |||
990 | if ('' === $agentRight->quantity && '' !== $agentRightQuantity) { |
||
991 | $changes->fromRightQuantityToAgentQuantity(); |
||
992 | } |
||
993 | |||
994 | if ('' !== $agentRight->quantity && '' === $agentRightQuantity) { |
||
995 | $changes->fromAgentQuantityToRightQuantity(); |
||
996 | } |
||
997 | |||
998 | $old_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit); |
||
999 | $agentRight->quantity = (string) $agentRightQuantity; |
||
1000 | $new_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit); |
||
1001 | |||
1002 | $changes->setQuantity($old_quantity, $new_quantity); |
||
1003 | |||
1004 | } |
||
1005 | |||
1006 | View Code Duplication | if (isset($ar['date_begin_valid']) && isset($ar['date_end_valid'])) |
|
1007 | { |
||
1008 | $date_begin_valid = $date->getISODate($ar['date_begin_valid']); |
||
1009 | $date_end_valid = $date->getISODate($ar['date_end_valid']); |
||
1010 | |||
1011 | $changes->setValidPeriod($agentRight->date_begin_valid, $agentRight->date_end_valid, $date_begin_valid, $date_end_valid); |
||
1012 | $agentRight->date_begin_valid = $date_begin_valid; |
||
1013 | $agentRight->date_end_valid = $date_end_valid; |
||
1014 | } |
||
1015 | |||
1016 | if (isset($ar['inperiod_start']) && isset($ar['inperiod_end'])) |
||
1017 | { |
||
1018 | $inperiod_start = $date->getISODate($ar['inperiod_start']); |
||
1019 | $inperiod_end = $date->getISODate($ar['inperiod_end']); |
||
1020 | |||
1021 | $changes->setInPeriod($agentRight->inperiod_start, $agentRight->inperiod_end, $inperiod_start, $inperiod_end); |
||
1022 | $changes->setValidOverlap($agentRight->validoverlap, $ar['validoverlap']); |
||
1023 | |||
1024 | $agentRight->inperiod_start = $inperiod_start; |
||
1025 | $agentRight->inperiod_end = $inperiod_end; |
||
1026 | $agentRight->validoverlap = $ar['validoverlap']; |
||
1027 | } |
||
1028 | |||
1029 | View Code Duplication | if (isset($ar['saving_begin']) && isset($ar['saving_end'])) |
|
1030 | { |
||
1031 | // CET |
||
1032 | $saving_begin = $date->getISODate($ar['saving_begin']); |
||
1033 | $saving_end = $date->getISODate($ar['saving_end']); |
||
1034 | |||
1035 | $changes->setSavingPeriod($agentRight->saving_begin, $agentRight->saving_end, $saving_begin, $saving_end); |
||
1036 | $agentRight->saving_begin = $saving_begin; |
||
1037 | $agentRight->saving_end = $saving_end; |
||
1038 | } |
||
1039 | |||
1040 | |||
1041 | $agentRight->save(); |
||
1042 | |||
1043 | $agentRight->addAgentMovement($agent, $changes, $ar['movement_comment']); |
||
1044 | |||
1045 | |||
1046 | |||
1047 | $url = bab_url::get_request('tg'); |
||
1048 | $url->idx = 'rights'; |
||
1049 | $url->idu = $agentRight->id_user; |
||
1050 | $url->location(); |
||
1051 | } |
||
1052 | } |
||
1053 | |||
1054 | |||
1055 | |||
1056 | |||
1057 | |||
1058 | |||
1059 | |||
1060 | |||
1061 | $page = $W->BabPage(); |
||
1062 | $page->addStyleSheet(absences_Addon()->getStylePath().'vacation.css'); |
||
1063 | |||
1064 | |||
1065 | |||
1066 | $page->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1067 | $page->addItemMenu("rights", absences_translate("User rights"), absences_addon()->getUrl()."vacadm&idx=rights&idu=".$agent->id_user); |
||
1068 | $page->addItemMenu("agentright", absences_translate("User right"), absences_addon()->getUrl()."vacadm&idx=agentright&ar=".bab_rp('ar')); |
||
1069 | |||
1070 | |||
1071 | |||
1072 | |||
1073 | $page->setTitle(sprintf(absences_translate('Right parameter only for %s'), $agent->getName())); |
||
1074 | |||
1075 | $agentCard = new absences_AgentCardFrame($agent); |
||
1076 | $agentCard->addClass('widget-bordered'); |
||
1077 | $agentCard->addClass('widget-centered'); |
||
1078 | $agentCard->setCanvasOptions($agentCard->Options()->width(70,'em')); |
||
1079 | |||
1080 | $page->addItem($agentCard); |
||
1081 | |||
1082 | |||
1083 | $rightCard = new absences_RightCardFrame($right); |
||
1084 | $rightCard->addClass('widget-bordered'); |
||
1085 | $rightCard->addClass('widget-centered'); |
||
1086 | $rightCard->setCanvasOptions($rightCard->Options()->width(70,'em')); |
||
1087 | |||
1088 | $page->addItem($rightCard); |
||
1089 | |||
1090 | |||
1091 | if ($message = $agentRight->getQuantityAlert()) |
||
1092 | { |
||
1093 | $rightCard->addItem($W->Icon($message, Func_Icons::STATUS_DIALOG_WARNING)); |
||
1094 | } |
||
1095 | |||
1096 | // liste des modification du solde par mois (droits variables par mois) |
||
1097 | |||
1098 | $dynrightCard = new absences_IncrementCardFrame($agentRight); |
||
1099 | $dynrightCard->addClass('widget-bordered'); |
||
1100 | $dynrightCard->addClass('widget-centered'); |
||
1101 | $dynrightCard->setCanvasOptions($rightCard->Options()->width(70,'em')); |
||
1102 | if ($dynrightCard->contain_rows) |
||
1103 | { |
||
1104 | $page->addItem($dynrightCard); |
||
1105 | } |
||
1106 | |||
1107 | |||
1108 | // liste des modification dynamiques du solde |
||
1109 | |||
1110 | $dynrightCard = new absences_DynamicRightCardFrame($agentRight); |
||
1111 | $dynrightCard->addClass('widget-bordered'); |
||
1112 | $dynrightCard->addClass('widget-centered'); |
||
1113 | $dynrightCard->setCanvasOptions($rightCard->Options()->width(70,'em')); |
||
1114 | if ($dynrightCard->contain_rows) |
||
1115 | { |
||
1116 | $page->addItem($dynrightCard); |
||
1117 | } |
||
1118 | |||
1119 | $editor = new absences_AgentRightEditor($agentRight); |
||
1120 | $page->addItem($editor); |
||
1121 | |||
1122 | $history = new absences_AgentRightMovementFrame($agentRight); |
||
1123 | if ($history->count) { |
||
1124 | $page->addItem($history); |
||
1125 | } |
||
1126 | |||
1127 | $page->displayHtml(); |
||
1128 | } |
||
1129 | |||
1130 | |||
1131 | |||
1132 | |||
1133 | |||
1134 | View Code Duplication | function absences_agentMovements($id_user) |
|
1135 | { |
||
1136 | require_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
1137 | require_once dirname(__FILE__).'/utilit/agent.ui.php'; |
||
1138 | |||
1139 | $babBody = bab_getInstance('babBody'); |
||
1140 | $agent = absences_Agent::getFromIdUser($id_user); |
||
1141 | $W = bab_Widgets(); |
||
1142 | |||
1143 | $card = new absences_AgentCardFrame($agent); |
||
1144 | |||
1145 | $card->addClass('widget-bordered'); |
||
1146 | $card->addClass('BabLoginMenuBackground'); |
||
1147 | |||
1148 | $list = new absences_AgentMovementList($agent); |
||
1149 | |||
1150 | $babBody->setTitle(absences_translate('User history')); |
||
1151 | |||
1152 | $babBody->babEcho($card->display($W->HtmlCanvas())); |
||
1153 | $babBody->babEcho($list->getHtml()); |
||
1154 | } |
||
1155 | |||
1156 | |||
1157 | |||
1158 | View Code Duplication | function absences_updateManagerVacationPersonnel($id_user) |
|
1159 | { |
||
1160 | $update = absences_updateVacationPersonnel($id_user); |
||
1161 | |||
1162 | if(true === $update) { |
||
1163 | return 'changeucol'; // vers la modification du regime |
||
1164 | } |
||
1165 | |||
1166 | if (false === $update) { |
||
1167 | return 'modp'; |
||
1168 | } |
||
1169 | |||
1170 | $url = bab_url::get_request('tg'); |
||
1171 | $url->idx = 'lper'; |
||
1172 | $url->location(); |
||
1173 | } |
||
1174 | |||
1175 | |||
1176 | |||
1177 | /* main */ |
||
1178 | bab_requireCredential(); |
||
1179 | $agent = absences_Agent::getCurrentUser(); |
||
1180 | |||
1181 | if( !$agent->isManager()) |
||
1182 | { |
||
1183 | $babBody->msgerror = absences_translate("Access denied"); |
||
1184 | return; |
||
1185 | } |
||
1186 | |||
1187 | $idx = bab_rp('idx', "menu"); |
||
1188 | |||
1189 | if( isset($_POST['add']) ) |
||
1190 | { |
||
1191 | switch($_POST['add']) |
||
1192 | { |
||
1193 | case 'addvt': |
||
1194 | |||
1195 | View Code Duplication | if(!saveVacationType(bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'))) |
|
1196 | $idx ='addvt'; |
||
1197 | |||
1198 | break; |
||
1199 | |||
1200 | case 'modvt': |
||
1201 | if(bab_rp('bdel', null)) |
||
1202 | { |
||
1203 | deleteVacationType(bab_rp('vtid')); |
||
1204 | } |
||
1205 | View Code Duplication | else if(!updateVacationType(bab_rp('vtid'), bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'))) |
|
1206 | { |
||
1207 | $idx ='addvt'; |
||
1208 | } |
||
1209 | break; |
||
1210 | |||
1211 | case 'addvc': |
||
1212 | if(!absences_saveVacationCollection(bab_rp('tname'), bab_rp('description'), bab_rp('category'))) |
||
1213 | { |
||
1214 | $idx ='addvc'; |
||
1215 | } |
||
1216 | break; |
||
1217 | |||
1218 | case 'modvc': |
||
1219 | |||
1220 | if(bab_rp('bdel', null)) |
||
1221 | { |
||
1222 | absences_deleteVacationCollection(bab_rp('vcid')); |
||
1223 | } |
||
1224 | else if(!absences_updateVacationCollection(bab_pp('vcid'), bab_pp('tname'), bab_pp('description'), bab_pp('category'))) |
||
1225 | { |
||
1226 | $idx ='addvc'; |
||
1227 | } |
||
1228 | break; |
||
1229 | |||
1230 | |||
1231 | case 'changeuser': |
||
1232 | |||
1233 | if (!empty($_POST['idp'])) { |
||
1234 | $idx = absences_updateManagerVacationPersonnel($_POST['idp']); |
||
1235 | } |
||
1236 | else { |
||
1237 | $idsa = bab_pp('idsa', 0); |
||
1238 | $id_sa_cet = bab_pp('id_sa_cet', 0); |
||
1239 | $id_sa_recover = bab_pp('id_sa_recover', 0); |
||
1240 | $emails = bab_pp('emails'); |
||
1241 | |||
1242 | try { |
||
1243 | |||
1244 | $messages = array(); |
||
1245 | if(!absences_saveVacationPersonnel(bab_pp('userid'), bab_pp('idcol'), $idsa, $id_sa_cet, $id_sa_recover, $emails, $messages)) |
||
1246 | { |
||
1247 | $idx ='addp'; |
||
1248 | } |
||
1249 | } catch (Exception $e) |
||
1250 | { |
||
1251 | $babBody->addError($e->getMessage()); |
||
1252 | $idx ='addp'; |
||
1253 | break; |
||
1254 | } |
||
1255 | |||
1256 | |||
1257 | if (!empty($messages)) |
||
1258 | { |
||
1259 | foreach($messages as $message) |
||
1260 | { |
||
1261 | $babBody->addNextPageMessage($message); |
||
1262 | } |
||
1263 | } |
||
1264 | |||
1265 | require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
||
1266 | |||
1267 | $url = bab_url::get_request('tg', 'pos', 'idcol', 'idsa'); |
||
1268 | $url->idx = 'lper'; |
||
1269 | $url->location(); |
||
1270 | } |
||
1271 | break; |
||
1272 | |||
1273 | |||
1274 | case 'changeucol': |
||
1275 | if (!absences_updateUserColl()) |
||
1276 | $idx = $add; |
||
1277 | break; |
||
1278 | |||
1279 | case 'modrbu': |
||
1280 | if (true === absences_updateVacationRightByUser( |
||
1281 | bab_pp('idu'), |
||
1282 | bab_pp('quantity'), |
||
1283 | bab_pp('comment') |
||
1284 | )) { |
||
1285 | |||
1286 | require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php'; |
||
1287 | |||
1288 | $url = bab_url::get_request('tg', 'idx', 'idu'); |
||
1289 | $url->location(); |
||
1290 | } |
||
1291 | break; |
||
1292 | } |
||
1293 | } |
||
1294 | else if( isset($_GET['action']) && $_GET['action'] == "Yes") |
||
1295 | { |
||
1296 | confirmDeletePersonnel($_GET['items']); |
||
1297 | $idx = "lper"; |
||
1298 | } |
||
1299 | |||
1300 | |||
1301 | |||
1302 | if ($agent->isInPersonnel()) |
||
1303 | { |
||
1304 | $babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser"); |
||
1305 | } |
||
1306 | |||
1307 | if( $agent->isEntityManager()) |
||
1308 | { |
||
1309 | $babBody->addItemMenu("entities", absences_translate("Delegate management"), absences_addon()->getUrl()."vacchart"); |
||
1310 | } |
||
1311 | |||
1312 | $babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu"); |
||
1313 | |||
1314 | |||
1315 | |||
1316 | switch($idx) |
||
1317 | { |
||
1318 | case "browu": |
||
1319 | include_once $babInstallPath."utilit/lusersincl.php"; |
||
1320 | bab_browseUsers(bab_rp('pos'), bab_rp('cb')); |
||
1321 | exit; |
||
1322 | break; |
||
1323 | case "browg": |
||
1324 | include_once $babInstallPath."utilit/grpincl.php"; |
||
1325 | browseGroups(bab_rp('cb')); |
||
1326 | exit; |
||
1327 | break; |
||
1328 | |||
1329 | View Code Duplication | case 'rights': |
|
0 ignored issues
–
show
|
|||
1330 | absences_listRightsByUser(bab_rp('idu')); |
||
1331 | |||
1332 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1333 | $babBody->addItemMenu("rights", absences_translate("User rights"), absences_addon()->getUrl()."vacadm&idx=rights&idu=".bab_rp('idu')); |
||
1334 | break; |
||
1335 | |||
1336 | case 'agentright': |
||
1337 | absences_editAgentRight(bab_rp('ar')); |
||
1338 | |||
1339 | break; |
||
1340 | |||
1341 | |||
1342 | View Code Duplication | case 'movement': |
|
1343 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1344 | $babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadm&idx=movement&idu=".bab_rp('idu')); |
||
1345 | absences_agentMovements(bab_rp('idu')); |
||
1346 | break; |
||
1347 | |||
1348 | |||
1349 | View Code Duplication | case "delu": |
|
1350 | $babBody->title = absences_translate("Delete users"); |
||
1351 | deleteVacationPersonnel( |
||
1352 | bab_rp('pos'), |
||
1353 | bab_rp('idcol'), |
||
1354 | bab_rp('idsa'), |
||
1355 | bab_rp('userids',array()) |
||
1356 | ); |
||
1357 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1358 | $babBody->addItemMenu("delu", absences_translate("Delete"), absences_addon()->getUrl()."vacadm&idx=delu"); |
||
1359 | break; |
||
1360 | |||
1361 | View Code Duplication | case "modp": |
|
1362 | $babBody->title = absences_translate("Modify user"); |
||
1363 | |||
1364 | absences_addVacationPersonnel($_REQUEST['idp']); |
||
1365 | |||
1366 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1367 | $babBody->addItemMenu("modp", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modp"); |
||
1368 | break; |
||
1369 | |||
1370 | View Code Duplication | case "addp": |
|
1371 | $babBody->title = absences_translate("Add users"); |
||
1372 | absences_addVacationPersonnel(); |
||
1373 | |||
1374 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1375 | $babBody->addItemMenu("addp", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addp"); |
||
1376 | break; |
||
1377 | |||
1378 | View Code Duplication | case 'changeucol': |
|
1379 | $babBody->title = sprintf(absences_translate("Change user collection for %s"), bab_getuserName($_POST['idp'])); |
||
1380 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1381 | $babBody->addItemMenu("changeucol", absences_translate("User collection"), absences_addon()->getUrl()."vacadm&idx=changeucol"); |
||
1382 | absences_changeucol($_POST['idp'],$_POST['idcol']); |
||
1383 | break; |
||
1384 | |||
1385 | View Code Duplication | case "addg": |
|
1386 | $babBody->title = absences_translate("Add/Modify users by group"); |
||
1387 | addGroupVacationPersonnel(); |
||
1388 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1389 | $babBody->addItemMenu("addg", absences_translate("Add/Modify"), absences_addon()->getUrl()."vacadm&idx=addg"); |
||
1390 | break; |
||
1391 | |||
1392 | case 'addg_progress': |
||
1393 | absences_updateVacationPersonnelGroup(); |
||
1394 | break; |
||
1395 | |||
1396 | case "lper": |
||
1397 | $babBody->title = absences_translate("Personnel"); |
||
1398 | |||
1399 | $pos = bab_rp('pos'); |
||
1400 | $chg = bab_rp('chg', null); |
||
1401 | |||
1402 | if( isset($chg)) |
||
1403 | { |
||
1404 | if( mb_strlen($pos) > 0 && $pos[0] == "-" ) |
||
1405 | $pos = mb_strlen($pos)>1? $pos[1]: ''; |
||
1406 | else |
||
1407 | $pos = "-" .$pos; |
||
1408 | } |
||
1409 | listVacationPersonnel(); |
||
1410 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1411 | |||
1412 | break; |
||
1413 | |||
1414 | // available balances export |
||
1415 | case 'abexport': |
||
1416 | $babBody->setTitle(absences_translate("Available balances export")); |
||
1417 | exportAvailableBalances(); |
||
1418 | $babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper"); |
||
1419 | $babBody->addItemMenu("abexport", absences_translate("Available balances export"), absences_addon()->getUrl()."vacadm&idx=abexport"); |
||
1420 | break; |
||
1421 | |||
1422 | case 'testexp': |
||
1423 | testExportBalances(); |
||
1424 | break; |
||
1425 | |||
1426 | |||
1427 | View Code Duplication | case "lcol": |
|
1428 | |||
1429 | $babBody->title = absences_translate("Vacations type's collections"); |
||
1430 | listVacationCollections(); |
||
1431 | $babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol"); |
||
1432 | $babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc"); |
||
1433 | break; |
||
1434 | |||
1435 | View Code Duplication | case "modvc": |
|
1436 | $babBody->title = absences_translate("Modify vacation type's collection"); |
||
1437 | |||
1438 | $vcid = bab_rp('vcid', bab_rp('id')); |
||
1439 | $what = bab_rp('what', 'modvc'); |
||
1440 | |||
1441 | addVacationCollection($vcid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('vtypeids', array()), bab_rp('category', 0)); |
||
1442 | |||
1443 | $babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol"); |
||
1444 | $babBody->addItemMenu("modvc", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modvc"); |
||
1445 | $babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc"); |
||
1446 | |||
1447 | break; |
||
1448 | |||
1449 | View Code Duplication | case "addvc": |
|
1450 | $babBody->title = absences_translate("Add vacation type's collection"); |
||
1451 | |||
1452 | $vcid = bab_rp('vcid', bab_rp('id')); |
||
1453 | $what = bab_rp('what', 'addvc'); |
||
1454 | |||
1455 | addVacationCollection($vcid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('vtypeids', array()), bab_rp('category', 0)); |
||
1456 | $babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol"); |
||
1457 | $babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc"); |
||
1458 | |||
1459 | break; |
||
1460 | |||
1461 | View Code Duplication | case "modvt": |
|
1462 | $babBody->title = absences_translate("Modify vacation type"); |
||
1463 | |||
1464 | $vtid = bab_rp('vtid', bab_rp('id')); |
||
1465 | $what = bab_rp('what', 'modvt'); |
||
1466 | |||
1467 | addVacationType($vtid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'), bab_rp('cbalance')); |
||
1468 | $babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt"); |
||
1469 | $babBody->addItemMenu("modvt", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modvt"); |
||
1470 | $babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt"); |
||
1471 | break; |
||
1472 | |||
1473 | View Code Duplication | case "addvt": |
|
1474 | $babBody->title = absences_translate("Add vacation type"); |
||
1475 | |||
1476 | $vtid = bab_rp('vtid', ''); |
||
1477 | $what = bab_rp('what', 'addvt'); |
||
1478 | |||
1479 | $babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt"); |
||
1480 | $babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt"); |
||
1481 | addVacationType($vtid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'), bab_rp('cbalance')); |
||
1482 | |||
1483 | break; |
||
1484 | |||
1485 | View Code Duplication | case "lvt": |
|
1486 | |||
1487 | $babBody->title = absences_translate("Vacations types"); |
||
1488 | $babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt"); |
||
1489 | $babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt"); |
||
1490 | listVacationTypes(); |
||
1491 | |||
1492 | break; |
||
1493 | |||
1494 | case 'export': |
||
1495 | require_once dirname(__FILE__).'/utilit/agent_export.class.php'; |
||
1496 | $excel = new absences_AgentXls(absences_Agent::getFromIdUser(bab_gp('id_user'))); |
||
1497 | die(); |
||
1498 | |||
1499 | case 'rightsexport': |
||
1500 | $babBody->setTitle(absences_translate('Export rights')); |
||
1501 | require_once dirname(__FILE__).'/utilit/right_export.class.php'; |
||
1502 | absences_exportForm(); |
||
1503 | break; |
||
1504 | |||
1505 | case "menu": |
||
1506 | default: |
||
1507 | $babBody->title = absences_translate("Vacations management"); |
||
1508 | admmenu(); |
||
1509 | break; |
||
1510 | } |
||
1511 | $babBody->setCurrentItemMenu($idx); |
||
1512 | bab_siteMap::setPosition('absences','User'); |
||
1513 | |||
1514 |
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.