vacadma.php ➔ absences_getUsersFromGroup()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
c 0
b 0
f 0
nc 4
nop 2
dl 0
loc 19
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
include_once dirname(__FILE__).'/functions.php';
26
include_once dirname(__FILE__).'/utilit/vacincl.php';
27
include_once dirname(__FILE__).'/utilit/vacfixedincl.php';
28
require_once dirname(__FILE__).'/utilit/right.class.php';
29
include_once dirname(__FILE__).'/utilit/agent.class.php';
30
31
32
33
function listVacationRigths($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery)
34
{
35
	global $babBody;
36
	require_once dirname(__FILE__).'/utilit/rightlist.ui.php';
37
38
	if ($recovery) {
39
		$babBody->setTitle(absences_translate("Recovery rights"));
40
	}	
41
	else if ($archived) {
42
		$babBody->setTitle(absences_translate("Archived vacations rights"));
43
	} else {
44
		$babBody->setTitle(absences_translate("Vacations rights"));
45
	}
46
		
47
	$babBody->babecho(absences_rightListMenu());
48
	
49
	$name = bab_rp('name');
50
51
	$temp = new absences_RightList($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery, $name);
52
	$babBody->babecho(	bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "vrightslist"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
53
	return $temp->count;
54
55
}
56
57
58
59
function absences_choseBeneficiariesMethod($id)
60
{
61
	bab_functionality::includeOriginal('Icons');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class bab_functionality as the method includeOriginal() does only exist in the following sub-classes of bab_functionality: Func_Archive, Func_Archive_Zip, Func_Archive_Zip_ZipArchive, Func_Archive_Zip_Zlib, Func_CalendarBackend, Func_CalendarBackend_Ovi, Func_ContextActions, Func_ContextActions_Article, Func_ContextActions_ArticleTopic, Func_Home, Func_Home_Ovidentia, Func_Icons, Func_Icons_Default, Func_Ovml, Func_Ovml_Container, Func_Ovml_Container_Addon, Func_Ovml_Container_Article, Func_Ovml_Container_ArticleCategories, Func_Ovml_Container_ArticleCategory, Func_Ovml_Container_ArticleCategoryNext, Func_Ovml_Container_ArticleCategoryPrevious, Func_Ovml_Container_ArticleFiles, Func_Ovml_Container_ArticleNext, Func_Ovml_Container_ArticlePrevious, Func_Ovml_Container_ArticleTopic, Func_Ovml_Container_ArticleTopicNext, Func_Ovml_Container_ArticleTopicPrevious, Func_Ovml_Container_ArticleTopics, Func_Ovml_Container_Articles, Func_Ovml_Container_ArticlesHomePages, Func_Ovml_Container_CalendarCategories, Func_Ovml_Container_CalendarEventDomains, Func_Ovml_Container_CalendarEvents, Func_Ovml_Container_CalendarGroupEvents, Func_Ovml_Container_CalendarResourceEvents, Func_Ovml_Container_CalendarUserEvents, Func_Ovml_Container_Calendars, Func_Ovml_Container_DbDirectories, Func_Ovml_Container_DbDirectory, Func_Ovml_Container_DbDirectoryAcl, Func_Ovml_Container_DbDirectoryEntry, Func_Ovml_Container_DbDirectoryEntryFields, Func_Ovml_Container_DbDirectoryFields, Func_Ovml_Container_DbDirectoryMemberFields, Func_Ovml_Container_DbDirectoryMembers, Func_Ovml_Container_Delegation, Func_Ovml_Container_DelegationAdministrators, Func_Ovml_Container_DelegationItems, Func_Ovml_Container_DelegationManaged, Func_Ovml_Container_Delegations, Func_Ovml_Container_DelegationsCategories, Func_Ovml_Container_DelegationsCategory, Func_Ovml_Container_DelegationsManaged, Func_Ovml_Container_Faq, Func_Ovml_Container_FaqNext, Func_Ovml_Container_FaqPrevious, Func_Ovml_Container_FaqQuestion, Func_Ovml_Container_FaqQuestionNext, Func_Ovml_Container_FaqQuestionPrevious, Func_Ovml_Container_FaqQuestions, Func_Ovml_Container_FaqSubCategories, Func_Ovml_Container_FaqSubCategory, Func_Ovml_Container_Faqs, Func_Ovml_Container_File, Func_Ovml_Container_FileFields, Func_Ovml_Container_FileNext, Func_Ovml_Container_FilePrevious, Func_Ovml_Container_Files, Func_Ovml_Container_Folder, Func_Ovml_Container_FolderNext, Func_Ovml_Container_FolderPrevious, Func_Ovml_Container_Folders, Func_Ovml_Container_Forum, Func_Ovml_Container_ForumNext, Func_Ovml_Container_ForumPrevious, Func_Ovml_Container_Forums, Func_Ovml_Container_IfEqual, Func_Ovml_Container_IfGreaterThan, Func_Ovml_Container_IfGreaterThanOrEqual, Func_Ovml_Container_IfIsSet, Func_Ovml_Container_IfLessThan, Func_Ovml_Container_IfLessThanOrEqual, Func_Ovml_Container_IfNotEqual, Func_Ovml_Container_IfNotIsSet, Func_Ovml_Container_IfUserMemberOfGroups, Func_Ovml_Container_Multipages, Func_Ovml_Container_ObjectsInfo, Func_Ovml_Container_OrgPathToEntity, Func_Ovml_Container_OrgUserEntities, Func_Ovml_Container_OvmlArray, Func_Ovml_Container_OvmlArrayFields, Func_Ovml_Container_OvmlSoap, Func_Ovml_Container_ParentsArticleCategory, Func_Ovml_Container_Post, Func_Ovml_Container_PostFiles, Func_Ovml_Container_RecentArticles, Func_Ovml_Container_RecentComments, Func_Ovml_Container_RecentFaqQuestions, Func_Ovml_Container_RecentFiles, Func_Ovml_Container_RecentPosts, Func_Ovml_Container_RecentThreads, Func_Ovml_Container_SitemapCustomNode, Func_Ovml_Container_SitemapEntries, Func_Ovml_Container_SitemapEntry, Func_Ovml_Container_SitemapPath, Func_Ovml_Container_Soap, Func_Ovml_Container_SubFolders, Func_Ovml_Container_Tags, Func_Ovml_Container_Thread, Func_Ovml_Container_TmProjects, Func_Ovml_Container_TmSpaces, Func_Ovml_Container_TmTaskFields, Func_Ovml_Container_TmTasks, Func_Ovml_Container_WaitingArticles, Func_Ovml_Container_WaitingComments, Func_Ovml_Container_WaitingFiles, Func_Ovml_Container_WaitingPosts, Func_Ovml_Function, Func_Ovml_Function_AOAddition, Func_Ovml_Function_AODivision, Func_Ovml_Function_AOModulus, Func_Ovml_Function_AOMultiplication, Func_Ovml_Function_AOSubtraction, Func_Ovml_Function_AddStyleSheet, Func_Ovml_Function_Addon, Func_Ovml_Function_Ajax, Func_Ovml_Function_ArticleTree, Func_Ovml_Function_CurrentNode, Func_Ovml_Function_FileTree, Func_Ovml_Function_Get, Func_Ovml_Function_GetCookie, Func_Ovml_Function_GetCsrfProtectToken, Func_Ovml_Function_GetCurrentAdmGroup, Func_Ovml_Function_GetLanguage, Func_Ovml_Function_GetPageTitle, Func_Ovml_Function_GetPath, Func_Ovml_Function_GetSelectedSkinPath, Func_Ovml_Function_GetSessionVar, Func_Ovml_Function_GetVar, Func_Ovml_Function_Header, Func_Ovml_Function_IfNotIsSet, Func_Ovml_Function_Include, Func_Ovml_Function_NextArticle, Func_Ovml_Function_Post, Func_Ovml_Function_PreviousArticle, Func_Ovml_Function_PreviousOrNextArticle, Func_Ovml_Function_PutArray, Func_Ovml_Function_PutSoapArray, Func_Ovml_Function_PutVar, Func_Ovml_Function_Recurse, Func_Ovml_Function_Request, Func_Ovml_Function_SetCookie, Func_Ovml_Function_SetSessionVar, Func_Ovml_Function_SitemapCustomNodeId, Func_Ovml_Function_SitemapMenu, Func_Ovml_Function_SitemapPosition, Func_Ovml_Function_SitemapUrl, Func_Ovml_Function_Translate, Func_Ovml_Function_UrlContent, Func_Ovml_Function_WebStat, Func_PortalAuthentication, Func_PortalAuthentication_AuthOvidentia, Func_PwdComplexity, Func_PwdComplexity_DefaultPortal, Func_SearchUi, Func_SitemapDynamicNode, Func_SitemapDynamicNode_Topic, Func_UserEditor, Func_WorkingHours, Func_WorkingHours_Ovidentia, Ovml_Container_Sitemap, bab_ArithmeticOperator, bab_Ovml_Container_Operator, bab_rgp. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
62
	$W = bab_Widgets();
63
	
64
	$page = $W->BabPage();
65
	$page->setTitle(absences_translate('Vacation right beneficiaries'));
66
	$right = new absences_Right($id);
67
	$frame = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1,'em'));
