Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
converttoserviceitem.php
1
<?php
2
3
namespace
Bitrix\Catalog\Grid\Row\Actions\Item
;
4
5
use
Bitrix\Catalog\Grid\ProductAction
;
6
use
Bitrix\Main\HttpRequest
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Result
;
9
use CUtil;
10
11
final
class
ConvertToServiceItem
extends
BaseItem
12
{
13
public
static
function
getId
(): ?string
14
{
15
return
'convert_to_service'
;
16
}
17
18
protected
function
getText
(): string
19
{
20
return
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_SERVICE_TEXT'
);
21
}
22
23
public
function
getControl
(array $rawFields): ?array
24
{
25
$id = (int)($rawFields[
'ID'
] ?? 0);
26
if
($id <= 0)
27
{
28
return
null
;
29
}
30
31
$actionId =
self::getId
();
32
$data = CUtil::PhpToJSObject([
33
'id'
=> $id,
34
]);
35
$confirmMessageTitle = \CUtil::JSEscape(
36
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_SERVICE_CONFIRM_MESSAGE_TITLE'
)
37
);
38
$confirmMessageContent = \CUtil::JSEscape(
39
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_SERVICE_CONFIRM_MESSAGE_CONTENT'
)
40
);
41
42
$confirmButtonMessage = \CUtil::JSEscape(
43
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_SERVICE_CONFIRM_BUTTON'
)
44
);
45
$backButtonMessage = \CUtil::JSEscape(
46
Loc::getMessage
(
'CATALOG_GRID_ROW_ACTIONS_CONVERT_TO_SERVICE_BACK_BUTTON'
)
47
);
48
49
$this->onclick =
"IblockGridInstance.sendMediumPopupWithConfirm("
50
.
"'{$actionId}', "
51
.
"{$data}, "
52
.
"'{$confirmMessageTitle}', "
53
.
"'{$confirmMessageContent}', "
54
.
"'{$confirmButtonMessage}', "
55
.
"'{$backButtonMessage}')"
56
;
57
58
return
parent::getControl($rawFields);
59
}
60
61
public
function
processRequest
(
HttpRequest
$request): ?
Result
62
{
63
$id = $request->getPost(
'id'
);
64
if
(empty($id) || !is_numeric($id))
65
{
66
return
null
;
67
}
68
$id = (int)$id;
69
70
return
ProductAction::convertToServiceElementList
($this->
getIblockId
(), [$id]);
71
}
72
}
Bitrix\Catalog\Grid\ProductAction
Definition
productaction.php:16
Bitrix\Catalog\Grid\ProductAction\convertToServiceElementList
static convertToServiceElementList(int $iblockId, array $elementIds)
Definition
productaction.php:387
Bitrix\Catalog\Grid\Row\Actions\Item\BaseItem
Definition
baseitem.php:8
Bitrix\Catalog\Grid\Row\Actions\Item\BaseItem\getIblockId
getIblockId()
Definition
baseitem.php:18
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem
Definition
converttoserviceitem.php:12
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem\getControl
getControl(array $rawFields)
Definition
converttoserviceitem.php:23
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem\getText
getText()
Definition
converttoserviceitem.php:18
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem\getId
static getId()
Definition
converttoserviceitem.php:13
Bitrix\Catalog\Grid\Row\Actions\Item\ConvertToServiceItem\processRequest
processRequest(HttpRequest $request)
Definition
converttoserviceitem.php:61
Bitrix\Main\HttpRequest
Definition
httprequest.php:20
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Catalog\Grid\Row\Actions\Item
Definition
baseitem.php:3
modules
catalog
lib
grid
row
actions
item
converttoserviceitem.php
Создано системой
1.10.0