1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
WorkflowUserGridView.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\UI;
4
5use Bitrix\Main\Type\DateTime;
6
8{
9 protected array $usedColumns = ['PROCESS', 'MODIFIED', 'TASK_PROGRESS', 'SUMMARY', 'TASK'];
10 protected ?DateTime $modified = null;
11
12 public function setUsedColumns(array $columns): static
13 {
14 $this->usedColumns = $columns;
15
16 return $this;
17 }
18
19 public function setModified(?DateTime $modified): static
20 {
21 $this->modified = $modified;
22
23 return $this;
24 }
25
52 public function jsonSerialize(): array
53 {
54 $complexDocumentId = $this->workflow->getComplexDocumentId();
55
56 $data = [
57 'workflowId' => $this->getId(),
58 'userId' => $this->userId,
59 'isCompleted' => $this->getIsCompleted(),
60 'task' => $this->getFirstRunningTask(),
61 'document' => [
62 'url' => $this->getDocumentUrl(),
63 'name' =>\CBPRuntime::getRuntime()->getDocumentService()->getDocumentName($complexDocumentId),
64 ],
65 'startedById' => $this->getAuthorId(),
66 ];
67
68 if ($this->isShowProcessDescription())
69 {
70 $data['name'] = $this->getName();
71 $data['typeName'] = $this->getTypeName();
72 $data['description'] = $this->getDescription();
73 }
74
75 if ($this->isShowModifiedDate())
76 {
77 $data['modified'] = $this->getTime();
78 $data['commentCnt'] = $this->getCommentCounter();
79 $data['taskCnt'] = count($this->getTasks());
80 }
81
82 if ($this->isShowFaces())
83 {
84 $data['taskProgress'] = $this->getFaces();
85 }
86
87 if ($this->isShowProcessStatus())
88 {
89 $data['statusText'] = $this->getStatusText();
90 $data['workflowResult'] = $this->getIsCompleted() ? $this->getWorkflowResult() : null;
91 }
92
93 if ($this->isShowStartedBy())
94 {
95 $authorView = $this->getAuthorView();
96 $data['startedById'] = $authorView?->getUserId();
97 $data['startedBy'] = $authorView?->getFullName();
98 }
99
100 if ($this->isShowOverdueDate())
101 {
102 $data['overdueDate'] = \CBPViewHelper::formatDateTime($this->getOverdueDate());
103 }
104
105 if ($this->isShowStartedDate())
106 {
107 $data['workflowStarted'] = \CBPViewHelper::formatDateTime($this->workflow->getStarted());
108 }
109
110 if ($this->isShowStatus())
111 {
112 $data['statusText'] = $this->getStatusText();
113 }
114
115 if ($this->isShowTemplateName())
116 {
117 $data['templateName'] = $this->workflow->getTemplate()?->fillName() ?? '';
118 }
119
120 if ($this->isShowDescription())
121 {
122 $data['description'] = $this->getDescription();
123 }
124
125 return $data;
126 }
127
128 public function getDescription(): ?string
129 {
130 return \CBPViewHelper::prepareTaskDescription(
131 \CBPHelper::convertBBtoText(
132 preg_replace('|\n+|', "\n", parent::getDescription())
133 )
134 );
135 }
136
137 public function getOverdueDate(): ?DateTime
138 {
139 $task = $this->getFirstRunningTask();
140
141 return $task && isset($task['overdueDate']) ? DateTime::createFromUserTime($task['overdueDate']) : null;
142 }
143
144 protected function prepareTasks(array $myTasks): array
145 {
146 $isRpa = $this->workflow->getModuleId() === 'rpa';
148
149 $tasks = [];
150 foreach ($myTasks as $task)
151 {
152 $isRunning = (int)$task['STATUS'] === \CBPTaskStatus::Running;
153 if ($isRunning)
154 {
155 $isRunning = $this->isRunningTaskUser($task);
156 }
157
158 $taskId = (int)$task['ID'];
159 $tasks[] = [
160 'id' => $taskId,
161 'name' => html_entity_decode($task['~NAME']),
162 'description' => $task['~DESCRIPTION'],
163 'isInline' => \CBPHelper::getBool($task['IS_INLINE']),
164 'controls' => $isRunning ? $this->getTaskControls($task) : [],
165 'overdueDate' => $task['~OVERDUE_DATE'] ?? null,
166 'url' => $isRpa
167 ? "/rpa/task/id/$taskId/"
168 : sprintf('/company/personal/bizproc/%u/?USER_ID=%u', $taskId, $userId)
169 ,
170 'userId' => $userId,
171 'isRunning' => $isRunning,
172 ];
173 }
174
175 return $tasks;
176 }
177
178 protected function getTaskControls(array $task): array
179 {
180 $controls = \CBPDocument::getTaskControls($task, $this->userId);
181 $buttons = $controls['BUTTONS'] ?? null;
182 if (!empty($buttons))
183 {
184 foreach ($buttons as &$button)
185 {
186 if (!empty($button['TEXT']))
187 {
188 $button['TEXT'] = html_entity_decode(htmlspecialcharsback($button['TEXT']));
189 }
190 }
191
192 unset($button);
193 }
194
195 return ['buttons' => $buttons];
196 }
197
198 protected function getTime(): string
199 {
200 return \CBPViewHelper::formatDateTime($this->modified);
201 }
202
203 private function isShowStartedBy(): bool
204 {
205 return in_array('WORKFLOW_STARTED_BY', $this->usedColumns, true);
206 }
207
208 private function isShowOverdueDate(): bool
209 {
210 return in_array('OVERDUE_DATE', $this->usedColumns, true);
211 }
212
213 private function isShowStartedDate(): bool
214 {
215 return in_array('WORKFLOW_STARTED', $this->usedColumns, true);
216 }
217
218 private function isShowStatus(): bool
219 {
220 return in_array('WORKFLOW_STATE', $this->usedColumns, true);
221 }
222
223 private function isShowTemplateName(): bool
224 {
225 return in_array('WORKFLOW_TEMPLATE_NAME', $this->usedColumns, true);
226 }
227
228 private function isShowDescription(): bool
229 {
230 return in_array('TASK_DESCRIPTION', $this->usedColumns, true);
231 }
232
233 private function isShowProcessDescription(): bool
234 {
235 return in_array('PROCESS', $this->usedColumns, true);
236 }
237
238 private function isShowModifiedDate(): bool
239 {
240 return in_array('MODIFIED', $this->usedColumns, true);
241 }
242
243 private function isShowFaces(): bool
244 {
245 return (
246 in_array('TASK_PROGRESS', $this->usedColumns, true)
247 || in_array('SUMMARY', $this->usedColumns, true)
248 );
249 }
250
251 private function isShowProcessStatus(): bool
252 {
253 return in_array('TASK', $this->usedColumns, true);
254 }
255}
setModified(?DateTime $modified)
Определения WorkflowUserGridView.php:19
isRunningTaskUser(array $task)
Определения WorkflowUserView.php:438
const Running
Определения constants.php:258
static formatDateTime(?DateTime $date)
Определения viewhelper.php:443
$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
htmlspecialcharsback($str)
Определения tools.php:2693
</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