68
	$page->addItem($frame);
69
	$frame->addClass('widget-bordered');
70
	$frame->addClass('BabLoginMenuBackground');
71
	$frame->addClass('widget-centered');
72
	$frame->setCanvasOptions($frame->Options()->width(60,'em'));
0 ignored issues
show
Bug introduced by
It seems like $frame->Options()->width(60, '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...
73
	
74
	$frame->addItem($W->Title($right->description, 4));
75
	
76
	$I = $right->getAgentRightIterator();
77
	
78
	if (0 === $I->count())
79
	{
80
		$frame->addItem($W->Label(absences_translate('This right has no beneficiaries, please use collections or personnel members to add beneficiaries to the vacation right')));
81
	}
82
	
83
	$buttons = $W->FlowLayout()->setSpacing(2,'em');
84
	$frame->addItem($buttons);
85
	
86
	$buttons->addItem(
87
		$W->Link(
88
			$W->Button()->addItem($W->Icon(absences_translate('By collections'), Func_Icons::ACTIONS_USER_GROUP_PROPERTIES)),
89
			absences_addon()->getUrl().'vacadma&idx=lvrc&idvr='.$id
90
		)
91
	);
92
	
93
	$buttons->addItem(
94
			$W->Link(
95
					$W->Button()->addItem($W->Icon(absences_translate('By users'), Func_Icons::ACTIONS_USER_PROPERTIES)),
96
					absences_addon()->getUrl().'vacadma&idx=lvrp&idvr='.$id
97
			)
98
	);
99
	
100
	
101
	$page->displayHtml();
102
}
103
104
105
106
107
function absences_addModifyVacationRight($id = false, $from = false)
108
{
109
	
110
	require_once dirname(__FILE__).'/utilit/right.ui.php';
111
	require_once dirname(__FILE__).'/utilit/right.act.php';
112
	
113
	
114
	if (isset($_POST['right']))
115
	{
116
		if ( isset($_POST['right']['cancel']) )
117
		{
118
			absences_RightAct::redirect();
119
		}
120
		
121
		
122
		if( isset($_POST['right']['save'] ))
123
		{
124
			absences_RightAct::save();
125
		}
126
		
127
		if( isset($_POST['right']['delete']))
128
		{
129
			deleteVacationRight($_POST['right']['id']);
130
		}
131
		
132
		
133
	}
134
	
135
	$W = bab_Widgets();
136
	
137
	$page = $W->BabPage();
138
	$right = null;
139
	
140
	if ($id)
141
	{
142
		$right = new absences_Right($id);
143
		$page->setTitle(absences_translate('Edit vacation right'));
144
		$editor = new absences_RightEditor($right);
145
	} else {
146
	    
147
	    if ($from) {
148
	        $right = new absences_Right($from);
149
	    }
150
	    
151
		$page->setTitle(absences_translate('Create vacation right'));
152
		$editor = new absences_CreateRightEditor($right);
153
	}
154
	
155
	
156
	$page->addItem($editor);
157
	
158
	
159
	$page->displayHtml();
160
}
161
162
163
164
165
166
167
function absences_fixedRightUpdate($id)
168
{
169
	
170
	$W = bab_Widgets();
171
	
172
	$page = $W->BabPage();
173
	
174
	$right = new absences_Right($id);
175
	
176
	
177
	if (!$right->getRow())
178
	{
179
		throw new Exception(absences_translate('The vacation right does not exists'));
180
	}
181
	
182
	if (absences_Right::FIXED !== $right->getKind())
183
	{
184
		throw new Exception(absences_translate('The vacation right is not fixed'));
185
	}
186
	
187
	
188
	$page->setTitle(sprintf(absences_translate('Update requests for the fixed vacation right "%s"'), $right->description));
189
	
190
	$nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next')));
191
	
192
	$page->addItem(
193
		$W->Frame()
194
		->setCanvasOptions($page->Options()->width(70,'em'))
0 ignored issues
show
Bug introduced by
It seems like $page->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...
195
		->addClass('widget-bordered')
196
		->addClass('BabLoginMenuBackground')
197
		->addClass('widget-centered')
198
		->addItem(
199
			$W->ProgressBar()
200
				->setTitle(absences_translate('Process beneficiaries list'))
201
				->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'fixedud_progress'))
202
				->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lrig'), $nextbutton)
203
		)
