Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
helper.php
1
<?php
2
3
namespace
Bitrix\Sale\Delivery
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Main\ModuleManager
;
7
use
Bitrix\Main\SystemException
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Currency
;
10
11
Loc::loadMessages
(__FILE__);
12
17
class
Helper
18
{
26
public
static
function
getCurrenciesList
()
27
{
28
static
$currencies =
null
;
29
30
if
($currencies ===
null
)
31
{
32
$currencies = array();
33
34
if
(!\
Bitrix
\Main\
Loader::includeModule
(
'currency'
))
35
throw
new
SystemException
(
"Can't include module \"Currency\"!"
);
36
37
$currencies = Currency\CurrencyManager::getCurrencyList();
38
}
39
40
return
$currencies;
41
}
42
49
protected
static
function
createTreeFromGroups
($flatGroups)
50
{
51
$result = array();
52
53
foreach
($flatGroups as $groupId => $groupParams)
54
{
55
if
(intval($groupParams[
"PARENT_ID"
]) <= 0)
56
{
57
$groupParams[
"LEVEL"
] = 1;
58
$groupParams[
"NAME"
] =
" . "
.$groupParams[
"NAME"
];
59
$result[$groupId] = $groupParams;
60
}
61
else
62
{
63
$groupParams[
"LEVEL"
] = $result[$groupParams[
"PARENT_ID"
]][
"LEVEL"
]+1;
64
$groupParams[
"NAME"
] = str_repeat(
" . "
, $groupParams[
"LEVEL"
]+1).$groupParams[
"NAME"
];
65
$result[$groupId] = $groupParams;
66
}
67
}
68
return
$result;
69
}
70
80
public
static
function
getGroupChooseControl
($selectedGroupId, $name, $addParams =
""
, $anyGroup =
false
)
81
{
82
$groups = array();
83
84
$dbRes = \Bitrix\Sale\Delivery\Services\Table::getList(array(
85
"filter"
=> array(
86
"=CLASS_NAME"
=>
'\Bitrix\Sale\Delivery\Services\Group'
87
),
88
"select"
=> array(
89
"ID"
,
"NAME"
,
"PARENT_ID"
90
),
91
"order"
=> array(
92
"PARENT_ID"
=>
"ASC"
,
93
"NAME"
=>
"ASC"
94
)
95
));
96
97
while
($group = $dbRes->fetch())
98
$groups[$group[
"ID"
]] = $group;
99
100
//$groups = self::createTreeFromGroups($groups);
101
$result =
'<select name='
.$name.
' id="sale_delivery_group_choose"'
.$addParams.
'>'
;
102
103
if
($anyGroup)
104
$result .=
'<option value="-1"'
.($selectedGroupId ==
"-1"
?
' selected'
:
''
).
'>'
.
Loc::getMessage
(
'SALE_DELIVERY_HELPER_ANY_LEVEL'
).
'</option>'
;
105
106
$result .=
'<option value="0"'
.($selectedGroupId == 0 ?
' selected'
:
''
).
'>'
.
Loc::getMessage
(
'SALE_DELIVERY_HELPER_UPPER_LEVELL'
).
'</option>'
;
107
108
foreach
($groups as $groupId => $group)
109
$result .=
'<option value="'
.$groupId.
'"'
.($selectedGroupId == $groupId ?
' selected'
:
''
).
'>'
.htmlspecialcharsbx($group[
"NAME"
]).
'</option>'
;
110
111
$result .=
'</select>'
;
112
113
return
$result;
114
}
115
122
public
static
function
getDefaultSiteId
()
123
{
124
static
$result =
null
;
125
126
if
($result ===
null
)
127
{
128
$res = \Bitrix\Main\SiteTable::getList(array(
129
'filter'
=> array(
'DEF'
=>
'Y'
),
130
'select'
=> array(
'LID'
)
131
));
132
133
if
($item = $res->fetch())
134
$result = $item[
'LID'
];
135
}
136
137
return
$result;
138
}
139
143
public
static
function
additionalHandlerCacheClean
()
144
{
145
require_once($_SERVER[
"DOCUMENT_ROOT"
].
"/bitrix/modules/sale/handlers/delivery/additional/cache.php"
);
146
\Sale\Handlers\Delivery\Additional\CacheManager::cleanAll();
147
}
148
155
public
static
function
getPortalZone
(): string
156
{
157
static
$result =
null
;
158
159
if
($result ===
null
)
160
{
161
$result =
''
;
162
163
if
(
ModuleManager::isModuleInstalled
(
'bitrix24'
)
164
&&
Loader::includeModule
(
'bitrix24'
)
165
)
166
{
167
$result = \CBitrix24::getLicensePrefix();
168
}
169
elseif (
ModuleManager::isModuleInstalled
(
'intranet'
)
170
&&
Loader::includeModule
(
'intranet'
)
171
)
172
{
173
$result = \CIntranetUtils::getPortalZone();
174
}
175
}
176
177
return
(
string
)$result;
178
}
179
}
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Definition
loader.php:69
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Main\ModuleManager\isModuleInstalled
static isModuleInstalled($moduleName)
Definition
modulemanager.php:67
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Sale\Delivery\Helper
Definition
helper.php:18
Bitrix\Sale\Delivery\Helper\getPortalZone
static getPortalZone()
Definition
helper.php:155
Bitrix\Sale\Delivery\Helper\getCurrenciesList
static getCurrenciesList()
Definition
helper.php:26
Bitrix\Sale\Delivery\Helper\createTreeFromGroups
static createTreeFromGroups($flatGroups)
Definition
helper.php:49
Bitrix\Sale\Delivery\Helper\getGroupChooseControl
static getGroupChooseControl($selectedGroupId, $name, $addParams="", $anyGroup=false)
Definition
helper.php:80
Bitrix\Sale\Delivery\Helper\additionalHandlerCacheClean
static additionalHandlerCacheClean()
Definition
helper.php:143
Bitrix\Sale\Delivery\Helper\getDefaultSiteId
static getDefaultSiteId()
Definition
helper.php:122
Bitrix\Currency
Bitrix\Sale\Delivery
Definition
calculationresult.php:2
Bitrix
modules
sale
lib
delivery
helper.php
Создано системой
1.10.0