92 !\CBPRuntime::isFeatureEnabled()
101 [$module,
$entity, $documentType] = \CBPHelper::parseDocumentId($this->target->getDocumentType());
108 $code = static::getCode();
110 WorkflowTemplateSettingsTable::query()
111 ->setSelect([
'TEMPLATE',
'TEMPLATE_ID'])
112 ->where(
'NAME',
"TRIGGER_$code")
113 ->where(
'VALUE',
'Y')
114 ->where(
'TEMPLATE.MODULE_ID', $module)
115 ->where(
'TEMPLATE.ENTITY',
$entity)
116 ->where(
'TEMPLATE.DOCUMENT_TYPE', $documentType)
123 $complexDocumentId = $this->target->getComplexDocumentId();
124 foreach ($triggers as $trigger)
127 \CBPDocument::startWorkflow($trigger->getTemplateId(), $complexDocumentId, [],
$errors);
149 $currentStatus = $this->
getTarget()->getDocumentStatus();
150 $allStatuses = array_keys($this->
getTarget()->getDocumentStatusList());
152 $needleKey = array_search($currentStatus, $allStatuses,
false);
154 if ($needleKey ===
false)
159 $forwardStatuses = array_slice($allStatuses, $needleKey + 1);
160 unset($allStatuses[$needleKey]);
162 $code = static::getCode();
164 $targetTriggers = $this->
getTarget()->getTriggers($allStatuses);
166 foreach ($targetTriggers as $row)
168 if ($row[
'CODE'] !==
$code)
173 if (!in_array($row[
'DOCUMENT_STATUS'], $forwardStatuses,
false))
176 !isset($row[
'APPLY_RULES'][
'ALLOW_BACKWARDS'])
178 $row[
'APPLY_RULES'][
'ALLOW_BACKWARDS'] !==
'Y'
185 $rows[$row[
'DOCUMENT_STATUS']][] = $row;
190 foreach ($allStatuses as $needleStatus)
192 if (isset(
$rows[$needleStatus]))
194 $triggers[] =
$rows[$needleStatus];
199 return array_merge(...$triggers);