204
		->addItem($nextbutton)
205
	);
206
	
207
	
208
	$page->displayHtml();
209
}
210
211
212
213
214
function absences_fixedRightUpdateProgress($id)
215
{
216
	require_once dirname(__FILE__).'/utilit/right.ui.php';
217
	require_once dirname(__FILE__).'/utilit/right.act.php';
218
	
219
	$W = bab_Widgets();
220
	
221
	$right = new absences_Right($id);
222
	
223
	if (absences_Right::FIXED !== $right->getKind())
224
	{
225
		throw new Exception(absences_translate('The vacation right is not fixed'));
226
	}
227
	
228
	$progress = $W->ProgressBar();
229
	
230
	absences_RightAct::updateFixed($right, $progress);
231
	die();
232
}
233
234
235
236 View Code Duplication
function absences_beneficiariesUpdateProgress($id)
0 ignored issues
show
Duplication introduced by
This function 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...
Best Practice introduced by
The function absences_beneficiariesUpdateProgress() has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L772-785) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
237
{
238
	require_once dirname(__FILE__).'/utilit/right.ui.php';
239
	require_once dirname(__FILE__).'/utilit/right.act.php';
240
	
241
	$W = bab_Widgets();
242
	
243
	$right = new absences_Right($id);
244
	
245
	$progress = $W->ProgressBar();
246
	
247
	absences_RightAct::updateCollectionsBeneficiaries($right, $progress, (array) bab_gp('collection', array()));
248
	die();
249
}
250
251
252
253
254
255
/**
256
 * 
257
 * @param int $id_right
258
 * @param string $next_idx
259
 */
260
function absences_userRightReport($id_right, $next_idx)
261
{
262
	require_once dirname(__FILE__).'/utilit/collection.class.php';
263
	$W = bab_Widgets();
264
265
	$page = $W->BabPage();
266
267
	$right = new absences_Right($id_right);
268
	
269
	if (!$right->getRow())
270
	{
271
		throw new Exception(absences_translate('The vacation right does not exists'));
272
	}
273
274
275
276
	$page->setTitle(sprintf(absences_translate('Error report for right "%s"'), $right->description));
277
	
278
	
279
	$frame = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(1.5,'em'))
280
		->setCanvasOptions($page->Options()->width(70,'em'))
0 ignored issues
show
Bug introduced by
It seems like $page->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...
281
		->addClass('widget-bordered')
282
		->addClass('BabLoginMenuBackground')
283
		->addClass('widget-centered');
284
	
285
	$page->addItem($frame);
286
	
287
288
	// si aucun probleme a signaler, diriger le gestionnaire vers la page droit/regime
289
	
290
	
291
	$I = $right->getAgentRightIterator();
292
	$display = false;
293
	
294
	foreach($I as $agentRight)
295
	{
296
		/*@var $agentRight absences_AgentRight */
297
		$errors = $agentRight->getErrors();
298
		
299
		if (empty($errors))
300
		{
301
			continue;
302
		}
303
		
304
		$display = true;
305
		
306
		$messageLayout = $W->VBoxLayout();
307
		$user = $W->Section($agentRight->getAgent()->getName(), $messageLayout);
308
		$frame->addItem($user);
309
		
310
		foreach($errors as $error)
311
		{
312
			$messageLayout->addItem($W->Label($error));
313
		}
314
	}
315
	
316
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
317
	$url = bab_url::get_request('tg', 'pos');
318
	$url->idx = $next_idx;
319
	$url->idvr = $id_right;
320
	
321
	
322
	if  (!$display)
323
	{
324
		global $babBody;
325
		/* @var $babBody babBody */
326
		
327
		// reporter les messages a la page suivante
328
		foreach($babBody->messages as $m)
329
		{
330
			$babBody->addNextPageMessage($m);
331
		}
332
		
333
		$url->location();
334
	}
335
	
336
	
337
	$frame->addItem($W->Link($W->Button()->addItem($W->Label(absences_translate('Continue'))), $url->toString()));
338
	
339
340
	$page->displayHtml();
341
}
342
343
344
345
346
347
348
349
350
351
352
/**
353
 * 
354
 * @param int $id_group
355
 * @param bool $tree
356
 * 
357
 * @return array
358
 */
