1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
workflowinstance.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Workflow\Entity;
4
5use Bitrix\Main;
6use Bitrix\Main\Entity;
7
25{
27
31 public static function getTableName()
32 {
33 return 'b_bp_workflow_instance';
34 }
35
39 public static function getMap()
40 {
41 return array(
42 'ID' => array(
43 'data_type' => 'string',
44 'primary' => true,
45 ),
46 'MODULE_ID' => array(
47 'data_type' => 'string'
48 ),
49 'ENTITY' => array(
50 'data_type' => 'string'
51 ),
52 'DOCUMENT_ID' => array(
53 'data_type' => 'string'
54 ),
55 'WORKFLOW_TEMPLATE_ID' => array(
56 'data_type' => 'integer'
57 ),
58 'WORKFLOW' => array(
59 'data_type' => 'string'
60 ),
61 'WORKFLOW_RO' => array(
62 'data_type' => 'string'
63 ),
64 'STARTED' => array(
65 'data_type' => 'datetime'
66 ),
67 'STARTED_BY' => array(
68 'data_type' => 'integer'
69 ),
70 'STARTED_USER' => array(
71 'data_type' => '\Bitrix\Main\UserTable',
72 'reference' => array(
73 '=this.STARTED_BY' => 'ref.ID'
74 ),
75 'join_type' => 'LEFT',
76 ),
77 'STARTED_EVENT_TYPE' => array(
78 'data_type' => 'integer'
79 ),
80 'STATUS' => array(
81 'data_type' => 'integer'
82 ),
83 'MODIFIED' => array(
84 'data_type' => 'datetime'
85 ),
86 'OWNER_ID' => array(
87 'data_type' => 'string'
88 ),
89 'OWNED_UNTIL' => array(
90 'data_type' => 'datetime'
91 ),
92 'STATE' => array(
93 'data_type' => '\Bitrix\Bizproc\Workflow\Entity\WorkflowStateTable',
94 'reference' => array(
95 '=this.ID' => 'ref.ID'
96 ),
97 'join_type' => 'LEFT',
98 ),
99 'TEMPLATE' => array(
100 'data_type' => '\Bitrix\Bizproc\WorkflowTemplateTable',
101 'reference' => array(
102 '=this.WORKFLOW_TEMPLATE_ID' => 'ref.ID'
103 ),
104 'join_type' => 'LEFT'
105 ),
106 );
107 }
108
109 public static function exists(string $workflowId)
110 {
111 return static::getCount(['=ID' => $workflowId]) > 0;
112 }
113
114 public static function getIdsByDocument(array $documentId)
115 {
116 $documentId = \CBPHelper::ParseDocumentId($documentId);
117 $rows = static::getList([
118 'select' => ['ID'],
119 'filter' => [
120 '=MODULE_ID' => $documentId[0],
121 '=ENTITY' => $documentId[1],
122 '=DOCUMENT_ID' => $documentId[2]
123 ]
124 ])->fetchAll();
125
126 return array_column($rows, 'ID');
127 }
128
129 public static function countByDocument(array $documentId): int
130 {
131 $documentId = \CBPHelper::ParseDocumentId($documentId);
132 $cnt = static::getCount([
133 '=MODULE_ID' => $documentId[0],
134 '=ENTITY' => $documentId[1],
135 '=DOCUMENT_ID' => $documentId[2]
136 ]);
137
138 return $cnt;
139 }
140
141 public static function getIdsByTemplateId(int ...$tplIds)
142 {
143 $filterKeyPrefix = count($tplIds) < 2 ? '=' : '@';
144 if (count($tplIds) < 2)
145 {
146 $tplIds = reset($tplIds);
147 }
148
149 $rows = static::getList([
150 'select' => ['ID'],
151 'filter' => [
152 $filterKeyPrefix.'WORKFLOW_TEMPLATE_ID' => $tplIds,
153 ]
154 ])->fetchAll();
155
156 return array_column($rows, 'ID');
157 }
158
159 public static function mergeByDocument($paramFirstDocumentId, $paramSecondDocumentId)
160 {
161 $firstDocumentId = \CBPHelper::parseDocumentId($paramFirstDocumentId);
162 $secondDocumentId = \CBPHelper::parseDocumentId($paramSecondDocumentId);
163
165 $sqlHelper = $connection->getSqlHelper();
166 $table = $sqlHelper->forSql(static::getTableName());
167
168 $firstDocId = $sqlHelper->forSql($firstDocumentId[2]);
169 $firstEntity = $sqlHelper->forSql($firstDocumentId[1]);
170 $firstModule = $sqlHelper->forSql($firstDocumentId[0]);
171
172 $secondDocId = $sqlHelper->forSql($secondDocumentId[2]);
173 $secondEntity = $sqlHelper->forSql($secondDocumentId[1]);
174 $secondModule = $sqlHelper->forSql($secondDocumentId[0]);
175
176 $connection->queryExecute("UPDATE {$table}
177 SET
178 DOCUMENT_ID = '{$firstDocId}',
179 ENTITY = '{$firstEntity}',
180 MODULE_ID = '{$firstModule}'
181 WHERE
182 DOCUMENT_ID = '{$secondDocId}'
183 AND ENTITY = '{$secondEntity}'
184 AND MODULE_ID = '{$secondModule}'
185 ");
186
187 return true;
188 }
189
190 public static function migrateDocumentType($paramOldType, $paramNewType, $workflowTemplateIds)
191 {
192 $oldType = \CBPHelper::parseDocumentId($paramOldType);
193 $newType = \CBPHelper::parseDocumentId($paramNewType);
194
196 $sqlHelper = $connection->getSqlHelper();
197 $table = $sqlHelper->forSql(static::getTableName());
198
199 $firstEntity = $sqlHelper->forSql($oldType[1]);
200 $firstModule = $sqlHelper->forSql($oldType[0]);
201
202 $secondEntity = $sqlHelper->forSql($newType[1]);
203 $secondModule = $sqlHelper->forSql($newType[0]);
204
205 $templates = implode(",", array_map('intval', $workflowTemplateIds));
206
207 $connection->queryExecute("UPDATE {$table}
208 SET
209 ENTITY = '{$firstEntity}',
210 MODULE_ID = '{$firstModule}'
211 WHERE
212 ENTITY = '{$secondEntity}'
213 AND MODULE_ID = '{$secondModule}'
214 AND WORKFLOW_TEMPLATE_ID IN ({$templates})
215 ");
216
217 return true;
218 }
219
220 public static function isDebugWorkflow(string $workflowId)
221 {
222 $row = static::getList([
223 'select' => ['STARTED_EVENT_TYPE'],
224 'filter' => [
225 '=ID' => $workflowId,
226 ]
227 ])->fetch();
228
229 return $row && (int)$row['STARTED_EVENT_TYPE'] === \CBPDocumentEventType::Debug;
230 }
231
237 public static function add(array $data)
238 {
239 throw new Main\NotImplementedException("Use CBPStateService class.");
240 }
241
248 public static function update($primary, array $data)
249 {
250 throw new Main\NotImplementedException("Use CBPStateService class.");
251 }
252}
$connection
Определения actionsdefinitions.php:38
static getIdsByDocument(array $documentId)
Определения workflowinstance.php:114
static countByDocument(array $documentId)
Определения workflowinstance.php:129
static getIdsByTemplateId(int ... $tplIds)
Определения workflowinstance.php:141
static mergeByDocument($paramFirstDocumentId, $paramSecondDocumentId)
Определения workflowinstance.php:159
static isDebugWorkflow(string $workflowId)
Определения workflowinstance.php:220
static exists(string $workflowId)
Определения workflowinstance.php:109
static migrateDocumentType($paramOldType, $paramNewType, $workflowTemplateIds)
Определения workflowinstance.php:190
static update($primary, array $data)
Определения workflowinstance.php:248
static getConnection($name="")
Определения application.php:638
const Debug
Определения constants.php:159
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$table
Определения mysql_to_pgsql.php:36
</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
$rows
Определения options.php:264