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__).'/functions.php'; |
26
|
|
|
require_once dirname(__FILE__).'/utilit/statistics.class.php'; |
27
|
|
|
include_once dirname(__FILE__).'/utilit/agent.class.php'; |
28
|
|
|
include_once dirname(__FILE__).'/utilit/statistics.ui.php'; |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/* main */ |
32
|
|
|
bab_requireCredential(); |
33
|
|
|
$agent = absences_Agent::getCurrentUser(); |
34
|
|
|
if( !$agent->isManager()) |
35
|
|
|
{ |
36
|
|
|
$babBody->msgerror = absences_translate("Access denied"); |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function absence_FilterStatistics() |
41
|
|
|
{ |
42
|
|
|
require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php'; |
43
|
|
|
require_once dirname(__FILE__).'/utilit/organization.class.php'; |
44
|
|
|
$resOrganization = new absences_OrganizationIterator(); |
45
|
|
|
|
46
|
|
View Code Duplication |
if (0 === $resOrganization->count()) { |
|
|
|
|
47
|
|
|
|
48
|
|
|
// nothing to filter on, redirect to statistics |
49
|
|
|
|
50
|
|
|
$url = bab_url::get_request('tg'); |
51
|
|
|
$url->idx = 'types'; |
52
|
|
|
$url->location(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$W = bab_Widgets(); |
56
|
|
|
$page = $W->BabPage(); |
57
|
|
|
$page->addStyleSheet(absences_Addon()->getStylePath().'vacation.css'); |
58
|
|
|
|
59
|
|
|
$page->setTitle(absences_translate('Statistics')); |
60
|
|
|
|
61
|
|
|
$editor = new absences_StatisticsEditor(); |
62
|
|
|
|
63
|
|
|
$page->addItem($editor); |
64
|
|
|
$page->displayHtml(); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
$idx = bab_rp('idx', "types"); |
70
|
|
|
|
71
|
|
|
switch($idx) |
72
|
|
|
{ |
73
|
|
|
case 'filter': |
74
|
|
|
absence_FilterStatistics(); |
75
|
|
|
break; |
76
|
|
|
|
77
|
|
|
case 'types': |
78
|
|
|
new absences_StatisticsXls(bab_rp('filter', array())); |
79
|
|
|
die(); |
80
|
|
|
break; |
81
|
|
|
} |
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.