359
function absences_getUsersFromGroup($id_group, $tree)
360
{
361
	$groups = array($id_group);
362
	
363
	if ($tree)
364
	{
365
		$arr = bab_getGroups($id_group, true);
366
		$groups = array_merge($groups, $arr['id']);
367
	}
368
	
369
	$members = bab_getGroupsMembers($groups);
370
	$users = array();
371
	foreach($members as $arr)
0 ignored issues
show
Bug introduced by
The expression $members of type array|false is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
372
	{
373
		$users[] = (int) $arr['id'];
374
	}
375
	
376
	return $users;
377
}
378
379
380
381
function absences_addVacationRightPersonnel($id)
382
{
383
	$W = bab_Widgets();
384
	require_once dirname(__FILE__).'/utilit/agent.class.php';
385
	require_once dirname(__FILE__).'/utilit/right.ui.php';
386
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
387
	global $babDB;
388
	
389
	$page = $W->BabPage();
390
	
391
	if (isset($_POST['right']))
392
	{	
393
	
394
		if( isset($_POST['right']['save'] ))
395
		{
396
			$id_right = (int) $_POST['right']['id'];
397
			$id_group = (int) $_POST['right']['group'];
398
			$tree = (bool) $_POST['right']['tree'];
399
			$users = absences_getUsersFromGroup($id_group, $tree);
400
			$right = new absences_Right($id_right);
401
			
402
			// croiser avec les membres du personnel
403
			
404
			$res = $babDB->db_query('SELECT * FROM absences_personnel WHERE id_user IN('.$babDB->quote($users).')');
405
			while ($arr = $babDB->db_fetch_assoc($res))
406
			{
407
				$agent = new absences_Agent;
408
				$agent->setRow($arr);
409 View Code Duplication
				if ($agent->addRight($right))
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...
410
				{
411
					try {
412
						$agent->addFixedEntry($right);
413
					} 
414
					catch(absences_EntryException $e)
415
					{
416
						$page->addError($agent->getName().' : '.$e->getMessage());
417
						$agent->removeRight($right);
418
					}
419
				}
420
			}
421
		}
422
		
423 View Code Duplication
		if (!$page->containErrors())
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...
424
		{
425
			$url = bab_url::get_request('tg', 'idvr');
426
			$url->idx = 'lvrp';
427
			$url->location();
428
		}
429
	}
430
	
431
	
432
	
433
	
434
	
435
	
436
	$right = new absences_Right($id);
437
	
438
	
439
	if (!$right->getRow())
440
	{
441
		throw new Exception(absences_translate('The vacation right does not exists'));
442
	}
443
	
444
	$page->setTitle(sprintf(absences_translate('Add personnel members to the right %s'), $right->description));
445
	
446
447
	$editor = new absences_RightAddPersonnelEditor($right);
448
	$page->addItem($editor);
449
	
450
	
451
	$page->displayHtml();
452
}
453
454
455
456
457
458
459
460
461
462
463
464 View Code Duplication
function listVacationRightPersonnel($idvr)
0 ignored issues
show
Duplication introduced by
This function 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...
465
{
466
    require_once dirname(__FILE__).'/utilit/beneficiarieslist.ui.php';
467
    
468
	$list = new absences_BeneficiariesList($idvr, (array) bab_rp('filter', array()));
469
	
470
	$addon = bab_getAddonInfosInstance('absences');
471
472
	$babBody = bab_getInstance('babBody');
473
	$babBody->addStyleSheet($addon->getStylePath().'vacation.css');
474
	$babBody->babecho(bab_printTemplate($list,  absences_addon()->getRelativePath()."vacadma.html", "vrpersonnellist"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
475
}
476
	
477
	
478
	
479
	
480
	
481
	
482
	
483
	
484
function listVacationRightCollection($idvr)
485
{
486
	
487
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
488
	{
489
490
		public $altbg = true;
491
		public $name;
492
		public $description;
493
		public $idvr;
494
495
		public function __construct($idvr)
496
		{
497
			require_once dirname(__FILE__).'/utilit/collection.class.php';
498
			require_once dirname(__FILE__).'/utilit/collection_right.class.php';
499
			require_once dirname(__FILE__).'/utilit/right.class.php';
500
501
			$babBody = bab_getInstance('babBody');
502
503
			$this->allname = absences_translate("All");
0 ignored issues
show
Bug introduced by
The property allname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
504
			$this->uncheckall = absences_translate("Uncheck all");
0 ignored issues
show
Bug introduced by
The property uncheckall does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
505
			$this->checkall = absences_translate("Check all");
0 ignored issues
show
Bug introduced by
The property checkall does not seem to exist. Did you mean t_checkall?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
506
			$this->modify = absences_translate("Modify");
0 ignored issues
show
Bug introduced by
The property modify does not seem to exist. Did you mean t_modify?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
507
			$this->t_name = absences_translate("Name");
0 ignored issues
show
Bug introduced by
The property t_name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
508
			$this->t_description = absences_translate("Description");
0 ignored issues
show
Bug introduced by
The property t_description does not seem to exist. Did you mean description?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
509
			$this->t_linked = absences_translate("Linked");
0 ignored issues
show
Bug introduced by
The property t_linked does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
510
			$this->t_unlinked = absences_translate("Unlinked");
0 ignored issues
show
Bug introduced by
The property t_unlinked does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
511
			$this->t_edit = absences_translate("Edit");
0 ignored issues
show
Bug introduced by
The property t_edit does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
512
513
			global $babDB;
514
			$this->idvr = (int) $idvr;
0 ignored issues
show
Bug introduced by
The property idvr does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
515
516
			
517
			$this->right = new absences_Right($idvr);
0 ignored issues
show
Bug introduced by
The property right does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
518
519
			$babBody->setTitle(sprintf(absences_translate("Collections associated to the right %s"), $this->right->description));
520
			$type = $this->right->getType();
521
			
522
			if ($type->id)
523
			{
524
				$this->right_type = bab_toHtml($type->name);
0 ignored issues
show
Bug introduced by
The property right_type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
525
			} else {
526
				$this->right_type = '';
527
			}
528
529
			$req = "select *
530
				from
531
					absences_collections 
532
				order by name";
533
			
534
			
535
			$this->res = $babDB->db_query($req);
536
		}
537
538
		public function getnext()
539
		{
540
			global $babDB;
541
			if($arr = $babDB->db_fetch_array($this->res))
542
			{
543
544
				
545
				$this->altbg = !$this->altbg;
546
547
				// create the agent and the agent_right objects
548
549
				$collection = new absences_Collection();
550
				$collection->setRow($arr);
551
552
553
				$this->selected = "";
0 ignored issues
show
Bug introduced by
The property selected does not seem to exist. Did you mean yselected?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
554
555
				$res2 = $babDB->db_query("select * from absences_coll_rights where id_coll='".$babDB->db_escape_string($collection->id)."' AND id_right ='".$babDB->db_escape_string($this->idvr)."'");
556
				if( $res2 && $babDB->db_num_rows($res2) > 0 )
557
				{
558
					$this->selected = "checked";
0 ignored issues
show
Bug introduced by
The property selected does not seem to exist. Did you mean yselected?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
559
				}
560
				
561
562
				$this->id_collection = bab_toHtml($collection->id);
0 ignored issues
show
Bug introduced by
The property id_collection does not seem to exist. Did you mean collection?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
563
				$this->name = bab_toHtml($collection->name);
564
				$this->description = bab_toHtml($collection->description);
565
566
				return true;
567
			}
568
			else
569
				return false;
570
571
		}
572
573
		
574
		
575
		
576
		public function displaySaveProgress()
577
		{
578
			$W = bab_Widgets();
579
			
580
			$page = $W->BabPage();
581
582
			
583
			$page->setTitle(sprintf(absences_translate('Update users associated to vacation right "%s"'), $this->right->description));
584
			
585
			$nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next')));
586
			
587
			$checked_collections = bab_pp('collection', array());
588
			
589
			$page->addItem(
590
					$W->Frame()
591
					->setCanvasOptions($page->Options()->width(70,'em'))
0 ignored issues
show
Bug introduced by
It seems like $page->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...
592
					->addClass('widget-bordered')
593
					->addClass('BabLoginMenuBackground')
594
					->addClass('widget-centered')
595
					->addItem(
596
							$W->ProgressBar()
597
							->setProgress(0)
598
							->setTitle(absences_translate('Process beneficiaries list'))
599
							->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'lvrc_progress')->setParameter('collection', $checked_collections))
600
							->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lvrc'), $nextbutton)
601
					)
602
					->addItem($nextbutton)
603
			);
604
			
605
			
606
			$page->displayHtml();
607
		}
608
	}
609
	
610
611
	$temp = new temp($idvr);
0 ignored issues
show
Bug introduced by
The call to temp::temp() misses some required arguments starting with $what.
Loading history...
612
	
613
	
614
	if (!empty($_POST))
615
	{
616
		// $temp->save();
617
		$temp->displaySaveProgress();
0 ignored issues
show
Bug introduced by
The method displaySaveProgress() does not seem to exist on object<temp>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
618
		return;
619
	}
620
	
621
622
	$babBody = bab_getInstance('babBody');
623
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "vrcollectionlist"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
624
}
625
	
