Completed
Push — master ( c3d86a...9979ee )
by Paul
07:00
created

absences_ManagerMenu::getFrame()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 17
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
//-------------------------------------------------------------------------
3
// OVIDENTIA http://www.ovidentia.org
4
// Ovidentia is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation; either version 2, or (at your option)
7
// any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
// See the GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17
// USA.
18
//-------------------------------------------------------------------------
19
/**
20
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
21
 * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
22
 */
23
24
bab_functionality::includeOriginal('Icons');
25
26
27
class absences_ManagerMenu
28
{
29
	protected function category($name)
30
	{
31
		$W = bab_Widgets();
32
33
		return $W->Section(
34
				$name,
35
				$W->VBoxItems()
36
				->setHorizontalSpacing(6, 'px')->setVerticalSpacing(1, 'em')
37
		)
38
		->setFoldable(false);
39
	}
40
41
	protected function category_settings()
42
	{
43
		$W = bab_Widgets();
44
		$cat = $this->category(absences_translate('Settings'));
45
46
		$cat->addItem(
47
			$W->Link(
48
				$W->Icon(absences_translate("Vacations types"), Func_Icons::ACTIONS_VIEW_LIST_TEXT),
49
				absences_addon()->getUrl()."vacadm&idx=lvt"
50
			)
51
		);
52
53
54
		$cat->addItem(
55
				$W->Link(
56
						$W->Icon(absences_translate("Collections"), Func_Icons::ACTIONS_VIEW_LIST_TEXT),
57
						absences_addon()->getUrl()."vacadm&idx=lcol"
58
				)
59
		);
60
61
62
		$cat->addItem(
63
				$W->Link(
64
						$W->Icon(absences_translate("Personnel members"), Func_Icons::ACTIONS_USER_GROUP_PROPERTIES),
65
						absences_addon()->getUrl()."vacadm&idx=lper"
66
				)
67
		);
68
69
70
		$cat->addItem(
71
				$W->Link(
72
						$W->Icon(absences_translate("Workdays types entitling recovery"), Func_Icons::APPS_PREFERENCES_DATE_TIME_FORMAT),
73
						absences_addon()->getUrl()."workperiod_type"
74
				)
75
		);
76
77
78 View Code Duplication
		if (absences_getVacationOption('sync_server'))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
79
		{
80
			$cat->addItem(
81
					$W->Link(
82
							$W->Icon(absences_translate("Configure the shared vacation rights"), Func_Icons::APPS_PREFERENCES_WEBSERVICES),
83
							absences_addon()->getUrl()."sync_server"
84
					)
85
			);
86
		}
87
88 View Code Duplication
		if (absences_getVacationOption('sync_url'))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
89
		{
90
			$cat->addItem(
91
					$W->Link(
92
							$W->Icon(absences_translate("Configure the synchronized rights"), Func_Icons::APPS_PREFERENCES_WEBSERVICES),
93
							absences_addon()->getUrl()."sync_client"
94
					)
95
			);
96
		}
97
98
99
		$WorkingHours = bab_functionality::get('WorkingHours');
100
		if ($WorkingHours instanceof Func_WorkingHours_Workschedules)
0 ignored issues
show
Bug introduced by
The class Func_WorkingHours_Workschedules does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
101
		{
102
			$cat->addItem(
103
					$W->Link(
104
							$W->Icon(absences_translate("Configure the works schedules"), Func_Icons::APPS_PREFERENCES_CALENDAR),
105
							$WorkingHours->getProfileListUrl()
106
					)
107
			);
108
		}
109
110
111
		
112
		$cat->addItem(
113
				$W->Link(
114
						$W->Icon(absences_translate("Plannings"), Func_Icons::APPS_CALENDAR),
115
						absences_addon()->getUrl()."planning&idx=list"
116
				)
117
		);
118
		
119
120
121
122
	    $cat->addItem(
123
	        $W->Link(
124
	            $W->Icon(absences_translate("Organizations"), Func_Icons::APPS_GROUPS),
125
	            absences_addon()->getUrl()."organizations"
126
	        )
127
	    );
128
129
130
		return $cat;
131
	}
132
133
134
	protected function category_rights()
135
	{
136
		$W = bab_Widgets();
137
		$cat = $this->category(absences_translate('Vacation rights'));
138
139
		$cat->addItem(
140
				$W->Link(
141
						$W->Icon(absences_translate("Vacations rights"), Func_Icons::APPS_VACATIONS),
142
						absences_addon()->getUrl()."vacadma&idx=lrig"
143
				)
144
		);
145
146
		$cat->addItem(
147
				$W->Link(
148
						$W->Icon(absences_translate("Rights groups"), Func_Icons::ACTIONS_LIST_ADD),
149
						absences_addon()->getUrl()."vacadma&idx=rgroup"
150
				)
151
		);
152
153
		$cat->addItem(
154
				$W->Link(
155
						$W->Icon(absences_translate("Rights renewal by years"), Func_Icons::ACTIONS_VIEW_CALENDAR_TIMELINE),
156
						absences_addon()->getUrl()."vacadma&idx=copy"
157
				)
158
		);
159
160
161
		$cat->addItem(
162
				$W->Link(
163
						$W->Icon(absences_translate("Archive rights"), Func_Icons::ACTIONS_ARCHIVE_CREATE),
164
						absences_addon()->getUrl()."archive&idx=right"
165
				)
166
		);
167
168
169
		$cat->addItem(
170
				$W->Link(
171
						$W->Icon(absences_translate("Sort rights"), Func_Icons::ACTIONS_ARROW_DOWN_DOUBLE),
172
						absences_addon()->getUrl()."sort&idx=right"
173
				)
174
		);
175
176
		return $cat;
177
	}
178
179
	protected function category_requests()
180
	{
181
		$W = bab_Widgets();
182
		$cat = $this->category(absences_translate('Users requests'));
183
184
		$cat->addItem(
185
				$W->Link(
186
						$W->Icon(absences_translate("Vacations requests"), Func_Icons::ACTIONS_VIEW_LIST_DETAILS),
187
						absences_addon()->getUrl()."vacadmb&idx=lreq"
188
				)
189
		);
190
191
		$cat->addItem(
192
				$W->Link(
193
						$W->Icon(absences_translate("Waiting requests"), Func_Icons::APPS_APPROBATIONS),
194
						absences_addon()->getUrl()."waiting"
195
				)
196
		);
197
198
		$cat->addItem(
199
				$W->Link(
200
						$W->Icon(absences_translate("Working days entitling recovery"), Func_Icons::ACTIONS_VIEW_CALENDAR_WORKWEEK),
201
						absences_addon()->getUrl()."vacadmwd"
202
				)
203
		);
204
205
		$cat->addItem(
206
				$W->Link(
207
						$W->Icon(absences_translate("Time saving accounts deposits"), Func_Icons::ACTIONS_VIEW_HISTORY),
208
						absences_addon()->getUrl()."vacadmcet"
209
				)
210
		);
211
212
		$cat->addItem(
213
				$W->Link(
214
						$W->Icon(absences_translate("Archive requests"), Func_Icons::ACTIONS_ARCHIVE_CREATE),
215
						absences_addon()->getUrl()."archive&idx=request"
216
				)
217
		);
218
		
219 View Code Duplication
		if (bab_isAccessValid('absences_search_absences_groups', 1)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
220
    		$cat->addItem(
221
    		    $W->Link(
222
    		        $W->Icon(absences_translate("Search in all absences"), Func_Icons::ACTIONS_EDIT_FIND),
223
    		        absences_addon()->getUrl()."search"
224
    	        )
225
    	    );
226
		}
227
228
229
		return $cat;
230
	}
231
	
232
	
233
	
234
	
235
	
236
	protected function category_export()
237
	{
238
	    $W = bab_Widgets();
239
	    $cat = $this->category(absences_translate('Exports'));
240
	    
241
	    
242
	    $cat->addItem(
243
	            $W->Link(
244
	                    $W->Icon(absences_translate("Vacation requests exports"), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET),
245
	                    absences_addon()->getUrl()."exportvac&idx=reqx"
246
	            )
247
	    );
248
	    
249
	    
250
	    $cat->addItem(
251
	            $W->Link(
252
	                    $W->Icon(absences_translate("Vacation requests Sage exports"), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET),
253
	                    absences_addon()->getUrl()."exportvac&idx=sage"
254
	            )
255
	    );
256
	    
257
	    
258
	    $cat->addItem(
259
	            $W->Link(
260
	                    $W->Icon(absences_translate("Available balances export"), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET),
261
	                    absences_addon()->getUrl()."vacadm&idx=abexport"
262
	            )
263
	    );
264
	    
265
	    
266
	    $cat->addItem(
267
	            $W->Link(
268
	                    $W->Icon(absences_translate("Download statistics"), Func_Icons::MIMETYPES_OFFICE_SPREADSHEET),
269
	                    absences_addon()->getUrl()."statistics&idx=filter"
270
	            )
271
	    );
272
	    
273
	    
274
	    return $cat;
275
	}
276
277
278
	public function getFrame()
279
	{
280
		$W = bab_Widgets();
281
282
		$frame = $W->Frame()
283
			->setLayout($W->FlowLayout()->setVerticalAlign('top')->setSpacing(5, 'em'))
284
			->addClass(Func_Icons::ICON_LEFT_24)
285
			->addClass('BabLoginMenuBackground')
286
			->addClass('widget-bordered');
287
288
		$frame->addItem($this->category_settings());
289
		$frame->addItem($this->category_rights());
290
		$frame->addItem($this->category_requests());
291
		$frame->addItem($this->category_export());
292
293
		return $frame;
294
	}
295
}