Completed
Push — master ( 907983...ba4b0b )
by Paul
03:21
created

absences_viewVacationCalendarCls::getnextuser()   B

Complexity

Conditions 6
Paths 24

Size

Total Lines 39
Code Lines 23

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 39
rs 8.439
cc 6
eloc 23
nc 24
nop 0
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
require_once dirname(__FILE__).'/vacincl.php';
27
28
29
30
31
32
/**
33
 * Get period index from database
34
 *
35
 * @param	int		$id_user
36
 * @param	int		$month
37
 * @param	int		$year
38
 * @param   string  $dateb      ISO date
39
 * @param   string  $datee      ISO date
40
 *
41
 * @return array
42
 */
43
function absences_getPeriodIndex($id_user, $month, $year, $dateb, $datee)
44
{
45
	require_once $GLOBALS['babInstallPath'].'utilit/settings.class.php';
46
	global $babDB;
47
48
	$req = "
49
	SELECT 
50
		c.id_user,
51
		c.cal_date,
52
		c.ampm,
53
		c.period_type,
54
		c.id_entry,
55
		c.color,
56
		c.title,
57
		e.status 
58
	FROM
59
		".ABSENCES_CALENDAR_TBL." c
60
		LEFT JOIN ".ABSENCES_ENTRIES_TBL." e ON e.id = c.id_entry 
61
	WHERE
62
		monthkey=".$babDB->quote($month.$year)."
63
		AND c.id_user=".$babDB->quote($id_user)."
64
	ORDER BY c.cal_date, c.ampm 
65
	";
66
	$res = $babDB->db_query($req);
67
68
69
	if (0 === $babDB->db_num_rows($res))
70
	{
71
		// cache not found
72
73
		absences_updateCalendar($id_user, $year, $month);
74
		$res = $babDB->db_query($req);
75
	}
76
77
78
	$periodIndex = array();
79
	
80
	while ($arr = $babDB->db_fetch_assoc($res)) {
81
	    
82
	    if ('0000-00-00' !== $dateb && $dateb > $arr['cal_date']) {
83
	        continue;
84
	    }
85
	    
86
	    if ('0000-00-00' !== $datee && $datee < $arr['cal_date']) {
87
	        continue;
88
	    }
89
		
90
		$arr['period_type'] = (int) $arr['period_type'];
91
		$arr['ampm'] = (int) $arr['ampm'];
92
		$arr['id_user'] = (int) $arr['id_user'];
93
		
94
		$key = 'd.'.$arr['cal_date'];
95
		$key .= $arr['ampm'] ? '.1' : '.0';
96
		$periodIndex[$key] = $arr;
97
	}
98
99
100
	return $periodIndex;
101
}
102
103
104
105
106
107
/**
108
 * 
109
 */
110 View Code Duplication
function absences_getEntites()
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

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

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

Loading history...
111
{
112
    $id_chart = absences_getVacationOption('id_chart');
113
    $org = new bab_OrgChartUtil($id_chart);
114
    if (!$org->isAccessValid()) {
115
        return array();
116
    }
117
    return bab_OCGetEntities($id_chart);
118
}
119
120
/**
121
 * 
122
 * @param int $ide
123
 */
124 View Code Duplication
function absences_getChildsEntities($ide)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

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

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

