1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
WorkflowStateToGet.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Bizproc\Api\Data\WorkflowStateService;
4
5
use Bitrix\Bizproc\Workflow\Entity\WorkflowUserCommentTable;
6
use Bitrix\Bizproc\Workflow\Entity\WorkflowUserTable;
7
use Bitrix\Bizproc\Workflow\Task\TaskSearchContentTable;
8
use Bitrix\Main\ArgumentException;
9
use Bitrix\Main\DB\SqlExpression;
10
use Bitrix\Main\ORM\Fields\Relations\Reference;
11
use Bitrix\Main\ORM\Query;
12
use Bitrix\Main\Type\DateTime;
13
14
class
WorkflowStateToGet
15
{
16
private
const
SEARCH_REF_NAME =
'SEARCH_CONTENT'
;
17
private
array
$select = [
'ID'
,
'MODULE_ID'
,
'DOCUMENT_ID'
,
'ENTITY'
];
18
private
int
$filterUserId = 0;
19
private
?
string
$filterPresetId;
20
private
?
array
$filterWorkflowIds;
21
private
?
string
$filterSearchQuery;
22
private
array
$filter = [];
23
private
int
$limit = 0;
24
private
int
$offset = 0;
25
private
bool
$isSelectAllFields =
false
;
26
27
private
array
$selectTaskFields = [];
28
private
?
int
$selectTaskLimit = 50;
29
30
private
bool
$countTotal =
false
;
31
32
public
function
setAdditionalSelectFields
(
array
$additionalSelect): static
33
{
34
$allowedFields
= $this->getAllowedAdditionalFields();
35
36
foreach
($additionalSelect as $fieldId)
37
{
38
if
(in_array($fieldId,
$allowedFields
,
true
) && !in_array($fieldId, $this->
select
,
true
))
39
{
40
$this->
select
[] = $fieldId;
41
}
42
}
43
44
return
$this;
45
}
46
47
public
function
setFilter
(
array
$filter): static
48
{
49
$this->filter = $filter;
50
51
return
$this;
52
}
53
54
public
function
setTaskSelectFields
(
array
$taskSelect): static
55
{
56
$allowedTaskFields = $this->getAllowedTaskFields();
57
58
foreach
($taskSelect as $fieldId)
59
{
60
if
(in_array($fieldId, $allowedTaskFields,
true
))
61
{
62
$this->selectTaskFields[] = $fieldId;
63
}
64
}
65
66
$this->selectTaskFields = array_unique($this->selectTaskFields);
67
68
return
$this;
69
}
70
71
public
function
getSelectTaskFields
():
array
72
{
73
return
$this->selectTaskFields;
74
}
75
83
public
function
setSelectTaskLimit
(?
int
$taskLimit): static
84
{
85
if
(is_int($taskLimit))
86
{
87
if
($taskLimit <= 0)
88
{
89
throw
new
ArgumentException
(
'Task limit must be positive integer or null'
);
90
}
91
$this->selectTaskLimit = $taskLimit;
92
}
93
else
94
{
95
$this->selectTaskLimit =
null
;
96
}
97
98
return
$this;
99
}
100
101
public
function
getSelectTaskLimit
(): ?int
102
{
103
return
$this->selectTaskLimit;
104
}
105
106
public
function
setSelectAllFields
(
bool
$flag =
true
): static
107
{
108
$this->isSelectAllFields = $flag;
109
110
return
$this;
111
}
112
113
public
function
setFilterUserId
(
int
$userId
): static
114
{
115
$this->filterUserId =
$userId
;
116
117
return
$this;
118
}
119
120
public
function
getFilterUserId
(): int
121
{
122
return
$this->filterUserId;
123
}
124
125
public
function
setFilterPresetId
(
string
$presetId): static
126
{
127
if
(
WorkflowStateFilter::isDefined
($presetId))
128
{
129
$this->filterPresetId = $presetId;
130
}
131
132
return
$this;
133
}
134
135
public
function
getFilterPresetId
(): ?string
136
{
137
return
$this->filterPresetId;
138
}
139
140
public
function
setFilterWorkflowIds
(
array
$workflowIds): static
141
{
142
$this->filterWorkflowIds = $workflowIds;
143
144
return
$this;
145
}
146
147
public
function
getFilterWorkflowIds
(): ?
array
148
{
149
return
$this->filterWorkflowIds;
150
}
151
152
public
function
setFilterSearchQuery
(
string
$query
): static
153
{
154
$this->filterSearchQuery =
TaskSearchContentTable::prepareSearchContent
(
$query
);
155
156
return
$this;
157
}
158
159
public
function
getFilterSearchQuery
(): ?string
160
{
161
return
$this->filterSearchQuery;
162
}
163
164
public
function
setLimit
(
int
$limit): static
165
{
166
if
($limit >= 0)
167
{
168
$this->limit = $limit;
169
}
170
171
return
$this;
172
}
173
174
public
function
setOffset
(
int
$offset): static
175
{
176
if
($offset >= 0)
177
{
178
$this->offset = $offset;
179
}
180
181
return
$this;
182
}
183
184
public
function
countTotal
(
bool
$count
=
true
): static
185
{
186
$this->
countTotal
=
$count
;
187
188
return
$this;
189
}
190
191
public
function
isCountingTotal
(): bool
192
{
193
return
$this->countTotal;
194
}
195
196
public
function
getSelect
():
array
197
{
198
if
($this->isSelectAllFields)
199
{
200
return
array_merge($this->
select
, $this->getAllowedAdditionalFields());
201
}
202
203
return
$this->select
;
204
}
205
206
public
function
getOrmFilter
():
array
207
{
208
$filter =
$this->filter
;
209
$filter[
'=USER_ID'
] = $this->filterUserId;
210
211
if
(!empty($this->filterWorkflowIds))
212
{
213
$filter[
'@WORKFLOW_ID'
] = $this->filterWorkflowIds;
214
}
215
216
$filterPresetId = $this->filterPresetId ??
null
;
217
218
if
($filterPresetId ===
WorkflowStateFilter::PRESET_STARTED
)
219
{
220
$filter[
'=IS_AUTHOR'
] = 1;
221
}
222
elseif
($filterPresetId ===
WorkflowStateFilter::PRESET_HAS_TASK
)
223
{
224
$filter[
'>TASK_STATUS'
] = WorkflowUserTable::TASK_STATUS_NONE;
225
}
226
elseif
($filterPresetId ===
WorkflowStateFilter::PRESET_ALL_COMPLETED
)
227
{
228
$filter[
'=WORKFLOW_STATUS'
] = WorkflowUserTable::WORKFLOW_STATUS_COMPLETED;
229
}
230
elseif
($filterPresetId ===
WorkflowStateFilter::PRESET_IN_WORK
)
231
{
232
$inWorkFilter = [
'LOGIC'
=>
'OR'
];
233
$inWorkFilter[] = [
234
'=WORKFLOW_STATUS'
=>
new
SqlExpression
(
'?i'
, WorkflowUserTable::WORKFLOW_STATUS_ACTIVE),
235
0 => [
236
'LOGIC'
=>
'OR'
,
237
'=IS_AUTHOR'
=> 1,
238
'=TASK_STATUS'
=> WorkflowUserTable::TASK_STATUS_ACTIVE,
239
],
240
];
241
242
$inWorkFilter[] = [
243
'!=COMMENTS.UNREAD_CNT'
=>
null
,
244
0 => [
245
'LOGIC'
=>
'OR'
,
246
'=COMMENTS.LAST_TYPE'
=>
new
SqlExpression
(
'?i'
,
WorkflowUserCommentTable::COMMENT_TYPE_DEFAULT
),
247
0 => [
248
'=COMMENTS.LAST_TYPE'
=>
WorkflowUserCommentTable::COMMENT_TYPE_SYSTEM
,
249
'>COMMENTS.MODIFIED'
=> DateTime::createFromTimestamp(time() - 86400)
// one day
250
],
251
],
252
];
253
254
$filter[] = $inWorkFilter;
255
}
256
elseif
($filterPresetId ===
WorkflowStateFilter::PRESET_ACTIVE_TASK
)
257
{
258
$filter[
'=TASK_STATUS'
] = WorkflowUserTable::TASK_STATUS_ACTIVE;
259
}
260
elseif
($filterPresetId ===
WorkflowStateFilter::PRESET_COMMENT
)
261
{
262
$filter[
'!=COMMENTS.UNREAD_CNT'
] =
null
;
263
}
264
265
if
(!empty($this->filterSearchQuery))
266
{
267
$find = Query\Filter\Helper::matchAgainstWildcard($this->filterSearchQuery);
268
269
$filter[] = [
270
'LOGIC'
=>
'AND'
,
271
'*'
. static::SEARCH_REF_NAME .
'.SEARCH_CONTENT'
=> $find,
272
'='
. static::SEARCH_REF_NAME .
'.USERS.USER_ID'
=> $this->filterUserId,
273
];
274
}
275
276
return
$filter;
277
}
278
279
public
function
getOrmRuntime
(): ?
Reference
280
{
281
if
(empty($this->filterSearchQuery))
282
{
283
return
null
;
284
}
285
286
$ref =
new
Reference
(
287
static::SEARCH_REF_NAME,
288
TaskSearchContentTable::getEntity
(),
289
[
290
'=this.WORKFLOW_ID'
=>
'ref.WORKFLOW_ID'
,
291
],
292
);
293
$ref->configureJoinType(
Query
\Join::TYPE_INNER);
294
295
return
$ref;
296
}
297
298
public
function
getOrder
():
array
299
{
300
return
[
'MODIFIED'
=>
'DESC'
];
301
}
302
303
public
function
getLimit
(): int
304
{
305
return
$this->limit;
306
}
307
308
public
function
getOffset
(): int
309
{
310
return
$this->offset;
311
}
312
313
private
function
getAllowedAdditionalFields():
array
314
{
315
return
array_merge(
316
[
317
'STARTED_BY'
,
318
'STARTED'
,
319
'MODIFIED'
,
320
'WORKFLOW_TEMPLATE_ID'
,
321
'TEMPLATE.NAME'
,
322
// 'DOCUMENT_ID_INT',
323
//'STATE',
324
'STATE_TITLE'
,
325
// 'STATE_PARAMETERS',
326
],
327
array_map(
static
fn($metaFieldName) =>
'META.'
. $metaFieldName, $this->getAllowedMetaFields()),
328
);
329
}
330
331
private
function
getAllowedTaskFields():
array
332
{
333
return
[
334
'ID'
,
335
'ACTIVITY'
,
336
'MODIFIED'
,
337
'OVERDUE_DATE'
,
338
'NAME'
,
339
'DESCRIPTION'
,
340
'STATUS'
,
341
'IS_INLINE'
,
342
'DELEGATION_TYPE'
,
343
'PARAMETERS'
,
344
345
'TASK_USERS.USER_ID'
,
346
'TASK_USERS.STATUS'
,
347
'TASK_USERS.DATE_UPDATE'
,
348
'TASK_USERS.ORIGINAL_USER_ID'
,
349
];
350
}
351
352
private
function
getAllowedMetaFields():
array
353
{
354
return
[
'ID'
,
'WORKFLOW_ID'
,
'START_DURATION'
];
355
}
356
}
select
return select
Определения
access_edit.php:440
$count
$count
Определения
admin_tab.php:4
$allowedFields
$allowedFields
Определения
push.php:9
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_COMMENT
const PRESET_COMMENT
Определения
WorkflowStateFilter.php:14
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_HAS_TASK
const PRESET_HAS_TASK
Определения
WorkflowStateFilter.php:11
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_IN_WORK
const PRESET_IN_WORK
Определения
WorkflowStateFilter.php:9
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_ALL_COMPLETED
const PRESET_ALL_COMPLETED
Определения
WorkflowStateFilter.php:12
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_STARTED
const PRESET_STARTED
Определения
WorkflowStateFilter.php:10
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\isDefined
static isDefined(string $presetId)
Определения
WorkflowStateFilter.php:48
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateFilter\PRESET_ACTIVE_TASK
const PRESET_ACTIVE_TASK
Определения
WorkflowStateFilter.php:13
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet
Определения
WorkflowStateToGet.php:15
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setFilterSearchQuery
setFilterSearchQuery(string $query)
Определения
WorkflowStateToGet.php:152
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setFilterPresetId
setFilterPresetId(string $presetId)
Определения
WorkflowStateToGet.php:125
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\countTotal
countTotal(bool $count=true)
Определения
WorkflowStateToGet.php:184
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setSelectTaskLimit
setSelectTaskLimit(?int $taskLimit)
Определения
WorkflowStateToGet.php:83
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setFilter
setFilter(array $filter)
Определения
WorkflowStateToGet.php:47
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getSelectTaskFields
getSelectTaskFields()
Определения
WorkflowStateToGet.php:71
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\isCountingTotal
isCountingTotal()
Определения
WorkflowStateToGet.php:191
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setTaskSelectFields
setTaskSelectFields(array $taskSelect)
Определения
WorkflowStateToGet.php:54
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getSelectTaskLimit
getSelectTaskLimit()
Определения
WorkflowStateToGet.php:101
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getOrmRuntime
getOrmRuntime()
Определения
WorkflowStateToGet.php:279
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setFilterWorkflowIds
setFilterWorkflowIds(array $workflowIds)
Определения
WorkflowStateToGet.php:140
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setSelectAllFields
setSelectAllFields(bool $flag=true)
Определения
WorkflowStateToGet.php:106
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setLimit
setLimit(int $limit)
Определения
WorkflowStateToGet.php:164
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getOrder
getOrder()
Определения
WorkflowStateToGet.php:298
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setFilterUserId
setFilterUserId(int $userId)
Определения
WorkflowStateToGet.php:113
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getFilterWorkflowIds
getFilterWorkflowIds()
Определения
WorkflowStateToGet.php:147
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getFilterSearchQuery
getFilterSearchQuery()
Определения
WorkflowStateToGet.php:159
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getFilterPresetId
getFilterPresetId()
Определения
WorkflowStateToGet.php:135
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setOffset
setOffset(int $offset)
Определения
WorkflowStateToGet.php:174
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getSelect
getSelect()
Определения
WorkflowStateToGet.php:196
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getOrmFilter
getOrmFilter()
Определения
WorkflowStateToGet.php:206
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\setAdditionalSelectFields
setAdditionalSelectFields(array $additionalSelect)
Определения
WorkflowStateToGet.php:32
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getLimit
getLimit()
Определения
WorkflowStateToGet.php:303
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getFilterUserId
getFilterUserId()
Определения
WorkflowStateToGet.php:120
Bitrix\Bizproc\Api\Data\WorkflowStateService\WorkflowStateToGet\getOffset
getOffset()
Определения
WorkflowStateToGet.php:308
Bitrix\Bizproc\Workflow\Entity\WorkflowUserCommentTable\COMMENT_TYPE_SYSTEM
const COMMENT_TYPE_SYSTEM
Определения
workflowusercommenttable.php:33
Bitrix\Bizproc\Workflow\Entity\WorkflowUserCommentTable\COMMENT_TYPE_DEFAULT
const COMMENT_TYPE_DEFAULT
Определения
workflowusercommenttable.php:31
Bitrix\Bizproc\Workflow\Task\TaskSearchContentTable\prepareSearchContent
static prepareSearchContent(string $content)
Определения
tasksearchcontenttable.php:59
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
Bitrix\Main\DB\SqlExpression
Определения
sqlexpression.php:21
Bitrix\Main\ORM\Data\DataManager\getEntity
static getEntity()
Определения
datamanager.php:65
Bitrix\Main\ORM\Fields\Relations\Reference
Определения
reference.php:26
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$query
$query
Определения
get_search.php:11
$select
$select
Определения
iblock_catalog_list.php:194
$filter
$filter
Определения
iblock_catalog_list.php:54
Bitrix\Main\ORM\Query
Определения
chain.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
bizproc
lib
Api
Data
WorkflowStateService
WorkflowStateToGet.php
Создано системой
1.14.0