1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
documentservice.php
См. документацию.
1<?php
2
6
8{
9 const FEATURE_MARK_MODIFIED_FIELDS = 'FEATURE_MARK_MODIFIED_FIELDS';
10 const FEATURE_SET_MODIFIED_BY = 'FEATURE_SET_MODIFIED_BY';
11
12 private $arDocumentsCache = [];
13 private $documentTypesCache = [];
14 private $documentFieldsCache = [];
15 private $typesMapCache = [];
16
17 private $tzFlag;
18
20 {
21 if ($moduleId)
22 {
23 CModule::IncludeModule($moduleId);
24 }
25
26 if (class_exists($entity) && method_exists($entity, 'getEntityName'))
27 {
28 return call_user_func_array(array($entity, "getEntityName"), array($entity));
29 }
30 return null;
31 }
32
33 public function getDocument($parameterDocumentId, $parameterDocumentType = null, array $select = [])
34 {
35 $this->checkCache();
36 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
37
38 $documentType = ($parameterDocumentType && is_array($parameterDocumentType)) ? $parameterDocumentType[2] : null;
40 $selectEnabled = \Bitrix\Main\Config\Option::get('bizproc', 'enable_getdocument_select', $defaultValue) === 'Y';
41
42 $k = $moduleId."@".$entity."@".$documentId.($documentType ? '@'.$documentType : '');
43 if ($selectEnabled && !empty($select))
44 {
45 $k .= '@' . implode('@', $select);
46 }
47
48 if (array_key_exists($k, $this->arDocumentsCache))
49 {
50 return $this->arDocumentsCache[$k];
51 }
52
53 if ($moduleId)
54 {
55 CModule::IncludeModule($moduleId);
56 }
57
58 if (class_exists($entity) && method_exists($entity, 'GetDocument'))
59 {
60 $args = [$documentId, $documentType];
61 if ($selectEnabled)
62 {
63 $args[] = $select;
64 }
65
66 $this->arDocumentsCache[$k] = call_user_func(
67 [$entity, "GetDocument"],
68 ...$args
69 );
70
71 return $this->arDocumentsCache[$k];
72 }
73
74 return null;
75 }
76
77 public function isDocumentExists(array $parameterDocumentId): bool
78 {
79 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
80
81 if ($moduleId)
82 {
83 CModule::IncludeModule($moduleId);
84 }
85
86 if (class_exists($entity) && method_exists($entity, 'isDocumentExists'))
87 {
88 return (bool)call_user_func_array([$entity, 'isDocumentExists'], [$documentId]);
89 }
90
91 //if no API
92 $document = $this->getDocument($parameterDocumentId, select: ['ID']);
93 if ($document instanceof Bizproc\Document\ValueCollection)
94 {
95 return (bool)$document['ID'];
96 }
97
98 return is_array($document) && count($document) > 0;
99 }
100
101 public function getFieldValue($parameterDocumentId, $fieldId, $parameterDocumentType = null, array $usedDocumentFields = [])
102 {
103 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
104 $documentType = ($parameterDocumentType && is_array($parameterDocumentType)) ? $parameterDocumentType[2] : null;
105
106 if ($moduleId)
107 {
108 CModule::IncludeModule($moduleId);
109 }
110 if (class_exists($entity) && method_exists($entity, 'getFieldValue'))
111 {
112 return call_user_func_array([$entity, "getFieldValue"], [$documentId, $fieldId, $documentType]);
113 }
114
115 $document = $this->GetDocument($parameterDocumentId, $parameterDocumentType, $usedDocumentFields);
116
117 return $document[$fieldId] ?? null;
118 }
119
120 public function updateDocument($parameterDocumentId, $arFields, $modifiedBy = null)
121 {
122 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
123
124 $this->clearCache();
125
126 if ($moduleId)
127 {
128 CModule::IncludeModule($moduleId);
129 }
130
131 if (class_exists($entity))
132 {
133 $modifiedById = $modifiedBy ? CBPHelper::ExtractUsers($modifiedBy, $parameterDocumentId, true) : null;
134 return call_user_func_array([$entity, 'UpdateDocument'], [$documentId, $arFields, $modifiedById]);
135 }
136
137 return false;
138 }
139
140 public function createDocument($parameterDocumentId, $arFields)
141 {
142 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
143
144 if ($moduleId)
145 {
146 CModule::IncludeModule($moduleId);
147 }
148
149 if (class_exists($entity))
150 return call_user_func_array(array($entity, "CreateDocument"), array($documentId, $arFields));
151
152 return false;
153 }
154
155 public function createTestDocument(array $parameterDocumentType, array $fields, int $createdById)
156 {
157 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
158
159 if ($moduleId)
160 {
161 CModule::IncludeModule($moduleId);
162 }
163
164 if (class_exists($entity) && method_exists($entity,'createTestDocument'))
165 {
166 return call_user_func_array([$entity, 'createTestDocument'], [$documentType, $fields, $createdById]);
167 }
168
169 return null;
170 }
171
172 public function publishDocument($parameterDocumentId)
173 {
174 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
175
176 $this->clearCache();
177
178 if ($moduleId)
179 {
180 CModule::IncludeModule($moduleId);
181 }
182
183 if (class_exists($entity))
184 {
185 $r = call_user_func_array(array($entity, "PublishDocument"), array($documentId));
186 if ($r)
187 $r = array($moduleId, $entity, $r);
188
189 return $r;
190 }
191
192 return false;
193 }
194
195 public function unpublishDocument($parameterDocumentId)
196 {
197 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
198
199 $this->clearCache();
200
201 if ($moduleId)
202 {
203 CModule::IncludeModule($moduleId);
204 }
205
206 if (class_exists($entity))
207 {
208 return call_user_func_array(array($entity, "UnpublishDocument"), array($documentId));
209 }
210
211 return false;
212 }
213
214 public function lockDocument($parameterDocumentId, $workflowId)
215 {
216 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
217
218 $this->clearCache();
219
220 if ($moduleId)
221 {
222 CModule::IncludeModule($moduleId);
223 }
224
225 if (class_exists($entity))
226 return call_user_func_array(array($entity, "LockDocument"), array($documentId, $workflowId));
227
228 return false;
229 }
230
231 public function unlockDocument($parameterDocumentId, $workflowId)
232 {
233 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
234
235 $this->clearCache();
236
237 if ($moduleId)
238 {
239 CModule::IncludeModule($moduleId);
240 }
241
242 if (class_exists($entity))
243 {
244 return call_user_func_array(array($entity, "UnlockDocument"), array($documentId, $workflowId));
245 }
246
247 return false;
248 }
249
250 public function deleteDocument($parameterDocumentId)
251 {
252 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
253
254 $this->clearCache();
255
256 if ($moduleId)
257 {
258 CModule::IncludeModule($moduleId);
259 }
260
261 if (class_exists($entity))
262 return call_user_func_array(array($entity, "DeleteDocument"), array($documentId));
263
264 return false;
265 }
266
267 public function isDocumentLocked($parameterDocumentId, $workflowId)
268 {
269 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
270
271 if ($moduleId)
272 {
273 CModule::IncludeModule($moduleId);
274 }
275
276 if (class_exists($entity))
277 return call_user_func_array(array($entity, "IsDocumentLocked"), array($documentId, $workflowId));
278
279 return false;
280 }
281
282 public function subscribeOnUnlockDocument($parameterDocumentId, $workflowId, $eventName)
283 {
284 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
285 RegisterModuleDependences($moduleId, $entity."_OnUnlockDocument", "bizproc", "CBPDocumentService", "OnUnlockDocument", 100, "", array($workflowId, $eventName));
286 }
287
288 public function unsubscribeOnUnlockDocument($parameterDocumentId, $workflowId, $eventName)
289 {
290 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
291 UnRegisterModuleDependences($moduleId, $entity."_OnUnlockDocument", "bizproc", "CBPDocumentService", "OnUnlockDocument", "", array($workflowId, $eventName));
292 }
293
294 public static function onUnlockDocument($workflowId, $eventName, $documentId = [])
295 {
296 CBPRuntime::SendExternalEvent($workflowId, $eventName, []);
297 }
298
299 public static function getBizprocEditorUrl($parameterDocumentType): ?string
300 {
301 [$moduleId, $entity, $documentType] = CBPHelper::parseDocumentId($parameterDocumentType);
302
303 if ($moduleId)
304 {
305 try
306 {
308 if (class_exists($entity) && method_exists($entity, "getBizprocEditorUrl"))
309 {
310
311 return call_user_func_array([$entity, "getBizprocEditorUrl"], [$parameterDocumentType]);
312 }
313 }
314 catch (Throwable)
315 {
316 return null;
317 }
318 }
319
320 return null;
321 }
322
323 public function getDocumentType($parameterDocumentId)
324 {
325 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
326
327 $k = $moduleId."@".$entity."@".$documentId;
328 if (isset($this->documentTypesCache[$k]))
329 return $this->documentTypesCache[$k];
330
331 if ($moduleId)
332 {
333 CModule::IncludeModule($moduleId);
334 }
335
336 if (class_exists($entity) && method_exists($entity, "GetDocumentType"))
337 {
338 $this->documentTypesCache[$k] = [$moduleId, $entity, call_user_func_array([$entity, "GetDocumentType"], [$documentId])];
339 return $this->documentTypesCache[$k];
340 }
341
342 return null;
343 }
344
345 public function normalizeDocumentId($parameterDocumentId, string $docType = null)
346 {
347 $normalized = $parameterDocumentId;
348 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
349
350 if ($moduleId)
351 {
352 CModule::IncludeModule($moduleId);
353 }
354
355 if (class_exists($entity) && method_exists($entity, "normalizeDocumentId"))
356 {
357 $normalized = [$moduleId, $entity, call_user_func_array([$entity, "normalizeDocumentId"], [$documentId, $docType])];
358 }
359
360 return $normalized;
361 }
362
363 public function getDocumentFields($parameterDocumentType, $importExportMode = false)
364 {
365 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
366
367 $k = $moduleId."@".$entity."@".$documentType;
368 if (isset($this->documentFieldsCache[$k]))
369 {
370 return $this->documentFieldsCache[$k];
371 }
372
373 if ($moduleId)
374 {
375 CModule::IncludeModule($moduleId);
376 }
377
378 if (class_exists($entity))
379 {
380 $fields = call_user_func_array(array($entity, "GetDocumentFields"), array($documentType, $importExportMode));
381 if (is_array($fields))
382 {
383 foreach ($fields as $key => $prop)
384 {
385 if ($prop["Type"] === 'integer')
386 {
387 $fields[$key]["Type"] = 'int';
388 }
389 if (empty($prop['BaseType']))
390 {
391 $baseTypes = [
392 "int",
393 "double",
394 "date",
395 "datetime",
396 "user",
397 "string",
398 "bool",
399 "file",
400 "text",
401 "select",
402 'time',
403 ];
404
405 $fields[$key]["BaseType"] =
406 in_array($prop["Type"], $baseTypes, true)
407 ? $prop["Type"]
408 : 'string'
409 ;
410 }
411 }
412 }
413
414 $this->documentFieldsCache[$k] = $fields;
415 return $this->documentFieldsCache[$k];
416 }
417
418 return null;
419 }
420
421 public function getDocumentFieldTypes($parameterDocumentType)
422 {
423 [$moduleId, $entity, $documentType] = CBPHelper::parseDocumentId($parameterDocumentType);
424
425 if ($moduleId)
426 {
428 }
429
430 if (class_exists($entity) && method_exists($entity, 'GetDocumentFieldTypes'))
431 {
432 return call_user_func([$entity, 'GetDocumentFieldTypes'], $documentType);
433 }
434
435 return CBPHelper::GetDocumentFieldTypes();
436 }
437
438 public function addDocumentField($parameterDocumentType, $arFields)
439 {
440 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
441
442 if ($moduleId)
443 {
444 CModule::IncludeModule($moduleId);
445 }
446
447 if (class_exists($entity))
448 {
449 $result = call_user_func_array([$entity, 'AddDocumentField'], [$documentType, $arFields]);
450 if ($result)
451 {
452 $k = $moduleId."@".$entity."@".$documentType;
453 unset($this->documentFieldsCache[$k]);
454 }
455
456 return $result;
457 }
458
459 return false;
460 }
461
462 public function updateDocumentField($parameterDocumentType, $arFields)
463 {
464 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
465
466 if ($moduleId)
467 {
468 CModule::IncludeModule($moduleId);
469 }
470
471 if (class_exists($entity) && method_exists($entity, 'UpdateDocumentField'))
472 return call_user_func_array(array($entity, "UpdateDocumentField"), array($documentType, $arFields));
473
474 return false;
475 }
476
477 public function getJSFunctionsForFields($parameterDocumentType, $objectName, $arDocumentFields = array(), $arDocumentFieldTypes = array())
478 {
479 if (!is_array($arDocumentFields) || count($arDocumentFields) <= 0)
480 $arDocumentFields = self::GetDocumentFields($parameterDocumentType);
481 if (!is_array($arDocumentFieldTypes) || count($arDocumentFieldTypes) <= 0)
482 $arDocumentFieldTypes = self::GetDocumentFieldTypes($parameterDocumentType);
483
484 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
485
486 if ($moduleId)
487 {
488 CModule::IncludeModule($moduleId);
489 }
490
491 $documentFieldsString = "";
492 foreach ($arDocumentFields as $fieldKey => $arFieldValue)
493 {
494 if ($documentFieldsString <> '')
495 $documentFieldsString .= ",";
496
497 $documentFieldsString .= "'".Cutil::JSEscape($fieldKey)."':{";
498
499 $documentFieldsString .= "'Name':'".CUtil::JSEscape($arFieldValue["Name"])."',";
500 $documentFieldsString .= "'Type':'".CUtil::JSEscape($arFieldValue["Type"])."',";
501 $documentFieldsString .= "'Multiple':'".CUtil::JSEscape(!empty($arFieldValue["Multiple"]) ? "Y" : "N")."',";
502 $documentFieldsString .= "'Complex':'".CUtil::JSEscape(!empty($arFieldValue["Complex"]) ? "Y" : "N")."',";
503
504 $documentFieldsString .= "'Options':";
505 if (array_key_exists("Options", $arFieldValue))
506 {
507 if (is_array($arFieldValue["Options"]))
508 {
509 $documentFieldsString .= "{";
510 $flTmp = false;
511 foreach ($arFieldValue["Options"] as $k => $v)
512 {
513 if (!is_scalar($v))
514 {
515 continue;
516 }
517
518 if ($flTmp)
519 $documentFieldsString .= ",";
520 $documentFieldsString .= "'".CUtil::JSEscape($k)."':'".CUtil::JSEscape($v)."'";
521 $flTmp = true;
522 }
523 $documentFieldsString .= "}";
524 }
525 else
526 {
527 $documentFieldsString .= "'".CUtil::JSEscape($arFieldValue["Options"])."'";
528 }
529 }
530 else
531 {
532 $documentFieldsString .= "''";
533 }
534
535 if (isset($arFieldValue["Options"]) && CBPHelper::IsAssociativeArray($arFieldValue["Options"]))
536 {
537 $documentFieldsString .= ", 'OptionsSort':";
538 $documentFieldsString .= CUtil::PhpToJSObject(array_keys($arFieldValue["Options"]));
539 }
540
541 if(isset($arFieldValue["Settings"]) && is_array($arFieldValue["Settings"]))
542 {
543 $documentFieldsString .= ", 'Settings':";
544 $documentFieldsString .= CUtil::PhpToJSObject($arFieldValue["Settings"]);
545 }
546
547 $documentFieldsString .= "}";
548 }
549
550 $fieldTypesString = "";
551 $ind = -1;
552 foreach ($arDocumentFieldTypes as $typeKey => $arTypeValue)
553 {
554 $ind++;
555 if ($fieldTypesString <> '')
556 $fieldTypesString .= ",";
557
558 $fieldTypesString .= "'".CUtil::JSEscape($typeKey)."':{";
559
560 $fieldTypesString .= "'Name':'".CUtil::JSEscape($arTypeValue["Name"])."',";
561 $fieldTypesString .= "'BaseType':'".CUtil::JSEscape($arTypeValue["BaseType"])."',";
562 $fieldTypesString .= "'Complex':'".CUtil::JSEscape(!empty($arTypeValue["Complex"]) ? "Y" : "N")."',";
563 $fieldTypesString .= "'Index':".$ind."";
564
565 $fieldTypesString .= "}";
566 }
567
568 $documentTypeString = CUtil::PhpToJSObject($parameterDocumentType);
569 $bitrixSessId = bitrix_sessid();
570
571$result = <<<EOS
572<script>
573var $objectName = {};
574
575$objectName.arDocumentFields = { $documentFieldsString };
576$objectName.arFieldTypes = { $fieldTypesString };
577
578$objectName.AddField = function(fldCode, fldName, fldType, fldMultiple, fldOptions)
579{
580 this.arDocumentFields[fldCode] = {};
581 this.arDocumentFields[fldCode]["Name"] = fldName;
582 this.arDocumentFields[fldCode]["Type"] = fldType;
583 this.arDocumentFields[fldCode]["Multiple"] = fldMultiple;
584 this.arDocumentFields[fldCode]["Options"] = fldOptions;
585}
586
587$objectName._PrepareResponse = function(v)
588{
589 v = v.replace(/^\s+|\s+$/g, '');
590 while (v.length > 0 && v.charCodeAt(0) == 65279)
591 v = v.substring(1);
592
593 if (v.length <= 0)
594 return undefined;
595
596 eval("v = " + v);
597
598 return v;
599}
600
601$objectName.GetFieldInputControl4Type = function(type, value, name, subtypeFunctionName, func)
602{
603 this.GetFieldInputControlInternal(
604 type,
605 value,
606 name,
607 function(v)
608 {
609 var p = v.indexOf('<!--__defaultOptionsValue:');
610 if (p >= 0)
611 {
612 p = p + '<!--__defaultOptionsValue:'.length;
613 var p1 = v.indexOf('-->', p);
614 type['Options'] = v.substring(p, p1);
615 }
616
617 var newPromt = "";
618
619 p = v.indexOf('<!--__modifyOptionsPromt:');
620 if (p >= 0)
621 {
622 p = p + '<!--__modifyOptionsPromt:'.length;
623 p1 = v.indexOf('-->', p);
624 newPromt = v.substring(p, p1);
625 }
626
627 func(v, newPromt);
628 },
629 false,
630 subtypeFunctionName,
631 'Type'
632 );
633}
634
635$objectName.GetFieldInputControl4Subtype = function(type, value, name, func)
636{
637 $objectName.GetFieldInputControlInternal(type, value, name, func, false, '', '');
638}
639
640$objectName.GetFieldInputControl = function(type, value, name, func, als)
641{
642 $objectName.GetFieldInputControlInternal(type, value, name, func, als, '', '');
643}
644
645$objectName.GetFieldInputControlInternal = function(type, value, name, func, als, subtypeFunctionName, mode)
646{
647 if (typeof name == "undefined" || name.length <= 0)
648 name = "BPVDDefaultValue";
649
650 if (typeof type != "object")
651 type = {'Type' : type, 'Multiple' : 0, 'Required' : 0, 'Options' : null};
652
653 if (typeof name != "object")
654 name = {'Field' : name, 'Form' : null};
655
656 BX.ajax.post(
657 '/bitrix/tools/bizproc_get_field.php',
658 {
659 'DocumentType' : $documentTypeString,
660 'Field' : name,
661 'Value' : value,
662 'Type' : type,
663 'Als' : als ? 1 : 0,
664 'rnd' : Math.random(),
665 'Mode' : mode,
666 'Func' : subtypeFunctionName,
667 'sessid' : '$bitrixSessId'
668 },
669 func
670 );
671}
672
673$objectName.GetFieldValueByTagName = function(tag, name, form)
674{
675 var fieldValues = {};
676
677 var ar;
678 if (form && (form.length > 0))
679 {
680 var obj = document.getElementById(form);
681 if (!obj)
682 {
683 for (var i in document.forms)
684 {
685 if (document.forms[i].name == form)
686 {
687 obj = document.forms[i];
688 break;
689 }
690 }
691 }
692
693 if (!obj)
694 return;
695
696 ar = obj.getElementsByTagName(tag);
697 }
698 else
699 {
700 ar = document.getElementsByTagName(tag);
701 }
702
703 for (var i in ar)
704 {
705 if (ar[i] && ar[i].name && (ar[i].name.length >= name.length) && (ar[i].name.substr(0, name.length) == name))
706 {
707 if (ar[i].type.substr(0, "select".length) == "select")
708 {
709 if (ar[i].multiple)
710 {
711 var newName = ar[i].name.replace(/\[\]/g, "");
712 for (var j = 0; j < ar[i].options.length; j++)
713 {
714 if (ar[i].options[j].selected)
715 {
716 if ((typeof(fieldValues[newName]) != 'object') || !(fieldValues[newName] instanceof Array))
717 {
718 if (fieldValues[newName])
719 fieldValues[newName] = [fieldValues[newName]];
720 else
721 fieldValues[newName] = [];
722 }
723 fieldValues[newName][fieldValues[newName].length] = ar[i].options[j].value;
724 }
725 }
726 }
727 else
728 {
729 if (ar[i].selectedIndex >= 0)
730 {
731 const name = ar[i].name;
732 const value = ar[i].options[ar[i].selectedIndex].value;
733
734 if (name.indexOf("[]", 0) >= 0)
735 {
736 const newName = name.replace(/\[\]/g, "");
737 if ((typeof(fieldValues[newName]) !== 'object') || !(fieldValues[newName] instanceof Array))
738 {
739 if (fieldValues[newName])
740 {
741 fieldValues[newName] = [fieldValues[newName]];
742 }
743 else
744 {
745 fieldValues[newName] = [];
746 }
747 }
748
749 fieldValues[newName][fieldValues[newName].length] = value;
750 }
751 else
752 {
753 fieldValues[name] = value;
754 }
755 }
756 }
757 }
758 else
759 {
760 if (ar[i].name.indexOf("[]", 0) >= 0)
761 {
762 var newName = ar[i].name.replace(/\[\]/g, "");
763
764 if ((typeof(fieldValues[newName]) != 'object') || !(fieldValues[newName] instanceof Array))
765 {
766 if (fieldValues[newName])
767 fieldValues[newName] = [fieldValues[newName]];
768 else
769 fieldValues[newName] = [];
770 }
771
772 fieldValues[newName][fieldValues[newName].length] = ar[i].value;
773 }
774 else
775 {
776 fieldValues[ar[i].name] = ar[i].value;
777 }
778 }
779 }
780 }
781
782 return fieldValues;
783}
784
785$objectName.GetFieldInputValue = function(type, name, func)
786{
787 if (typeof name == "undefined" || name.length <= 0)
788 name = "BPVDDefaultValue";
789
790 if (typeof type != "object")
791 type = {'Type' : type, 'Multiple' : 0, 'Required' : 0, 'Options' : null};
792
793 if (typeof name != "object")
794 name = {'Field' : name, 'Form' : null};
795
796 var s = {
797 'DocumentType' : $documentTypeString,
798 'Field' : name,
799 'Type' : type,
800 'rnd' : Math.random(),
801 'sessid' : '$bitrixSessId'
802 };
803
804 if (name['Form'])
805 {
806 var objForm = document.getElementById(name['Form']);
807 if (!objForm)
808 {
809 for (var i in document.forms)
810 {
811 if (document.forms[i].name == name['Form'])
812 {
813 objForm = document.forms[i];
814 break;
815 }
816 }
817 }
818
819 if (objForm)
820 {
821 BX.ajax.prepareForm(objForm, s);
822 }
823 }
824
825 if (type != null && type['Type'] != "F")
826 {
827 var ar = this.GetFieldValueByTagName('input', name['Field'], name['Form']);
828 for (var v in ar)
829 s[v] = ar[v];
830 ar = this.GetFieldValueByTagName('select', name['Field'], name['Form']);
831 for (var v in ar)
832 s[v] = ar[v];
833 ar = this.GetFieldValueByTagName('textarea', name['Field'], name['Form']);
834 for (var v in ar)
835 s[v] = ar[v];
836 ar = this.GetFieldValueByTagName('hidden', name['Field'], name['Form']);
837 for (var v in ar)
838 s[v] = ar[v];
839 }
840
841 BX.ajax.post('/bitrix/tools/bizproc_set_field.php', s, function(v){v = $objectName._PrepareResponse(v); func(v);});
842}
843
844$objectName.HtmlSpecialChars = function(string, quote)
845{
846 string = string.toString();
847 string = string.replace(/&/g, '&amp;');
848 string = string.replace(/</g, '&lt;');
849 string = string.replace(/>/g, '&gt;');
850 string = string.replace(/"/g, '&quot;');
851
852 if (quote)
853 string = string.replace(/'/g, '&#039;');
854
855 return string;
856}
857
858$objectName.GetGUITypeEdit = function(type)
859{
860 return "";
861}
862
863$objectName.SetGUITypeEdit = function(type)
864{
865 return "";
866}
867
868function __dump_bx(arr, limitLevel, txt)
869{
870 if (limitLevel == undefined)
871 limitLevel = 3;
872 if (txt == undefined)
873 txt = "";
874 else
875 txt += ":\\n";
876 alert(txt+__dumpInternal_bx(arr, 0, limitLevel));
877}
878function __dumpInternal_bx(arr, level, limitLevel) {
879 var dumped_text = "";
880 if(!level) level = 0;
881 if (level > limitLevel)
882 return "";
883 var level_padding = "";
884 for(var j=0;j<level+1;j++) level_padding += " ";
885 if(typeof(arr) == 'object') {
886 for(var item in arr) {
887 var value = arr[item];
888 if(typeof(value) == 'object') {
889 dumped_text += level_padding + "'" + item + "' ...\\n";
890 dumped_text += __dumpInternal_bx(value, level+1, limitLevel);
891 } else {
892 dumped_text += level_padding + "'" + item + "' => '" + value + "'\\n";
893 }
894 }
895 } else {
896 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
897 }
898
899 return dumped_text;
900}
901
902</script>
903EOS;
904
905 if (class_exists($entity) && method_exists($entity, "GetJSFunctionsForFields"))
906 {
907 $result .= call_user_func_array(array($entity, "GetJSFunctionsForFields"), array($documentType, $objectName, $arDocumentFields, $arDocumentFieldTypes));
908 }
909 else
910 {
911 if (!is_array($arDocumentFields) || count($arDocumentFields) <= 0)
912 $arDocumentFields = $this->GetDocumentFields($parameterDocumentType);
913 if (!is_array($arDocumentFieldTypes) || count($arDocumentFieldTypes) <= 0)
914 $arDocumentFieldTypes = $this->GetDocumentFieldTypes($parameterDocumentType);
915
916 $result .= CBPHelper::GetJSFunctionsForFields($objectName, $arDocumentFields, $arDocumentFieldTypes);
917 }
918
919 return $result;
920 }
921
922 public function getFieldInputControlOptions($parameterDocumentType, &$fieldType, $jsFunctionName, &$value)
923 {
924 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
925
926 if ($moduleId)
927 {
928 CModule::IncludeModule($moduleId);
929 }
930
931 $arFieldType = FieldType::normalizeProperty($fieldType);
932 if ((string) $arFieldType["Type"] == "")
933 return "";
934
935 $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType);
936 if ($fieldTypeObject)
937 {
938 return $fieldTypeObject->renderControlOptions($jsFunctionName, $value);
939 }
940
941 $fieldType = $arFieldType;
942
943 if (class_exists($entity) && method_exists($entity, "GetFieldInputControlOptions"))
944 return call_user_func_array(array($entity, "GetFieldInputControlOptions"), array($documentType, &$fieldType, $jsFunctionName, &$value));
945
946 return "";
947 }
948
949 public function getFieldInputControl($parameterDocumentType, $fieldType, $fieldName, $fieldValue, $bAllowSelection = false, $publicMode = false)
950 {
951 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
952
953 if ($moduleId)
954 {
955 CModule::IncludeModule($moduleId);
956 }
957
958 $arFieldType = FieldType::normalizeProperty($fieldType);
959 if ((string) $arFieldType["Type"] == "")
960 return "";
961
962 if (is_array($fieldName))
963 {
964 $arFieldName = array(
965 'Form' => null,
966 'Field' => null,
967 );
968 foreach ($fieldName as $key => $val)
969 {
970 switch(mb_strtoupper($key))
971 {
972 case "FORM":
973 case "0":
974 $arFieldName["Form"] = $val;
975 break;
976 case "FIELD":
977 case "1":
978 $arFieldName["Field"] = $val;
979 break;
980 }
981 }
982 }
983 else
984 {
985 $arFieldName = array("Form" => null, "Field" => $fieldName);
986 }
987 if ((string) $arFieldName["Field"] == "" || preg_match("#[^a-z0-9_\[\]]#i", $arFieldName["Field"]))
988 return "";
989 if ((string) $arFieldName["Form"] != "" && preg_match("#[^a-z0-9_]#i", $arFieldName["Form"]))
990 return "";
991
992 if ($publicMode && !array_key_exists("BP_AddShowParameterInit_".$moduleId."_".$entity."_".$documentType, $GLOBALS))
993 {
994 $GLOBALS["BP_AddShowParameterInit_".$moduleId."_".$entity."_".$documentType] = 1;
995 CBPDocument::AddShowParameterInit($moduleId, "only_users", $documentType, $entity);
996 }
997
998 $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType);
999 if ($fieldTypeObject)
1000 {
1001 $renderMode = $publicMode ? FieldType::RENDER_MODE_PUBLIC : FieldType::RENDER_MODE_DESIGNER;
1002 if (defined('ADMIN_SECTION') && ADMIN_SECTION)
1003 {
1004 $renderMode |= FieldType::RENDER_MODE_ADMIN;
1005 $renderMode &= ~FieldType::RENDER_MODE_PUBLIC;
1006 }
1007
1008 if (defined('BX_MOBILE') && BX_MOBILE)
1009 {
1010 $renderMode |= FieldType::RENDER_MODE_MOBILE;
1011 }
1012
1013 if ($renderMode & FieldType::RENDER_MODE_PUBLIC)
1014 {
1015 CUtil::InitJSCore(['bp_field_type']);
1016 }
1017
1018 return $fieldTypeObject->renderControl($arFieldName, $fieldValue, $bAllowSelection, $renderMode);
1019 }
1020
1021 if (class_exists($entity))
1022 {
1023 if (method_exists($entity, "GetFieldInputControl"))
1024 return call_user_func_array(array($entity, "GetFieldInputControl"), array($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection, $publicMode));
1025
1026 if (method_exists($entity, "GetGUIFieldEdit"))
1027 return call_user_func_array(array($entity, "GetGUIFieldEdit"), array($documentType, $arFieldName["Form"], $arFieldName["Field"], $fieldValue, $arFieldType, $bAllowSelection));
1028 }
1029
1030 return CBPHelper::GetFieldInputControl($parameterDocumentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection);
1031 }
1032
1033 public function getFieldInputValue($parameterDocumentType, $fieldType, $fieldName, $arRequest, &$arErrors)
1034 {
1035 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1036
1037 if ($moduleId)
1038 {
1039 CModule::IncludeModule($moduleId);
1040 }
1041
1042 $arFieldType = FieldType::normalizeProperty($fieldType);
1043 if ((string) $arFieldType["Type"] == "")
1044 return "";
1045
1046 if (is_array($fieldName))
1047 {
1048 $arFieldName = array("Form" => null, "Field" => null);
1049 foreach ($fieldName as $key => $val)
1050 {
1051 switch(mb_strtoupper($key))
1052 {
1053 case "FORM":
1054 case "0":
1055 $arFieldName["Form"] = $val;
1056 break;
1057 case "FIELD":
1058 case "1":
1059 $arFieldName["Field"] = $val;
1060 break;
1061 }
1062 }
1063 }
1064 else
1065 {
1066 $arFieldName = array("Form" => null, "Field" => $fieldName);
1067 }
1068 if ((string) $arFieldName["Field"] == "" || preg_match("#[^a-z0-9_\[\]]#i", $arFieldName["Field"]))
1069 return "";
1070 if ((string) $arFieldName["Form"] != "" && preg_match("#[^a-z0-9_]#i", $arFieldName["Form"]))
1071 return "";
1072
1073 $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType);
1074 if ($fieldTypeObject)
1075 {
1076 return $fieldTypeObject->extractValue($arFieldName, $arRequest, $arErrors);
1077 }
1078
1079 if (class_exists($entity))
1080 {
1081 if (method_exists($entity, "GetFieldInputValue"))
1082 return call_user_func_array(array($entity, "GetFieldInputValue"), array($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors));
1083
1084 if (method_exists($entity, "SetGUIFieldEdit"))
1085 return call_user_func_array(array($entity, "SetGUIFieldEdit"), array($documentType, $arFieldName["Field"], $arRequest, &$arErrors, $arFieldType));
1086 }
1087
1088 return CBPHelper::GetFieldInputValue($parameterDocumentType, $arFieldType, $arFieldName, $arRequest, $arErrors);
1089 }
1090
1091 public function getFieldInputValuePrintable($parameterDocumentType, $fieldType, $fieldValue)
1092 {
1093 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1094
1095 if ($moduleId)
1096 {
1097 CModule::IncludeModule($moduleId);
1098 }
1099
1100 $arFieldType = FieldType::normalizeProperty($fieldType);
1101 if ((string) $arFieldType["Type"] == "")
1102 return "";
1103
1104 $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType);
1105 if ($fieldTypeObject)
1106 {
1107 return $fieldTypeObject->formatValue($fieldValue, 'printable');
1108 }
1109
1110 if (class_exists($entity))
1111 {
1112 if (method_exists($entity, "GetFieldInputValuePrintable"))
1113 return call_user_func_array(array($entity, "GetFieldInputValuePrintable"), array($documentType, $arFieldType, $fieldValue));
1114
1115 if (method_exists($entity, "GetFieldValuePrintable"))
1116 return call_user_func_array(array($entity, "GetFieldValuePrintable"), array(null, "", $arFieldType["Type"], $fieldValue, $arFieldType));
1117 }
1118
1119 return CBPHelper::GetFieldInputValuePrintable($parameterDocumentType, $arFieldType, $fieldValue);
1120 }
1121
1122 public function getFieldValuePrintable($parameterDocumentId, $fieldName, $fieldType, $fieldValue, $arFieldType = null)
1123 {
1124 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1125
1126 if ($moduleId)
1127 {
1128 CModule::IncludeModule($moduleId);
1129 }
1130
1131 if (class_exists($entity) && method_exists($entity, "GetFieldValuePrintable"))
1132 return call_user_func_array(array($entity, "GetFieldValuePrintable"), array($documentId, $fieldName, $fieldType, $fieldValue, $arFieldType));
1133
1134 return CBPHelper::GetFieldValuePrintable($fieldName, $fieldType, $fieldValue, $arFieldType);
1135 }
1136
1141 public function getTypesMap(array $parameterDocumentType)
1142 {
1143 $k = implode('@', $parameterDocumentType);
1144
1145 if (isset($this->typesMapCache[$k]))
1146 {
1147 return $this->typesMapCache[$k];
1148 }
1149
1150 $result = FieldType::getBaseTypesMap();
1151
1152 $documentFieldTypes = $this->GetDocumentFieldTypes($parameterDocumentType);
1153 foreach ($documentFieldTypes as $name => $field)
1154 {
1155 if (isset($field['typeClass']))
1156 {
1157 $result[mb_strtolower($name)] = $field['typeClass'];
1158 }
1159 }
1160
1161 $this->typesMapCache[$k] = $result;
1162
1163 return $result;
1164 }
1165
1166 public function getTypesConversionMap(array $parameterDocumentType)
1167 {
1168 $typesMap = $this->getTypesMap($parameterDocumentType);
1169 $typesConversionMap = array();
1170
1172 foreach ($typesMap as $documentTypeName => $typeClass)
1173 {
1174 if (!isset($typesConversionMap[$documentTypeName]))
1175 $typesConversionMap[$documentTypeName] = array();
1176
1177 $typeMap = $typeClass::getConversionMap();
1178 if (!empty($typeMap[0]))
1179 {
1180 $typesConversionMap[$documentTypeName] = array_merge($typesConversionMap[$documentTypeName], $typeMap[0]);
1181 }
1182
1183 if (!empty($typeMap[1]))
1184 {
1185 foreach ($typeMap[1] as $from)
1186 {
1187 if (!isset($typesConversionMap[$from]))
1188 $typesConversionMap[$from] = array();
1189
1190 $typesConversionMap[$from][] = $documentTypeName;
1191 }
1192 }
1193 }
1194
1195 return $typesConversionMap;
1196 }
1197
1203 public function getTypeClass(array $parameterDocumentType, $type)
1204 {
1205 $typeClass = null;
1206 $map = $this->getTypesMap($parameterDocumentType);
1207 $type = mb_strtolower($type);
1208 if (isset($map[$type]))
1209 $typeClass = $map[$type];
1210
1211 return $typeClass;
1212 }
1213
1219 public function getFieldTypeObject(array $parameterDocumentType, array $property)
1220 {
1221 $type = $property['Type'] ?? null;
1222 $typeClass = $this->getTypeClass($parameterDocumentType, $type);
1223 if ($typeClass && class_exists($typeClass))
1224 {
1225 return new FieldType($property, $parameterDocumentType, $typeClass);
1226 }
1227 return null;
1228 }
1229
1241 public function getGUIFieldEdit($parameterDocumentType, $formName, $fieldName, $fieldValue, $arDocumentField = array(), $bAllowSelection = false)
1242 {
1243 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1244
1245 if ($moduleId)
1246 {
1247 CModule::IncludeModule($moduleId);
1248 }
1249
1250 if (!is_array($arDocumentField) || count($arDocumentField) <= 0)
1251 {
1252 $arDocumentFields = $this->GetDocumentFields($parameterDocumentType);
1253 $arDocumentField = $arDocumentFields[$fieldName];
1254 }
1255
1256 if (!array_key_exists("BP_AddShowParameterInit_".$moduleId."_".$entity."_".$documentType, $GLOBALS))
1257 {
1258 $GLOBALS["BP_AddShowParameterInit_".$moduleId."_".$entity."_".$documentType] = 1;
1259 CBPDocument::AddShowParameterInit($moduleId, "only_users", $documentType, $entity);
1260 }
1261
1262 if (class_exists($entity) && method_exists($entity, "GetGUIFieldEdit"))
1263 return call_user_func_array(array($entity, "GetGUIFieldEdit"), array($documentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection));
1264
1265 return CBPHelper::GetGUIFieldEdit($parameterDocumentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection);
1266 }
1267
1278 public function setGUIFieldEdit($parameterDocumentType, $fieldName, $arRequest, &$arErrors, $arDocumentField = array())
1279 {
1280 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1281
1282 if ($moduleId)
1283 {
1284 CModule::IncludeModule($moduleId);
1285 }
1286
1287 if (!is_array($arDocumentField) || count($arDocumentField) <= 0)
1288 {
1289 $arDocumentFields = $this->GetDocumentFields($parameterDocumentType);
1290 $arDocumentField = $arDocumentFields[$fieldName];
1291 }
1292
1293 if (class_exists($entity) && method_exists($entity, "SetGUIFieldEdit"))
1294 return call_user_func_array(array($entity, "SetGUIFieldEdit"), array($documentType, $fieldName, $arRequest, &$arErrors, $arDocumentField));
1295
1296 return CBPHelper::SetGUIFieldEdit($parameterDocumentType, $fieldName, $arRequest, $arErrors, $arDocumentField);
1297 }
1298
1299 public function getDocumentAdminPage($parameterDocumentId)
1300 {
1301 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1302
1303 if ($moduleId)
1304 {
1305 CModule::IncludeModule($moduleId);
1306 }
1307
1308 if (class_exists($entity))
1309 return call_user_func_array(array($entity, "GetDocumentAdminPage"), array($documentId));
1310
1311 return "";
1312 }
1313
1314 public function getDocumentDetailUrl(array $parameterDocumentId, array $options = [])
1315 {
1316 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1317
1318 if ($moduleId)
1319 {
1320 CModule::IncludeModule($moduleId);
1321 }
1322
1323 if (class_exists($entity))
1324 {
1325 if (method_exists($entity, 'getDocumentDetailUrl'))
1326 {
1327 return call_user_func_array(
1328 [$entity, 'getDocumentDetailUrl'],
1329 [[$moduleId, $entity, $documentId], $options]
1330 );
1331 }
1332
1333 if (method_exists($entity, 'GetDocumentAdminPage'))
1334 {
1335 return call_user_func_array([$entity, 'GetDocumentAdminPage'], [$documentId]);
1336 }
1337 }
1338
1339 return '';
1340 }
1341
1342 public function getDocumentName($parameterDocumentId)
1343 {
1344 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1345
1346 if ($moduleId)
1347 {
1348 CModule::IncludeModule($moduleId);
1349 }
1350
1351 if (class_exists($entity) && method_exists($entity, "getDocumentName"))
1352 return call_user_func_array(array($entity, "getDocumentName"), array($documentId));
1353
1354 return "";
1355 }
1356
1357 public function getDocumentCategories($parameterDocumentType)
1358 {
1359 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1360
1361 if ($moduleId)
1362 {
1363 CModule::IncludeModule($moduleId);
1364 }
1365
1366 if (class_exists($entity) && method_exists($entity, 'getDocumentCategories'))
1367 {
1368 return call_user_func_array([$entity, 'getDocumentCategories'], [$documentType]);
1369 }
1370
1371 return null;
1372 }
1373
1374 public function getDocumentCategoryId(array $parameterDocumentId): ?int
1375 {
1376 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1377
1378 if ($moduleId)
1379 {
1380 CModule::IncludeModule($moduleId);
1381 }
1382
1383 if (class_exists($entity) && method_exists($entity, 'getDocumentCategoryId'))
1384 {
1385 return call_user_func_array([$entity, 'getDocumentCategoryId'], [$documentId]);
1386 }
1387
1388 return null;
1389 }
1390
1391 public function getDocumentTypeName($parameterDocumentType)
1392 {
1393 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1394
1395 if ($moduleId)
1396 {
1397 CModule::IncludeModule($moduleId);
1398 }
1399
1400 if (class_exists($entity))
1401 {
1402 if (method_exists($entity, "getDocumentTypeName"))
1403 return call_user_func_array(array($entity, "getDocumentTypeName"), array($documentType));
1404 if (method_exists($entity, "getEntityName"))
1405 return call_user_func_array(array($entity, "getEntityName"), array($entity));
1406 }
1407
1408 return null;
1409 }
1410
1411 public function getDocumentTypeCaption($parameterDocumentType)
1412 {
1413 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1414
1415 if ($moduleId)
1416 {
1417 CModule::IncludeModule($moduleId);
1418 }
1419
1420 if (class_exists($entity))
1421 {
1422 if (method_exists($entity, 'getDocumentTypeCaption'))
1423 {
1424 return call_user_func_array([$entity, 'getDocumentTypeCaption'], [$documentType]);
1425 }
1426 }
1427
1428 return $this->getDocumentTypeName($parameterDocumentType);
1429 }
1430
1431 public function getDocumentIcon($parameterDocumentId)
1432 {
1433 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1434
1435 if ($moduleId)
1436 {
1437 CModule::IncludeModule($moduleId);
1438 }
1439
1440 if (class_exists($entity) && method_exists($entity, 'getDocumentIcon'))
1441 return call_user_func_array(array($entity, 'getDocumentIcon'), array($documentId));
1442
1443 return null;
1444 }
1445
1446 public function getDocumentResponsible(array $parameterDocumentId)
1447 {
1448 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1449
1450 if ($moduleId)
1451 {
1452 CModule::IncludeModule($moduleId);
1453 }
1454
1455 if (class_exists($entity) && method_exists($entity, 'getDocumentResponsible'))
1456 {
1457 return call_user_func_array([$entity, 'getDocumentResponsible'], [$documentId]);
1458 }
1459
1460 return null;
1461
1462 }
1463
1464 public function getDocumentForHistory($parameterDocumentId, $historyIndex)
1465 {
1466 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1467
1468 if ($moduleId)
1469 {
1470 CModule::IncludeModule($moduleId);
1471 }
1472
1473 if (class_exists($entity))
1474 return call_user_func_array(array($entity, "GetDocumentForHistory"), array($documentId, $historyIndex));
1475
1476 return null;
1477 }
1478
1479 public function recoverDocumentFromHistory($parameterDocumentId, $arDocument)
1480 {
1481 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1482
1483 if ($moduleId)
1484 {
1485 CModule::IncludeModule($moduleId);
1486 }
1487
1488 if (class_exists($entity))
1489 return call_user_func_array(array($entity, "RecoverDocumentFromHistory"), array($documentId, $arDocument));
1490
1491 return false;
1492 }
1493
1494 public function getUsersFromUserGroup($group, $parameterDocumentId)
1495 {
1496 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1497
1498 if ($moduleId)
1499 {
1500 CModule::IncludeModule($moduleId);
1501 }
1502
1503 if (class_exists($entity))
1504 return call_user_func_array(array($entity, "GetUsersFromUserGroup"), array($group, $documentId));
1505
1506 return array();
1507 }
1508
1509 public function getAllowableUserGroups($parameterDocumentType, $withExtended = false)
1510 {
1511 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1512
1513 if ($moduleId)
1514 {
1515 CModule::IncludeModule($moduleId);
1516 }
1517
1518 if (class_exists($entity))
1519 {
1520 $result = call_user_func_array(array($entity, "GetAllowableUserGroups"), array($documentType, $withExtended));
1521 $result1 = array();
1522 foreach ($result as $key => $value)
1523 $result1[mb_strtolower($key)] = $value;
1524 return $result1;
1525 }
1526
1527 return array();
1528 }
1529
1530 public function getAllowableOperations($parameterDocumentType)
1531 {
1532 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1533
1534 if ($moduleId)
1535 {
1536 CModule::IncludeModule($moduleId);
1537 }
1538
1539 if (class_exists($entity))
1540 return call_user_func_array(array($entity, "GetAllowableOperations"), array($documentType));
1541
1542 return array();
1543 }
1544
1545 public function setPermissions($parameterDocumentId, $workflowId, $arPermissions, $bRewrite = true)
1546 {
1547 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1548
1549 if ($moduleId)
1550 {
1551 CModule::IncludeModule($moduleId);
1552 }
1553
1554 if (class_exists($entity) && method_exists($entity, "SetPermissions"))
1555 return call_user_func_array(array($entity, "SetPermissions"), array($documentId, $workflowId, $arPermissions, $bRewrite));
1556
1557 return false;
1558 }
1559
1560 public function isFeatureEnabled($parameterDocumentType, $feature)
1561 {
1562 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1563
1564 if ($moduleId)
1565 {
1566 CModule::IncludeModule($moduleId);
1567 }
1568
1569 if (class_exists($entity) && method_exists($entity, 'isFeatureEnabled'))
1570 return call_user_func_array(array($entity, 'isFeatureEnabled'), array($documentType, $feature));
1571
1572 return false;
1573 }
1574
1575 public function isExtendedPermsSupported($parameterDocumentType)
1576 {
1577 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1578
1579 if ($moduleId)
1580 {
1581 CModule::IncludeModule($moduleId);
1582 }
1583
1584 if (class_exists($entity) && method_exists($entity, "isExtendedPermsSupported"))
1585 return call_user_func_array(array($entity, "isExtendedPermsSupported"), array($documentType));
1586
1587 return false;
1588 }
1589
1590 public function toInternalOperations($parameterDocumentType, $permissions)
1591 {
1592 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1593
1594 if ($moduleId)
1595 {
1596 CModule::IncludeModule($moduleId);
1597 }
1598
1599 if (class_exists($entity) && method_exists($entity, "toInternalOperations"))
1600 return call_user_func_array(array($entity, "toInternalOperations"), array($documentType, $permissions));
1601
1602 return $permissions;
1603 }
1604
1605 public function toExternalOperations($parameterDocumentType, $permissions)
1606 {
1607 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1608
1609 if ($moduleId)
1610 {
1611 CModule::IncludeModule($moduleId);
1612 }
1613
1614 if (class_exists($entity) && method_exists($entity, "toExternalOperations"))
1615 return call_user_func_array(array($entity, "toExternalOperations"), array($documentType, $permissions));
1616
1617 return $permissions;
1618 }
1619
1620 public function onTaskChange($parameterDocumentId, $taskId, $taskData, $status)
1621 {
1622 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1623
1624 if ($moduleId)
1625 {
1626 CModule::IncludeModule($moduleId);
1627 }
1628
1629 if (class_exists($entity) && method_exists($entity, "onTaskChange"))
1630 return call_user_func_array(array($entity, "onTaskChange"), array($documentId, $taskId, $taskData, $status));
1631
1632 return false;
1633 }
1634
1635 public function onWorkflowStatusChange($parameterDocumentId, $workflowId, $status, $rootActivity = null)
1636 {
1637 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1638
1639 if (
1640 $rootActivity
1641 && $rootActivity->workflow->isNew()
1642 && $status === CBPWorkflowStatus::Running
1643 )
1644 {
1645 $this->clearCache();
1646 }
1647
1648 if ($moduleId)
1649 {
1650 CModule::IncludeModule($moduleId);
1651 }
1652
1653 if (class_exists($entity) && method_exists($entity, "onWorkflowStatusChange"))
1654 return call_user_func_array(array($entity, "onWorkflowStatusChange"), array($documentId, $workflowId, $status, $rootActivity));
1655
1656 return false;
1657 }
1658
1659 public function onWorkflowCommentAdded($parameterDocumentId, string $workflowId, int $authorId): void
1660 {
1661 $documentId = CBPHelper::parseDocumentId($parameterDocumentId);
1662 [$moduleId, $entity] = $documentId;
1663
1664 if ($moduleId)
1665 {
1666 Loader::includeModule($moduleId);
1667 }
1668
1669 if (class_exists($entity) && method_exists($entity, "onWorkflowCommentAdded"))
1670 {
1671 call_user_func_array([$entity, "onWorkflowCommentAdded"], [$documentId, $workflowId, $authorId]);
1672 }
1673 }
1674
1675 public function onWorkflowCommentDeleted($parameterDocumentId, string $workflowId, int $authorId): void
1676 {
1677 $documentId = CBPHelper::parseDocumentId($parameterDocumentId);
1678 [$moduleId, $entity] = $documentId;
1679
1680 if ($moduleId)
1681 {
1682 Loader::includeModule($moduleId);
1683 }
1684
1685 if (class_exists($entity) && method_exists($entity, "onWorkflowCommentDeleted"))
1686 {
1687 call_user_func_array([$entity, "onWorkflowCommentDeleted"], [$documentId, $workflowId, $authorId]);
1688 }
1689 }
1690
1691 public function onWorkflowAllCommentViewed($parameterDocumentId, string $workflowId, int $authorId): void
1692 {
1693 $documentId = CBPHelper::parseDocumentId($parameterDocumentId);
1694 [$moduleId, $entity] = $documentId;
1695
1696 if ($moduleId)
1697 {
1698 Loader::includeModule($moduleId);
1699 }
1700
1701 if (class_exists($entity) && method_exists($entity, "onWorkflowAllCommentViewed"))
1702 {
1703 call_user_func_array([$entity, "onWorkflowAllCommentViewed"], [$documentId, $workflowId, $authorId]);
1704 }
1705 }
1706
1707 public function onDebugSessionDocumentStatusChanged(array $parameterDocumentId, int $userId, string $status)
1708 {
1709 [$moduleId, $entity, $documentId] = CBPHelper::ParseDocumentId($parameterDocumentId);
1710
1711 if (!\Bitrix\Bizproc\Debugger\Session\DocumentStatus::isStatus($status) || $userId <= 0)
1712 {
1713 return;
1714 }
1715
1716 if ($moduleId)
1717 {
1718 CModule::IncludeModule($moduleId);
1719 }
1720
1721 if (class_exists($entity) && method_exists($entity,'onDebugSessionDocumentStatusChanged'))
1722 {
1723 return call_user_func_array([$entity, 'onDebugSessionDocumentStatusChanged'], [$documentId, $userId, $status]);
1724 }
1725
1726 return;
1727 }
1728
1729 public function createAutomationTarget($parameterDocumentType)
1730 {
1731 [$moduleId, $entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
1732
1733 if ($moduleId)
1734 {
1735 CModule::IncludeModule($moduleId);
1736 }
1737
1738 if (class_exists($entity) && method_exists($entity, "createAutomationTarget"))
1739 {
1741 $target = call_user_func_array([$entity, "createAutomationTarget"], [$documentType]);
1742
1743 return $target;
1744 }
1745
1746 return null;
1747 }
1748
1749 private function clearCache()
1750 {
1751 $this->arDocumentsCache = [];
1752 }
1753
1754 private function checkCache()
1755 {
1756 $state = \CTimeZone::Enabled();
1757 if ($this->tzFlag !== null && $this->tzFlag !== $state)
1758 {
1759 $this->clearCache();
1760 }
1761 $this->tzFlag = $state;
1762 }
1763}
return select
Определения access_edit.php:440
<?endif?> for(var taskID in BXTaskArray) select selectedIndex
Определения access_edit.php:438
<?=$taskID?> selected
Определения access_edit.php:348
if($_SERVER $defaultValue['REQUEST_METHOD']==="GET" &&!empty($RestoreDefaults) && $bizprocPerms==="W" &&check_bitrix_sessid())
Определения options.php:32
static get($moduleId, $name, $default="", $siteId=false)
Определения option.php:30
Определения loader.php:13
static includeModule($moduleName)
Определения loader.php:67
static isModuleInstalled($moduleName)
Определения modulemanager.php:125
getDocumentFieldTypes($parameterDocumentType)
Определения documentservice.php:421
getDocumentTypeName($parameterDocumentType)
Определения documentservice.php:1391
unpublishDocument($parameterDocumentId)
Определения documentservice.php:195
getDocument($parameterDocumentId, $parameterDocumentType=null, array $select=[])
Определения documentservice.php:33
toInternalOperations($parameterDocumentType, $permissions)
Определения documentservice.php:1590
lockDocument($parameterDocumentId, $workflowId)
Определения documentservice.php:214
getFieldValue($parameterDocumentId, $fieldId, $parameterDocumentType=null, array $usedDocumentFields=[])
Определения documentservice.php:101
addDocumentField($parameterDocumentType, $arFields)
Определения documentservice.php:438
onWorkflowStatusChange($parameterDocumentId, $workflowId, $status, $rootActivity=null)
Определения documentservice.php:1635
getJSFunctionsForFields($parameterDocumentType, $objectName, $arDocumentFields=array(), $arDocumentFieldTypes=array())
Определения documentservice.php:477
static onUnlockDocument($workflowId, $eventName, $documentId=[])
Определения documentservice.php:294
createDocument($parameterDocumentId, $arFields)
Определения documentservice.php:140
publishDocument($parameterDocumentId)
Определения documentservice.php:172
onWorkflowCommentDeleted($parameterDocumentId, string $workflowId, int $authorId)
Определения documentservice.php:1675
subscribeOnUnlockDocument($parameterDocumentId, $workflowId, $eventName)
Определения documentservice.php:282
static getBizprocEditorUrl($parameterDocumentType)
Определения documentservice.php:299
getEntityName($moduleId, $entity)
Определения documentservice.php:19
unlockDocument($parameterDocumentId, $workflowId)
Определения documentservice.php:231
getDocumentType($parameterDocumentId)
Определения documentservice.php:323
createTestDocument(array $parameterDocumentType, array $fields, int $createdById)
Определения documentservice.php:155
isExtendedPermsSupported($parameterDocumentType)
Определения documentservice.php:1575
isDocumentExists(array $parameterDocumentId)
Определения documentservice.php:77
unsubscribeOnUnlockDocument($parameterDocumentId, $workflowId, $eventName)
Определения documentservice.php:288
onTaskChange($parameterDocumentId, $taskId, $taskData, $status)
Определения documentservice.php:1620
const FEATURE_MARK_MODIFIED_FIELDS
Определения documentservice.php:9
getDocumentName($parameterDocumentId)
Определения documentservice.php:1342
onWorkflowCommentAdded($parameterDocumentId, string $workflowId, int $authorId)
Определения documentservice.php:1659
getDocumentFields($parameterDocumentType, $importExportMode=false)
Определения documentservice.php:363
onWorkflowAllCommentViewed($parameterDocumentId, string $workflowId, int $authorId)
Определения documentservice.php:1691
normalizeDocumentId($parameterDocumentId, string $docType=null)
Определения documentservice.php:345
toExternalOperations($parameterDocumentType, $permissions)
Определения documentservice.php:1605
isDocumentLocked($parameterDocumentId, $workflowId)
Определения documentservice.php:267
updateDocumentField($parameterDocumentType, $arFields)
Определения documentservice.php:462
deleteDocument($parameterDocumentId)
Определения documentservice.php:250
const FEATURE_SET_MODIFIED_BY
Определения documentservice.php:10
updateDocument($parameterDocumentId, $arFields, $modifiedBy=null)
Определения documentservice.php:120
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$entity
$moduleId
$select
Определения iblock_catalog_list.php:194
bitrix_sessid()
Определения tools.php:4656
RegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $SORT=100, $TO_PATH="", $TO_METHOD_ARG=[])
Определения tools.php:5295
UnRegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $TO_PATH="", $TO_METHOD_ARG=[])
Определения tools.php:5289
Определения collection.php:2
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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
$k
Определения template_pdf.php:567
$fields
Определения yandex_run.php:501