Issues (1940)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

programs/vacadm.php (166 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/************************************************************************
3
 * OVIDENTIA http://www.ovidentia.org                                   *
4
 ************************************************************************
5
 * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr )              *
6
 *                                                                      *
7
 * This file is part of Ovidentia.                                      *
8
 *                                                                      *
9
 * Ovidentia is free software; you can redistribute it and/or modify    *
10
 * it under the terms of the GNU General Public License as published by *
11
 * the Free Software Foundation; either version 2, or (at your option)  *
12
 * any later version.													*
13
 *																		*
14
 * This program is distributed in the hope that it will be useful, but  *
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of			*
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.					*
17
 * See the  GNU General Public License for more details.				*
18
 *																		*
19
 * You should have received a copy of the GNU General Public License	*
20
 * along with this program; if not, write to the Free Software			*
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,*
22
 * USA.																	*
23
************************************************************************/
24
25
26
27
28
include_once dirname(__FILE__).'/functions.php';
29
include_once $babInstallPath."utilit/afincl.php";
30
include_once $babInstallPath."utilit/mailincl.php";
31
include_once dirname(__FILE__).'/utilit/vacincl.php';
32
include_once dirname(__FILE__).'/utilit/agent.class.php';
33
include_once dirname(__FILE__).'/utilit/right.class.php';
34
35
function addVacationType($vtid, $what, $tname, $description, $tcolor, $cbalance)
36
	{
37
	global $babBody, $babDB;
38
	class temp
39
		{
40
		var $name;
41
		var $description;
42
		var $quantity;
43
		var $tnameval;
44
		var $descriptionval;
45
		var $quantityval;
46
		var $vtid;
47
		var $what;
48
49
		var $invalidentry1;
50
51
		var $add;
52
53
		function temp($vtid, $what, $tname, $description, $tcolor, $cbalance)
0 ignored issues
show
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...
54
			{
55
			global $babDB;
56
			$this->what = $what;
57
			$this->vtid = $vtid;
58
			$this->name = absences_translate("Name");
59
			$this->description = absences_translate("Description");
60
			$this->colortxt = absences_translate("Color");
0 ignored issues
show
The property colortxt 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...
61
			$this->yestxt = absences_translate("Yes");
0 ignored issues
show
The property yestxt 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...
62
			$this->notxt = absences_translate("No");
0 ignored issues
show
The property notxt 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...
63
			$this->t_recover = absences_translate("Use this right type to store the created recovery rights");
0 ignored issues
show
The property t_recover 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...
64
65
			$this->selctorurl = bab_toHtml($GLOBALS['babUrlScript']."?tg=selectcolor&idx=popup&callback=setColor");
0 ignored issues
show
The property selctorurl 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...
66
			$this->tcolor = $tcolor;
0 ignored issues
show
The property tcolor 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...
67
68
			if( $what == "modvt" && empty($tname))
69
				{
70
				$arr = $babDB->db_fetch_array($babDB->db_query("select * from ".ABSENCES_TYPES_TBL." where id=".$babDB->quote($vtid)));
71
				$this->tnameval = bab_toHtml($arr['name']);
72
				$this->descriptionval = bab_toHtml($arr['description']);
73
				$this->tcolorval = bab_toHtml($arr['color']);
0 ignored issues
show
The property tcolorval does not seem to exist. Did you mean tcolor?

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...
74
				$this->recover = (bool) $arr['recover'];
0 ignored issues
show
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...
75
76 View Code Duplication
				if( $arr['cbalance'] == 'Y')
0 ignored issues
show
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...
77
					{
78
					$this->yselected = 'selected';
0 ignored issues
show
The property yselected 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...
79
					$this->nselected = '';
0 ignored issues
show
The property nselected 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...
80
					}
81
				else
82
					{
83
					$this->yselected = '';
84
					$this->nselected = 'selected';
85
					}
86
				}
87
			else
88
				{
89
				$this->tnameval = bab_toHtml($tname);
90
				$this->descriptionval = bab_toHtml($description);
91
				$this->tcolorval = bab_toHtml($tcolor);
0 ignored issues
show
The property tcolorval does not seem to exist. Did you mean tcolor?

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...
92
				$this->recover = false;
0 ignored issues
show
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...
93
94 View Code Duplication
				if( $cbalance == 'N')
0 ignored issues
show
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...
95
					{
96
					$this->nselected = 'selected';
97
					$this->yselected = '';
98
					}
99
				else
100
					{
101
					$this->nselected = '';
102
					$this->yselected = 'selected';
103
					}
104
				}
105
106 View Code Duplication
			if( $what == "modvt" )
0 ignored issues
show
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...
107
				{
108
				$this->bdel = true;
0 ignored issues
show
The property bdel 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...
109
				$this->del = absences_translate("Delete");
0 ignored issues
show
The property del 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...
110
				$this->add = absences_translate("Modify");
111
				}
112
			else
113
				{
114
				$this->bdel = false;
115
				$this->add = absences_translate("Add");
116
				}
117
			}
118
		}
119
120
	list($count) = $babDB->db_fetch_row($babDB->db_query("select count(*) as total from ".ABSENCES_TYPES_TBL));
121
	$temp = new temp($vtid, $what, $tname, $description, $tcolor, $cbalance);
122
	$babBody->babecho(	bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vtypecreate"));
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...
123
	return $count;
124
	}
125
126
function listVacationCollections()
127
	{
128
	global $babBody;
129
130
	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 this file (L38-118) is considered.

This check looks for classes that have been defined more than once in the same file.

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...
131
		{
132
		var $nametxt;
133
		var $urlname;
134
		var $url;
135
		var $descriptiontxt;
136
		var $description;
137
138
		var $arr = array();
139
		var $count;
140
		var $res;
141
142
		public $altbg = true;
143
144 View Code Duplication
		function temp()
0 ignored issues
show
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...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
145
			{
146
			$this->nametxt = absences_translate("Name");
0 ignored issues
show
The property nametxt 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...
147
			$this->descriptiontxt = absences_translate("Description");
0 ignored issues
show
The property descriptiontxt 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...
148
			$this->t_rights = absences_translate('Rights');
0 ignored issues
show
The property t_rights 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...
149
			$babDB = $GLOBALS['babDB'];
150
			$req = "select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc";
151
			$this->res = $babDB->db_query($req);
0 ignored issues
show
The property res 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...
152
			$this->count = $babDB->db_num_rows($this->res);
0 ignored issues
show
The property count 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...
153
			}
154
155
		function getnext()
0 ignored issues
show
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...
156
			{
157
			static $i = 0;
158
			if( $i < $this->count)
159
				{
160
				global $babDB;
161
				$this->altbg = !$this->altbg;
0 ignored issues
show
The property altbg 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...
162
				$arr = $babDB->db_fetch_array($this->res);
163
				$this->url = absences_addon()->getUrl()."vacadm&idx=modvc&id=".$arr['id'];
0 ignored issues
show
The property url 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...
164
				$this->urlname = bab_toHtml($arr['name']);
0 ignored issues
show
The property urlname 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...
165
				$this->description = bab_toHtml($arr['description']);
166
				$this->righturl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=lrig&idcoll=".$arr['id']);
0 ignored issues
show
The property righturl 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...
167
				$i++;
168
				return true;
169
				}
170
			else
171
				return false;
172
173
			}
174
		}
175
176
	$temp = new temp();
0 ignored issues
show
The call to temp::temp() misses some required arguments starting with $vtid.
Loading history...
177
	$babBody->babecho(	bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadm.html", "vcollist"));
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...
178
	return $temp->count;
179
180
	}
181
182
function listVacationTypes()
183
	{
184
	global $babBody;
185
186
	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 this file (L38-118) is considered.

This check looks for classes that have been defined more than once in the same file.

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...
187
		{
188
		var $nametxt;
189
		var $urlname;
190
		var $url;
191
		var $descriptiontxt;
192
		var $quantitytxt;
193
		var $description;
194
		var $quantity;
195
		var $altaddvr;
196
		public $altbg = true;
197
		var $arr = array();
198
		var $count;
199
		var $res;
200
201 View Code Duplication
		function temp()
0 ignored issues
show
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...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
202
			{
203
			$this->nametxt = absences_translate("Name");
204
			$this->descriptiontxt = absences_translate("Description");
0 ignored issues
show
The property descriptiontxt 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...
205
			$this->colortxt = absences_translate("Color");
206
			$this->altaddvr = absences_translate("Allocate vacation rights");
0 ignored issues
show
The property altaddvr 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...
207
			$babDB = $GLOBALS['babDB'];
208
			$req = "select * from ".ABSENCES_TYPES_TBL." order by name asc";
209
			$this->res = $babDB->db_query($req);
210
			$this->count = $babDB->db_num_rows($this->res);
211
			}
212
213
		function getnext()
0 ignored issues
show
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...
214
			{
215
			static $i = 0;
216
			if( $i < $this->count)
217
				{
218
				global $babDB;
219
				$arr = $babDB->db_fetch_array($this->res);
220
				$this->altbg = !$this->altbg;
221
				$this->url = bab_toHtml(absences_addon()->getUrl()."vacadm&idx=modvt&id=".$arr['id']);
222
				$this->urlname = bab_toHtml($arr['name']);
223
				$this->description = bab_toHtml($arr['description']);
224
				$this->tcolor = bab_toHtml($arr['color']);
225
				$this->addurl = bab_toHtml(absences_addon()->getUrl()."vacadma&idx=addvr&idtype=".$arr['id']);
0 ignored issues
show
The property addurl 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...
226
				$i++;
227
				return true;
228
				}
229
			else
230
				return false;
231
232
			}
233
		}
234
235
	$temp = new temp();
0 ignored issues
show
The call to temp::temp() misses some required arguments starting with $vtid.
Loading history...
236
	$babBody->babecho(	bab_printTemplate($temp,  absences_addon()->getRelativePath()."vacadm.html", "vtypelist"));
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...
237
	return $temp->count;
238
239
	}
240
241
function addVacationCollection($vcid, $what, $tname, $description, $vtypeids, $category)
242
	{
243
	global $babBody;
244
	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 this file (L38-118) is considered.

This check looks for classes that have been defined more than once in the same file.

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...
245
		{
246
		var $name;
247
		var $description;
248
		var $vactypes;
249
		var $tnameval;
250
		var $descriptionval;
251
		var $add;
252
		var $vtypename;
253
		var $vtcheck;
254
		var $vcid;
255
		var $vtids = array();
256
257
		var $arr = array();
258
		var $count;
259
		var $res;
260
		function temp($vcid, $what, $tname, $description, $vtypeids, $category)
0 ignored issues
show
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...
261
			{
262
			global $babDB;
263
			$this->name = absences_translate("Name");
264
			$this->description = absences_translate("Description");
265
			$this->vactypes = absences_translate("Vacations types");
0 ignored issues
show
The property vactypes 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...
266
			$this->category = absences_translate("Category to use in calendar");
0 ignored issues
show
The property category 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...
267
			$this->t_checkall = absences_translate("Check/Uncheck all types");
0 ignored issues
show
The property t_checkall 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...
268
			$this->vcid = $vcid;
0 ignored issues
show
The property vcid 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...
269
			$this->what = $what;
270
271 View Code Duplication
			if( $what == "modvc")
0 ignored issues
show
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...
272
				{
273
				$this->bdel = true;
274
				$this->del = absences_translate("Delete");
275
				$this->add = absences_translate("Modify");
276
				}
277
			else
278
				{
279
				$this->bdel = false;
280
				$this->add = absences_translate("Add");
281
				}
282
283
			if( $what == "modvc" && empty($tname))
284
				{
285
				$arr = $babDB->db_fetch_array($babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." where id=".$babDB->quote($vcid)));
286
				$this->tnameval = bab_toHtml($arr['name']);
287
				$this->descriptionval = bab_toHtml($arr['description']);
288
				$this->categoryval = bab_toHtml($arr['id_cat']);
0 ignored issues
show
The property categoryval does not seem to exist. Did you mean category?

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...
289
290
				}
291
			else
292
				{
293
				$this->tnameval = bab_toHtml($tname);
294
				$this->descriptionval = bab_toHtml($description);
295
				$this->categoryval = bab_toHtml($category);
0 ignored issues
show
The property categoryval does not seem to exist. Did you mean category?

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...
296
				}
297
298
299
			include_once $GLOBALS['babInstallPath']."utilit/calapi.php";
300
			$this->categs = bab_calGetCategories();
0 ignored issues
show
The property categs 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...
301
302
			$this->catcount = count($this->categs);
0 ignored issues
show
The property catcount 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...
303
			}
304
305
306
307
		function getnextcat()
0 ignored issues
show
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...
308
			{
309
			static $i = 0;
310
			if( $i < $this->catcount)
311
				{
312
				$this->categid = $this->categs[$i]['id'];
0 ignored issues
show
The property categid 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...
313
				$this->categname = bab_toHtml($this->categs[$i]['name']);
0 ignored issues
show
The property categname 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...
314
				if( $this->categid == $this->categoryval )
0 ignored issues
show
The property categoryval does not seem to exist. Did you mean category?

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...
315
					{
316
					$this->selected = 'selected';
0 ignored issues
show
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...
317
					}
318
				else
319
					{
320
					$this->selected = '';
0 ignored issues
show
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...
321
					}
322
				$i++;
323
				return true;
324
				}
325
			else
326
				return false;
327
328
			}
329
		}
330
331
	$temp = new temp($vcid, $what, $tname, $description, $vtypeids, $category);
332
	$babBody->babecho(	bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vcolcreate"));
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...
333
	}
334
335
	
336
/**
337
 * Tester l'export pour 1 utilisateur, valeurs avec date et sans date
338
 */
339
function testExportBalances()
340
{
341
    require_once dirname(__FILE__).'/utilit/exportbalance.php';
342
    
343
    $W = bab_Widgets();
344
    $export = new exportAvailableBalancesCls();
345
    
346
    $page = $W->BabPage();
347
    $page->addItem($export->compareDateForOneUser(bab_rp('id_user')));
348
    $page->displayHtml();
349
}
350
	
351
352
// 	available balances export
353
function exportAvailableBalances()
354
{
355
	global $babBody;
356
    require_once dirname(__FILE__).'/utilit/exportbalance.php';
357
358
359
	$export = new exportAvailableBalancesCls();
360
361
	if (!empty($_POST)) {
362
		$export->csv();
363
	}
364
365
	$babBody->babecho($export->getHtml());
366
}
367
368
369 View Code Duplication
function listVacationPersonnel()
0 ignored issues
show
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...
370
{
371
	require_once dirname(__FILE__).'/utilit/agentlist.ui.php';
372
	$babBody = bab_getBody();
373
374
	$babBody->babecho(absences_agentListMenu());
375
376
	$addon = bab_getAddonInfosInstance('absences');
377
	$babBody->addStyleSheet($addon->getStylePath().'vacation.css');
378
379
	$temp = new absences_AgentList((array) bab_rp('filter', array()));
380
	$babBody->babecho(	bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadm.html", "vpersonnellist"));
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...
381
	return $temp->count;
382
}
383
384
385
386
387
function addGroupVacationPersonnel()
388
	{
389
	global $babBody;
390
	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 this file (L38-118) is considered.

This check looks for classes that have been defined more than once in the same file.

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...
391
		{
392
393
		function temp()
0 ignored issues
show
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...
394
			{
395
			$this->grouptext = absences_translate("Group");
0 ignored issues
show
The property grouptext 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...
396
			$this->collection = absences_translate("Collection");
0 ignored issues
show
The property collection 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...
397
			$this->appschema = absences_translate("Approbation schema for vacation requests:");
0 ignored issues
show
The property appschema 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...
398
			$this->cetschema = absences_translate("Approbation schema for deposit into the time savings account:");
0 ignored issues
show
The property cetschema 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...
399
			$this->recoverschema = absences_translate("Approbation schema for declaration of worked days entitling recovery:");
0 ignored issues
show
The property recoverschema 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...
400
			$this->t_use_vr = absences_translate("Use schema for vacation requests");
0 ignored issues
show
The property t_use_vr 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...
401
			$this->groupsbrowurl = absences_addon()->getUrl()."vacadm&idx=browg&cb=";
0 ignored issues
show
The property groupsbrowurl 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...
402
			$this->t_add = absences_translate("Add");
0 ignored issues
show
The property t_add 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...
403
			$this->t_modify = absences_translate("Modify");
0 ignored issues
show
The property t_modify 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...
404
			$this->t_record = absences_translate("Record");
0 ignored issues
show
The property t_record 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...
405
			$this->t_add_modify = absences_translate("Add or modify users by group");
0 ignored issues
show
The property t_add_modify 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...
406
			$this->t_modify_alert = absences_translate("Users with waiting requests will not be modified");
0 ignored issues
show
The property t_modify_alert 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...
407
408
			global $babDB;
409
410
			$this->idsa = bab_rp('idsa', 0);
0 ignored issues
show
The property idsa 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...
411
			$this->idcol = isset($_REQUEST['idcol']) ? $_REQUEST['idcol'] : '';
0 ignored issues
show
The property idcol 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...
412
413
414
			$this->groupval = "";
0 ignored issues
show
The property groupval 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...
415
			$this->groupid = "";
0 ignored issues
show
The property groupid 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...
416
417
			$W = bab_Widgets();
418
419
			$this->grouppicker = $W->GroupPicker()->setName('groupid')->display($W->HtmlCanvas());
0 ignored issues
show
The property grouppicker 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...
420
421
			$this->sares = $babDB->db_query("select * from ".BAB_FLOW_APPROVERS_TBL." order by name asc");
0 ignored issues
show
The property sares 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...
422
			if( !$this->sares )
423
				$this->countsa = 0;
0 ignored issues
show
The property countsa 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...
424
			else
425
				$this->countsa = $babDB->db_num_rows($this->sares);
426
427
			$this->colres = $babDB->db_query("select * from ".ABSENCES_COLLECTIONS_TBL." order by name asc");
0 ignored issues
show
The property colres 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...
428
			$this->countcol = $babDB->db_num_rows($this->colres);
0 ignored issues
show
The property countcol 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...
429
			}
430
431
		function getnextsa()
0 ignored issues
show
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...
432
			{
433
			global $babDB;
434
			static $j= 0;
435
			if( $j < $this->countsa )
436
				{
437
438
				$arr = $babDB->db_fetch_array($this->sares);
439
				$this->saname = bab_toHtml($arr['name']);
0 ignored issues
show
The property saname 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...
440
				$this->idsapp = bab_toHtml($arr['id']);
0 ignored issues
show
The property idsapp 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...
441
				if( $this->idsa == $this->idsapp )
442
					$this->selected = "selected";
0 ignored issues
show
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...
443
				else
444
					$this->selected = "";
0 ignored issues
show
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...
445
				$j++;
446
				return true;
447
				}
448
			else
449
				{
450
				$j = 0;
451
				if ($this->countsa > 0)
452
					$babDB->db_data_seek($this->sares,0);
453
				return false;
454
				}
455
			}
456
457 View Code Duplication
		function getnextcol()
0 ignored issues
show
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...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
458
			{
459
			static $j= 0;
460
			if( $j < $this->countcol )
461
				{
462
				global $babDB;
463
				$arr = $babDB->db_fetch_array($this->colres);
464
				$this->collname = bab_toHtml($arr['name']);
0 ignored issues
show
The property collname 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...
465
				$this->idcollection = bab_toHtml($arr['id']);
0 ignored issues
show
The property idcollection 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...
466
				if( $this->idcol == $this->idcollection )
0 ignored issues
show
The property idcollection 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...
467
					$this->selected = "selected";
0 ignored issues
show
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...
468
				else
469
					$this->selected = "";
0 ignored issues
show
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...
470
				$j++;
471
				return true;
472
				}
473
			else
474
				return false;
475
			}
476
477
		function printhtml()
0 ignored issues
show
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...
478
			{
479
			$GLOBALS['babBody']->babecho(	bab_printTemplate($this, absences_addon()->getRelativePath()."vacadm.html", "grouppersonnelcreate"));
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...
480
			}
481
482
483
		public function displaySaveProgress()
484
			{
485
				$W = bab_Widgets();
486
				$page = $W->BabPage();
487
488
489
				$groupid = (int) bab_pp('groupid');
490
491
492
				$page->setTitle(sprintf(absences_translate('Add users of group %s into personel members'), bab_getGroupName($groupid)));
493
494
				$nextbutton = $W->Button()->addItem($W->Label(absences_translate('Next')));
495
496
497
				$page->addItem(
498
						$W->Frame()
499
						->setCanvasOptions($page->Options()->width(70,'em'))
0 ignored issues
show
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...
500
						->addClass('widget-bordered')
501
						->addClass('BabLoginMenuBackground')
502
						->addClass('widget-centered')
503
						->addItem(
504
								$W->ProgressBar()
505
								->setProgress(0)
506
								->setTitle(absences_translate('Process users list'))
507
								->setProgressAction($W->Action()->fromRequest()->setParameter('idx', 'addg_progress'))
508
								->setCompletedAction($W->Action()->fromRequest()->setParameter('idx', 'lper'), $nextbutton)
509
						)
510
						->addItem($nextbutton)
511
				);
512
513
514
				$page->displayHtml();
515
			}
516
517
		}
518
519
	$temp = new temp();
0 ignored issues
show
The call to temp::temp() misses some required arguments starting with $vtid.
Loading history...
520
521
	if (!empty($_POST))
522
	{
523
		$temp->displaySaveProgress();
0 ignored issues
show
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...
524
		return;
525
	}
526
527
	$temp->printhtml();
0 ignored issues
show
The method printhtml() 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...
528
	}
529
530
531
532
533
534
535
536
537
538
539
function deleteVacationPersonnel($pos, $idcol, $idsa, $userids)
540
	{
541
	global $babBody, $idx;
542
543
	class tempa
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type tempa has been defined more than once; this definition is ignored, only the first definition in programs/utilit/vacincl.php (L1109-1321) 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...
544
		{
545
		var $warning;
546
		var $message;
547
		var $title;
548
		var $urlyes;
549
		var $urlno;
550
		var $yes;
551
		var $no;
552
553
		function tempa($pos, $idcol, $idsa, $userids)
0 ignored issues
show
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...
554
			{
555
			global $BAB_SESS_USERID, $babDB;
556
			$this->message = absences_translate("Are you sure you want to remove those personnel members");
0 ignored issues
show
The property message 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...
557
			$this->title = "";
0 ignored issues
show
The property title 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...
558
			$items = "";
559
560
			for($i = 0; $i < count($userids); $i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() 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...
561
				{
562
				$req = "select * from ".BAB_USERS_TBL." where id='".$babDB->db_escape_string($userids[$i])."'";
563
				$res = $babDB->db_query($req);
564
				if( $babDB->db_num_rows($res) > 0)
565
					{
566
					$arr = $babDB->db_fetch_array($res);
567
					$this->title .= "<br>". bab_composeUserName($arr['firstname'], $arr['lastname']);
568
					$items .= $arr['id'];
569
					}
570
				if( $i < count($userids) -1)
571
					$items .= ",";
572
				}
573
			$this->warning = absences_translate("WARNING: This operation will remove personnel members, all the vacations parameters and the users vacation requests, the ovidentia users will remain"). "!";
0 ignored issues
show
The property warning 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...
574
			$this->urlyes = absences_addon()->getUrl()."vacadm&idx=lper&pos=".$pos."&idcol=".$idcol."&idsa=".$idsa."&action=Yes&items=".$items;
0 ignored issues
show
The property urlyes 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...
575
			$this->yes = absences_translate("Yes");
0 ignored issues
show
The property yes 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...
576
			$this->urlno = absences_addon()->getUrl()."vacadm&idx=lper&pos=".$pos."&idcol=".$idcol."&idsa=".$idsa;
0 ignored issues
show
The property urlno 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...
577
			$this->no = absences_translate("No");
0 ignored issues
show
The property no 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...
578
			}
579
		}
580
581
	if( count($userids) <= 0)
582
		{
583
		$babBody->msgerror = absences_translate("Please select at least one item");
584
		listVacationPersonnel();
585
		$idx = "lper";
586
		return;
587
		}
588
	$tempa = new tempa($pos, $idcol, $idsa, $userids);
0 ignored issues
show
The call to tempa::tempa() has too many arguments starting with $idsa.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
589
	$babBody->babecho(	bab_printTemplate($tempa, absences_addon()->getRelativePath()."warning.html", "warningyesno"));
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...
590
	}
591
592
593
function admmenu()
594
{
595
	require_once dirname(__FILE__).'/utilit/menu.ui.php';
596
597
	$W = bab_Widgets();
598
	$page = $W->BabPage();
599
600
	$menu = new absences_ManagerMenu();
601
602
	$page->setTitle(absences_translate('Vacation management'));
603
	$page->addItem($menu->getFrame());
604
	$page->displayHtml();
605
}
606
607
608
function saveVacationType($tname, $description, $tcolor, $maxdays=0, $mindays=0, $default=0)
609
	{
610
	global $babBody;
611
	if( empty($tname)) {
612
		$babBody->msgerror = absences_translate("ERROR: You must provide a name")." !";
613
		return false;
614
		}
615
616
	$babDB = $GLOBALS['babDB'];
617
618
	$req = "select id from ".ABSENCES_TYPES_TBL." where name='".$babDB->db_escape_string($tname)."'";
619
	$res = $babDB->db_query($req);
620 View Code Duplication
	if( $res && $babDB->db_num_rows($res) > 0 )
0 ignored issues
show
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...
621
		{
622
		$babBody->msgerror = absences_translate("This vacation type already exists") ." !";
623
		return false;
624
		}
625
626
	$req = "insert into ".ABSENCES_TYPES_TBL." ( name, description, quantity, maxdays, mindays, defaultdays, color, recover)";
627
	$req .= " values (
628
	'".$babDB->db_escape_string($tname)."',
629
	'" .$babDB->db_escape_string($description). "',
630
		'" .$babDB->db_escape_string(0). "',
631
		'" .$babDB->db_escape_string($maxdays). "',
632
		'" .$babDB->db_escape_string($mindays). "',
633
		'" .$babDB->db_escape_string($default). "',
634
		'" .$babDB->db_escape_string($tcolor). "',
635
		".$babDB->quote(bab_pp('recover', 0))."
636
	)";
637
	$res = $babDB->db_query($req);
0 ignored issues
show
$res 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...
638
	return true;
639
	}
640
641
function updateVacationType($vtid, $tname, $description, $tcolor, $maxdays=0, $mindays=0, $default=0)
642
	{
643
	global $babBody;
644
	if( empty($tname))
645
		{
646
		$babBody->msgerror = absences_translate("ERROR: You must provide a name")." !";
647
		return false;
648
		}
649
650
	$babDB = $GLOBALS['babDB'];
651
652
	$req = "SELECT id from ".ABSENCES_TYPES_TBL." WHERE name='".$babDB->db_escape_string($tname)."' AND id!='".$babDB->db_escape_string($vtid)."'";
653
	$res = $babDB->db_query($req);
654 View Code Duplication
	if( $res && $babDB->db_num_rows($res) > 0 )
0 ignored issues
show
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...
655
		{
656
		$babBody->msgerror = absences_translate("This vacation type already exists") ." !";
657
		return false;
658
		}
659
660
	$req = "UPDATE ".ABSENCES_TYPES_TBL."
661
		SET
662
			name='".$babDB->db_escape_string($tname)."',
663
			description='".$babDB->db_escape_string($description)."',
664
			quantity='0',
665
			maxdays='".$babDB->db_escape_string($maxdays)."',
666
			mindays='".$babDB->db_escape_string($mindays)."',
667
			defaultdays='".$babDB->db_escape_string($default)."',
668
			color='".$babDB->db_escape_string($tcolor)."',
669
			recover=".$babDB->quote(bab_pp('recover', 0))."
670
		WHERE
671
			id='".$babDB->db_escape_string($vtid)."'";
672
	$res = $babDB->db_query($req);
0 ignored issues
show
$res 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...
673
674
675
	// clear planning cache
676
	$babDB->db_query("DELETE FROM ".ABSENCES_CALENDAR_TBL."");
677
678
	return true;
679
	}
680
681
/**
682
 *
683
 * @param int $vtid
684
 */
685 View Code Duplication
function deleteVacationType($vtid)
0 ignored issues
show
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...
686
	{
687
	global $babBody, $babDB;
688
	$bdel = true;
689
690
	list($total) = $babDB->db_fetch_array($babDB->db_query("select count(id) as total from ".ABSENCES_RIGHTS_TBL." where id_type='".$babDB->db_escape_string($vtid)."'"));
691
	if( $total > 0 )
692
	{
693
		$bdel = false;
694
	}
695
696
	if( $bdel )
697
		{
698
		$babDB->db_query("delete from ".ABSENCES_TYPES_TBL." where id='".$babDB->db_escape_string($vtid)."'");
699
		$babDB->db_query("delete from ".ABSENCES_COLL_TYPES_TBL." where id_type='".$babDB->db_escape_string($vtid)."'");
0 ignored issues
show
Deprecated Code introduced by
The constant ABSENCES_COLL_TYPES_TBL has been deprecated with message: : liaison regime/type : on laisse les anciennes donnes dans la table mais elle ne doit plus etre utilise

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

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

Loading history...
700
		}
701
	else
702
		$babBody->msgerror = absences_translate("This vacation type is used and can't be deleted") ." !";
703
	}
704
705
706
/**
707
 *
708
 * @param unknown_type $tname
709
 * @param unknown_type $description
710
 * @param unknown_type $category
711
 * @return boolean
712
 */
713
function absences_saveVacationCollection($tname, $description, $category)
714
	{
715
	global $babBody;
716
	if( empty($tname))
717
		{
718
		$babBody->msgerror = absences_translate("ERROR: You must provide a name")." !";
719
		return false;
720
		}
721
722
	$babDB = $GLOBALS['babDB'];
723
724
	$req = "select id from ".ABSENCES_COLLECTIONS_TBL." where name='".$babDB->db_escape_string($tname)."'";
725
	$res = $babDB->db_query($req);
726 View Code Duplication
	if( $res && $babDB->db_num_rows($res) > 0 )
0 ignored issues
show
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...
727
		{
728
		$babBody->msgerror = absences_translate("This collection already exists") ." !";
729
		return false;
730
		}
731
732
	$req = "insert into ".ABSENCES_COLLECTIONS_TBL." ( name, description, id_cat )";
733
	$req .= " values ('".$babDB->db_escape_string($tname)."', '" .$babDB->db_escape_string($description)."', '" .$babDB->db_escape_string($category). "')";
734
	$res = $babDB->db_query($req);
0 ignored issues
show
$res 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...
735
	$id = $babDB->db_insert_id();
0 ignored issues
show
$id 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...
736
737
	return true;
738
	}
739
740
741
/**
742
 *
743
 * @param int $vcid
744
 * @param string $tname
745
 * @param string $description
746
 * @param int $category
747
 */
748
function absences_updateVacationCollection($vcid, $tname, $description, $category)
749
	{
750
	global $babBody, $babDB;
751
	if( empty($tname))
752
		{
753
		$babBody->msgerror = absences_translate("ERROR: You must provide a name")." !";
754
		return false;
755
		}
756
757
758
	$req = "select id from ".ABSENCES_COLLECTIONS_TBL." where name='".$babDB->db_escape_string($tname)."' and id!='".$babDB->db_escape_string($vcid)."'";
759
	$res = $babDB->db_query($req);
760 View Code Duplication
	if( $res && $babDB->db_num_rows($res) > 0 )
0 ignored issues
show
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...
761
		{
762
		$babBody->msgerror = absences_translate("This collection already exists") ." !";
763
		return false;
764
		}
765
766
	$res = $babDB->db_query("update ".ABSENCES_COLLECTIONS_TBL." set name='".$babDB->db_escape_string($tname)."', description='".$babDB->db_escape_string($description)."', id_cat='".$babDB->db_escape_string($category)."' where id='".$babDB->db_escape_string($vcid)."'");
0 ignored issues
show
$res 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...
767
768
	return true;
769
	}
770
771
772 View Code Duplication
function absences_beneficiariesUpdateProgress($id)
0 ignored issues
show
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...
773
	{
774
		require_once dirname(__FILE__).'/utilit/right.ui.php';
775
		require_once dirname(__FILE__).'/utilit/right.act.php';
776
777
		$W = bab_Widgets();
778
779
		$right = new absences_Right($id);
780
781
		$progress = $W->ProgressBar();
782
783
		absences_RightAct::updateCollectionsBeneficiaries($right, $progress, (array) bab_gp('collection', array()));
784
		die();
785
	}
786
787
788
function absences_updateVacationPersonnelGroup()
789
{
790
	global $babDB, $babBody;
791
792
	$W = bab_Widgets();
793
	$progress = $W->ProgressBar();
794
795
796
	$groupid 		= bab_rp('groupid');
797
	$addmodify 		= bab_rp('addmodify');
798
	$idcol 			= bab_rp('idcol');
799
	$idsa 			= bab_rp('idsa');
800
	$id_sa_cet 		= bab_rp('id_sa_cet');
801
	$id_sa_recover 	= bab_rp('id_sa_recover');
802
803
804
	if( empty($groupid) )
805
		{
806
		echo bab_toHtml(absences_translate("You must specify a group"), BAB_HTML_ALL);
807
		return false;
808
		}
809
810
	if( !in_array($addmodify, array('add','modify')) )
811
		{
812
		echo bab_toHtml(absences_translate("error"), BAB_HTML_ALL);
813
		return false;
814
		}
815
816
	if( empty($idcol) && $addmodify == 'add' )
817
		{
818
		echo bab_toHtml(absences_translate("You must specify a vacation collection"), BAB_HTML_ALL);
819
		return false;
820
		}
821
822
	if( empty($idsa) )
823
		{
824
		echo bab_toHtml(absences_translate("You must specify an approbation schema") , BAB_HTML_ALL);
825
		return false;
826
		}
827
828
829
	$users = (array) bab_getGroupsMembers($groupid);
830
	$total = count($users);
831
	$pos = 1;
832
833
	foreach($users as $user)
834
	{
835
		$agent = absences_Agent::getFromIdUser($user['id']);
836
837
		if( $agent->exists() && $addmodify == 'modify')
838
		{
839
			if ($agent->id_sa != $idsa || $agent->id_sa_cet != $id_sa_cet || $agent->id_sa_recover != $id_sa_recover)
840
			{
841
				$wr = $agent->getRequestIterator()->count();
842
843
				if ($wr > 0)
844
				{
845
					// modification d'un membre du personnel avec des demandes en attente
846
					// absences_updateVacationUser($arr['id_user'], $idsa);
847
848
					echo bab_toHtml(sprintf(absences_translate(
849
						'%s has not been modified because of %d waiting request',
850
						'%s has not been modified because of %d waiting requests', $wr ), $agent->getName(), $wr) , BAB_HTML_ALL);
851
852 View Code Duplication
				} else {
0 ignored issues
show
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...
853
854
					// modification d'un membre du personnel qui n'a pas de demande en attente
855
					$babDB->db_query("update ".ABSENCES_PERSONNEL_TBL." set
856
						id_sa='".$babDB->db_escape_string($idsa)."',
857
						id_sa_cet=".$babDB->quote($id_sa_cet).",
858
						id_sa_recover=".$babDB->quote($id_sa_recover)."
859
					WHERE id_user=".$babDB->quote($user['id']));
860
				}
861
			}
862
		}
863
		else if (!$agent->exists() && $addmodify == 'add')
864
		{
865
			// creation du nouveau membre du personnel
866
			try {
867
				$messages = array();
868
				absences_saveVacationPersonnel($user['id'], $idcol, $idsa, $id_sa_cet, $id_sa_recover, null, $messages);
869
870
				foreach($messages as $m)
871
				{
872
					echo bab_toHtml($user['name'].' : '.$m, BAB_HTML_ALL);
873
				}
874
875
876
			} catch (Exception $e)
877
			{
878
				echo bab_toHtml($e->getMessage() , BAB_HTML_ALL);
879
			}
880
		}
881
882
883
		$progress->updateProgress(($pos * 100) / $total, $agent->getName());
884
		$pos++;
885
	}
886
887
	$progress->updateProgress(100, absences_translate('Finished'));
888
	die();
889
}
890
891
892
/**
893
 *
894
 * @param int $vcid
895
 */
896 View Code Duplication
function absences_deleteVacationCollection($vcid)
0 ignored issues
show
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...
897
	{
898
	global $babDB;
899
	$bdel = true;
900
901
	list($total) = $babDB->db_fetch_array($babDB->db_query("select count(id) as total from ".ABSENCES_PERSONNEL_TBL." where id_coll='".$babDB->db_escape_string($vcid)."'"));
902
	if( $total > 0 )
903
		{
904
		$bdel = false;
905
		}
906
907
	if( $bdel )
908
		{
909
		$babDB->db_query("delete from ".ABSENCES_COLLECTIONS_TBL." where id='".$babDB->db_escape_string($vcid)."'");
910
		$babDB->db_query("delete from ".ABSENCES_COLL_TYPES_TBL." where id_coll='".$babDB->db_escape_string($vcid)."'");
0 ignored issues
show
Deprecated Code introduced by
The constant ABSENCES_COLL_TYPES_TBL has been deprecated with message: : liaison regime/type : on laisse les anciennes donnes dans la table mais elle ne doit plus etre utilise

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

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

Loading history...
911
		}
912
	else
913
		$babBody->msgerror = absences_translate("This vacation collection is used and can't be deleted") ." !";
0 ignored issues
show
The variable $babBody does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
914
	}
915
916
917
/**
918
 * Remove vacation personnel
919
 * @param unknown_type $items
920
 */
921
function confirmDeletePersonnel($items)
922
{
923
924
	global $babDB;
925
926
	$arr = explode(",", $items);
927
	$cnt = count($arr);
928
	for($i = 0; $i < $cnt; $i++)
929
	{
930
		$agent = absences_Agent::getFromIdUser($arr[$i]);
931
		$agent->delete();
932
		bab_siteMap::clear($arr[$i]);
933
	}
934
935
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
936
	$url = bab_url::get_request('tg', 'idx');
937
	$url->location();
938
}
939
940
941
942
943
/**
944
 * Edit the agent-right link
945
 * @param int $agent_right
946
 */
947
function absences_editAgentRight($agent_right)
948
{
949
	$W = bab_Widgets();
950
	require_once dirname(__FILE__).'/utilit/agent_right.class.php';
951
	require_once dirname(__FILE__).'/utilit/agent.ui.php';
952
	require_once dirname(__FILE__).'/utilit/right.ui.php';
953
	require_once dirname(__FILE__).'/utilit/agent_right.ui.php';
954
	require_once dirname(__FILE__).'/utilit/changes.class.php';
955
	require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
956
957
958
	$agentRight = absences_AgentRight::getById($agent_right);
959
	$agent = $agentRight->getAgent();
960
	$right = $agentRight->getRight();
961
	
962
963
964
	if (isset($_POST['agent_right']))
965
	{
966
		$changes = new absences_Changes();
967
		$ar = $_POST['agent_right'];
968
969
		if ( isset($ar['cancel']) )
970
		{
971
			$url = bab_url::get_request('tg');
972
			$url->idx = 'rights';
973
			$url->idu = $agentRight->id_user;
974
			$url->location();
975
		}
976
977
978
		if( isset($ar['save'] ))
979
		{
980
			$date = $W->DatePicker();
981
982
			if ('right' === $ar['quantity_type']) {
983
			    $ar['quantity'] = '';
984
			}
985
			
986
			$agentRightQuantity = $agentRight->getQuantityFromInput($ar['quantity']);
987
			
988
			if (isset($agentRightQuantity)) {
989
			    
990
			    if ('' === $agentRight->quantity && '' !== $agentRightQuantity) {
991
			        $changes->fromRightQuantityToAgentQuantity();
992
			    }
993
			    
994
			    if ('' !== $agentRight->quantity && '' === $agentRightQuantity) {
995
			        $changes->fromAgentQuantityToRightQuantity();
996
			    }
997
			    
998
    			$old_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit);
999
    			$agentRight->quantity = (string) $agentRightQuantity;
1000
    			$new_quantity = absences_quantity($agentRight->getQuantity(), $right->quantity_unit);
1001
1002
    			$changes->setQuantity($old_quantity, $new_quantity);
1003
    			
1004
			}
1005
1006 View Code Duplication
			if (isset($ar['date_begin_valid']) && isset($ar['date_end_valid']))
0 ignored issues
show
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...
1007
			{
1008
				$date_begin_valid = $date->getISODate($ar['date_begin_valid']);
1009
				$date_end_valid = $date->getISODate($ar['date_end_valid']);
1010
1011
				$changes->setValidPeriod($agentRight->date_begin_valid, $agentRight->date_end_valid, $date_begin_valid, $date_end_valid);
0 ignored issues
show
It seems like $date_begin_valid defined by $date->getISODate($ar['date_begin_valid']) on line 1008 can also be of type false; however, absences_Changes::setValidPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $date_end_valid defined by $date->getISODate($ar['date_end_valid']) on line 1009 can also be of type false; however, absences_Changes::setValidPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
1012
				$agentRight->date_begin_valid = $date_begin_valid;
1013
				$agentRight->date_end_valid = $date_end_valid;
1014
			}
1015
1016
			if (isset($ar['inperiod_start']) && isset($ar['inperiod_end']))
1017
			{
1018
				$inperiod_start = $date->getISODate($ar['inperiod_start']);
1019
				$inperiod_end = $date->getISODate($ar['inperiod_end']);
1020
1021
				$changes->setInPeriod($agentRight->inperiod_start, $agentRight->inperiod_end, $inperiod_start, $inperiod_end);
0 ignored issues
show
It seems like $inperiod_start defined by $date->getISODate($ar['inperiod_start']) on line 1018 can also be of type false; however, absences_Changes::setInPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $inperiod_end defined by $date->getISODate($ar['inperiod_end']) on line 1019 can also be of type false; however, absences_Changes::setInPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
1022
				$changes->setValidOverlap($agentRight->validoverlap, $ar['validoverlap']);
0 ignored issues
show
$agentRight->validoverlap is of type integer, 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...
1023
1024
				$agentRight->inperiod_start = $inperiod_start;
1025
				$agentRight->inperiod_end = $inperiod_end;
1026
				$agentRight->validoverlap = $ar['validoverlap'];
1027
			}
1028
1029 View Code Duplication
			if (isset($ar['saving_begin']) && isset($ar['saving_end']))
0 ignored issues
show
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...
1030
			{
1031
				// CET
1032
				$saving_begin = $date->getISODate($ar['saving_begin']);
1033
				$saving_end = $date->getISODate($ar['saving_end']);
1034
1035
				$changes->setSavingPeriod($agentRight->saving_begin, $agentRight->saving_end, $saving_begin, $saving_end);
0 ignored issues
show
It seems like $saving_begin defined by $date->getISODate($ar['saving_begin']) on line 1032 can also be of type false; however, absences_Changes::setSavingPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $saving_end defined by $date->getISODate($ar['saving_end']) on line 1033 can also be of type false; however, absences_Changes::setSavingPeriod() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
1036
				$agentRight->saving_begin = $saving_begin;
1037
				$agentRight->saving_end = $saving_end;
1038
			}
1039
1040
1041
			$agentRight->save();
1042
1043
			$agentRight->addAgentMovement($agent, $changes, $ar['movement_comment']);
1044
			
1045
1046
1047
			$url = bab_url::get_request('tg');
1048
			$url->idx = 'rights';
1049
			$url->idu = $agentRight->id_user;
1050
			$url->location();
1051
		}
1052
	}
1053
1054
1055
1056
1057
1058
1059
1060
1061
	$page = $W->BabPage();
1062
	$page->addStyleSheet(absences_Addon()->getStylePath().'vacation.css');
1063
1064
1065
1066
	$page->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

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...
1067
	$page->addItemMenu("rights", absences_translate("User rights"), absences_addon()->getUrl()."vacadm&idx=rights&idu=".$agent->id_user);
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

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...
1068
	$page->addItemMenu("agentright", absences_translate("User right"), absences_addon()->getUrl()."vacadm&idx=agentright&ar=".bab_rp('ar'));
0 ignored issues
show
Deprecated Code introduced by
The method Widget_BabPage::addItemMenu() has been deprecated with message: Replaced by Widget_Tabs

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...
1069
1070
1071
1072
1073
	$page->setTitle(sprintf(absences_translate('Right parameter only for %s'), $agent->getName()));
1074
1075
	$agentCard = new absences_AgentCardFrame($agent);
1076
	$agentCard->addClass('widget-bordered');
1077
	$agentCard->addClass('widget-centered');
1078
	$agentCard->setCanvasOptions($agentCard->Options()->width(70,'em'));
0 ignored issues
show
It seems like $agentCard->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...
1079
1080
	$page->addItem($agentCard);
1081
1082
1083
	$rightCard = new absences_RightCardFrame($right);
0 ignored issues
show
It seems like $right defined by $agentRight->getRight() on line 960 can be null; however, absences_RightCardFrame::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
1084
	$rightCard->addClass('widget-bordered');
1085
	$rightCard->addClass('widget-centered');
1086
	$rightCard->setCanvasOptions($rightCard->Options()->width(70,'em'));
0 ignored issues
show
It seems like $rightCard->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...
1087
1088
	$page->addItem($rightCard);
1089
1090
1091
	if ($message = $agentRight->getQuantityAlert())
1092
	{
1093
		$rightCard->addItem($W->Icon($message, Func_Icons::STATUS_DIALOG_WARNING));
1094
	}
1095
	
1096
	// liste des modification du solde par mois (droits variables par mois)
1097
1098
	$dynrightCard = new absences_IncrementCardFrame($agentRight);
1099
	$dynrightCard->addClass('widget-bordered');
1100
	$dynrightCard->addClass('widget-centered');
1101
	$dynrightCard->setCanvasOptions($rightCard->Options()->width(70,'em'));
0 ignored issues
show
It seems like $rightCard->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...
1102
	if ($dynrightCard->contain_rows)
1103
	{
1104
	    $page->addItem($dynrightCard);
1105
	}
1106
	
1107
1108
	// liste des modification dynamiques du solde
1109
1110
	$dynrightCard = new absences_DynamicRightCardFrame($agentRight);
1111
	$dynrightCard->addClass('widget-bordered');
1112
	$dynrightCard->addClass('widget-centered');
1113
	$dynrightCard->setCanvasOptions($rightCard->Options()->width(70,'em'));
0 ignored issues
show
It seems like $rightCard->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...
1114
	if ($dynrightCard->contain_rows)
1115
	{
1116
		$page->addItem($dynrightCard);
1117
	}
1118
1119
	$editor = new absences_AgentRightEditor($agentRight);
1120
	$page->addItem($editor);
1121
	
1122
	$history = new absences_AgentRightMovementFrame($agentRight);
1123
	if ($history->count) {
1124
	   $page->addItem($history);
1125
	}
1126
1127
	$page->displayHtml();
1128
}
1129
1130
1131
1132
1133
1134 View Code Duplication
function absences_agentMovements($id_user)
0 ignored issues
show
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...
1135
{
1136
	require_once dirname(__FILE__).'/utilit/agent.class.php';
1137
	require_once dirname(__FILE__).'/utilit/agent.ui.php';
1138
1139
	$babBody = bab_getInstance('babBody');
1140
	$agent = absences_Agent::getFromIdUser($id_user);
1141
	$W = bab_Widgets();
1142
1143
	$card = new absences_AgentCardFrame($agent);
1144
1145
	$card->addClass('widget-bordered');
1146
	$card->addClass('BabLoginMenuBackground');
1147
1148
	$list = new absences_AgentMovementList($agent);
1149
1150
	$babBody->setTitle(absences_translate('User history'));
1151
1152
	$babBody->babEcho($card->display($W->HtmlCanvas()));
1153
	$babBody->babEcho($list->getHtml());
1154
}
1155
1156
1157
1158 View Code Duplication
function absences_updateManagerVacationPersonnel($id_user)
0 ignored issues
show
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...
1159
{
1160
    $update = absences_updateVacationPersonnel($id_user);
1161
    
1162
    if(true === $update) {
1163
        return 'changeucol'; // vers la modification du regime
1164
    }
1165
1166
    if (false === $update) {
1167
        return 'modp';
1168
    }
1169
    
1170
    $url = bab_url::get_request('tg');
1171
    $url->idx = 'lper';
1172
    $url->location();
1173
}
1174
1175
1176
1177
/* main */
1178
bab_requireCredential();
1179
$agent = absences_Agent::getCurrentUser();
1180
1181
if( !$agent->isManager())
1182
	{
1183
	$babBody->msgerror = absences_translate("Access denied");
1184
	return;
1185
	}
1186
1187
$idx = bab_rp('idx', "menu");
1188
1189
if( isset($_POST['add']) )
1190
	{
1191
	switch($_POST['add'])
1192
		{
1193
		case 'addvt':
1194
1195 View Code Duplication
			if(!saveVacationType(bab_rp('tname'), bab_rp('description'), bab_rp('tcolor')))
0 ignored issues
show
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...
1196
				$idx ='addvt';
1197
1198
			break;
1199
1200
		case 'modvt':
1201
			if(bab_rp('bdel', null))
1202
			{
1203
				deleteVacationType(bab_rp('vtid'));
1204
			}
1205 View Code Duplication
			else if(!updateVacationType(bab_rp('vtid'), bab_rp('tname'), bab_rp('description'), bab_rp('tcolor')))
0 ignored issues
show
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...
1206
			{
1207
				$idx ='addvt';
1208
			}
1209
			break;
1210
1211
		case 'addvc':
1212
			if(!absences_saveVacationCollection(bab_rp('tname'), bab_rp('description'), bab_rp('category')))
1213
			{
1214
				$idx ='addvc';
1215
			}
1216
			break;
1217
1218
		case 'modvc':
1219
1220
			if(bab_rp('bdel', null))
1221
			{
1222
				absences_deleteVacationCollection(bab_rp('vcid'));
1223
			}
1224
			else if(!absences_updateVacationCollection(bab_pp('vcid'), bab_pp('tname'), bab_pp('description'), bab_pp('category')))
1225
			{
1226
				$idx ='addvc';
1227
			}
1228
			break;
1229
1230
1231
		case 'changeuser':
1232
1233
			if (!empty($_POST['idp'])) {
1234
			    $idx = absences_updateManagerVacationPersonnel($_POST['idp']);
1235
			}
1236
			else {
1237
				$idsa = bab_pp('idsa', 0);
1238
				$id_sa_cet = bab_pp('id_sa_cet', 0);
1239
				$id_sa_recover = bab_pp('id_sa_recover', 0);
1240
				$emails = bab_pp('emails');
1241
1242
				try {
1243
1244
					$messages = array();
1245
					if(!absences_saveVacationPersonnel(bab_pp('userid'), bab_pp('idcol'), $idsa, $id_sa_cet, $id_sa_recover, $emails, $messages))
1246
					{
1247
					$idx ='addp';
1248
					}
1249
				} catch (Exception $e)
1250
				{
1251
					$babBody->addError($e->getMessage());
1252
					$idx ='addp';
1253
					break;
1254
				}
1255
1256
1257
				if (!empty($messages))
1258
				{
1259
					foreach($messages as $message)
1260
					{
1261
						$babBody->addNextPageMessage($message);
1262
					}
1263
				}
1264
1265
				require_once $GLOBALS['babInstallPath'].'utilit/urlincl.php';
1266
1267
				$url = bab_url::get_request('tg', 'pos', 'idcol', 'idsa');
1268
				$url->idx = 'lper';
1269
				$url->location();
1270
			}
1271
			break;
1272
1273
1274
		case 'changeucol':
1275
			if (!absences_updateUserColl())
1276
				$idx = $add;
1277
			break;
1278
1279
		case 'modrbu':
1280
			if (true === absences_updateVacationRightByUser(
1281
				bab_pp('idu'),
1282
				bab_pp('quantity'),
1283
				bab_pp('comment')
1284
			)) {
1285
1286
				require_once $GLOBALS['babInstallPath'] . 'utilit/urlincl.php';
1287
1288
				$url = bab_url::get_request('tg', 'idx', 'idu');
1289
				$url->location();
1290
			}
1291
			break;
1292
		}
1293
	}
1294
else if( isset($_GET['action']) && $_GET['action'] == "Yes")
1295
	{
1296
	confirmDeletePersonnel($_GET['items']);
1297
	$idx = "lper";
1298
	}
1299
1300
1301
1302
if ($agent->isInPersonnel())
1303
{
1304
	$babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser");
1305
}
1306
1307
if( $agent->isEntityManager())
1308
{
1309
	$babBody->addItemMenu("entities", absences_translate("Delegate management"), absences_addon()->getUrl()."vacchart");
1310
}
1311
1312
$babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu");
1313
1314
1315
1316
switch($idx)
1317
	{
1318
	case "browu":
1319
		include_once $babInstallPath."utilit/lusersincl.php";
1320
		bab_browseUsers(bab_rp('pos'), bab_rp('cb'));
1321
		exit;
1322
		break;
1323
	case "browg":
1324
		include_once $babInstallPath."utilit/grpincl.php";
1325
		browseGroups(bab_rp('cb'));
1326
		exit;
1327
		break;
1328
1329 View Code Duplication
	case 'rights':
0 ignored issues
show
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...
1330
		absences_listRightsByUser(bab_rp('idu'));
1331
1332
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1333
		$babBody->addItemMenu("rights", absences_translate("User rights"), absences_addon()->getUrl()."vacadm&idx=rights&idu=".bab_rp('idu'));
1334
		break;
1335
1336
	case 'agentright':
1337
		absences_editAgentRight(bab_rp('ar'));
1338
1339
		break;
1340
1341
1342 View Code Duplication
	case 'movement':
0 ignored issues
show
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...
1343
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1344
		$babBody->addItemMenu("movement", absences_translate("History"), absences_addon()->getUrl()."vacadm&idx=movement&idu=".bab_rp('idu'));
1345
		absences_agentMovements(bab_rp('idu'));
1346
		break;
1347
1348
1349 View Code Duplication
	case "delu":
0 ignored issues
show
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...
1350
		$babBody->title = absences_translate("Delete users");
1351
		deleteVacationPersonnel(
1352
			bab_rp('pos'),
1353
			bab_rp('idcol'),
1354
			bab_rp('idsa'),
1355
			bab_rp('userids',array())
1356
		);
1357
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1358
		$babBody->addItemMenu("delu", absences_translate("Delete"), absences_addon()->getUrl()."vacadm&idx=delu");
1359
		break;
1360
1361 View Code Duplication
	case "modp":
0 ignored issues
show
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...
1362
		$babBody->title = absences_translate("Modify user");
1363
1364
		absences_addVacationPersonnel($_REQUEST['idp']);
1365
1366
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1367
		$babBody->addItemMenu("modp", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modp");
1368
		break;
1369
1370 View Code Duplication
	case "addp":
0 ignored issues
show
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...
1371
		$babBody->title = absences_translate("Add users");
1372
		absences_addVacationPersonnel();
1373
1374
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1375
		$babBody->addItemMenu("addp", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addp");
1376
		break;
1377
1378 View Code Duplication
	case 'changeucol':
0 ignored issues
show
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...
1379
		$babBody->title = sprintf(absences_translate("Change user collection for %s"), bab_getuserName($_POST['idp']));
1380
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1381
		$babBody->addItemMenu("changeucol", absences_translate("User collection"), absences_addon()->getUrl()."vacadm&idx=changeucol");
1382
		absences_changeucol($_POST['idp'],$_POST['idcol']);
1383
		break;
1384
1385 View Code Duplication
	case "addg":
0 ignored issues
show
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...
1386
		$babBody->title = absences_translate("Add/Modify users by group");
1387
		addGroupVacationPersonnel();
1388
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1389
		$babBody->addItemMenu("addg", absences_translate("Add/Modify"), absences_addon()->getUrl()."vacadm&idx=addg");
1390
		break;
1391
1392
	case 'addg_progress':
1393
		absences_updateVacationPersonnelGroup();
1394
		break;
1395
1396
	case "lper":
1397
		$babBody->title = absences_translate("Personnel");
1398
1399
		$pos = bab_rp('pos');
1400
		$chg = bab_rp('chg', null);
1401
1402
		if( isset($chg))
1403
		{
1404
			if( mb_strlen($pos) > 0 && $pos[0] == "-" )
1405
				$pos = mb_strlen($pos)>1? $pos[1]: '';
1406
			else
1407
				$pos = "-" .$pos;
1408
		}
1409
		listVacationPersonnel();
1410
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1411
		
1412
		break;
1413
1414
	// 	available balances export
1415
	case 'abexport':
1416
		$babBody->setTitle(absences_translate("Available balances export"));
1417
		exportAvailableBalances();
1418
		$babBody->addItemMenu("lper", absences_translate("Personnel"), absences_addon()->getUrl()."vacadm&idx=lper");
1419
		$babBody->addItemMenu("abexport", absences_translate("Available balances export"), absences_addon()->getUrl()."vacadm&idx=abexport");
1420
		break;
1421
		
1422
	case 'testexp':
1423
	    testExportBalances();
1424
	    break;
1425
1426
1427 View Code Duplication
	case "lcol":
0 ignored issues
show
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...
1428
1429
		$babBody->title = absences_translate("Vacations type's collections");
1430
		listVacationCollections();
1431
		$babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol");
1432
		$babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc");
1433
		break;
1434
1435 View Code Duplication
	case "modvc":
0 ignored issues
show
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...
1436
		$babBody->title = absences_translate("Modify vacation type's collection");
1437
1438
		$vcid = bab_rp('vcid', bab_rp('id'));
1439
		$what = bab_rp('what', 'modvc');
1440
1441
		addVacationCollection($vcid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('vtypeids', array()), bab_rp('category', 0));
1442
1443
		$babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol");
1444
		$babBody->addItemMenu("modvc", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modvc");
1445
		$babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc");
1446
1447
		break;
1448
1449 View Code Duplication
	case "addvc":
0 ignored issues
show
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...
1450
		$babBody->title = absences_translate("Add vacation type's collection");
1451
1452
		$vcid = bab_rp('vcid', bab_rp('id'));
1453
		$what = bab_rp('what', 'addvc');
1454
1455
		addVacationCollection($vcid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('vtypeids', array()), bab_rp('category', 0));
1456
		$babBody->addItemMenu("lcol", absences_translate("Collections"), absences_addon()->getUrl()."vacadm&idx=lcol");
1457
		$babBody->addItemMenu("addvc", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvc");
1458
1459
		break;
1460
1461 View Code Duplication
	case "modvt":
0 ignored issues
show
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...
1462
		$babBody->title = absences_translate("Modify vacation type");
1463
1464
		$vtid = bab_rp('vtid', bab_rp('id'));
1465
		$what = bab_rp('what', 'modvt');
1466
1467
		addVacationType($vtid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'), bab_rp('cbalance'));
1468
		$babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt");
1469
		$babBody->addItemMenu("modvt", absences_translate("Modify"), absences_addon()->getUrl()."vacadm&idx=modvt");
1470
		$babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt");
1471
		break;
1472
1473 View Code Duplication
	case "addvt":
0 ignored issues
show
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...
1474
		$babBody->title = absences_translate("Add vacation type");
1475
1476
		$vtid = bab_rp('vtid', '');
1477
		$what = bab_rp('what', 'addvt');
1478
1479
		$babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt");
1480
		$babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt");
1481
		addVacationType($vtid, $what, bab_rp('tname'), bab_rp('description'), bab_rp('tcolor'), bab_rp('cbalance'));
1482
1483
		break;
1484
1485 View Code Duplication
	case "lvt":
0 ignored issues
show
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...
1486
1487
		$babBody->title = absences_translate("Vacations types");
1488
		$babBody->addItemMenu("lvt", absences_translate("Types"), absences_addon()->getUrl()."vacadm&idx=lvt");
1489
		$babBody->addItemMenu("addvt", absences_translate("Add"), absences_addon()->getUrl()."vacadm&idx=addvt");
1490
		listVacationTypes();
1491
1492
		break;
1493
1494
	case 'export':
1495
		require_once dirname(__FILE__).'/utilit/agent_export.class.php';
1496
		$excel = new absences_AgentXls(absences_Agent::getFromIdUser(bab_gp('id_user')));
1497
		die();
1498
1499
	case 'rightsexport':
1500
	    $babBody->setTitle(absences_translate('Export rights'));
1501
	    require_once dirname(__FILE__).'/utilit/right_export.class.php';
1502
	    absences_exportForm();
1503
	    break;
1504
1505
	case "menu":
1506
	default:
1507
		$babBody->title = absences_translate("Vacations management");
1508
		admmenu();
1509
		break;
1510
	}
1511
$babBody->setCurrentItemMenu($idx);
1512
bab_siteMap::setPosition('absences','User');
1513
1514