3namespace Bitrix\Bizproc\Controller;
5use Bitrix\Bizproc\FieldType;
6use Bitrix\Bizproc\Script\Entity\ScriptTable;
7use Bitrix\Bizproc\Script\Queue;
8use Bitrix\Bizproc\Script\StartScriptResult;
9use Bitrix\Main\Localization\Loc;
10use Bitrix\Bizproc\Script\Manager;
23 $userId = $this->getCurrentUser()->getId();
24 $documentIds = array_unique($documentIds);
29 'status' => static::START_STATUS_NOT_PERMITTED,
30 'error' => Loc::getMessage(
31 'BIZPROC_CONTROLLER_SCRIPT_ERROR_DOCUMENT_ID_LIMIT',
34 '#SELECTED#' =>
count($documentIds),
44 'status' => static::START_STATUS_NOT_EXISTS,
45 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
48 if (!$script->getActive())
51 'status' => static::START_STATUS_NOT_PERMITTED,
52 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_START_INACTIVE')
59 'status' => static::START_STATUS_NOT_PERMITTED,
60 'error' => Loc::getMessage(
61 'BIZPROC_CONTROLLER_SCRIPT_ERROR_QUEUES_LIMIT',
70 $script->fill(
'WORKFLOW_TEMPLATE');
71 $tpl = $script->getWorkflowTemplate();
75 'status' => static::START_STATUS_NOT_EXISTS,
76 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NO_TEMPLATE')
80 $templateParameters = $tpl->getParameters();
81 if ($templateParameters)
83 $parameters = $this->grabParameters($templateParameters, $parameters);
85 if (empty($parameters))
88 'status' => static::START_STATUS_FILL_PARAMETERS,
89 'parameters' => self::convertTemplateParameters($templateParameters, $tpl->getDocumentComplexType()),
90 'documentType' => $tpl->getDocumentComplexType(),
91 'scriptName' => $script->getName(),
103 'status' => static::START_STATUS_NOT_PERMITTED,
104 'error' =>
$error->getMessage(),
110 'status' => static::START_STATUS_INVALID_PARAMETERS,
111 'error' =>
$error->getMessage(),
116 'error' =>
$error->getMessage(),
121 'status' => static::START_STATUS_QUEUED,
122 'queueId' =>
$result->getData()[
'queueId'],
128 $userId = $this->getCurrentUser()->getId();
134 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
141 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_DELETE_SCRIPT')
149 return [
'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_DELETE_RUNNING_SCRIPT')];
152 return [
'status' =>
'success'];
162 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
166 $userId = $this->getCurrentUser()->getId();
170 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_UPDATE_SCRIPT')
176 return [
'status' =>
'success'];
186 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
190 $userId = $this->getCurrentUser()->getId();
194 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_UPDATE_SCRIPT')
200 return [
'status' =>
'success'];
205 $userId = (int)$this->getCurrentUser()->getId();
211 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
218 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_TERMINATE')
225 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_TERMINATE_FINISHED')
230 return [
'status' =>
'success'];
240 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
247 $stepper->setOuterParams([$queueId, $queue->getScriptId()]);
250 return [
'status' =>
'success',
'finished' => (
$result === $stepper::FINISH_EXECUTION)];
255 $userId = (int)$this->getCurrentUser()->getId();
261 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_NOT_EXISTS')
268 'error' => Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_DELETE_QUEUE')
273 return [
'status' =>
'success'];
276 private static function convertTemplateParameters(
array $parameters,
array $documentType):
array
279 foreach ($parameters as $id => $parameter)
282 $parameter[
'Id'] = $id;
284 if ($parameter[
'Type'] ===
'user')
286 $parameter[
'Default'] = \CBPHelper::UsersArrayToString(
287 $parameter[
'Default'], [], $documentType
296 private function getFileParameters():
array
300 foreach ($this->request->getFileList()->getValues() as
$key => $value)
302 if (array_key_exists(
'name', $value))
304 if (is_array($value[
'name']))
306 $ks = array_keys($value[
"name"]);
310 foreach ($value as $k1 => $v1)
311 $ar[$k1] = $v1[$ks[
$i]];
330 private function grabParameters(
array $templateParameters,
array $parameters):
array
332 $parameters += $this->getFileParameters();
334 foreach (array_keys($templateParameters) as $paramId)
336 if (!array_key_exists($paramId, $parameters) && $this->request->getPost($paramId) !==
null)
338 $parameters[
$paramId] = $this->request->getPost($paramId);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
activateAction(int $scriptId)
const START_STATUS_INVALID_PARAMETERS
terminateQueueAction(int $queueId)
const START_STATUS_NOT_PERMITTED
startAction($scriptId, array $documentIds, array $parameters=[])
const START_STATUS_NO_DOCUMENTS
deleteQueueAction(int $queueId)
const START_STATUS_NOT_EXISTS
const START_STATUS_FILL_PARAMETERS
deactivateAction(int $scriptId)
execQueueAction(int $queueId)
const START_STATUS_QUEUED
static normalizeProperty($property)
static deactivateScript($id)
static getQueueById(int $queueId)
static checkQueuesCount(int $scriptId)
static getDocumentIdLimit()
static checkDocumentIdsLimit(array $documentIds)
static getActiveQueueCountByScriptId(int $scriptId)
static canUserStartScript(int $scriptId, int $userId)
static startScript(int $scriptId, int $userId, array $documentIds, array $parameters=[])
static deleteQueue(int $queueId, int $userId)
static canUserEditScript(int $scriptId, int $userId)
static terminateQueue(int $queueId, int $userId)
static activateScript($id)
const CODE_NOT_ENOUGH_RIGHTS
const CODE_INVALID_PARAMETERS
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key
</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."%"