1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
delivery.php
См. документацию.
1
<?php
2
namespace
Bitrix\Sale\Services\Company\Restrictions;
3
4
use Bitrix\Main\Localization\Loc;
5
use Bitrix\Sale\Internals\CollectableEntity;
6
use Bitrix\Sale\Internals\CompanyServiceTable;
7
use Bitrix\Sale;
8
use Bitrix\Sale\Services\Base;
9
10
Loc::loadMessages(__FILE__);
11
12
class
Delivery
extends
Base\Restriction
13
{
14
public
static
$easeSort
= 200;
15
19
public
static
function
getClassTitle
()
20
{
21
return
Loc::getMessage(
"SALE_COMPANY_RULES_BY_DLV_TITLE"
);
22
}
23
27
public
static
function
getClassDescription
()
28
{
29
return
Loc::getMessage(
"SALE_COMPANY_RULES_BY_DLV_DESC"
);
30
}
31
38
public
static
function
check
(
$params
,
array
$restrictionParams, $serviceId = 0)
39
{
40
if
((
int
)$serviceId <= 0)
41
return
true
;
42
43
if
(!
$params
)
44
return
true
;
45
46
$deliveryIds = self::getDeliveryByCompanyId($serviceId);
47
48
if
(empty($deliveryIds))
49
return
true
;
50
51
$diff = array_diff(
$params
, $deliveryIds);
52
53
return
empty($diff);
54
}
55
61
protected
static
function
extractParams(
Sale
\
Internals
\
Entity
$entity
)
62
{
63
$result
=
array
();
64
66
$shipmentCollection =
null
;
67
68
if
(
$entity
instanceof
Sale
\
Shipment
)
69
{
70
$shipmentCollection =
$entity
->getCollection();
71
}
72
elseif
(
$entity
instanceof
Sale
\
Payment
)
73
{
75
$paymentCollection
=
$entity
->getCollection();
76
if
(
$paymentCollection
)
77
{
79
$order
=
$paymentCollection
->getOrder();
80
if
(
$order
)
81
$shipmentCollection =
$order
->getShipmentCollection();
82
}
83
}
84
elseif
(
$entity
instanceOf
Sale
\Order)
85
{
86
$shipmentCollection =
$entity
->getShipmentCollection();
87
}
88
89
if
($shipmentCollection !==
null
)
90
{
92
foreach
($shipmentCollection as $shipment)
93
{
94
if
($shipment->isSystem())
95
{
96
continue
;
97
}
98
99
if
($deliveryId = $shipment->getDeliveryId())
100
{
101
$result
[] = $deliveryId;
102
}
103
}
104
}
105
106
return
$result
;
107
}
108
112
protected
static
function
getDeliveryList
()
113
{
114
$result
=
array
();
115
116
$serviceList =
array
();
117
$dbRes
= Sale\Delivery\Services\Table::getList(
array
(
'select'
=>
array
(
'ID'
,
'NAME'
,
'PARENT_ID'
)));
118
while
(
$service
=
$dbRes
->fetch())
119
$serviceList[
$service
[
'ID'
]] =
$service
;
120
121
foreach
($serviceList as
$service
)
122
{
123
if
((
int
)
$service
[
'PARENT_ID'
] > 0)
124
$name
= $serviceList[
$service
[
'PARENT_ID'
]][
'NAME'
].
': '
.
$service
[
'NAME'
].
' ['
.
$service
[
'ID'
].
']'
;
125
else
126
$name
=
$service
[
'NAME'
].
' ['
.
$service
[
'ID'
].
']'
;
127
128
$result
[
$service
[
'ID'
]] =
$name
;
129
}
130
131
return
$result
;
132
}
133
138
public
static
function
getParamsStructure
(
$entityId
= 0)
139
{
140
$result
=
array
(
141
"DELIVERY"
=>
array
(
142
"TYPE"
=>
"ENUM"
,
143
'MULTIPLE'
=>
'Y'
,
144
"LABEL"
=> Loc::getMessage(
"SALE_COMPANY_RULES_BY_DLV"
),
145
"OPTIONS"
=> self::getDeliveryList()
146
)
147
);
148
149
return
$result
;
150
}
151
157
protected
static
function
getDeliveryByCompanyId
($companyId = 0)
158
{
159
$result
=
array
();
160
if
($companyId == 0)
161
return
$result
;
162
163
$dbRes
= CompanyServiceTable::getList(
164
array
(
165
'select'
=>
array
(
'SERVICE_ID'
),
166
'filter'
=>
array
(
167
'COMPANY_ID'
=> $companyId,
168
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
)
169
)
170
);
171
172
while
(
$data
=
$dbRes
->fetch())
173
$result
[] =
$data
[
'SERVICE_ID'
];
174
175
return
$result
;
176
}
177
183
public
static
function
save
(
array
$fields
, $restrictionId = 0)
184
{
185
$serviceIds =
$fields
[
"PARAMS"
];
186
$fields
[
"PARAMS"
] =
array
();
187
188
if
($restrictionId > 0)
189
{
190
$dbRes
= CompanyServiceTable::getList(
191
array
(
192
'select'
=>
array
(
'SERVICE_ID'
),
193
'filter'
=>
array
(
194
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
,
195
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
]
196
)
197
)
198
);
199
200
while
(
$data
=
$dbRes
->fetch())
201
{
202
$key
= array_search(
$data
[
'SERVICE_ID'
], $serviceIds[
'DELIVERY'
]);
203
if
(!
$key
)
204
{
205
CompanyServiceTable::delete(
array
(
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
],
'SERVICE_ID'
=>
$data
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
));
206
}
207
else
208
{
209
unset($serviceIds[
'DELIVERY'
][
$key
]);
210
}
211
}
212
}
213
214
$result
= parent::save(
$fields
, $restrictionId);
215
216
$addFields =
array
(
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
);
217
foreach
($serviceIds[
'DELIVERY'
] as $id)
218
{
219
$addFields[
'SERVICE_ID'
] = $id;
220
CompanyServiceTable::add($addFields);
221
}
222
223
return
$result
;
224
}
225
231
public
static
function
prepareParamsValues
(
array
$paramsValues,
$entityId
= 0)
232
{
233
return
array
(
"DELIVERY"
=> self::getDeliveryByCompanyId(
$entityId
));
234
}
235
242
public
static
function
delete
($restrictionId,
$entityId
= 0)
243
{
244
$dbRes
= CompanyServiceTable::getList(
245
array
(
246
'select'
=>
array
(
'SERVICE_ID'
),
247
'filter'
=>
array
(
248
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
,
249
'COMPANY_ID'
=>
$entityId
250
)
251
)
252
);
253
254
while
(
$data
=
$dbRes
->fetch())
255
{
256
CompanyServiceTable::delete(
array
(
'COMPANY_ID'
=>
$entityId
,
'SERVICE_ID'
=>
$data
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_SHIPMENT
));
257
}
258
259
return
parent::delete($restrictionId);
260
}
261
}
Bitrix\Sale\Payment
Определения
payment.php:19
Bitrix\Sale\Services\Base\RestrictionManager\SERVICE_TYPE_SHIPMENT
const SERVICE_TYPE_SHIPMENT
Определения
restrictionmanager.php:33
Bitrix\Sale\Services\Company\Restrictions\Delivery\prepareParamsValues
static prepareParamsValues(array $paramsValues, $entityId=0)
Определения
delivery.php:231
Bitrix\Sale\Services\Company\Restrictions\Delivery\getDeliveryByCompanyId
static getDeliveryByCompanyId($companyId=0)
Определения
delivery.php:157
Bitrix\Sale\Services\Company\Restrictions\Delivery\$easeSort
static $easeSort
Определения
delivery.php:14
Bitrix\Sale\Services\Company\Restrictions\Delivery\check
static check($params, array $restrictionParams, $serviceId=0)
Определения
delivery.php:38
Bitrix\Sale\Services\Company\Restrictions\Delivery\getClassTitle
static getClassTitle()
Определения
delivery.php:19
Bitrix\Sale\Services\Company\Restrictions\Delivery\save
static save(array $fields, $restrictionId=0)
Определения
delivery.php:183
Bitrix\Sale\Services\Company\Restrictions\Delivery\getClassDescription
static getClassDescription()
Определения
delivery.php:27
Bitrix\Sale\Services\Company\Restrictions\Delivery\getParamsStructure
static getParamsStructure($entityId=0)
Определения
delivery.php:138
Bitrix\Sale\Services\Company\Restrictions\Delivery\getDeliveryList
static getDeliveryList()
Определения
delivery.php:112
Bitrix\Sale\Shipment
Определения
shipment.php:21
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
$name
$name
Определения
menu_edit.php:35
Bitrix\Catalog\Restriction
Определения
toolavailabilitymanager.php:3
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Sale\Cashbox\Internals
Bitrix\Sale\Cashbox\Restrictions
Определения
company.php:2
Bitrix\Sale\Delivery\Services
Определения
automatic.php:3
Bitrix\Sale\Delivery
Определения
calculationresult.php:2
Bitrix\Sale
$order
$order
Определения
payment.php:8
$paymentCollection
$paymentCollection
Определения
payment.php:11
$service
$service
Определения
payment.php:18
$entityId
$entityId
Определения
payment.php:4
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$dbRes
$dbRes
Определения
yandex_detail.php:168
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
services
company
restrictions
delivery.php
Создано системой
1.14.0