24 public function getLog(array $statuses)
26 return $this->getBizprocTrackingEntries($statuses);
29 private function getBizprocTrackingEntries($statuses)
33 $states = $this->getStatusesStates($statuses);
37 $trackIterator = \CBPTrackingService::GetList(
39 [
'@WORKFLOW_ID' => array_keys($states)]
42 $workflowStatuses = [];
44 while ($row = $trackIterator->fetch())
46 if (!array_key_exists($row[
'WORKFLOW_ID'], $workflowStatuses))
48 $hasInstance = $row[
'WORKFLOW_ID'] && WorkflowInstanceTable::exists($row[
'WORKFLOW_ID']);
49 $workflowStatus = $hasInstance ? \CBPWorkflowStatus::Running : \CBPWorkflowStatus::Completed;
51 $workflowStatuses[$row[
'WORKFLOW_ID']] = $workflowStatus;
54 $status = $states[$row[
'WORKFLOW_ID']];
55 $row[
'WORKFLOW_STATUS'] = $workflowStatuses[$row[
'WORKFLOW_ID']];
56 $entries[$status][] = $row;
63 private function getStatusesStates($statuses)
66 $templateIds = $this->getBizprocTemplateIds($statuses);
71 $stateIterator = WorkflowStateTable::getList(array(
72 'select' => array(
'ID',
'WORKFLOW_TEMPLATE_ID'),
74 '=DOCUMENT_ID' => $this->target->getDocumentId(),
75 '@WORKFLOW_TEMPLATE_ID' => array_keys($templateIds)
77 'order' => array(
'STARTED' =>
'DESC')
80 while ($row = $stateIterator->fetch())
82 $status = $templateIds[$row[
'WORKFLOW_TEMPLATE_ID']];
83 if (!in_array($status, $states))
84 $states[$row[
'ID']] = $status;
90 private function getBizprocTemplateIds($statuses)
92 $documentType = $this->target->getDocumentType();
95 $iterator = WorkflowTemplateTable::getList(array(
96 'select' => array(
'ID',
'DOCUMENT_STATUS'),
98 '=MODULE_ID' => $documentType[0],
99 '=ENTITY' => $documentType[1],
100 '=DOCUMENT_TYPE' => $documentType[2],
102 '@DOCUMENT_STATUS' => $statuses
106 while ($row = $iterator->fetch())
108 $ids[$row[
'ID']] = $row[
'DOCUMENT_STATUS'];