1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
scripttemplateprovider.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Integration\UI\EntitySelector;
4
5use Bitrix\Bizproc\Workflow\Template\Tpl;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Main\ORM\Query\Filter\ConditionTree;
8use Bitrix\UI\EntitySelector\Dialog;
9use Bitrix\UI\EntitySelector\Tab;
10
12{
13 protected const ENTITY_ID = 'bizproc-script-template';
14 protected const TAB_ID = 'script-templates';
15
16 public function __construct(array $options = [])
17 {
18 parent::__construct($options);
19 $this->options = [];
20 }
21
22 public function fillDialog(Dialog $dialog): void
23 {
24 $this->addTemplatesTab($dialog);
25 $currentUserId = $this->getCurrentUserId();
26
27 $complexDocumentTypes = $this->getComplexDocumentTypes();
28 foreach ($complexDocumentTypes as $documentType)
29 {
30 $moduleId = $documentType[0];
31 if (IsModuleInstalled($moduleId) && $this->canUserStartWorkflow($currentUserId, $documentType))
32 {
33 $documentItem = $this->getDocumentItem($dialog, $documentType);
34 if (!$dialog->getItemCollection()->has($documentItem))
35 {
36 $documentItem->setNodeOptions(['dynamic' => true, 'open' => false]);
37 $dialog->addItem($documentItem);
38 }
39 }
40 }
41
42 if (count($dialog->getItemCollection()->getEntityItems(static::ENTITY_ID)) === 1)
43 {
44 $first = current($dialog->getItemCollection()->getEntityItems(static::ENTITY_ID));
45 $first->setNodeOptions(['dynamic' => true, 'open' => true]);
46 }
47
48 $this->openPreselectedItemTree($dialog);
49 }
50
51 protected function addTemplatesTab(Dialog $dialog): void
52 {
53 $dialog->addTab(new Tab([
54 'id' => self::TAB_ID,
55 'title' => Loc::getMessage('BIZPROC_ENTITY_SELECTOR_TEMPLATES_TAB_SCRIPT_TEMPLATES_TITLE'),
56 'itemOrder' => ['sort' => 'asc nulls last'],
57 'stub' => true,
58 ]));
59 }
60
61 protected function openTemplateTree(Dialog $dialog, Tpl $template): void
62 {
63 $currentUserId = $this->getCurrentUserId();
64
65 $documentItem = $dialog->getItemCollection()->get(
66 static::ENTITY_ID,
67 static::ITEM_DOCUMENT_TYPE_PREFIX . $template->getDocumentType()
68 );
69
70 if ($documentItem)
71 {
72 $documentItem
73 ->setNodeOptions(['open' => true, 'dynamic' => false, 'itemOrder' => ['sort' => 'asc nulls last']])
74 ->setSort(1)
75 ;
76
77 $templateItem = $documentItem->getChildren()->get(static::ENTITY_ID, $template->getId());
78 if (!$templateItem)
79 {
80 $this->fillDocumentItem($dialog, $documentItem, $currentUserId);
81 $templateItem = $documentItem->getChildren()->get(self::ENTITY_ID, $template->getId());
82 }
83
84 $templateItem->setSort(1);
85 }
86 }
87
88 protected function canUserStartWorkflow(int $userId, array $complexDocumentType): bool
89 {
90 // todo: use API \Bitrix\Bizproc\Script\Manager
91
92 return (
93 $this->isUserWorkflowTemplateAdmin($userId)
94 || \CBPDocument::canUserOperateDocumentType(
96 $userId,
97 $complexDocumentType
98 )
99 );
100 }
101
103 {
104 return (
105 \Bitrix\Main\ORM\Query\Query::filter()
106 ->where('ACTIVE', 'Y')
107 ->where('AUTO_EXECUTE', \CBPDocumentEventType::Script)
108 );
109 }
110}
if(isset( $_REQUEST["mode"]) &&$_REQUEST["mode"]=="ajax") if(isset($_REQUEST["mode"]) && $_REQUEST["mode"]=="save_lru" &&check_bitrix_sessid()) $first
Определения access_dialog.php:54
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
canUserStartWorkflow(int $userId, array $complexDocumentType)
Определения scripttemplateprovider.php:88
fillDocumentItem(Dialog $dialog, Item $documentItem, int $currentUserId)
Определения templateprovider.php:257
getDocumentItem(Dialog $dialog, array $complexDocumentType)
Определения templateprovider.php:192
addItem(Item $item)
Определения dialog.php:126
addTab(Tab $tab)
Определения dialog.php:256
getItemCollection()
Определения dialog.php:116
const ViewWorkflow
Определения constants.php:211
const Script
Определения constants.php:158
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$moduleId
IsModuleInstalled($module_id)
Определения tools.php:5301
Определения chain.php:3
</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