626
	
627
	
628
	
629
630
function viewVacationRightPersonnel($idvr)
631
{
632
	require_once dirname(__FILE__).'/utilit/right.ui.php';
633
	
634
	
635
	
636
	$W = bab_Widgets();
637
	
638
	$page = $W->BabPage();
639
	$right = null;
0 ignored issues
show
Unused Code introduced by
$right is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
640
	
641
	
642
	$right = new absences_Right($idvr);
643
	$page->setTitle(absences_translate('View vacation right'));
644
645
	$fullframe = new absences_RightFullFrame($right);
646
	$page->addItem($fullframe);
647
	
648
	
649
	$page->displayHtml();
650
}
651
652
653
654
function rgrouplist() {
655
656
	global $babBody;
657
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
658
		{
659
		var $altbg = true;
660
661
		function temp()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
662
			{
663
			$this->t_name = absences_translate('Name');
664
			$this->t_edit = absences_translate('Edit');
665
			$this->t_rights = absences_translate('Rights');
666
			global $babDB;
667
			$this->res = $babDB->db_query("SELECT * FROM ".ABSENCES_RGROUPS_TBL."");
668
			}
669
670
		function getnext()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
671
			{
672
			global $babDB;
673
			if ($arr = $babDB->db_fetch_assoc($this->res)) {
674
				$this->altbg		= !$this->altbg;
675
				$this->name			= bab_toHtml($arr['name']);
676
				$this->id_rgroup	= bab_toHtml($arr['id']);
0 ignored issues
show
Bug introduced by
The property id_rgroup does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
677
678
679
				$this->rgroup = $babDB->db_query("SELECT description FROM ".ABSENCES_RIGHTS_TBL." WHERE id_rgroup=".$babDB->quote($arr['id']));
0 ignored issues
show
Bug introduced by
The property rgroup does not seem to exist. Did you mean id_rgroup?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
680
				return true;
681
			}
682
			return false;
683
		}
684
685
		function getnextright() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
686
			global $babDB;
687
			
688
			static $i = 0;
689
			
690
			if ($i === 10) {
691
			    $this->description = bab_toHtml(
692
		            sprintf(
693
		                absences_translate('And %d more vacation rights...'),
694
		                $babDB->db_num_rows($this->rgroup)
0 ignored issues
show
Bug introduced by
The property rgroup does not seem to exist. Did you mean id_rgroup?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
695
		            )
696
		        );
697
			    
698
			    $i++;
699
			    return true;
700
			}
701
			
702
			if ($i > 10) {
703
			    return false;
704
			}
705
			
706
			
707
			
708
			if ($arr = $babDB->db_fetch_assoc($this->rgroup)) {
0 ignored issues
show
Bug introduced by
The property rgroup does not seem to exist. Did you mean id_rgroup?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
709
				$this->description = bab_toHtml($arr['description']);
710
				$i++;
711
				
712
				
713
				return true;
714
			}
715
			
716
			$i = 0;
717
			return false;
718
		}
719
720
	}
721
722
	$temp = new temp();
