CBPDocument::getWorkflowTemplatesForDocumentType

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPDocument
  4. getWorkflowTemplatesForDocumentType
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/document.php
  • Класс: CBPDocument
  • Вызов: CBPDocument::getWorkflowTemplatesForDocumentType
static function getWorkflowTemplatesForDocumentType($documentType, $showSystemTemplates = true)
{
	$arResult = [];
	$filter = [
		"DOCUMENT_TYPE" => $documentType,
		"ACTIVE" => "Y",
		' CBPDocumentEventType::Automation
	];

	if (!$showSystemTemplates)
	{
		$filter['IS_SYSTEM'] = 'N';
	}

	$dbWorkflowTemplate = CBPWorkflowTemplateLoader::GetList(
		['SORT'=>'ASC','NAME'=>'ASC'],
		$filter,
		false,
		false,
		array("ID", "NAME", "DESCRIPTION", "MODIFIED", "USER_ID", "AUTO_EXECUTE", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_SECOND_NAME", 'PARAMETERS')
	);
	while ($arWorkflowTemplate = $dbWorkflowTemplate->GetNext())
	{
		$arWorkflowTemplate["USER"] = "(".$arWorkflowTemplate["USER_LOGIN"].")".(($arWorkflowTemplate["USER_NAME"] <> '' || $arWorkflowTemplate["USER_LAST_NAME"] <> '') ? " " : "").CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), array("NAME" => $arWorkflowTemplate["USER_NAME"], "LAST_NAME" => $arWorkflowTemplate["USER_LAST_NAME"], "SECOND_NAME" => $arWorkflowTemplate["USER_SECOND_NAME"]), false, false);

		$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] = "";

		if ($arWorkflowTemplate["AUTO_EXECUTE"] == CBPDocumentEventType::None)
			$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= GetMessage("BPCGDOC_AUTO_EXECUTE_NONE");

		if (($arWorkflowTemplate["AUTO_EXECUTE"] & CBPDocumentEventType::Create) != 0)
		{
			if ($arWorkflowTemplate["AUTO_EXECUTE_TEXT"] <> '')
				$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= ", ";
			$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= GetMessage("BPCGDOC_AUTO_EXECUTE_CREATE");
		}

		if (($arWorkflowTemplate["AUTO_EXECUTE"] & CBPDocumentEventType::Edit) != 0)
		{
			if ($arWorkflowTemplate["AUTO_EXECUTE_TEXT"] <> '')
				$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= ", ";
			$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= GetMessage("BPCGDOC_AUTO_EXECUTE_EDIT");
		}

		if (($arWorkflowTemplate["AUTO_EXECUTE"] & CBPDocumentEventType::Delete) != 0)
		{
			if ($arWorkflowTemplate["AUTO_EXECUTE_TEXT"] <> '')
				$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= ", ";
			$arWorkflowTemplate["AUTO_EXECUTE_TEXT"] .= GetMessage("BPCGDOC_AUTO_EXECUTE_DELETE");
		}

		$arWorkflowTemplate['HAS_PARAMETERS'] = count($arWorkflowTemplate['PARAMETERS']) > 0;

		$arResult[] = $arWorkflowTemplate;
	}

	return $arResult;
}

Добавить комментарий