Loading history...
125
{
126
    $id_chart = absences_getVacationOption('id_chart');
127
    $org = new bab_OrgChartUtil($id_chart);
128
    if (!$org->isAccessValid()) {
129
        return array();
130
    }
131
    return bab_OCGetChildsEntities($ide, $id_chart);
132
}
133
134
135
136
137
class absences_viewVacationCalendarCls
138
{
139
	var $entries = array();
140
	var $fullname;
141
	var $vacwaitingtxt;
142
	var $vacapprovedtxt;
143
	var $print;
144
	var $close;
145
	var $emptylines = true;
146
147
	public $display_types;
148
	
149
	
150
	public $public = false;
151
	public $total = null;
152
	
153
	public $loadmore = null;
154
	
155
	
156
	public $nbmonth;
157
	
158
	public $limit;
159
160
161
	/**
162
	 * 
163
	 * @param array 	$users			Users displayed by default
164
	 * @param bool 		$period			Allow period selection (vacation request creation first step)
165
	 * @param bool 		$display_types	Display types color and legend on planning
166
	 * @param int		$nbmonth		Number of month to load
167
	 * @param bool		$dispusers		Display user names column
168
	 */
169
	public function __construct($users, $period, $display_types, $nbmonth, $dispusers, $shiftmonth = 0, $legend = true)
170
	{
171
		global $babBody;
172
173
		include_once $GLOBALS['babInstallPath']."utilit/dateTime.php";
174
		include_once $GLOBALS['babInstallPath']."utilit/urlincl.php";
175
176
		$month = isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : (date("n") + $shiftmonth);
177
		$year = isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : date("Y");
178
179
		global $babDB;
180
		$this->month = $month;
0 ignored issues
show
Bug introduced by
The property month 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...
181
		$this->year = $year;
0 ignored issues
show
Bug introduced by
The property year 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...
182
183
		$this->dispusers = $dispusers;
0 ignored issues
show
Bug introduced by
The property dispusers 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...
184
		$this->display_types = $display_types;
185
		$this->display_legend = $legend;
0 ignored issues
show
Bug introduced by
The property display_legend 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...
186
187
		$this->userNameArr = array();
0 ignored issues
show
Bug introduced by
The property userNameArr 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...
188
		
189
		foreach ($users as $uid)
190
		{
191
			$uid = (int) $uid;
192
			$this->userNameArr[$uid] = bab_getUserName($uid);
193
		}
194
195
		bab_sort::natcasesort($this->userNameArr);
196
197
198
		$this->idusers 		= array_keys($this->userNameArr);
0 ignored issues
show
Bug introduced by
The property idusers 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...
199
		$this->nbusers 		= count($this->idusers);
0 ignored issues
show
Bug introduced by
The property nbusers 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...
200
		$this->firstuser 	= bab_toHtml(current($this->userNameArr));
0 ignored issues
show
Bug introduced by
The property firstuser 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...
201
		$this->display_firstuser = 1 === $this->nbusers;
0 ignored issues
show
Bug introduced by
The property display_firstuser does not seem to exist. Did you mean firstuser?

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...
202
203
		$this->period = $period;
0 ignored issues
show
Bug introduced by
The property period 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...
204
		$this->vacwaitingtxt = absences_translate("Waiting vacation request");
205
		$this->vacapprovedtxt = absences_translate("Approved vacation request");
206
		$this->t_selected = absences_translate("Selected period");
0 ignored issues
show
Bug introduced by
The property t_selected 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
		$this->print = absences_translate("Print");
208
		$this->close = absences_translate("Close");
209
		$this->t_noresult = absences_translate("No results found for this search query");
0 ignored issues
show
Bug introduced by
The property t_noresult 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...
210
211
		$this->t_previousmonth = absences_translate("Previous month");
0 ignored issues
show
Bug introduced by
The property t_previousmonth 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...
212
		$this->t_previousyear = absences_translate("Previous year");
0 ignored issues
show
Bug introduced by
The property t_previousyear 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...
213
		$this->t_nextmonth = absences_translate("Next month");
0 ignored issues
show
Bug introduced by
The property t_nextmonth 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...
214
		$this->t_nextyear = absences_translate("Next year");
0 ignored issues
show
Bug introduced by
The property t_nextyear 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...
215
216
		$this->t_nonworking = absences_translate("Non-working day");
0 ignored issues
show
Bug introduced by
The property t_nonworking 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...
217
		$this->t_weekend = absences_translate("Week-end");
0 ignored issues
show
Bug introduced by
The property t_weekend 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...
218
		$this->t_rotate = absences_translate("Print in landscape");
0 ignored issues
show
Bug introduced by
The property t_rotate 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...
219
		$this->t_non_used = $this->display_types ? absences_translate("Non-used days") : absences_translate("Absences");
0 ignored issues
show
Bug introduced by
The property t_non_used 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...
220
		$this->t_waiting = absences_translate("Waiting vacation request");
0 ignored issues
show
Bug introduced by
The property t_waiting 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...
221
		$this->t_previsional = absences_translate("Previsional vacation request");
0 ignored issues
show
Bug introduced by
The property t_previsional 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...
222
		$this->t_waiting_vac = absences_translate("Waiting vacation request");
0 ignored issues
show
Bug introduced by
The property t_waiting_vac does not seem to exist. Did you mean t_waiting?

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...
223
		$this->t_legend = absences_translate("Legend");
0 ignored issues
show
Bug introduced by
The property t_legend 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...
224
225
		$this->id_request = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
0 ignored issues
show
Bug introduced by
The property id_request does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
226
227
		$this->nbmonth = $nbmonth;
228
		
229
		$this->limit = absences_getSearchLimit($nbmonth);
230
231
		$urltmp = bab_url::get_request_gp();
232
		$this->nwd_color = 'yellow'; // default color for non working days if no categories
0 ignored issues
show
Bug introduced by
The property nwd_color 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...
233
234
		if( $GLOBALS['babBody']->babsite['id_calendar_cat'] != 0)
235
		{
236
			include_once $GLOBALS['babInstallPath']."utilit/calapi.php";
237
			$idcat = bab_calGetCategories($GLOBALS['babBody']->babsite['id_calendar_cat']);
238
			if( isset($idcat[0]['color']))
239
			{
240
				$this->nwd_color = $idcat[0]['color'];
241
			}
242
		}
243
244
		if (!empty($_REQUEST['popup']))
245
		{
246
			$this->popup = true;
0 ignored issues
show
Bug introduced by
The property popup 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...
247
		}
248
249
		if (!isset($_REQUEST['ide']))
250
		{
251
			$urltmp->idu = implode(',',$this->idusers);
252
		}
253
254
		$switchurl = clone $urltmp;
255
256
		if (1 == $this->nbmonth) {
257
258
			$switchurl->nbmonth = 12;
259
			$this->switchurl = $switchurl->toString();
0 ignored issues
show
Bug introduced by
The property switchurl 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...
260
			$this->switchlabel = absences_translate("Year view");
0 ignored issues
show
Bug introduced by
The property switchlabel 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...
261
			
262
			
263
			
264
			$this->prevmonthclass = 'prev1';
0 ignored issues
show
Bug introduced by
The property prevmonthclass 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...
265
			$this->prevyearclass = 'prev2';
0 ignored issues
show
Bug introduced by
The property prevyearclass 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
			
267
			$this->nextmonthclass = 'next1';
0 ignored issues
show
Bug introduced by
The property nextmonthclass 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->nextyearclass = 'next2';
0 ignored issues
show
Bug introduced by
The property nextyearclass 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
			
270
		} else {
271
			$switchurl->nbmonth = 1;
272
			$this->switchurl = $switchurl->toString();
273
			$this->switchlabel = absences_translate("Month view");
274
			
275
			$this->prevmonthclass = 'prev2';
276
			$this->prevyearclass = 'prev1';
277
			
278
			$this->nextmonthclass = 'next2';
279
			$this->nextyearclass = 'next1';
280
		}
281
282
		$urltmp->nbmonth = $this->nbmonth;
283
284
285
		$previousmonth = clone $urltmp;
286
		$previousmonth->month = date("n", mktime( 0,0,0, $month-1, 1, $year));
287
		$previousmonth->year = date("Y", mktime( 0,0,0, $month-1, 1, $year));
288
		$this->previousmonth	= $previousmonth->toString();
0 ignored issues
show
Bug introduced by
The property previousmonth does not seem to exist. Did you mean t_previousmonth?

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
		$nextmonth = clone $urltmp;
291
		$nextmonth->month = date("n", mktime( 0,0,0, $month+1, 1, $year));
292
		$nextmonth->year = date("Y", mktime( 0,0,0, $month+1, 1, $year));
293
		$this->nextmonth = $nextmonth->toString();
0 ignored issues
show
Bug introduced by
The property nextmonth does not seem to exist. Did you mean t_nextmonth?

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...
294
295
		$previousyear = clone $urltmp;
296
		$previousyear->month = date("n", mktime( 0,0,0, $month, 1, $year-1));
297
		$previousyear->year = date("Y", mktime( 0,0,0, $month, 1, $year-1));
298
		$this->previousyear = $previousyear->toString();
0 ignored issues
show
Bug introduced by
The property previousyear does not seem to exist. Did you mean t_previousyear?

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...
299
300
		$nextyear = clone $urltmp;
301
		$nextyear->month = date("n", mktime( 0,0,0, $month, 1, $year+1));
302
		$nextyear->year = date("Y", mktime( 0,0,0, $month, 1, $year+1));
303
		$this->nextyear = $nextyear->toString();
0 ignored issues
show
Bug introduced by
The property nextyear does not seem to exist. Did you mean t_nextyear?

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...
304
305
		$dateb = new BAB_DateTime($year, $month, 1);
306
		$datee = $dateb->cloneDate();
307
		$datee->add($this->nbmonth, BAB_DATETIME_MONTH);
308
		
309
		
310
311
		$this->yearname = $this->getTitle($dateb, $datee);
0 ignored issues
show
Bug introduced by
The property yearname 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...
312
		
313
		
314
315
316
317
318
319
		if ($this->display_types)
320
		{
321
			$this->restypes = $babDB->db_query("
0 ignored issues
show
Bug introduced by
The property restypes 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...
322
323
				SELECT
324
					t.*
325
					FROM
326
					".ABSENCES_TYPES_TBL." t,
327
					absences_rights r,
328
					absences_users_rights ur,
329
					".ABSENCES_PERSONNEL_TBL." p
330
				WHERE
331
					p.id_user IN(".$babDB->quote($this->idusers).")
332
					AND p.id_user=ur.id_user
333
					AND ur.id_right=r.id
334
					AND r.id_type=t.id
335
				GROUP BY
336
					t.id
337
					");
338
339
		}
340
		
341
		
342
		// filtre par service
343
		
344
		$W = bab_Widgets();
345
		$departments = $W->Multiselect();
346
		$departments->setName('departments')->setValue(bab_rp('departments'));
347
		
348
		$entities = absences_getEntites();
349
		foreach($entities as $e) {
350
		    $departments->addOption($e['id'], $e['name']);
351
		}
352
		
353
		$this->departments = '';
0 ignored issues
show
Bug introduced by
The property departments 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...
354
355
		if (count($entities) > 0) {
356
		    $this->departments = $departments->display($W->HtmlCanvas());
357
		}
358
		
359
		
360
		// filtre recherche par date
361
		
362
		$this->datefilter = $this->getDateFilter()->display($W->HtmlCanvas());
0 ignored issues
show
Bug introduced by
The property datefilter 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...
363
	}
364
	
365
	
366
	
367
	private function getDateFilter()
368
	{
369
	    $W = bab_Widgets();
370
	    
371
	    switch (bab_rp('searchtype')) {
372 View Code Duplication
	        case '2':
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
373
    	       $dateb = bab_rp('dateb');
374
    	       $datee = bab_rp('datee');
375
    	       $_date = null;
376
    	       break;
377
    	      
378
	        default:
379 View Code Duplication
	        case '1':
0 ignored issues
show
Unused Code introduced by
case '1': $dateb = n..._rp('date'); break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

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

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

Loading history...
380
	           $dateb = null;
381
	           $datee = null;
382
	           $_date = bab_rp('date');
383
	           break;
384
	    }
385
	    
386
	    $period = $W->LabelledWidget(
387
	            absences_translate('Date'),
388
	            $W->PeriodPicker()->setNames('dateb', 'datee')->setValues($dateb, $datee)
389
	    );
390
	    
391
	    $date = $W->LabelledWidget(
392
	            absences_translate('Date'),
393
	            $picker = $W->DatePicker()->setValue($_date)->addClass('absences-search-by-date'),
394
	            'date'
395
	    );
396
	    
397
	    $begin = $picker->getISODate($dateb);
398
	    $end = $picker->getISODate($datee);
399
	    $d = $picker->getISODate($_date);
400
	    
401
	    if ('0000-00-00' !== $d) {
402
	        $begin = $d;
403
	        $end = $d;
404
	    }
405
	    
406
	    if ('0000-00-00' !== $begin && '0000-00-00' !== $end) {
407
	        $picker->setMetadata('dateb', $begin);
408
	        $picker->setMetadata('datee', $end);
409
	    }
410
	    
411
	    
412
	    $frame = $W->Frame(null , $W->HBoxItems());
413
	    
414
	    
415
	    $frame->addItem(
416
	            $W->LabelledWidget(
417
	                    absences_translate('Search by date'),
418
	                    $W->Select()
419
	                    ->setAssociatedDisplayable($date, array('1'))
420
	                    ->setAssociatedDisplayable($period, array('2'))
421
	                    ->addOption('1', absences_translate("Absences on a date"))
422
	                    ->addOption('2', absences_translate("Absences in a period"))
423
	                    ->setValue(bab_rp('searchtype', 1)),
424
	                    'searchtype'
425
	            )
426
	    );
427
	    
428
	    
429
	    $frame->addItem($period);
430
	    $frame->addItem($date);
431
	    
432
	    return $frame;
433
	}
434
	
435
	
436
	/**
437
	 * @param BAB_DateTime $dateb
438
	 * @param BAB_DateTime $datee
439
	 * 
440
	 * @return string
441
	 */
442
	private function getTitle(BAB_DateTime $dateb, BAB_DateTime $datee)
443
	{
444
	    $months = bab_DateStrings::getMonths();
445
	    $duration = (int) round(($datee->getTimeStamp() - $dateb->getTimeStamp()) / 86400);
446
447
	    if ($duration > 33) {
448
	        
449
	        $end = $datee->cloneDate();
450
	        $end->less(1, BAB_DATETIME_DAY);
451
	        
452
	        return $months[$dateb->getMonth()].' '.$dateb->getYear()."-".$months[$end->getMonth()].' '.$end->getYear();
453
	    }
454
	    
455
	    return $months[$dateb->getMonth()].' '.$dateb->getYear();
456
	}
457
	
458
	
459
	
460
	
461
	public function getnexthidden()
462
	{
463
		if (list($name, $value) = each($_GET))
464
		{
465
			if (is_array($value))
466
			{
467
				return true;
468
			}
469
			
470
			$this->name = bab_toHtml($name);
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
471
			$this->value = bab_toHtml($value);
0 ignored issues
show
Bug introduced by
The property value 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...
472
			return true;
473
		}
474
		
475
		reset($_GET);
476
		return false;
477
	}
478
	
479
	
480
481
	public function getdayname()
482
	{
483
		static $i = 1;
484
		if( $i <= 31)
485
		{
486
			$this->dayname = sprintf('%02d',$i);
0 ignored issues
show
Bug introduced by
The property dayname 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...
487
			$i++;
488
			return true;
489
		}
490
		else
491
			return false;
492
	}
493
	
494
	
495
	/**
496
	 *
497
	 */
498
	public function getmonth()
499
	{
500
		static $i = 0;
501
		if( $i < $this->nbmonth)
502
		{
503
	
504
			$dateb = new BAB_DateTime($this->year, $this->month + $i, 1);
505
	
506
			$this->curyear = $dateb->getYear();
0 ignored issues
show
Bug introduced by
The property curyear 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...
507
			$this->curmonth = $dateb->getMonth();
0 ignored issues
show
Bug introduced by
The property curmonth does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
508
			$months = bab_DateStrings::getMonths();
509
			$this->monthname = bab_toHtml($months[$this->curmonth]);
0 ignored issues
show
Bug introduced by
The property monthname does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

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

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
511
			$this->previous_period = NULL;
0 ignored issues
show
Bug introduced by
The property previous_period does not seem to exist. Did you mean period?

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...
512
			$i++;
513
			return true;
514
		}
515
		else
516
			return false;
517
	}
518
	
519
	
520
	
521
	
522
523
	public function getnextuser()
524
	{
525
		static $i = 0;
526
527
		$n = $this->nbusers;
528
529
		if ( $n == 0 )
530
			$n = 1;
531
532
		$this->rowspan = $this->emptylines ? $this->nbusers : $n;
0 ignored issues
show
Bug introduced by
The property rowspan 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...
533
534
		if ($i < $n)
535
		{
536
			$this->first = $i == 0 ;
0 ignored issues
show
Bug introduced by
The property first 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...
537
			$this->id_user = $this->idusers[$i];
0 ignored issues
show
Bug introduced by
The property id_user 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...
538
			$this->username = bab_toHtml($this->userNameArr[$this->id_user]);
0 ignored issues
show
Bug introduced by
The property username does not seem to exist. Did you mean userNameArr?

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...
539
			try {
540
				$agent = absences_Agent::getCurrentUser();
541
				if ($agent->isManager())
542
				{
543
					$this->userurl = bab_toHtml('?tg=addon/absences/vacadm&idx=modp&idp='.$this->idusers[$i]);
0 ignored issues
show
Bug introduced by
The property userurl 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...
544
				} else {
545
					$this->userurl = false;
546
				}
547
			} catch(Exception $e)
548
			{
549
				$this->userurl = false;
550
			}
551
			
552
553
			$i++;
554
			return true;
555
		}
556
		else
557
		{
558
			$i = 0;
559
			return false;
560
		}
561
	}
562
563
564
	/**
565
	 * 
566
	 * @return boolean
567
	 */
568
	public function getday()
569
	{
570
		static $d = 1;
571
		static $total = 0;
572
		if( $d <= 31)
573
		{
574
			$time = mktime(0, 0, 0, $this->curmonth, $d, $this->curyear);
575
            $this->day = bab_formatDate('%D', $time).' '.date('j', $time);
0 ignored issues
show
Bug introduced by
The property day 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
			$d++;
577
			return true;
578
		}
579
		else
580
		{
581
			$d = 1;
582
			return false;
583
		}
584
	}
585
586
	public function getnexttype()
587
	{
588
589
		if (!$this->display_types) {
590
			return false;
591
		}
592
593
		global $babDB;
594
		if ($this->arr = $babDB->db_fetch_array($this->restypes)) {
595
			$this->arr['name'] 			= bab_toHtml($this->arr['name']);
0 ignored issues
show
Bug introduced by
The property arr 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...
596
			$this->arr['description'] 	= bab_toHtml($this->arr['description']);
597
			return true;
598
		}
599
		else {
600
			return false;
601
		}
602
	}
603
	
604
	
605
	public function entity($ide, $all = false)
606
	{
607
	    // permettre de charger les sous-entites fusionnes dans le meme planning
608
	    
609
	    $url = bab_url::get_request_gp();
610
	    $url->all = $all ? '0' : '1';
611
	    
612
	    $this->mergedurl = false;
0 ignored issues
show
Bug introduced by
The property mergedurl 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...
613
	    
614
	    if (bab_OCGetChildCount($ide)) {
615
	        $this->mergedurl = bab_toHtml($url->toString());
616
	    }
617
	    
618
	    if ($all) {
619
	        $this->t_merged = absences_translate('View the entity only');
0 ignored issues
show
Bug introduced by
The property t_merged 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...
620
	    } else {
621
	        $this->t_merged = absences_translate('View users from all entities');
622
	    }
623
	}
624
	
625
	
626
	public function publiccalendar($total)
627
	{
628
		$this->display_firstuser = false;
0 ignored issues
show
Bug introduced by
The property display_firstuser does not seem to exist. Did you mean firstuser?

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...
629
		$this->public = true;
630
		$this->t_search_name = absences_translate('Search by name');
0 ignored issues
show
Bug introduced by
The property t_search_name does not exist. Did you maybe forget to declare it?

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

class MyClass { }

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

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

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
631
		$this->t_search_entity = absences_translate('By entity');
0 ignored issues
show
Bug introduced by
The property t_search_entity 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...
632
		$this->keyword = bab_rp('keyword');
0 ignored issues
show
Bug introduced by
The property keyword 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...
633
		$this->t_ok = absences_translate('Ok');
0 ignored issues
show
Bug introduced by
The property t_ok 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...
634
		
635
		$this->total = $total;
636
		$this->t_total = sprintf(absences_translate('%d result found', '%d results found', $total), $total);
0 ignored issues
show
Bug introduced by
The property t_total 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...
637
		
638
		
639
		// prepare button for first load
640
		
641
		$this->t_use_month_view = false;
0 ignored issues
show
Bug introduced by
The property t_use_month_view 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...
642
		
643
		$this->t_loadall = absences_translate('View all results');
0 ignored issues
show
Bug introduced by
The property t_loadall 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...
644
		$this->t_viewBegin = absences_translate('View the first 30 only');
0 ignored issues
show
Bug introduced by
The property t_viewBegin 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...
645
		
646
		if ($total > $this->nbusers)
647
		{
648
			$last = $total - $this->nbusers;
649
			
650
			if (1 < $this->nbmonth)
651
			{
652
				$this->t_use_month_view = sprintf(absences_translate('The planning display only %d results from %d total results, use the month view to fetch next results'), $this->nbusers, $total);
653
				$this->loadmore = false;
654
			} else {
655
656
				$this->loadmore = $this->limit < $last ? $this->limit : $last;
657
				$this->t_loadmore = sprintf(absences_translate('Load the next %d results'), $this->loadmore);
0 ignored issues
show
Bug introduced by
The property t_loadmore does not seem to exist. Did you mean loadmore?

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...
658
			}
659
		} else {
660
			$this->loadmore = false;
661
		}
662
	}
663
	
664
	
665
	public function getHtml()
666
	{
667
		return bab_printTemplate($this, absences_addon()->getRelativePath()."vacuser.html", "calendarbyuser");
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...
668
	}
669
	
670
	
671
672
	public function printhtml()
673
	{
674
		global $babBody;
675
		
676
		/*@var $babBody babBody */
677
		
678
		$html = $this->getHtml();
679
		
680
		/*@var $jquery Func_Jquery */
681
		$jquery = bab_functionality::get('jquery');
682
		$jquery->includeCore();
683
684
		$babBody->addStyleSheet(absences_addon()->getStylePath().'vacation.css');
685
		$babBody->addJavascriptFile(absences_addon()->getTemplatePath().'calendar.jquery.js', true);
686
687
		if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 1) {
688
			$babBody->babpopup($html);
689
		}
690
		else {
691
			$babBody->babecho($html);
692
		}
693
	}
694
}
695
696
697
698
699
700
701
702
/**
703
 * Display a vacation calendar
704
 * @param	array		$users			array of id_user to display
705
 * @param	boolean		$period			allow period selection, first step of vacation request
706
 * @param	boolean		$display_types	Display types color and legend on planning
707
 * @param	int			$nbmonth		Number of month to display
708
 * @param	bool		$dispusers		display a column with user names
709
 * @param 	int			$total			Total number of results in search
710
 */
