Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
manager.php
1<?php
3
6
7class Manager
8{
14 public static function getList($parameters)
15 {
16 return Internals\CompanyTable::getList($parameters);
17 }
18
24 public static function getById($id)
25 {
26 return Internals\CompanyTable::getById($id);
27 }
28
34 public static function getListWithRestrictions(Internals\Entity $entity, $mode = Restrictions\Manager::MODE_CLIENT)
35 {
36 $result = array();
37
38 $dbRes = self::getList(array(
39 'filter' => array('ACTIVE' => 'Y')
40 ));
41
42 while ($company = $dbRes->fetch())
43 {
44 if ($mode == Restrictions\Manager::MODE_MANAGER)
45 {
46 $checkServiceResult = Restrictions\Manager::checkService($company['ID'], $entity, $mode);
47 if ($checkServiceResult != Restrictions\Manager::SEVERITY_STRICT)
48 {
49 if ($checkServiceResult == Restrictions\Manager::SEVERITY_SOFT)
50 $company['RESTRICTED'] = $checkServiceResult;
51 $result[$company['ID']] = $company;
52 }
53 }
54 else if ($mode == Restrictions\Manager::MODE_CLIENT)
55 {
56 if (Restrictions\Manager::checkService($company['ID'], $entity, $mode) === Restrictions\Manager::SEVERITY_NONE)
57 $result[$company['ID']] = $company;
58 }
59 }
60
61 return $result;
62 }
63
69 public static function getAvailableCompanyIdByEntity(Internals\Entity $entity, $mode = Restrictions\Manager::MODE_CLIENT)
70 {
71 $dbRes = self::getList(array(
72 'select' => array('ID'),
73 'filter' => array('=ACTIVE' => 'Y'),
74 'order' => array('SORT' => 'ASC')
75 ));
76
77 while ($company = $dbRes->fetch())
78 {
79 $result = Restrictions\Manager::checkService($company['ID'], $entity, $mode);
80 if ($mode == Restrictions\Manager::MODE_CLIENT)
81 {
82 if ($result == Restrictions\Manager::SEVERITY_NONE)
83 return $company['ID'];
84 }
85 else
86 {
87 if ($result != Restrictions\Manager::SEVERITY_STRICT)
88 return $company['ID'];
89 }
90 }
91
92 return 0;
93 }
94
99 public static function getLocationConnectorEntityName()
100 {
101 return 'Bitrix\Sale\Internals\CompanyLocation';
102 }
103
109 public static function getUserCompanyList($id)
110 {
111 static $list = array();
112
113 if (empty($list[$id]))
114 {
115 $list[$id] = array();
116
117 $groups = \CUser::GetUserGroup($id);
118
119 $filterCompany = array(
120 'select' => array(
121 'ID',
122 ),
123 'filter' => array(
124 '=GROUP.GROUP_ID' => $groups
125 ),
126 'runtime' => array(
127 new Main\Entity\ReferenceField(
128 'GROUP',
129 '\Bitrix\Sale\Internals\CompanyGroupTable',
130 array(
131 '=this.ID' => 'ref.COMPANY_ID',
132 )
133 )
134 ),
135 'order' => array('ID'),
136 );
137
138 $resCompany = Internals\CompanyTable::getList($filterCompany);
139 while($companyData = $resCompany->fetch())
140 {
141 $list[$id][] = $companyData['ID'];
142 }
143 }
144
145 return $list[$id];
146 }
147}
static getList(array $parameters=[])
Definition manager.php:135
static getListWithRestrictions(Internals\Entity $entity, $mode=Restrictions\Manager::MODE_CLIENT)
Definition manager.php:34
static getAvailableCompanyIdByEntity(Internals\Entity $entity, $mode=Restrictions\Manager::MODE_CLIENT)
Definition manager.php:69