Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/bizproc/lib/copy/implement/ |
Upload File : |
<?php namespace Bitrix\Bizproc\Copy\Implement; use Bitrix\Main\Error; use Bitrix\Main\Result; class WorkflowTemplate { const WORKFLOW_TEMPLATE_COPY_ERROR = 'WORKFLOW_TEMPLATE_COPY_ERROR'; protected $targetDocumentType = []; protected $mapStatusIdsCopiedDocument = []; protected $result; public function __construct($targetDocumentType = [], $mapStatusIdsCopiedDocument = []) { $this->targetDocumentType = $targetDocumentType; $this->mapStatusIdsCopiedDocument = $mapStatusIdsCopiedDocument; $this->result = new Result(); } public function getFields($workflowTemplateId) { $queryResult = \CBPWorkflowTemplateLoader::getList([], ['ID' => $workflowTemplateId]); return (($fields = $queryResult->fetch()) ? $fields : []); } public function prepareFieldsToCopy(array $fields) { if (isset($fields['ID'])) { unset($fields['ID']); } if ($this->targetDocumentType) { $fields['DOCUMENT_TYPE'] = $this->targetDocumentType; } if (array_key_exists($fields['DOCUMENT_STATUS'], $this->mapStatusIdsCopiedDocument)) { $fields['DOCUMENT_STATUS'] = $this->mapStatusIdsCopiedDocument[$fields['DOCUMENT_STATUS']]; } return $fields; } public function add(array $fields) { $result = false; if ($fields) { $result = \CBPWorkflowTemplateLoader::add($fields, true); } if (!$result) { $this->result->addError( new Error('Failed to copy workflow template', self::WORKFLOW_TEMPLATE_COPY_ERROR) ); } return $result; } }