0 ignored issues
show
Bug introduced by
The call to temp::temp() misses some required arguments starting with $vtid.
Loading history...
723
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "rgrouplist"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
724
}
725
726
727
728
function rgroupmod() {
729
730
	global $babBody;
731
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
732
	{
733
		function temp()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
734
		{
735
			$this->t_name = absences_translate('Name');
736
			$this->t_recover = absences_translate('Use this right group to store the created recovery rights');
737
			$this->t_quantity_unit = absences_translate('Allowed quantity unit');
0 ignored issues
show
Bug introduced by
The property t_quantity_unit does not seem to exist. Did you mean quantity?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
738
			$this->t_days = absences_translate('Days');
0 ignored issues
show
Bug introduced by
The property t_days does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
739
			$this->t_hours = absences_translate('Hours');
0 ignored issues
show
Bug introduced by
The property t_hours does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
740
			$this->t_record = absences_translate('Record');
741
			$this->t_delete = absences_translate('Delete');
0 ignored issues
show
Bug introduced by
The property t_delete does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
742
			global $babDB;
743
			$this->id_rgroup = bab_rp('id_rgroup');
744
			if ($this->id_rgroup) {
745
				$res = $babDB->db_query("SELECT * FROM ".ABSENCES_RGROUPS_TBL." WHERE id=".$babDB->quote($this->id_rgroup));
746
				$arr = $babDB->db_fetch_assoc($res);
747
				$this->name = bab_toHtml($arr['name']);
748
				$this->recover = $arr['recover'];
0 ignored issues
show
Bug introduced by
The property recover does not seem to exist. Did you mean t_recover?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
749
				$this->quantity_unit = bab_toHtml($arr['quantity_unit']);
0 ignored issues
show
Bug introduced by
The property quantity_unit does not seem to exist. Did you mean quantity?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
750
			} else {
751
				$this->name = '';
752
				$this->recover = 0;
0 ignored issues
show
Bug introduced by
The property recover does not seem to exist. Did you mean t_recover?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
753
				$this->quantity_unit = 'D';
0 ignored issues
show
Bug introduced by
The property quantity_unit does not seem to exist. Did you mean quantity?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
754
			}
755
		}
756
	}
757
758
	$temp = new temp();
0 ignored issues
show
Bug introduced by
The call to temp::temp() misses some required arguments starting with $vtid.
Loading history...
759
	$babBody->babecho(bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadma.html", "rgroupmod"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
760
}
761
762
763
764
765
function modifyVacationRightPersonnel($idvr, $userids, $nuserids)
766
{
767
	
768
	global $babDB;
769
	require_once dirname(__FILE__).'/utilit/right.class.php';
770
	require_once dirname(__FILE__).'/utilit/agent.class.php';
771
	
772
	$babBody = bab_getInstance('babBody');
773
	/*@var $babBody babBody */
774
	$count = sizeof($userids);
775
	
776
	$right = new absences_Right($idvr);
777
778
	if (!$right->getRow())
779
	{
780
		throw new Exception('This vacation right does not exists');
781
	}
782
783
	for( $i = 0; $i < sizeof($nuserids); $i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
784
	{
785
	    bab_setTimeLimit(10);
786
	    
787
		if( $nuserids[$i] != "" && ( $count == 0 || !in_array($nuserids[$i], $userids)))
788
		{
789
			$agent = absences_Agent::getFromIdUser($nuserids[$i]);
790
			if ($agent->removeRight($right))
791
			{
792
				$agent->removeFixedEntry($right);
793
			}
794
		}
795
	}
796
	
797
	bab_setTimeLimit(60);
798
	
799
800
	for( $i = 0; $i < $count; $i++)
801
	{
802
		if( !in_array($userids[$i], $nuserids) )
803
		{
804
		    bab_setTimeLimit(10);
805
			$agent = absences_Agent::getFromIdUser($userids[$i]);
806 View Code Duplication
			if ($agent->addRight($right))
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...
807
			{
808
				try {
809
					$agent->addFixedEntry($right);
810
				} catch(absences_EntryException $e)
811
				{
812
					$babBody->addError($agent->getName().' : '.$e->getMessage());
813
					$agent->removeRight($right);
814
				}
815
			}
816
		}
817
	}
818
	
819
	bab_setTimeLimit(60);
820
	
821
	if (0 === count($babBody->errors))
822
	{
823
		$babBody->addNextPageMessage(sprintf(absences_translate('The checked personal members were associated with "%s"'), $right->description));
0 ignored issues
show
Documentation introduced by
sprintf(absences_transla...), $right->description) is of type string, but the function expects a object<unknown_type>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
824
		return true;
825
	}
826
	
827
	return false;
828
}
829
830
831
function deleteVacationRightConf($idvr) {
832
833
	global $babBody;
834
	class temp
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type temp has been defined more than once; this definition is ignored, only the first definition in programs/vacadm.php (L38-118) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
835
		{
836
		var $yes;
837
		var $no;
838
		var $invalidentry1;
839
		var $tpsel;
840
		var $colsel;
841
842
		function temp($idvr)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
843
			{
844
			$this->idvr = $idvr;
845
			$this->t_alert = absences_translate("Some vacation requests are linked to this right, if you delete the right, the vacation requests will be deleted with it");
0 ignored issues
show
Bug introduced by
The property t_alert does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
846
847
			$this->t_request = absences_translate("Last request with this right");
0 ignored issues
show
Bug introduced by
The property t_request does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
848
			$this->t_confirm = absences_translate("Confirm");
0 ignored issues
show
Bug introduced by
The property t_confirm does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
849
850
			global $babDB;
851
			$this->res = $babDB->db_query(
852
				"SELECT
853
					UNIX_TIMESTAMP(e.date_begin) date_begin
854
				FROM
855
					".ABSENCES_ENTRIES_ELEM_TBL." ee,
856
					".ABSENCES_ENTRIES_TBL." e
857
				WHERE
858
					ee.id_right=".$babDB->quote($idvr)."
859
					AND e.id = ee.id_entry
860
861
				ORDER BY e.date_begin DESC"
862
				);
863
864
			$arr = $babDB->db_fetch_assoc($this->res);
865
			$nb_requests = $babDB->db_num_rows($this->res);
866
			$this->request = bab_toHtml(absences_longDate($arr['date_begin']));
0 ignored issues
show
Bug introduced by
The property request does not seem to exist. Did you mean t_request?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
867
			if (1 == $nb_requests) {
868
				$this->t_nb_requests = bab_toHtml(absences_translate("one request will be deleted"));
0 ignored issues
show
Bug introduced by
The property t_nb_requests does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
869
			} else {
870
				$this->t_nb_requests = bab_toHtml(sprintf(absences_translate("%d requests will be deleted"),$nb_requests));
871
			}
872
		}
873
	}
874
875
	$temp = new temp($idvr);
0 ignored issues
show
Bug introduced by
The call to temp::temp() misses some required arguments starting with $what.
Loading history...
876
	$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightsdelete"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
877
	$babBody->title = absences_translate("Delete vacation right");
878
	$babBody->addItemMenu("delvr", absences_translate("Delete"), absences_addon()->getUrl()."vacadma&idx=delvr");
879
}
880
881
882
883
884
885
/**
886
 * 
887
 */
888
function rightcopy() {
889
890
	global $babBody;
891
	require_once dirname(__FILE__).'/utilit/rightincl.php';
892
893
	if (isset($_POST['copy_rights'])) {
894
		$temp = new absences_RightCopyStep2();
895
		$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightcopy2"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
896
897
	} else {
898
		$temp = new absences_RightCopyStep1();
899
		$babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadma.html", "rightcopy"));
0 ignored issues
show
Deprecated Code introduced by
The method bab_addonInfos::getRelativePath() has been deprecated with message: Do not use relative path in addons Addons are subject to move out of the core folder in futures version for bab_printTemplate, replace with $addon->printTemplate() for babBody->addStyleSheet use $addon->getStylePath() instead of relative path the addStyleSheet method support full path starting with vendor/ since the 8.1.98 version

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
900
	}
901
}
902
903
904
905
906
/**
907
 * Delete vacation right and request associated to the vacation right
908
 * @param int $idvr
909
 * @return bool
910
 */
911
function deleteVacationRight($idvr)
912
{
913
	global $babBody, $babDB;
914
	list($total) = $babDB->db_fetch_row($babDB->db_query("select count(id) as total from ".ABSENCES_ENTRIES_ELEM_TBL." where id_right=".$babDB->quote($idvr)));
915
	if( $total == 0 )
916
	{
917
		$babDB->db_query("DELETE FROM ".ABSENCES_RIGHTS_TBL." WHERE id=".$babDB->quote($idvr));
918
		$babDB->db_query("DELETE FROM ".ABSENCES_USERS_RIGHTS_TBL." WHERE id_right=".$babDB->quote($idvr));
919
		$babDB->db_query("DELETE FROM ".ABSENCES_RIGHTS_RULES_TBL." WHERE id_right=".$babDB->quote($idvr));
920
		$babDB->db_query("UPDATE absences_movement SET id_right='0' WHERE id_right=".$babDB->quote($idvr));
921
922
		$res = $babDB->db_query("SELECT id_entry FROM ".ABSENCES_ENTRIES_ELEM_TBL." WHERE id_right=".$babDB->quote($idvr));
923
		while ($arr = $babDB->db_fetch_assoc($res)) {
924
			absences_delete_request($arr['id_entry']);
925
		}
926
		
927
		require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
928
		$url = bab_url::get_request('tg');
929
		$url->idx = 'lrig';
930
		$url->location();
931
	}
932
933
	$babBody->addError(absences_translate('The vacation right cannot be deleted because of existing associated requests'));
934
	return false;
935
}
936
937
938
function modRgroup() {
939
940
	global $babDB, $babBody;
941
942
	$name = bab_pp('name');
943
	if (empty($name)) {
944
		$babBody->addError(absences_translate('The name is mandatory'));
945
		return false;
946
	}	
947
		
948
	global $babDB;
949
	$id = bab_pp('id_rgroup');
950
	$recover = bab_pp('recover', 0);
951
	$quantity_unit = bab_pp('quantity_unit', 'D');
952
	
953
	if (empty($id)) {
954
		$babDB->db_query("INSERT INTO absences_rgroup (name, recover, quantity_unit) VALUES (".$babDB->quote($name).", ".$babDB->quote($recover).", ".$babDB->quote($quantity_unit).")");
955
		$id = $babDB->db_insert_id();
956
	} else {
957
		
958
		if ($recover)
959
		{
960
			$res = $babDB->db_query('SELECT g.id FROM absences_rgroup g, absences_rights r 
961
					WHERE r.id_rgroup=g.id AND g.id='.$babDB->quote($id).' AND r.kind<>'.$babDB->quote(absences_Right::RECOVERY));
962
			
963
			if ($babDB->db_num_rows($res) > 0)
964
			{
965
				$babBody->addError(absences_translate('This right group already contains rights of a different kind than recovery'));
966
				return false;
967
			}
968
		}
969
		
970
		
971
		
972
		$babDB->db_query("UPDATE absences_rgroup SET 
973
			name=".$babDB->quote($name).", 
974
			recover=".$babDB->quote($recover).",  
975
			quantity_unit=".$babDB->quote($quantity_unit)." 
976
		WHERE id=".$babDB->quote($id));
977
	}
978
	
979
	if ($recover)
980
	{
981
		$babDB->db_query("UPDATE absences_rgroup SET recover='0' WHERE id<>".$babDB->quote($id));
982
	}
983
	
984
	return true;
985
}
986
987
988
function deleteRgroup() {
989
	global $babDB;
990
	$id = bab_rp('id_rgroup');
991
	if (!empty($id)) {
992
		$babDB->db_query("DELETE FROM ".ABSENCES_RGROUPS_TBL." WHERE id=".$babDB->quote($id));
993
	}
994
}
995
996
997
998
999 View Code Duplication
function absences_rightMovements($id_right)
0 ignored issues
show
Duplication introduced by
This function 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...
1000
{
1001
    require_once dirname(__FILE__).'/utilit/right.class.php';
1002
    require_once dirname(__FILE__).'/utilit/right.ui.php';
1003
1004
    $babBody = bab_getInstance('babBody');
1005
    $right = new absences_Right($id_right);
1006
    $W = bab_Widgets();
1007
1008
    $card = new absences_RightCardFrame($right);
1009
1010
    $card->addClass('widget-bordered');
1011
    $card->addClass('BabLoginMenuBackground');
1012
1013
    $list = new absences_RightMovementList($right);
1014
1015
    $babBody->setTitle(absences_translate('Right history'));
1016
1017
    $babBody->babEcho($card->display($W->HtmlCanvas()));
1018
    $babBody->babEcho($list->getHtml());
1019
}
1020
1021
1022
1023
1024
/* main */
1025
bab_requireCredential();
1026
$agent = absences_Agent::getCurrentUser();
1027
if( !$agent->isManager())
1028
	{
1029
	$babBody->msgerror = absences_translate("Access denied");
1030
	return;
1031
	}
1032
	
1033
$idx = bab_rp('idx', "lrig");
1034
1035
1036
if( isset($_POST['action']) )
1037
	{
1038
	switch ($_POST['action'])
1039
		{
1040
1041
		case 'rgroupmod':
1042
			if (isset($_POST['rgroup_delete'])) {
1043
				deleteRgroup();
1044
1045
			} else if (!modRgroup()) {
1046
				$idx = 'rgroupmod';
1047
			}
1048
			break;
1049
1050
		}
1051
1052
	}
1053
1054
	
1055
	
1056
if ($agent->isInPersonnel())
1057
{
1058
	$babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser");
1059
}
1060
$babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu");
1061
1062
1063
1064
switch($idx)
1065
	{
1066
1067
1068
1069
	case "delvru":
1070
		$userids = bab_rp('userids', array());
1071
		if (modifyVacationRightPersonnel(bab_rp('idvr'), $userids, bab_rp('nuserids', array())))
1072
		{
1073
			
1074
			require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
1075
			$url = bab_url::get_request('tg', 'pos');
1076
			$url->idx = 'user_right_report';
1077
			$url->id_right = bab_rp('idvr');
1078
			$url->nextidx = 'lvrp';
1079
			$url->location();
1080
		}
1081
		
1082
		$idx = 'lvrp';
1083
		// no break
1084
		
1085 View Code Duplication
	case "lvrp":
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...
1086
		listVacationRightPersonnel(bab_rp('idvr'));
1087
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1088
		$babBody->addItemMenu("lvrc", absences_translate("Collections beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".bab_rp('idvr'));
1089
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1090
		break;
1091
		
1092 View Code Duplication
	case 'lvrp_add':
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...
1093
		absences_addVacationRightPersonnel(bab_rp('idvr'));
1094
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1095
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1096
		$babBody->addItemMenu("lvrp_add", absences_translate("Grant by group"), absences_addon()->getUrl()."vacadma&idx=lvrp_add&idvr=".bab_rp('idvr'));
1097
		break;
1098
		
1099 View Code Duplication
	case "lvrc":
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...
1100
	
1101
		listVacationRightCollection(bab_rp('idvr'));
1102
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1103
		$babBody->addItemMenu("lvrc", absences_translate("Collections beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrc&idvr=".bab_rp('idvr'));
1104
		$babBody->addItemMenu("lvrp", absences_translate("Users beneficiaries"), absences_addon()->getUrl()."vacadma&idx=lvrp&idvr=".bab_rp('idvr'));
1105
		break;
1106
		
1107
	case 'lvrc_progress':
1108
		absences_beneficiariesUpdateProgress(bab_rp('idvr'));
1109
		break;
1110
		
1111 View Code Duplication
	case "viewvr":
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...
1112
	    viewVacationRightPersonnel(bab_rp('idvr'));
1113
	    $babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1114
	    $babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1115
	    $babBody->addItemMenu("modvr", absences_translate("Edit"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1116
	    $babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1117
	    break;
1118
		
1119 View Code Duplication
	case 'movement':
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...
1120
	    $babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1121
	    $babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1122
		$babBody->addItemMenu("modvr", absences_translate("Modify"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1123
		$babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1124
	    absences_rightMovements(bab_rp('idvr'));
1125
	    break;
1126
1127 View Code Duplication
	case "modvr":
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...
1128
		absences_addModifyVacationRight(bab_rp('idvr'));
1129
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1130
		$babBody->addItemMenu("viewvr", absences_translate("Vacation right"), absences_addon()->getUrl()."vacadma&idx=viewvr&idvr=".bab_rp('idvr'));
1131
		$babBody->addItemMenu("modvr", absences_translate("Modify"), absences_addon()->getUrl()."vacadma&idx=modvr&idvr=".bab_rp('idvr'));
1132
		$babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadma&idx=movement&idvr=".bab_rp('idvr'));
1133
		break;
1134
1135 View Code Duplication
	case "addvr":
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...
1136
		absences_addModifyVacationRight(false, bab_rp('from'));
1137
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1138
		$babBody->addItemMenu("addvr", absences_translate("Add"), absences_addon()->getUrl()."vacadma&idx=addvr");
1139
		break;
1140
		
1141
	case 'nobenef';
1142
		absences_choseBeneficiariesMethod(bab_rp('idvr'));
1143
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1144
		$babBody->addItemMenu("nobenef", absences_translate("Beneficiaries"), absences_addon()->getUrl()."vacadma&idx=nobenef");
1145
		break;
1146
		
1147
	case 'fixedud':
1148
		// fixed vacation right requests progress bar
1149
		absences_fixedRightUpdate(bab_rp('idvr'));
1150
		$babBody->addItemMenu("fixedud", absences_translate("Update"), absences_addon()->getUrl()."vacadma&idx=fixedud");
1151
		break;
1152
		
1153
	case 'fixedud_progress':
1154
		absences_fixedRightUpdateProgress(bab_rp('idvr'));
1155
		break;
1156
		
1157 View Code Duplication
	case 'user_right_report':
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...
1158
		// user-right links report
1159
		absences_userRightReport(bab_rp('id_right'), bab_rp('nextidx'));
1160
		$babBody->addItemMenu("user_right_report", absences_translate("Update"), absences_addon()->getUrl()."vacadma&idx=user_right_update");
1161
		break;
1162
	
1163
1164 View Code Duplication
	case 'rgroup':
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...
1165
		$babBody->title = absences_translate("Rights groups");
1166
		$babBody->addItemMenu("rgroup", absences_translate("Rights groups"), absences_addon()->getUrl()."vacadma&idx=rgroup");
1167
		$babBody->addItemMenu("rgroupmod", absences_translate("Add"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1168
		rgrouplist();
1169
		break;
1170
1171 View Code Duplication
	case 'rgroupmod':
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...
1172
		$babBody->title = absences_translate("Right group");
1173
		$babBody->addItemMenu("rgroup", absences_translate("Rights groups"), absences_addon()->getUrl()."vacadma&idx=rgroup");
1174
		$babBody->addItemMenu("rgroupmod", absences_translate("Edit"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1175
		rgroupmod();
1176
		break;
1177
1178
1179 View Code Duplication
	case 'copy':
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...
1180
		$babBody->title = absences_translate("Rights renewal by years");
1181
		$babBody->addItemMenu('copy', absences_translate("Rights renewal"), absences_addon()->getUrl()."vacadma&idx=rgroupmod");
1182
		rightcopy();
1183
		break;
1184
1185
	case "lrig":
1186
	case 'recovery':
1187
	case 'archives':
1188
	default:
1189
		$datee			= bab_rp('datee');
1190
		$dateb			= bab_rp('dateb');
1191
		$idtype			= bab_rp('idtype');
1192
		$idcoll			= bab_rp('idcoll');
1193
		$rgroup			= bab_rp('rgroup');
1194
		$pos			= bab_rp('pos',0);
1195
		$active			= bab_rp('active','');
1196
		$archived		= bab_rp('archived', 0);
1197
		$recovery		= bab_rp('recovery', 0);
1198
1199
		listVacationRigths($idtype, $idcoll, $rgroup, $dateb, $datee, $active, $pos, $archived, $recovery);
1200
		$babBody->addItemMenu("lrig", absences_translate("Rights"), absences_addon()->getUrl()."vacadma&idx=lrig");
1201
		$babBody->addItemMenu("recovery", absences_translate("Recovery rights"), absences_addon()->getUrl()."vacadma&idx=recovery&recovery=1");
1202
		$babBody->addItemMenu("archives", absences_translate("Archives"), absences_addon()->getUrl()."vacadma&idx=archives&archived=1");
1203
		break;
1204
	}
1205
$babBody->setCurrentItemMenu($idx);
1206
bab_siteMap::setPosition('absences','User');
1207
1208