1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
taskusertable.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Workflow\Task;
4
5use Bitrix\Main\ArgumentException;
6use Bitrix\Main\DB\SqlQueryException;
7use Bitrix\Main\Entity\DataManager;
8use Bitrix\Main\Entity\DatetimeField;
9use Bitrix\Main\Entity\IntegerField;
10use Bitrix\Main\NotImplementedException;
11use Bitrix\Main\ORM\Data\UpdateResult;
12use Bitrix\Main\ORM\Query\Join;
13use Bitrix\Main\SystemException;
14use Bitrix\Main\Type\DateTime;
15
33{
37 public static function getTableName()
38 {
39 return 'b_bp_task_user';
40 }
41
42 public static function getMap()
43 {
44 return [
45 (new IntegerField('ID'))
46 ->configurePrimary()
47 ->configureAutocomplete()
48 ,
49 (new IntegerField('USER_ID'))
50 ->configureNullable(false)
51 ,
52 (new IntegerField('TASK_ID'))
53 ->configureNullable(false)
54 ,
55 (new IntegerField('STATUS'))
56 ->configureNullable(false)
57 ->configureDefaultValue(0)
58 ,
59 (new DatetimeField('DATE_UPDATE'))
60 ->configureNullable()
61 ,
62 (new IntegerField('ORIGINAL_USER_ID'))
63 ->configureNullable(false)
64 ->configureDefaultValue(0)
65 ,
66 new \Bitrix\Main\ORM\Fields\Relations\Reference(
67 'USER_TASKS',
68 TaskTable::class,
69 Join::on('this.TASK_ID', 'ref.ID')
70 ),
71 (new \Bitrix\Main\ORM\Fields\Relations\Reference(
72 'USER_TASKS_SEARCH_CONTENT',
73 TaskSearchContentTable::class,
74 Join::on('this.TASK_ID', 'ref.TASK_ID')
75 ))
76 ->configureJoinType(Join::TYPE_INNER)
77 ,
78 ];
79 }
80
86 public static function add(array $data)
87 {
88 throw new NotImplementedException('Use CBPTaskService class.');
89 }
90
96 public static function delete($primary)
97 {
98 throw new NotImplementedException('Use CBPTaskService class.');
99 }
100
114 public static function updateStatus(int $taskId, array $userIds, int $status = \CBPTaskUserStatus::Ok): ?UpdateResult
115 {
116 $ids = static::getPrimariesByUniqueKey($taskId, $userIds);
117 if (!$ids)
118 {
119 return null;
120 }
121
122 $update = ['STATUS' => $status, 'DATE_UPDATE' => new DateTime()];
123
124 if (count($ids) > 1)
125 {
126 return static::updateMulti($ids, $update);
127 }
128
129 return static::update($ids[0], $update);
130 }
131
142 public static function delegateTask(int $taskId, int $fromUserId, int $toUserId): ?UpdateResult
143 {
144 $ids = static::getPrimariesByUniqueKey($taskId, [$fromUserId]);
145 if (!$ids)
146 {
147 return null;
148 }
149
150 $originalUserId = static::getOriginalTaskUserId($taskId, $fromUserId) ?? 0;
151 $update = ['USER_ID' => $toUserId];
152 if ($originalUserId <= 0)
153 {
154 $update['ORIGINAL_USER_ID'] = $fromUserId;
155 }
156
157 return static::update($ids[0], $update);
158 }
159
160 public static function getOriginalTaskUserId(int $taskId, int $userId): ?int
161 {
162 $row =
163 static::query()
164 ->setSelect(['ORIGINAL_USER_ID'])
165 ->where('TASK_ID', $taskId)
166 ->where('USER_ID', $userId)
167 ->exec()
168 ->fetch()
169 ;
170 if ($row)
171 {
172 return (int)$row['ORIGINAL_USER_ID'];
173 }
174
175 return null;
176 }
177
178 protected static function getPrimariesByUniqueKey(int $taskId, array $userIds): array
179 {
180 $query =
181 static::query()
182 ->setSelect(['ID'])
183 ->where('TASK_ID', $taskId)
184 ;
185 if (count($userIds) > 1)
186 {
187 $query->whereIn('USER_ID', $userIds);
188 }
189 else
190 {
191 $query->where('USER_ID', $userIds[0] ?? 0);
192 }
193
194 return array_column($query->exec()->fetchAll(), 'ID');
195 }
196}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static delegateTask(int $taskId, int $fromUserId, int $toUserId)
Определения taskusertable.php:142
static getOriginalTaskUserId(int $taskId, int $userId)
Определения taskusertable.php:160
static getPrimariesByUniqueKey(int $taskId, array $userIds)
Определения taskusertable.php:178
static updateStatus(int $taskId, array $userIds, int $status=\CBPTaskUserStatus::Ok)
Определения taskusertable.php:114
static add(array $data)
Определения taskusertable.php:86
const Ok
Определения constants.php:276
$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
$query
Определения get_search.php:11
$status
Определения session.php:10
</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