21 return $this->preparedProperties[$name] ?? parent::__get($name);
26 if (!static::checkModules())
28 return \CBPActivityExecutionStatus::Closed;
33 if ($errorCollection->isEmpty())
38 foreach ($errorCollection as $error)
40 $this->
logError($error->getMessage());
43 return \CBPActivityExecutionStatus::Closed;
48 $fieldsMap = static::getPropertiesDialogMap();
50 foreach (array_keys($this->arProperties) as $propertyId)
52 $propertyValue = $this->getRawProperty($propertyId);
55 if (isset($this->arPropertiesTypes) && isset($this->arPropertiesTypes[$propertyId]))
57 $type = $this->arPropertiesTypes[$propertyId][
'Type'] ??
'';
59 if (!$type && isset($fieldsMap[$propertyId]))
61 $type = $fieldsMap[$propertyId][
'Type'] ??
'';
64 $parsedValue = $this->ParseValue($propertyValue);
77 return \CBPHelper::getBool($value);
80 return (
double)$value;
97 protected function logError(
string $message =
'',
int $userId = 0): void
99 $this->
log($message, $userId, \CBPTrackingType::Error);
102 protected function log(
string $message =
'',
int $userId = 0,
int $type = -1): void
104 $this->WriteToTrackingService($message, $userId, $type);
113 $currentValues =
null,
119 if (!static::checkModules())
124 $dialog = new \Bitrix\Bizproc\Activity\PropertiesDialog(static::getFileName(), [
125 'documentType' => $documentType,
126 'activityName' => $activityName,
127 'workflowTemplate' => $workflowTemplate,
128 'workflowParameters' => $workflowParameters,
129 'workflowVariables' => $workflowVariables,
130 'currentValues' => $currentValues,
131 'formName' => $formName,
136 ->setMapCallback([static::class,
'getPropertiesDialogMap'])
137 ->setRuntimeData(static::getRuntimeData())
140 if (!static::hasRenderer())
142 $dialog->setRenderer([static::class,
'renderPropertiesDialog']);
148 private static function hasRenderer(): bool
160 $propertiesDialogHtml =
'';
162 foreach ($dialog->
getMap() as $field)
164 $propertiesDialogHtml .=
166 ? static::renderRobotProperty($dialog, $field)
167 : static::renderBizprocProperty($dialog, $field)
171 return $propertiesDialogHtml;
184 '<tr><td align="right" width="40%%">%s:</td><td width="60%%">%s</td></tr>',
185 htmlspecialcharsbx($field[
'Name']),
193 <div class="bizproc-automation-popup-settings">
194 <span class="bizproc-automation-popup-settings-title bizproc-automation-popup-settings-title-autocomplete">
203 htmlspecialcharsbx($field[
'Name']),
212 &$workflowParameters,
218 if (!static::checkModules())
224 'documentType' => $documentType,
225 'activityName' => $activityName,
226 'workflowTemplate' => $workflowTemplate,
227 'workflowParameters' => $workflowParameters,
228 'workflowVariables' => $workflowVariables,
229 'currentValues' => $currentValues,
232 $extractingResult = static::extractPropertiesValues($dialog, static::getPropertiesDialogMap($dialog));
233 if (!$extractingResult->isSuccess())
235 foreach ($extractingResult->getErrors() as $error)
238 'code' => $error->getCode(),
239 'message' => $error->getMessage(),
240 'parameter' => $error->getCustomData(),
246 $errors = static::ValidateProperties(
247 $extractingResult->getData(),
248 new \CBPWorkflowTemplateUser(\CBPWorkflowTemplateUser::CurrentUser)
257 $currentActivity = &\CBPWorkflowTemplateLoader::FindActivityByName(
261 $currentActivity[
'Properties'] = $extractingResult->getData();
273 $documentService = static::getDocumentService();
275 foreach ($fieldsMap as $propertyKey => $fieldProperties)
277 $field = $documentService->getFieldTypeObject($dialog->
getDocumentType(), $fieldProperties);
283 $properties[$propertyKey] = $field->extractValue(
284 [
'Field' => $fieldProperties[
'FieldName']],
292 foreach ($errors as $error)
296 $error[
'message'] ??
'',
297 $error[
'code'] ??
'',
298 $error[
'parameter'] ??
''
305 $result->setData($properties);
313 public static function validateProperties($testProperties = [], \CBPWorkflowTemplateUser $user =
null)
317 if (!static::checkModules())
322 foreach (static::getPropertiesDialogMap() as $propertyKey => $fieldProperties)
325 \CBPHelper::getBool($fieldProperties[
'Required'] ??
null)
326 && \CBPHelper::isEmptyValue($testProperties[$propertyKey] ??
null)
330 'code' =>
'NotExist',
331 'parameter' =>
'FieldValue',
332 'message' =>
Loc::getMessage(
'BIZPROC_BA_EMPTY_PROP', [
'#PROPERTY#' => $fieldProperties[
'Name']]),
337 return array_merge($errors, parent::ValidateProperties($testProperties, $user));
342 foreach (static::$requiredModules as $module)
344 if (!Loader::includeModule($module))
355 return \CBPRuntime::GetRuntime(
true)->getDocumentService();
static getPropertiesDialogValues( $documentType, $activityName, &$workflowTemplate, &$workflowParameters, &$workflowVariables, $currentValues, &$errors)
static getDocumentService()
convertPropertyValue(string $type, $value)
static getPropertiesDialog( $documentType, $activityName, $workflowTemplate, $workflowParameters, $workflowVariables, $currentValues=null, $formName='', $popupWindow=null, $siteId='')
static validateProperties($testProperties=[], \CBPWorkflowTemplateUser $user=null)
logError(string $message='', int $userId=0)
static getPropertiesDialogMap(?PropertiesDialog $dialog=null)
log(string $message='', int $userId=0, int $type=-1)
static extractPropertiesValues(PropertiesDialog $dialog, array $fieldsMap)
static renderPropertiesDialog(PropertiesDialog $dialog)
static renderBizprocProperty(PropertiesDialog $dialog, array $field)
static renderRobotProperty(PropertiesDialog $dialog, array $field)
getCurrentValues($compatible=false)
renderFieldControl($field, $value=null, $allowSelection=true, $renderMode=FieldType::RENDER_MODE_PUBLIC)
getCurrentValue($valueKey, $default=null)
const RENDER_MODE_DESIGNER
static isFileExists($path)
static getDirectory($path)
static getMessage($code, $replace=null, $language=null)