1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
OldDepartment.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Integration\HumanResources\Department;
4
5
use Bitrix\Main\Loader;
6
use CIntranetUtils;
7
8
class
OldDepartment
extends
BaseDepartment
9
{
10
public
function
getTopId
(): ?int
11
{
12
if
(!Loader::includeModule(
"iblock"
))
13
{
14
return
null
;
15
}
16
17
if
(self::$wasSearchedTopId)
18
{
19
return
self::$topId;
20
}
21
22
self::$wasSearchedTopId =
true
;
23
24
$departmentId =
null
;
25
$res
= \CIBlock::GetList([], [
"CODE"
=>
"departments"
]);
26
if
(
$iblock
=
$res
->Fetch())
27
{
28
$res
= \CIBlockSection::GetList(
29
[],
30
[
31
"SECTION_ID"
=> 0,
32
"IBLOCK_ID"
=>
$iblock
[
"ID"
]
33
]
34
);
35
if
($department =
$res
->Fetch())
36
{
37
$departmentId = (int)$department[
'ID'
];
38
}
39
}
40
self::$topId = $departmentId;
41
42
return
self::$topId;
43
}
44
45
public
function
getList
():
array
46
{
47
if
(!empty($this->structureDepartments))
48
{
49
return
$this->structureDepartments
;
50
}
51
52
if
(
53
Loader::includeModule(
'iblock'
)
54
&& Loader::includeModule(
'intranet'
)
55
)
56
{
57
$departments = CIntranetUtils::GetStructureWithoutEmployees(
false
)[
'DATA'
] ?? [];
58
59
foreach
($departments as $department)
60
{
61
$this->structureDepartments[$department[
'ID'
]] = $this->
formatDepartment
($department);
62
}
63
}
64
65
return
$this->structureDepartments
;
66
}
67
68
public
function
getListByIds
(
array
$ids):
array
69
{
70
$departments = $this->
getList
();
71
72
$departmentsByIds = [];
73
foreach
($departments as $department)
74
{
75
if
(in_array($department->id, $ids,
true
))
76
{
77
$departmentsByIds[$department->id] = $department;
78
}
79
}
80
81
return
$departmentsByIds;
82
}
83
84
public
function
getListByXml
(
string
$xmlId):
array
85
{
86
if
(!Loader::includeModule(
'iblock'
))
87
{
88
return
[];
89
}
90
91
$departmentRootId =
\Bitrix\Main\Config\Option::get
(
'intranet'
,
'iblock_structure'
, 0);
92
if
($departmentRootId <= 0)
93
{
94
return
[];
95
}
96
97
$departments = \CIBlockSection::GetList(
98
[],
99
[
100
'=ACTIVE'
=>
'Y'
,
101
'=IBLOCK_ID'
=> $departmentRootId,
102
'=XML_ID'
=> $xmlId
103
]
104
);
105
106
$result
= [];
107
while
($row = $departments->fetch())
108
{
109
$result
[] = $this->
formatDepartment
($row);
110
}
111
112
return
$result
;
113
}
114
115
public
function
getEmployeeIdsWithLimit
(
array
$ids,
int
$limit = 50):
array
116
{
117
if
(!Loader::includeModule(
'intranet'
))
118
{
119
return
[];
120
}
121
122
$structure = \CIntranetUtils::GetStructure();
123
124
if
(!$structure || !isset($structure[
'DATA'
]))
125
{
126
return
[];
127
}
128
129
$employees = $managers = [];
130
foreach
($structure[
'DATA'
] as $department)
131
{
132
if
(!in_array((
int
)$department[
'ID'
], $ids,
true
))
133
{
134
continue
;
135
}
136
137
if
(!is_array($department[
'EMPLOYEES'
]))
138
{
139
$employees[$department[
'ID'
]] = [];
140
continue
;
141
}
142
143
foreach
($department[
'EMPLOYEES'
] as $value)
144
{
145
$value = (int)$value;
146
if
($department[
'UF_HEAD'
] === $value)
147
{
148
$managers[$value] = $value;
149
}
150
else
151
{
152
$employees[$value] = $value;
153
}
154
}
155
}
156
157
$allUsers = $managers + $employees;
158
159
return
array_splice($allUsers, 0, $limit);
160
}
161
162
protected
function
formatDepartment
(
array
$department):
Entity
163
{
164
return
new
Entity
(
165
name: (
string
)$department[
'NAME'
],
166
headUserID: isset($department[
'UF_HEAD'
]) ? (
int
)$department[
'UF_HEAD'
] : 0,
167
id
: isset($department[
'ID'
]) ? (
int
)$department[
'ID'
] :
null
,
168
depthLevel: isset($department[
'DEPTH_LEVEL'
]) ? ((
int
)$department[
'DEPTH_LEVEL'
] - 1) :
null
,
169
parent: isset($department[
'IBLOCK_SECTION_ID'
]) ? (
int
)$department[
'IBLOCK_SECTION_ID'
]:
null
170
);
171
}
172
}
Bitrix\Im\V2\Integration\HumanResources\Department\BaseDepartment
Определения
BaseDepartment.php:6
Bitrix\Im\V2\Integration\HumanResources\Department\BaseDepartment\$structureDepartments
array $structureDepartments
Определения
BaseDepartment.php:9
Bitrix\Im\V2\Integration\HumanResources\Department\Entity
Определения
Entity.php:6
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment
Определения
OldDepartment.php:9
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\getListByIds
getListByIds(array $ids)
Определения
OldDepartment.php:68
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\getList
getList()
Определения
OldDepartment.php:45
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\getEmployeeIdsWithLimit
getEmployeeIdsWithLimit(array $ids, int $limit=50)
Определения
OldDepartment.php:115
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\formatDepartment
formatDepartment(array $department)
Определения
OldDepartment.php:162
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\getListByXml
getListByXml(string $xmlId)
Определения
OldDepartment.php:84
Bitrix\Im\V2\Integration\HumanResources\Department\OldDepartment\getTopId
getTopId()
Определения
OldDepartment.php:10
Bitrix\Main\Config\Option\get
static get($moduleId, $name, $default="", $siteId=false)
Определения
option.php:30
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
$iblock
if(! $catalogEdit->isSuccess()) $iblock
Определения
iblock_catalog_edit.php:38
bitrix
modules
im
lib
V2
Integration
HumanResources
Department
OldDepartment.php
Создано системой
1.14.0