absences_OptionsEditor::boolfield()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 9.4285
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 $GLOBALS['babInstallPath'].'utilit/ocapi.php';
26
bab_Widgets()->includePhpClass('Widget_Form');
27
28
29
class absences_OptionsEditor extends Widget_Form 
30
{
31
	private $I;
32
	
33
	public function __construct()
34
	{
35
		$W = bab_Widgets();
36
	
37
		parent::__construct(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
38
	
39
	
40
		$this->setName('options');
41
		$this->addClass('widget-bordered');
42
		$this->addClass('BabLoginMenuBackground');
43
		$this->addClass('widget-centered');
44
		$this->colon();
45
	
46
		$this->setCanvasOptions($this->Options()->width(70,'em'));
0 ignored issues
show
Bug introduced by
It seems like $this->Options()->width(70, 'em') targeting Widget_CanvasOptions::width() can also be of type double; however, Widget_Item::setCanvasOptions() does only seem to accept object<Widget_CanvasOptions>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
47
	
48
		$this->addFields();
49
		$this->loadFormValues();
50
	
51
		$this->addButtons();
52
		$this->setSelfPageHiddenFields();
53
	}
54
	
55
	
56
	
57
	protected function addFields()
58
	{
59
		$W = bab_Widgets();
60
		
61
		$this->addItem($W->Acl()->setTitle(absences_translate('Vacations mangers'))->setName('managers'));
62
		
63
		if (null !== bab_OCgetPrimaryOcId())
64
		{
65
			$this->addItem($this->id_chart());
66
		}
67
	
68
		$this->addItem($this->boolfield('chart_superiors_create_request', absences_translate("Allow delegated managers to create vacation requests for users in chart")));
69
		$this->addItem($this->boolfield('chart_superiors_set_rights', absences_translate("Allow delegated managers to update vacations rights for users in chart")));
70
		$this->addItem($this->boolfield('chart_superiors_user_edit', absences_translate("Allow delegated managers to update users settings for users in chart")));
71
		$this->addItem($this->boolfield('allow_mismatch', absences_translate("Allow users to create vacation requests with mismatch in total number of days")));
72
		$this->addItem($this->boolfield('workperiod_recover_request', absences_translate("Allow users to create workperiods request recovery")));
73
		$this->addItem($this->boolfield('display_personal_history', absences_translate("Users can access to the personal history")));
74
		$this->addItem($this->boolfield('modify_confirmed', absences_translate("Users can edit or delete confirmed requests")));
75
		$this->addItem($this->boolfield('modify_waiting', absences_translate("Users can edit or delete waiting requests")));
76
		$this->addItem($this->boolfield('email_manager_ondelete', absences_translate('Notify managers when a vacation request is deleted')));
77
		$this->addItem($this->boolfield('approb_email_defer', absences_translate('Use defered approbation email (daily notification)'),
78
		        absences_translate('The notification is sent every day between 12:00 and 13:00 to all approvers with waiting items')));
79
		$this->addItem($this->boolfield('user_add_email', absences_translate('Allow users to notify emails about the accepted vacations requests')));
80
81
		
82
		$this->addItem($W->Acl()->setTitle(absences_translate('Who can view the public calendar?'))->setName('public_planning'));		
83
		
84
		$this->addItem($this->boolfield('appliquant_email', absences_translate('Send an email to appliquant when a request is confirmed')));
85
		
86
		$this->addItem($W->LabelledWidget(
87
				absences_translate('Alert for waiting request not modified in more than'), 
88
				$W->LineEdit()->setSize(3)->setMaxSize(3),
89
				'approb_alert',
90
				absences_translate('Requests exceeding this period will be displayed in red in the email sent to approvers and displayed as bold in the manager waiting requests list, no additional mail are sent with this parameter'),
91
				absences_translate('days')
92
		));
93
		
94
		$this->addItem($this->boolfield('auto_approval', absences_translate('Auto approve if current user is responsible of the first approval step')));
95
		
96
		$this->addItem($W->LabelledWidget(
97
				absences_translate('Auto confirm waiting request not modified in more than'),
98
				$W->LineEdit()->setSize(3)->setMaxSize(3),
99
				'auto_confirm',
100
				null,
101
				absences_translate('days')
102
		));
103
		
104
		$this->addItem($W->LabelledWidget(
105
				absences_translate('End of avaibility for the recuperation in days after the working periode'),
106
				$W->LineEdit()->setSize(3)->setMaxSize(3),
107
				'end_recup',
108
				null,
109
				absences_translate('days')
110
		));
111
		
112
		$this->addItem($W->LabelledWidget(
113
				absences_translate("Anticipation delay for the recovery period deposit"),
114
				$W->LineEdit()->setSize(3)->setMaxSize(3),
115
				'delay_recovery',
116
				null,
117
				absences_translate('days')
118
		));
119
		
120
		$months = array(
121
			1 => absences_translate('January'),
122
			2 => absences_translate('February'),
123
			3 => absences_translate('March'),
124
			4 => absences_translate('April'),
125
			5 => absences_translate('May'),
126
			6 => absences_translate('June'),
127
			7 => absences_translate('July'),
128
			8 => absences_translate('August'),
129
			9 => absences_translate('September'),
130
			10 => absences_translate('October'),
131
			11 => absences_translate('November'),
132
			12 => absences_translate('December')
133
		);
134
135
		$this->addItem(
136
			$W->VBoxItems(
137
				$W->Label(absences_translate('The day when the periode is changing') . ' :')->addClass('widget-description'),
138
				$W->FlowItems(
139
					$W->LineEdit()->setSize(2)->setMaxSize(2)->setName('archivage_day'),
140
					$W->Select()->setOptions($months)->setName('archivage_month')
141
				)
142
			)
143
		);
144
		
145
		$this->addItem($this->boolfield('entity_planning', absences_translate("Allow chart members to access the entity planning of their main entity")));
146
		$this->addItem($this->boolfield('entity_planning_display_types', absences_translate("Display types and legend for all users in the entity planning, instead of entity responsible and managers only")));
147
		$this->addItem($this->boolfield('maintenance', absences_translate("Use mainteance mode, only managers can create or modify requests")));
148
		$this->addItem($this->organization_sync());
149
		$this->addItem($this->boolfield('sync_server', absences_translate("This server act as a synchronization server")));
150
		
151
		$client = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
152
		
153
		$client->addItem($W->LabelledWidget(
154
				absences_translate('Shared rights server url'),
155
				$W->LineEdit()->setSize(40)->setMaxSize(255),
156
				'sync_url'
157
		));
158
		
159
		$client->addItem($W->LabelledWidget(
160
				absences_translate('Nickname'),
161
				$W->LineEdit()->setSize(20)->setMaxSize(255),
162
				'sync_nickname'
163
		));
164
		
165
		$client->addItem($W->LabelledWidget(
166
				absences_translate('Password'),
167
				$W->LineEdit()->setSize(20)->setMaxSize(255),
168
				'sync_password'
169
		));
170
		
171
		$this->addItem($W->Section(absences_translate('This server act as a synchronization client'), $client)->setFoldable(true, true));
172
	}
173
	
174
	
175
	
176
	protected function organization_sync()
177
	{
178
	    require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
179
	    $W = bab_Widgets();
180
	    
181
	    $initUrl = bab_url::get_request('tg');
182
	    $initUrl->idx = 'init';
183
	    
184
	    return $W->FlowItems(
185
	        $this->boolfield('organization_sync', absences_translate("Synchronize organizations with directory entry.")),
186
	        $W->Link(absences_translate('Initialize all personnel members'), $initUrl->toString())->setOpenMode(Widget_Link::OPEN_POPUP)
187
	    )->setVerticalAlign('middle')->setHorizontalSpacing(.5, 'em');
188
	}
189
	
190
	
191
	
192 View Code Duplication
	protected function id_chart()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
193
	{
194
		
195
		$W = bab_Widgets();
196
		$select = $W->Select();
197
198
		$arr = bab_OCGetGroupDirOrgCharts();
199
		$select->setOptions($arr);
200
		
201
		// ne pas permettre une valeur vide car les anciennes version n'avais pas ce parametre
202
		// mais utilisais malgre tout l'organigramme
203
		$select->setValue(bab_OCgetPrimaryOcId());
204
		
205
		return $W->LabelledWidget(absences_translate('Organization chart used for delegated management'), $select, __FUNCTION__);
206
	}
207
	
208
	
209
	protected function boolfield($name, $title, $description = null)
210
	{
211
		$W = bab_Widgets();
212
		return $W->LabelledWidget($title, $W->CheckBox(), $name, $description);
213
	}
214
215
	
216
	protected function loadFormValues()
217
	{
218
		global $babDB;
219
		
220
		$req = "SELECT * FROM absences_options";
221
		$values = $babDB->db_fetch_assoc($babDB->db_query($req));
222
		
223
		require_once $GLOBALS['babInstallPath'].'admin/acl.php';
224
		$values['managers'] = aclGetRightsString('absences_managers_groups', 1);
225
		$values['public_planning'] = aclGetRightsString('absences_public_planning_groups', 1);
226
		
227
		$this->setValues($values, array('options'));
228
	}
229
	
230
	
231 View Code Duplication
	protected function addButtons()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
232
	{
233
		$W = bab_Widgets();
234
	
235
		$button = $W->FlowItems(
236
				$W->SubmitButton()->setName('save')->setLabel(absences_translate('Save'))
237
		)->setSpacing(1,'em');
238
	
239
		$this->addItem($button);
240
	}
241
}
242