711
function absences_viewVacationCalendar($users, $period, $display_types, $nbmonth = 12, $dispusers = true, $total = null )
712
{
713
	global $babBody;
714
715
	$temp = new absences_viewVacationCalendarCls($users, $period, $display_types, $nbmonth, $dispusers);
716
717
	if (count($users) == 0)
718
	{
719
		$babBody->addError(absences_translate("ERROR: No members"));
720
	}
721
	
722
	if (bab_rp('idx') == 'entity_cal')
723
	{
724
	    $temp->entity(bab_rp('ide'), (bool) bab_rp('all', false));
725
	}
726
	
727
	if (bab_rp('idx') == 'public')
728
	{
729
		$temp->publiccalendar($total);
730
	}
731
	
732
	$temp->printhtml();
733
}
734
735
736
737
/**
738
 * Serach in active users to display the public calendar
739
 * @param string $keyword
740
 * @param array $departments
741
 * @param string $dateb
742
 * @param string $datee
743
 * @param string $date
744
 */
745
function absences_publicCalendarUsers($keyword, $departments, $searchtype, $dateb, $datee, $date)
746
{
747
	global $babDB;
748
	require_once $GLOBALS['babInstallPath'].'utilit/userinfosincl.php';
749
	
750
	
751
	$W = bab_Widgets();
752
	$datePicker = $W->DatePicker();
753
	
754
	switch($searchtype) {
755
	    default:
756
	    case 1:
757
	        $dateb = '0000-00-00';
758
	        $datee = '0000-00-00';
759
	        $date = $datePicker->getISODate($date);
760
	        break;
761
	        
762
	    case 2:
763
	        $dateb = $datePicker->getISODate($dateb);
764
	        $datee = $datePicker->getISODate($datee);
765
	        $date = '0000-00-00';
766
	        break;
767
	}
768
	
769
	$dateb = $datePicker->getISODate($dateb);
770
	$datee = $datePicker->getISODate($datee);
771
	$date = $datePicker->getISODate($date);
772
	
773
	if ('0000-00-00' !== $date && false !== $date) {
774
	    $dateb = $date;
775
	    $datee = $date;
776
	}
777
	
778
	
779
	$query = 'SELECT
780
			u.id,
781
			u.lastname,
782
			u.firstname
783
		FROM
784
			bab_users u
785
	           LEFT JOIN bab_oc_roles_users ru ON ru.id_user=u.id 
786
	           LEFT JOIN bab_oc_roles r ON r.id=ru.id_role,
787
			absences_personnel p
788
	
789
		WHERE
790
			p.id_user=u.id AND '.bab_userInfos::queryAllowedUsers('u');
791
792
	
793
	if (isset($keyword))
794
	{
795
		$query .= ' AND (u.lastname LIKE \'%'.$babDB->db_escape_like($keyword).'%\' OR u.firstname LIKE \'%'.$babDB->db_escape_like($keyword).'%\')';
796
	}
797
	
798
	if (isset($departments))
799
	{
800
	    $query .= ' AND r.id_entity IN('.$babDB->quote($departments).')';
801
	}
802
	
803
	if ('0000-00-00' !== $dateb && '0000-00-00' !== $datee && false !== $dateb && false !== $datee) {
804
	    $subquery = 'SELECT id_user FROM absences_entries WHERE date_begin<'.$babDB->quote($datee.' 23:59:59').' AND date_end>'.$babDB->quote($dateb.' 00:00:00').' GROUP BY id_user';
805
	    $query .= ' AND u.id IN('.$subquery.')';
806
	}
807
	
808
	
809
	$query .= 'GROUP BY u.id ORDER BY u.lastname, u.firstname';
810
	
811
	$res = $babDB->db_query($query);
812
	
813
	return $res;
814
}
815
816
817
function absences_getSearchLimit($nbmonth)
818
{
819
    $initusers = (int) bab_rp('limit');
820
    if (empty($initusers)) {
821
        // preload the 30 first users if limit not set
822
        $initusers = 1 === $nbmonth ? 30 : 10;
823
    }
824
    
825
    return $initusers;
826
}
827