1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
base.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Bizproc\Automation\Component
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Errorable
;
7
use
Bitrix\Main\ErrorCollection
;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Bizproc\Api\Enum\Template\WorkflowTemplateType
;
10
11
abstract
class
Base
extends
\CBitrixComponent implements
Errorable
12
{
14
protected
$errorCollection
;
15
16
public
function
__construct
($component =
null
)
17
{
18
parent::__construct($component);
19
20
$this->errorCollection =
new
ErrorCollection
();
21
}
22
23
public
function
getErrors
():
array
24
{
25
return
$this->errorCollection->toArray();
26
}
27
28
public
function
getErrorByCode
(
$code
): ?
Error
29
{
30
return
$this->errorCollection->getErrorByCode(
$code
);
31
}
32
33
public
static
function
getTemplateViewData
(
array
$template
, $documentType)
34
{
35
foreach
(
$template
[
'ROBOTS'
] as
$i
=> $robot)
36
{
37
$template
[
'ROBOTS'
][
$i
][
'viewData'
] = static::getRobotViewData($robot, $documentType);
38
}
39
40
return
$template
;
41
}
42
43
public
static
function
getRobotViewData
($robot,
array
$documentType):
array
44
{
45
$availableRobots =
\Bitrix\Bizproc\Automation\Engine\Template::getAvailableRobots
($documentType);
46
$result
= [
47
'responsibleLabel'
=>
''
,
48
'responsibleUrl'
=>
''
,
49
'responsibleId'
=> 0,
50
'isInvalid'
=>
false
,
51
];
52
53
$type
= mb_strtolower($robot[
'Type'
] ??
''
);
54
if
(isset($availableRobots[
$type
][
'ROBOT_SETTINGS'
]))
55
{
56
$settings
= $availableRobots[
$type
][
'ROBOT_SETTINGS'
];
57
58
if
(!empty(
$settings
[
'RESPONSIBLE_TO_HEAD'
]) && $robot[
'Properties'
][
$settings
[
'RESPONSIBLE_TO_HEAD'
]] ===
'Y'
)
59
{
60
$result
[
'responsibleLabel'
] = Loc::getMessage(
'BIZPROC_AUTOMATION_COMPONENT_BASE_TO_HEAD'
);
61
}
62
63
if
(isset(
$settings
[
'RESPONSIBLE_PROPERTY'
]))
64
{
65
$users = static::getUsersFromResponsibleProperty($robot,
$settings
[
'RESPONSIBLE_PROPERTY'
]);
66
$usersLabel = \CBPHelper::UsersArrayToString($users, [], $documentType,
false
);
67
68
if
(
$result
[
'responsibleLabel'
] && $usersLabel)
69
{
70
$result
[
'responsibleLabel'
] .=
', '
;
71
}
72
$result
[
'responsibleLabel'
] .= $usersLabel;
73
74
if
($users &&
count
($users) === 1 && $users[0] && mb_strpos($users[0],
'user_'
) === 0)
75
{
76
$id = (int) \CBPHelper::StripUserPrefix($users[0]);
77
$result
[
'responsibleUrl'
] = \CComponentEngine::MakePathFromTemplate(
78
'/company/personal/user/#user_id#/'
,
79
array
(
'user_id'
=> $id)
80
);
81
$result
[
'responsibleId'
] = $id;
82
}
83
}
84
}
85
elseif
(!isset($availableRobots[
$type
]))
86
{
87
$result
[
'isInvalid'
] =
true
;
88
}
89
90
return
$result
;
91
}
92
93
public
static
function
getRunningCustomRobots
(
array
$documentId,
$template
):
array
94
{
95
if
(!empty(
$template
) &&
$template
?->getId() > 0)
96
{
97
return \Bitrix\Bizproc\Workflow\Entity\WorkflowInstanceTable::getList([
98
'select'
=> [
'ID'
],
99
'filter'
=> [
100
'=MODULE_ID'
=> $documentId[0],
101
'=ENTITY'
=> $documentId[1],
102
'=DOCUMENT_ID'
=> $documentId[2],
103
'=WORKFLOW_TEMPLATE_ID'
=>
$template
->getId(),
104
'!STARTED_EVENT_TYPE'
=> \
CBPDocumentEventType::Debug
,
105
'=TEMPLATE.TYPE'
=> WorkflowTemplateType::CustomRobots->value,
106
]
107
])->fetchAll();
108
}
109
110
return
[];
111
}
112
113
protected
static
function
getUsersFromResponsibleProperty
(
array
$robot, $propertyName): ?
array
114
{
115
$value =
null
;
116
$props
= $robot[
'Properties'
];
117
$path
= explode(
'.'
, $propertyName);
118
119
foreach
(
$path
as $chain)
120
{
121
$value = (
$props
&& is_array(
$props
) && isset(
$props
[$chain])) ?
$props
[$chain] :
null
;
122
$props
= $value;
123
}
124
125
return
$value ? (
array
)$value :
null
;
126
}
127
}
$path
$path
Определения
access_edit.php:21
$type
$type
Определения
options.php:106
Bitrix\Bizproc\Automation\Component\Base
Определения
base.php:12
Bitrix\Bizproc\Automation\Component\Base\__construct
__construct($component=null)
Определения
base.php:16
Bitrix\Bizproc\Automation\Component\Base\getErrors
getErrors()
Определения
base.php:23
Bitrix\Bizproc\Automation\Component\Base\$errorCollection
$errorCollection
Определения
base.php:14
Bitrix\Bizproc\Automation\Component\Base\getTemplateViewData
static getTemplateViewData(array $template, $documentType)
Определения
base.php:33
Bitrix\Bizproc\Automation\Component\Base\getRunningCustomRobots
static getRunningCustomRobots(array $documentId, $template)
Определения
base.php:93
Bitrix\Bizproc\Automation\Component\Base\getUsersFromResponsibleProperty
static getUsersFromResponsibleProperty(array $robot, $propertyName)
Определения
base.php:113
Bitrix\Bizproc\Automation\Component\Base\getRobotViewData
static getRobotViewData($robot, array $documentType)
Определения
base.php:43
Bitrix\Bizproc\Automation\Component\Base\getErrorByCode
getErrorByCode($code)
Определения
base.php:28
Bitrix\Bizproc\Automation\Engine\Template\getAvailableRobots
static getAvailableRobots(array $documentType)
Определения
template.php:350
Bitrix\Main\ErrorCollection
Определения
errorcollection.php:14
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Localization\Loc
Определения
loc.php:12
CBPDocumentEventType\Debug
const Debug
Определения
constants.php:159
$template
$template
Определения
file_edit.php:49
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
Bitrix\Main\Errorable
Определения
errorable.php:6
$code
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения
options.php:195
Bitrix\Bizproc\Api\Enum\Template\WorkflowTemplateType
WorkflowTemplateType
Определения
WorkflowTemplateType.php:6
Bitrix\Bizproc\Automation\Component
Определения
base.php:3
$settings
$settings
Определения
product_settings.php:43
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$i
$i
Определения
factura.php:643
count
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения
waybill.php:936
$props
$props
Определения
template.php:269
bitrix
modules
bizproc
lib
automation
component
base.php
Создано системой
1.14.0