6if (!CModule::IncludeModule(
"iblock") || !class_exists(
"CIBlockDocument"))
18 if (mb_strpos($documentType,
'type_') !== 0)
21 $id = (int)mb_substr($documentType, 5);
35 static $arDocumentFieldTypes =
array();
36 if (!array_key_exists($documentType, $arDocumentFieldTypes))
41 if (!array_key_exists($arFieldType[
"Type"], $arDocumentFieldTypes[$documentType])
42 || !$arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"Complex"])
47 if ($arFieldType[
"Type"] ==
"E:EList")
52 $valueTmp = intval(current($value));
56 $valueTmp = intval($value);
66 if (
$iblockId <= 0 && intval($arFieldType[
"Options"]) > 0)
67 $iblockId = intval($arFieldType[
"Options"]);
71 $result .=
'<select onchange="'.htmlspecialcharsbx($jsFunctionName).
'(this.options[this.selectedIndex].value)">';
75 $result .=
'<optgroup label="'.$iblockTypeName.
'">';
87 $result .=
'</select><!--__defaultOptionsValue:'.$defaultIBlockId.
'--><!--__modifyOptionsPromt:'.
GetMessage(
"IBD_DOCUMENT_MOPROMT").
'-->';
89 $arFieldType[
"Options"] = $defaultIBlockId;
91 elseif ($arFieldType[
"Type"] ==
"L")
93 $valueTmp = $arFieldType[
"Options"];
94 if (!is_array($valueTmp))
95 $valueTmp =
array($valueTmp => $valueTmp);
98 foreach ($valueTmp as
$k => $v)
100 if (is_array($v) &&
count($v) == 2)
102 $v1 = array_values($v);
108 $str .=
'['.$k.
']'.$v;
114 $result .=
'<textarea id="WFSFormOptionsX" rows="5" cols="30">'.htmlspecialcharsbx(
$str).
'</textarea><br />';
118 function WFSFormOptionsXFunction()
121 var i, id, val, str = document.getElementById("WFSFormOptionsX").value;
123 var arr = str.split(/[\r\n]+/);
124 var p, re = /\[([^\]]+)\].+/;
127 str = arr[i].replace(/^\s+|\s+$/g, \'\');
133 p = str.indexOf(\']\');
135 val = str.substr(p + 1);
149 $result .=
'<input type="button" onclick="'.htmlspecialcharsbx($jsFunctionName).
'(WFSFormOptionsXFunction())" value="'.
GetMessage(
"IBD_DOCUMENT_XFORMOPTIONS3").
'">';
157 $v = mb_substr($documentType, mb_strlen(
"type_"));
158 if (intval($v).
"!" != $v.
"!")
162 static $arDocumentFieldTypes =
array();
163 if (!array_key_exists($documentType, $arDocumentFieldTypes))
166 $arFieldType[
"BaseType"] =
"string";
167 $arFieldType[
"Complex"] =
false;
168 if (array_key_exists($arFieldType[
"Type"], $arDocumentFieldTypes[$documentType]))
170 $arFieldType[
"BaseType"] = $arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"BaseType"];
171 $arFieldType[
"Complex"] = $arDocumentFieldTypes[$documentType][$arFieldType[
"Type"]][
"Complex"];
174 if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::IsAssociativeArray($fieldValue))
175 $fieldValue =
array($fieldValue);
177 $customMethodName =
"";
178 $customMethodNameMulty =
"";
179 if (mb_strpos($arFieldType[
"Type"],
":") !==
false)
181 $ar = CIBlockProperty::GetUserType(mb_substr($arFieldType[
"Type"], 2));
182 if (array_key_exists(
"GetPublicEditHTML",
$ar))
183 $customMethodName =
$ar[
"GetPublicEditHTML"];
184 if (array_key_exists(
"GetPublicEditHTMLMulty",
$ar))
185 $customMethodNameMulty =
$ar[
"GetPublicEditHTMLMulty"];
190 if ($arFieldType[
"Type"] ==
"L")
192 $fieldValueTmp = $fieldValue;
194 <
select id=
"id_<?= htmlspecialcharsbx($arFieldName["Field"]) ?>" name=
"<?= htmlspecialcharsbx($arFieldName["Field"]).($arFieldType["Multiple
"] ? "[]
" : "") ?>"<?= ($arFieldType[
"Multiple"] ?
' size="5" multiple' :
'') ?>>
196 if (!$arFieldType[
"Required"])
197 echo
'<option value="">['.GetMessage(
"BPVDX_NOT_SET").
']</option>';
198 foreach ($arFieldType[
"Options"] as
$k => $v)
200 if (is_array($v) &&
count($v) == 2)
202 $v1 = array_values($v);
207 $ind = array_search(
$k, $fieldValueTmp);
208 echo
'<option value="'.htmlspecialcharsbx(
$k).
'"'.($ind !==
false ?
' selected' :
'').
'>'.
htmlspecialcharsbx($v).
'</option>';
210 unset($fieldValueTmp[$ind]);
215 if ($bAllowSelection)
218 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" value=
"<?
219 if (count($fieldValueTmp) > 0)
221 $a = array_values($fieldValueTmp);
222 echo htmlspecialcharsbx($a[0]);
225 echo CBPHelper::renderControlSelectorButton(
'id_'.$arFieldName[
"Field"].
'_text',
'select');
228 elseif ($arFieldType[
"Type"] ==
"S:UserID")
230 $fieldValue = CBPHelper::UsersArrayToString($fieldValue,
null,
array(
"bizproc",
"CBPVirtualDocument", $documentType));
231 ?><input type=
"text" size=
"40" style=
"max-width: 85%" id=
"id_<?= $arFieldName["Field"] ?>" name=
"<?= $arFieldName["Field"] ?>" value=
"<?= htmlspecialcharsbx($fieldValue) ?>">
232 <? echo CBPHelper::renderControlSelectorButton(
'id_'.$arFieldName[
"Field"],
'user');
234 elseif ((mb_strpos($arFieldType[
"Type"],
":") !==
false)
235 && $arFieldType[
"Multiple"]
237 is_array($customMethodNameMulty) &&
count($customMethodNameMulty) > 0
238 || !is_array($customMethodNameMulty) && $customMethodNameMulty <>
''
242 if (!is_array($fieldValue))
243 $fieldValue =
array();
245 if ($bAllowSelection)
247 $fieldValueTmp1 =
array();
248 $fieldValueTmp2 =
array();
249 foreach ($fieldValue as $v)
253 $fieldValueTmp1[] = $vTrim;
255 $fieldValueTmp2[] = $v;
260 $fieldValueTmp1 =
array();
261 $fieldValueTmp2 = $fieldValue;
264 if (($arFieldType[
"Type"] ==
"S:employee") && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
265 $fieldValueTmp2 = CBPHelper::StripUserPrefix($fieldValueTmp2);
266 if ($arFieldType[
"Type"] ==
"E:EList")
271 $GLOBALS[
"APPLICATION"]->AddHeadScript(
'/bitrix/js/iblock/iblock_edit.js');
277 $fieldValueTmp21 =
array();
278 foreach ($fieldValueTmp2 as
$k => $fld)
280 if ($fld ===
null || $fld ===
"")
282 if (is_array($fld) && isset($fld[
"VALUE"]))
283 $fieldValueTmp21[
$k] = $fld;
285 $fieldValueTmp21[
$k] =
array(
"VALUE" => $fld);
287 $fieldValueTmp2 = $fieldValueTmp21;
289 echo call_user_func_array(
290 $customMethodNameMulty,
292 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
295 "FORM_NAME" => $arFieldName[
"Form"],
302 if ($bAllowSelection)
305 <br /><input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" value=
"<?
306 if (count($fieldValueTmp1) > 0)
308 $a = array_values($fieldValueTmp1);
309 echo htmlspecialcharsbx($a[0]);
312 echo CBPHelper::renderControlSelectorButton(
313 'id_'.$arFieldName[
"Field"].
'_text',
314 $arFieldType[
"BaseType"],
315 array(
'mode' => $arFieldType[
"Type"] ==
'S:employee'?
'employee' :
'')
321 if (!array_key_exists(
"CBPVirtualDocumentCloneRowPrinted_".$documentType,
$GLOBALS) && $arFieldType[
"Multiple"])
323 $GLOBALS[
"CBPVirtualDocumentCloneRowPrinted_".$documentType] = 1;
327 function CBPVirtualDocumentCloneRow(tableID)
329 var tbl = document.getElementById(tableID);
330 var cnt = tbl.rows.length;
331 var oRow = tbl.insertRow(cnt);
332 var oCell = oRow.insertCell(0);
333 var sHTML = tbl.rows[cnt - 1].cells[0].innerHTML;
337 var s = sHTML.indexOf(
'[n', p);
340 var e = sHTML.indexOf(
']', s);
343 var n = parseInt(sHTML.substr(s + 2, e - s));
344 sHTML = sHTML.substr(0, s) +
'[n' + (++n) +
']' + sHTML.substr(e + 1);
350 var s = sHTML.indexOf(
'__n', p);
353 var e = sHTML.indexOf(
'_', s + 2);
356 var n = parseInt(sHTML.substr(s + 3, e - s));
357 sHTML = sHTML.substr(0, s) +
'__n' + (++n) +
'_' + sHTML.substr(e + 1);
360 oCell.innerHTML = sHTML;
361 var patt =
new RegExp(
'<' +
'script' +
'>[^\000]*?<' +
'\/' +
'script' +
'>',
'ig');
362 var code = sHTML.match(patt);
365 for (var i = 0; i < code.length; i++)
369 var s = code[i].substring(8, code[i].length - 9);
370 jsUtils.EvalGlobal(s);
380 if ($arFieldType[
"Multiple"])
381 echo
'<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table">';
383 $fieldValueTmp = $fieldValue;
385 if (
sizeof($fieldValue) == 0)
386 $fieldValue[] =
null;
389 foreach ($fieldValue as
$key => $value)
392 $fieldNameId =
'id_'.htmlspecialcharsbx($arFieldName[
"Field"]).
'__n'.$ind.
'_';
393 $fieldNameName =
htmlspecialcharsbx($arFieldName[
"Field"]).($arFieldType[
"Multiple"] ?
"[n".$ind.
"]" :
"");
395 if ($arFieldType[
"Multiple"])
398 if (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
'')
404 unset($fieldValueTmp[
$key]);
406 if (($arFieldType[
"Type"] ==
"S:employee") && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
407 $value1 = CBPHelper::StripUserPrefix($value1);
409 echo call_user_func_array(
412 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
413 array(
"VALUE" => $value1),
415 "FORM_NAME" => $arFieldName[
"Form"],
416 "VALUE" => $fieldNameName
424 switch ($arFieldType[
"Type"])
427 unset($fieldValueTmp[
$key]);
428 ?><input type=
"text" size=
"10" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
434 ?><input type=
"file" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?
438 if (in_array($value,
array(
"Y",
"N")))
439 unset($fieldValueTmp[
$key]);
441 <
select id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>">
443 if (!$arFieldType[
"Required"])
444 echo
'<option value="">['.GetMessage(
"BPVDX_NOT_SET").
']</option>';
446 <option value=
"Y"<?= (in_array(
"Y", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPVDX_YES") ?></option>
447 <option value=
"N"<?= (in_array(
"N", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPVDX_NO") ?></option>
452 unset($fieldValueTmp[
$key]);
453 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
456 unset($fieldValueTmp[
$key]);
457 ?><input type=
"text" size=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
461 if ($bAllowSelection)
463 if (!in_array($arFieldType[
"Type"],
array(
"F",
"B")) && (is_array($customMethodName) &&
count($customMethodName) <= 0 || !is_array($customMethodName) && $customMethodName ==
''))
465 echo CBPHelper::renderControlSelectorButton($fieldNameId, $arFieldType[
"BaseType"]);
469 if ($arFieldType[
"Multiple"])
473 if ($arFieldType[
"Multiple"])
476 if ($arFieldType[
"Multiple"] && (($arFieldType[
"Type"] !=
"F") ||
$publicMode))
477 echo
'<input type="button" value="'.GetMessage(
"BPVDX_ADD").
'" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.
htmlspecialcharsbx($arFieldName[
"Field"]).
'_Table\')"/><br />';
479 if ($bAllowSelection)
481 if (in_array($arFieldType[
"Type"],
array(
"F",
"B")) || (is_array($customMethodName) &&
count($customMethodName) > 0 || !is_array($customMethodName) && $customMethodName <>
''))
484 <input type=
"text" id=
"id_<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" name=
"<?= htmlspecialcharsbx($arFieldName["Field"]) ?>_text" value=
"<?
485 if (count($fieldValueTmp) > 0)
487 $a = array_values($fieldValueTmp);
488 echo htmlspecialcharsbx($a[0]);
491 echo CBPHelper::renderControlSelectorButton(
492 'id_'.$arFieldName[
"Field"].
'_text',
493 $arFieldType[
"BaseType"],
494 array(
'mode' => $arFieldType[
"Type"] ==
'S:employee'?
'employee' :
'')
500 $s = ob_get_contents();
506 public static function getFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
508 $v = mb_substr($documentType, mb_strlen(
"type_"));
509 if (intval($v).
"!" != $v.
"!")
515 if ($arFieldType[
"Type"] ==
"S:UserID")
517 $value = $arRequest[$arFieldName[
"Field"]];
520 $arErrorsTmp1 =
array();
521 $result = CBPHelper::UsersStringToArray($value,
array(
"bizproc",
"CBPVirtualDocument", $documentType), $arErrorsTmp1);
522 if (
count($arErrorsTmp1) > 0)
524 foreach ($arErrorsTmp1 as $e)
529 elseif (array_key_exists($arFieldName[
"Field"], $arRequest) || array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
532 if (array_key_exists($arFieldName[
"Field"], $arRequest))
534 $arValue = $arRequest[$arFieldName[
"Field"]];
535 if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue))
536 $arValue =
array($arValue);
538 if (array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
539 $arValue[] = $arRequest[$arFieldName[
"Field"].
"_text"];
541 foreach ($arValue as $value)
546 if ($arFieldType[
"Type"] ==
"N")
550 $value = str_replace(
" ",
"", str_replace(
",",
".", $value));
551 if (is_numeric($value))
553 $value = doubleval($value);
559 "code" =>
"ErrorValue",
561 "parameter" => $arFieldName[
"Field"],
570 elseif ($arFieldType[
"Type"] ==
"L")
572 if (!is_array($arFieldType[
"Options"]) ||
count($arFieldType[
"Options"]) <= 0 || $value ==
'')
578 $ar = array_values($arFieldType[
"Options"]);
579 if (is_array(
$ar[0]))
594 "code" =>
"ErrorValue",
596 "parameter" => $arFieldName[
"Field"],
602 if (!array_key_exists($value, $arFieldType[
"Options"]))
606 "code" =>
"ErrorValue",
608 "parameter" => $arFieldName[
"Field"],
614 elseif ($arFieldType[
"Type"] ==
"B")
616 if ($value !==
"Y" && $value !==
"N")
628 $value = mb_strtolower($value);
629 if (in_array($value,
array(
"y",
"yes",
"true",
"1")))
633 elseif (in_array($value,
array(
"n",
"no",
"false",
"0")))
641 "code" =>
"ErrorValue",
643 "parameter" => $arFieldName[
"Field"],
653 elseif ($arFieldType[
"Type"] ==
"F")
655 if (array_key_exists(
"name", $value) && $value[
"name"] <>
'')
657 if (!array_key_exists(
"MODULE_ID", $value))
658 $value[
"MODULE_ID"] =
"bizproc";
660 $value = CFile::SaveFile($value,
"bizproc_wf");
665 "code" =>
"ErrorValue",
667 "parameter" => $arFieldName[
"Field"],
676 elseif (mb_strpos($arFieldType[
"Type"],
":") !==
false)
678 $arCustomType = CIBlockProperty::GetUserType(mb_substr($arFieldType[
"Type"], 2));
679 if (array_key_exists(
"GetLength", $arCustomType))
681 if (call_user_func_array(
682 $arCustomType[
"GetLength"],
684 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
685 array(
"VALUE" => $value)
694 if (!is_array($value) && ($value ==
'') || is_array($value) && (
count($value) == 0 ||
count($value) == 1 && isset($value[
"VALUE"]) && !is_array($value[
"VALUE"]) && $value[
"VALUE"] ==
''))
698 if (($value !==
null) && array_key_exists(
"CheckFields", $arCustomType))
700 $arErrorsTmp1 = call_user_func_array(
701 $arCustomType[
"CheckFields"],
703 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
704 array(
"VALUE" => $value)
707 if (
count($arErrorsTmp1) > 0)
710 foreach ($arErrorsTmp1 as $e)
712 "code" =>
"ErrorValue",
714 "parameter" => $arFieldName[
"Field"],
719 if (($value !==
null)
720 && ($arFieldType[
"Type"] ==
"S:employee")
721 && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
723 $value =
"user_".$value;
728 if (!is_array($value) && $value ==
'')
738 if (!$arFieldType[
"Multiple"])
753 switch ($arFieldType[
'Type'])
756 if (!is_array($fieldValue))
757 $fieldValue =
array($fieldValue);
759 $result = CBPHelper::UsersArrayToString($fieldValue,
null,
array(
"bizproc",
"CBPVirtualDocument", $documentType));
763 if (is_array($fieldValue))
766 foreach ($fieldValue as $r)
776 if (is_array($fieldValue))
779 foreach ($fieldValue as $r)
782 $dbImg = CFile::GetByID($r);
783 if ($arImg = $dbImg->Fetch())
784 $result[] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$r.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
789 $fieldValue = intval($fieldValue);
790 $dbImg = CFile::GetByID($fieldValue);
791 if ($arImg = $dbImg->Fetch())
792 $result =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$fieldValue.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
796 if (is_array($arFieldType[
"Options"]))
798 if (is_array($fieldValue))
801 foreach ($fieldValue as $r)
803 if (array_key_exists($r, $arFieldType[
"Options"]))
804 $result[] = $arFieldType[
"Options"][$r];
809 if (array_key_exists($fieldValue, $arFieldType[
"Options"]))
810 $result = $arFieldType[
"Options"][$fieldValue];
816 if (mb_strpos($arFieldType[
'Type'],
":") !==
false)
818 if ($arFieldType[
"Type"] ==
"S:employee")
819 $fieldValue = CBPHelper::StripUserPrefix($fieldValue);
821 $arCustomType = CIBlockProperty::GetUserType(mb_substr($arFieldType[
'Type'], 2));
822 if (array_key_exists(
"GetPublicViewHTML", $arCustomType))
824 if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue))
826 $checkValue = $arCustomType[
"GetPublicViewHTML"][0] ==
"CIBlockPropertyElementList";
828 foreach ($fieldValue as $value)
830 $v = $checkValue && isset($value[
'VALUE']) ? $value :
array(
'VALUE' => $value);
831 $r = call_user_func_array(
832 $arCustomType[
"GetPublicViewHTML"],
834 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
845 $result = call_user_func_array(
846 $arCustomType[
"GetPublicViewHTML"],
848 array(
"LINK_IBLOCK_ID" => $arFieldType[
"Options"]),
849 array(
"VALUE" => $fieldValue),
864 $documentId = trim($documentId);
865 if ($documentId ==
'')
870 if (array_key_exists(
"UserIsAdmin", $arParameters))
872 if ($arParameters[
"UserIsAdmin"] ===
true)
882 if (!array_key_exists(
"TargetUser", $arParameters) || !array_key_exists(
"DocumentType", $arParameters))
884 $dbElementList = CIBlockElement::GetList(
886 array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y"),
889 array(
"ID",
"IBLOCK_ID",
"CREATED_BY")
891 $arElement = $dbElementList->Fetch();
896 $arParameters[
"TargetUser"] = $arElement[
"CREATED_BY"];
897 $arParameters[
"DocumentType"] =
"type_".$arElement[
"IBLOCK_ID"];
900 if (!array_key_exists(
"AllUserGroups", $arParameters))
902 if (!array_key_exists(
"UserGroups", $arParameters))
903 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
905 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
906 if (
$userId == $arParameters[
"TargetUser"])
907 $arParameters[
"AllUserGroups"][] =
"author";
910 if (!array_key_exists(
"DocumentStates", $arParameters))
912 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
913 array(
"bizproc",
"CBPVirtualDocument", $arParameters[
"DocumentType"]),
914 array(
"bizproc",
"CBPVirtualDocument", $documentId)
918 if (array_key_exists(
"WorkflowId", $arParameters))
920 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
921 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
926 $arAllowableOperations = CBPDocument::GetAllowableOperations(
928 $arParameters[
"AllUserGroups"],
929 $arParameters[
"DocumentStates"]
935 if (!is_array($arAllowableOperations))
936 return in_array(
"author", $arParameters[
"AllUserGroups"]);
942 $r = in_array(
"read", $arAllowableOperations);
945 $r = in_array(
"create", $arAllowableOperations);
951 $r = in_array(
"create", $arAllowableOperations);
954 $r = in_array(
"read", $arAllowableOperations);
965 $documentType = trim($documentType);
966 if ($documentType ==
'')
971 if (array_key_exists(
"UserIsAdmin", $arParameters))
973 if ($arParameters[
"UserIsAdmin"] ===
true)
983 if (!array_key_exists(
"AllUserGroups", $arParameters))
985 if (!array_key_exists(
"UserGroups", $arParameters))
986 $arParameters[
"UserGroups"] = CUser::GetUserGroup(
$userId);
988 $arParameters[
"AllUserGroups"] = $arParameters[
"UserGroups"];
989 $arParameters[
"AllUserGroups"][] =
"author";
992 if (!array_key_exists(
"DocumentStates", $arParameters))
994 $arParameters[
"DocumentStates"] = CBPDocument::GetDocumentStates(
995 array(
"bizproc",
"CBPVirtualDocument", $documentType),
1000 if (array_key_exists(
"WorkflowId", $arParameters))
1002 if (array_key_exists($arParameters[
"WorkflowId"], $arParameters[
"DocumentStates"]))
1003 $arParameters[
"DocumentStates"] =
array($arParameters[
"WorkflowId"] => $arParameters[
"DocumentStates"][$arParameters[
"WorkflowId"]]);
1008 $arAllowableOperations = CBPDocument::GetAllowableOperations(
1010 $arParameters[
"AllUserGroups"],
1011 $arParameters[
"DocumentStates"]
1017 if (!is_array($arAllowableOperations) && $operation != 4)
1020 if ($operation == 4)
1030 $r = in_array(
"create", $arAllowableOperations);
1036 $r = in_array(
"create", $arAllowableOperations);
1053 if (
count($arSelectFields) > 0)
1055 if (!in_array(
"ID", $arSelectFields))
1056 $arSelectFields[] =
"ID";
1057 if (!in_array(
"IBLOCK_ID", $arSelectFields))
1058 $arSelectFields[] =
"IBLOCK_ID";
1059 if (!in_array(
"CREATED_BY", $arSelectFields))
1060 $arSelectFields[] =
"CREATED_BY";
1063 $arResultList =
array();
1067 $dbTasksList = CIBlockElement::GetList(
1074 while (
$obTask = $dbTasksList->GetNextElement())
1079 foreach (
$arFields as $fieldKey => $fieldValue)
1081 if (mb_substr($fieldKey, 0, 1) !=
"~")
1083 $fieldKey = mb_substr($fieldKey, 1);
1086 $arResult[$fieldKey.
"_PRINTABLE"] = $fieldValue;
1088 if (in_array($fieldKey,
array(
"MODIFIED_BY",
"CREATED_BY")))
1090 $arResult[$fieldKey] =
"user_".$fieldValue;
1091 $arResult[$fieldKey.
"_PRINTABLE"] = self::PrepareUserForPrint($fieldValue);
1112 $arResult[
"PROPERTY_".$propertyKey][] =
"user_".$v;
1117 $arResult[
"PROPERTY_".$propertyKey] =
"";
1128 foreach ($vx as $vx1 => $vx2)
1129 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"][$vx1] = $vx2[
"NAME"];
1137 if (!is_array($arPropertyValue))
1139 $arPropertyValue =
array($arPropertyValue);
1140 $arPropertyKey =
array($arPropertyKey);
1143 for (
$i = 0, $cnt =
count($arPropertyValue);
$i < $cnt;
$i++)
1144 $arResult[
"PROPERTY_".$propertyKey][$arPropertyKey[
$i]] = $arPropertyValue[
$i];
1146 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"] =
$arResult[
"PROPERTY_".$propertyKey];
1150 if (array_key_exists(
$arFields[
"ID"], $arIDMap))
1152 foreach ($arResultList[$arIDMap[
$arFields[
"ID"]]] as
$key => &$value)
1156 if (!is_array($value))
1157 $value =
array($value);
1164 $index =
count($arResultList);
1171 $dbTasksList1->InitFromArray($arResultList);
1173 return array($dbTasksList1, $dbTasksList);
1176 private static function prepareUserForPrint($value)
1178 $arReturn =
array();
1181 if (!is_array($valueTmp))
1182 $valueTmp =
array($valueTmp);
1184 if (empty($nameTemplate))
1185 $nameTemplate = COption::GetOptionString(
"bizproc",
"name_template", CSite::GetNameFormat(
false),
SITE_ID);
1187 foreach ($valueTmp as
$val)
1189 $dbUser = CUser::GetByID(
$val);
1190 if ($arUser = $dbUser->fetch())
1192 $formatName = CUser::FormatName($nameTemplate, $arUser,
true,
false);
1193 $arReturn[] = $formatName.
" <".$arUser[
"EMAIL"].
"> [".$arUser[
"ID"].
"]";
1197 return (is_array($value) ? $arReturn : ((
count($arReturn) > 0) ? $arReturn[0] :
""));
1200 private static function prepareSectionForPrint($value,
$iblockId = 0)
1213 if (!is_array($valueTmp))
1215 $valueTmp = [$valueTmp];
1218 foreach ($valueTmp as
$val)
1224 [
'ID',
'NAME',
'XML_ID'],
1227 while ($arSection = $dbSectionsList->fetch())
1229 $ar[$arSection[
"ID"]] = [
"NAME" => $arSection[
"NAME"],
"XML_ID" => $arSection[
"XML_ID"]];
1235 return (is_array($value) ? $arReturn : ($arReturn[0] ?? []));
1246 $documentId = intval($documentId);
1247 if ($documentId <= 0)
1250 $db = CIBlockElement::GetList(
1252 array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y"),
1255 array(
"ID",
"IBLOCK_ID",
"IBLOCK_TYPE_ID")
1257 if (
$ar = $db->Fetch())
1258 return "/bitrix/admin/iblock_element_edit.php?view=Y&ID=".$documentId.
"&IBLOCK_ID=".
$ar[
"IBLOCK_ID"].
"&type=".
$ar[
"IBLOCK_TYPE_ID"];
1265 $args = func_get_args();
1267 $documentId = (int)$documentId;
1268 if ($documentId <= 0)
1276 $select = array_filter(
$select, fn($field) => !str_starts_with($field,
'PROPERTY_'));
1279 if (in_array(
'CREATED_BY',
$select) && !in_array(
'CREATED_USER_NAME',
$select))
1281 $select[] =
'CREATED_USER_NAME';
1283 if (in_array(
'MODIFIED_BY',
$select) && !in_array(
'USER_NAME',
$select))
1290 'CREATED_BY_PRINTABLE' =>
'CREATED_USER_NAME',
1291 'MODIFIED_BY_PRINTABLE' =>
'USER_NAME',
1294 $select = array_map(
static fn($selectField) => $userNameFields[$selectField] ?? $selectField,
$select);
1298 [
'ID' => $documentId,
'SHOW_NEW' =>
'Y'],
1301 if ($objDocument =
$iterator->GetNextElement(
false,
true))
1303 $arDocumentFields = $objDocument->GetFields();
1304 $arDocumentProperties = $objDocument->GetProperties();
1306 foreach ($arDocumentFields as $fieldKey => $fieldValue)
1308 if (mb_substr($fieldKey, 0, 1) ==
"~")
1312 if (in_array($fieldKey,
array(
"MODIFIED_BY",
"CREATED_BY")))
1314 $arResult[$fieldKey] =
"user_".$fieldValue;
1315 $arResult[$fieldKey.
"_PRINTABLE"] = $arDocumentFields[($fieldKey ==
"MODIFIED_BY") ?
"~USER_NAME" :
"~CREATED_USER_NAME"];
1317 elseif (in_array($fieldKey,
array(
"PREVIEW_TEXT",
"DETAIL_TEXT")))
1319 if ($arDocumentFields[$fieldKey.
"_TYPE"] ==
"html")
1324 foreach ($arDocumentProperties as $propertyKey =>
$propertyValue)
1329 ||
$propertyValue[
"USER_TYPE"] ==
"employee" && (COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y"))
1334 if (
$ar = $db->fetch())
1337 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"] =
"(".$ar[
"LOGIN"].
")".((
$ar[
"NAME"] <>
'' ||
$ar[
"LAST_NAME"] <>
'') ?
" " :
"").CUser::FormatName(COption::GetOptionString(
"bizproc",
"name_template", CSite::GetNameFormat(
false),
SITE_ID),
$ar,
false,
false);
1345 if (
$ar = $db->fetch())
1348 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"][
$propertyValue[
"VALUE"][
$i]] =
"(".$ar[
"LOGIN"].
")".((
$ar[
"NAME"] <>
'' ||
$ar[
"LAST_NAME"] <>
'') ?
" " :
"").CUser::FormatName(COption::GetOptionString(
"bizproc",
"name_template", CSite::GetNameFormat(
false),
SITE_ID),
$ar,
false,
false);
1362 if (!is_array($arPropertyValue))
1364 $arPropertyValue =
array($arPropertyValue);
1365 $arPropertyKey =
array($arPropertyKey);
1368 for (
$i = 0, $cnt =
count($arPropertyValue);
$i < $cnt;
$i++)
1369 $arResult[
"PROPERTY_".$propertyKey][$arPropertyKey[
$i]] = $arPropertyValue[
$i];
1378 $arResult[
"PROPERTY_".$propertyKey.
"_PRINTABLE"] =
$ar[
"SRC"];
1405 if (mb_substr($documentId, 0, mb_strlen(
"type_")) ==
"type_")
1408 $documentId = intval($documentId);
1409 if ($documentId <= 0)
1412 $dbResult = CIBlockElement::GetList(
array(),
array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y"),
false,
false,
array(
"ID",
"IBLOCK_ID"));
1415 throw new Exception(
"Element is not found");
1417 return "type_".$arResult[
"IBLOCK_ID"];
1422 $v = mb_substr($documentType, mb_strlen(
"type_"));
1423 if (intval($v).
"!" != $v.
"!")
1433 "Filterable" =>
true,
1434 "Editable" =>
false,
1435 "Required" =>
false,
1437 "TIMESTAMP_X" =>
array(
1438 "Name" =>
GetMessage(
"BPVDX_FIELD_TIMESTAMP_X"),
1439 "Type" =>
"S:DateTime",
1440 "Filterable" =>
true,
1442 "Required" =>
false,
1444 "MODIFIED_BY" =>
array(
1445 "Name" =>
GetMessage(
"BPVDX_FIELD_MODYFIED"),
1446 "Type" =>
"S:UserID",
1447 "Filterable" =>
true,
1449 "Required" =>
false,
1451 "MODIFIED_BY_PRINTABLE" =>
array(
1452 "Name" =>
GetMessage(
"BPVDX_FIELD_MODIFIED_BY_USER_PRINTABLE"),
1454 "Filterable" =>
false,
1455 "Editable" =>
false,
1456 "Required" =>
false,
1458 "DATE_CREATE" =>
array(
1459 "Name" =>
GetMessage(
"BPVDX_FIELD_DATE_CREATE"),
1460 "Type" =>
"S:DateTime",
1461 "Filterable" =>
true,
1463 "Required" =>
false,
1465 "CREATED_BY" =>
array(
1467 "Type" =>
"S:UserID",
1468 "Filterable" =>
true,
1469 "Editable" =>
false,
1470 "Required" =>
false,
1472 "CREATED_BY_PRINTABLE" =>
array(
1473 "Name" =>
GetMessage(
"BPVDX_FIELD_CREATED_BY_USER_PRINTABLE"),
1475 "Filterable" =>
false,
1476 "Editable" =>
false,
1477 "Required" =>
false,
1479 "IBLOCK_ID" =>
array(
1480 "Name" =>
GetMessage(
"BPVDX_FIELD_IBLOCK_ID"),
1482 "Filterable" =>
true,
1484 "Required" =>
false,
1489 "Filterable" =>
true,
1491 "Required" =>
false,
1500 "ACTIVE_FROM" =>
array(
1501 "Name" =>
GetMessage(
"BPVDX_FIELD_DATE_ACTIVE_FROM"),
1502 "Type" =>
"S:DateTime",
1503 "Filterable" =>
true,
1505 "Required" =>
false,
1507 "ACTIVE_TO" =>
array(
1508 "Name" =>
GetMessage(
"BPVDX_FIELD_DATE_ACTIVE_TO"),
1509 "Type" =>
"S:DateTime",
1510 "Filterable" =>
true,
1512 "Required" =>
false,
1517 "Filterable" =>
true,
1519 "Required" =>
false,
1524 "Filterable" =>
true,
1528 "PREVIEW_PICTURE" =>
array(
1529 "Name" =>
GetMessage(
"BPVDX_FIELD_PREVIEW_PICTURE"),
1531 "Filterable" =>
false,
1533 "Required" =>
false,
1535 "PREVIEW_TEXT" =>
array(
1536 "Name" =>
GetMessage(
"BPVDX_FIELD_PREVIEW_TEXT"),
1538 "Filterable" =>
false,
1540 "Required" =>
false,
1542 "PREVIEW_TEXT_TYPE" =>
array(
1543 "Name" =>
GetMessage(
"BPVDX_FIELD_PREVIEW_TEXT_TYPE"),
1546 "text" =>
GetMessage(
"BPVDX_DESC_TYPE_TEXT"),
1549 "Filterable" =>
false,
1551 "Required" =>
false,
1553 "DETAIL_PICTURE" =>
array(
1554 "Name" =>
GetMessage(
"BPVDX_FIELD_DETAIL_PICTURE"),
1556 "Filterable" =>
false,
1558 "Required" =>
false,
1560 "DETAIL_TEXT" =>
array(
1561 "Name" =>
GetMessage(
"BPVDX_FIELD_DETAIL_TEXT"),
1563 "Filterable" =>
false,
1565 "Required" =>
false,
1567 "DETAIL_TEXT_TYPE" =>
array(
1568 "Name" =>
GetMessage(
"BPVDX_FIELD_DETAIL_TEXT_TYPE"),
1571 "text" =>
GetMessage(
"BPVDX_DESC_TYPE_TEXT"),
1574 "Filterable" =>
false,
1576 "Required" =>
false,
1581 "Filterable" =>
true,
1583 "Required" =>
false,
1588 "Filterable" =>
true,
1590 "Required" =>
false,
1595 foreach ($arKeys as
$key)
1598 $dbProperties = CIBlockProperty::GetList(
1599 array(
"sort" =>
"asc",
"name" =>
"asc"),
1602 while ($arProperty = $dbProperties->Fetch())
1604 if (trim($arProperty[
"CODE"]) <>
'')
1605 $key =
"PROPERTY_".$arProperty[
"CODE"];
1607 $key =
"PROPERTY_".$arProperty[
"ID"];
1610 "Name" => $arProperty[
"NAME"],
1611 "Filterable" => ($arProperty[
"FILTRABLE"] ==
"Y"),
1613 "Required" => ($arProperty[
"IS_REQUIRED"] ==
"Y"),
1614 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1615 "Type" => $arProperty[
"PROPERTY_TYPE"],
1618 if ($arProperty[
"USER_TYPE"] <>
'')
1622 if ($arProperty[
"USER_TYPE"] ==
"UserID"
1623 || $arProperty[
"USER_TYPE"] ==
"employee" && (COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y"))
1626 "Name" => $arProperty[
"NAME"].
GetMessage(
"BPVDX_FIELD_USERNAME_PROPERTY"),
1627 "Filterable" =>
false,
1628 "Editable" =>
false,
1629 "Required" =>
false,
1630 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1634 elseif ($arProperty[
"USER_TYPE"] ==
"EList")
1640 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"L")
1643 $dbPropertyEnums = CIBlockProperty::GetPropertyEnum($arProperty[
"ID"]);
1644 while ($arPropertyEnum = $dbPropertyEnums->GetNext())
1645 $arResult[
$key][
"Options"][$arPropertyEnum[
"XML_ID"]] = $arPropertyEnum[
"VALUE"];
1647 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"F")
1650 "Name" => $arProperty[
"NAME"].
GetMessage(
"BPVDX_FIELD_USERNAME_PROPERTY"),
1651 "Filterable" =>
false,
1652 "Editable" =>
false,
1653 "Required" =>
false,
1654 "Multiple" => ($arProperty[
"MULTIPLE"] ==
"Y"),
1658 elseif ($arProperty[
"PROPERTY_TYPE"] ==
"S" && intval($arProperty[
"ROW_COUNT"]) > 1)
1663 foreach ($arKeys as
$k)
1685 foreach (CIBlockProperty::GetUserType() as
$ar)
1687 $t =
$ar[
"PROPERTY_TYPE"].
":".
$ar[
"USER_TYPE"];
1694 if (COption::GetOptionString(
"bizproc",
"SkipNonPublicCustomTypes",
"N") ==
"Y"
1695 && !array_key_exists(
"GetPublicEditHTML",
$ar) && $t !=
"S:UserID" && $t !=
"S:DateTime")
1699 if ($t ==
"S:UserID")
1704 elseif ($t ==
"S:employee" && COption::GetOptionString(
"bizproc",
"employee_compatible_mode",
"N") !=
"Y")
1707 $arResult[$t][
'typeClass'] = BizprocType\UserTypePropertyEmployee::class;
1709 elseif ($t ==
"S:DateTime")
1723 $arResult[$t][
'typeClass'] = BizprocType\UserTypePropertyElist::class;
1727 $arResult[$t][
'typeClass'] = BizprocType\UserTypePropertyHtml::class;
1729 elseif($t ==
'S:DiskFile')
1732 $arResult[$t][
'typeClass'] = BizprocType\UserTypePropertyDiskFile::class;
1738 $arResult[$t][
'typeClass'] = BizprocType\ECrm::class;
1747 $iblockId = intval(mb_substr($documentType, mb_strlen(
"type_")));
1751 if (mb_substr(
$arFields[
"code"], 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
1754 $arFieldsTmp =
array(
1765 if (mb_strpos(
"0123456789", mb_substr($arFieldsTmp[
"CODE"], 0, 1)) !==
false)
1766 unset($arFieldsTmp[
"CODE"]);
1768 if (array_key_exists(
"additional_type_info",
$arFields))
1769 $arFieldsTmp[
"LINK_IBLOCK_ID"] = intval(
$arFields[
"additional_type_info"]);
1771 if (mb_strstr(
$arFields[
"type"],
":") !==
false)
1773 [$arFieldsTmp[
"PROPERTY_TYPE"], $arFieldsTmp[
"USER_TYPE"]] = explode(
":",
$arFields[
"type"], 2);
1775 $arFieldsTmp[
"LINK_IBLOCK_ID"] =
$arFields[
"options"];
1779 $arFieldsTmp[
"PROPERTY_TYPE"] =
$arFields[
"type"];
1780 $arFieldsTmp[
"USER_TYPE"] =
false;
1783 if ($arFieldsTmp[
"PROPERTY_TYPE"] ==
"T")
1785 $arFieldsTmp[
"PROPERTY_TYPE"] =
"S";
1786 $arFieldsTmp[
"ROW_COUNT"] = 5;
1796 $arFieldsTmp[
"VALUES"][] =
array(
"XML_ID" =>
$k,
"VALUE" => $v,
"DEF" =>
"N",
"SORT" =>
$i);
1806 $v = trim(trim($v),
"\r\n");
1808 if (mb_substr($v, 0, 1) ==
"[" && mb_strpos($v,
"]") !==
false)
1810 $v1 = mb_substr($v, 1, mb_strpos($v,
"]") - 1);
1811 $v2 = trim(mb_substr($v, mb_strpos($v,
"]") + 1));
1813 $arFieldsTmp[
"VALUES"][] =
array(
"XML_ID" => $v1,
"VALUE" => $v2,
"DEF" =>
"N",
"SORT" =>
$i);
1820 $propId = $ibp->
Add($arFieldsTmp);
1822 if (intval($propId) <= 0)
1825 return "PROPERTY_".$arFields[
"code"];
1830 $documentId = intval($documentId);
1831 if ($documentId <= 0)
1834 CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
1836 $arFieldsPropertyValues =
array();
1838 $dbResult = CIBlockElement::GetList(
array(),
array(
"ID" => $documentId,
"SHOW_NEW" =>
"Y"),
false,
false,
array(
"ID",
"IBLOCK_ID"));
1841 throw new Exception(
"Element is not found");
1846 foreach ($arKeys as
$key)
1848 if (!array_key_exists(
$key, $arDocumentFields))
1855 foreach ($arFieldsTmp as $value)
1861 if ($arDocumentFields[
$key][
"Type"] ==
"S:UserID")
1866 if (mb_substr($v1, 0, mb_strlen(
"user_")) ==
"user_")
1868 $ar[] = mb_substr($v1, mb_strlen(
"user_"));
1873 foreach ($a1 as $a11)
1880 elseif ($arDocumentFields[
$key][
'Type'] ==
'S:employee')
1884 elseif ($arDocumentFields[
$key][
"Type"] ==
"L")
1886 $realKey = ((mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")? mb_substr(
$key, mb_strlen(
"PROPERTY_")) :
$key);
1889 $db = CIBlockProperty::GetPropertyEnum($realKey,
false,
array(
"IBLOCK_ID" =>
$arResult[
"IBLOCK_ID"]));
1890 while (
$ar = $db->GetNext())
1891 $arV[
$ar[
"XML_ID"]] =
$ar[
"ID"];
1895 if (array_key_exists($value, $arV))
1896 $value = $arV[$value];
1899 elseif ($arDocumentFields[
$key][
"Type"] ==
"F")
1902 $value = CFile::MakeFileArray($value);
1904 elseif ($arDocumentFields[
$key][
"Type"] ==
"S:HTML")
1907 $value =
array(
"VALUE" => $value);
1923 if (mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
1925 $realKey = mb_substr(
$key, mb_strlen(
"PROPERTY_"));
1933 if (
count($arFieldsPropertyValues) > 0)
1934 $iblockElement->SetPropertyValuesEx($documentId,
$arResult[
"IBLOCK_ID"], $arFieldsPropertyValues);
1938 $res = $iblockElement->Update($documentId,
$arFields,
false,
true,
true);
1940 throw new Exception($iblockElement->LAST_ERROR);
1946 if (!array_key_exists(
"IBLOCK_ID",
$arFields) || intval(
$arFields[
"IBLOCK_ID"]) <= 0)
1947 throw new Exception(
"IBlock ID is not found");
1952 $arFieldsPropertyValues = [];
1953 foreach ($arKeys as
$key)
1955 if (!array_key_exists(
$key, $arDocumentFields))
1962 foreach ($arFieldsTmp as $value)
1968 if ($arDocumentFields[
$key][
"Type"] ==
"S:UserID")
1973 if (mb_substr($v1, 0, mb_strlen(
"user_")) ==
"user_")
1975 $ar[] = mb_substr($v1, mb_strlen(
"user_"));
1980 foreach ($a1 as $a11)
1987 elseif ($arDocumentFields[
$key][
"Type"] ==
"L")
1989 $realKey = ((mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")? mb_substr(
$key, mb_strlen(
"PROPERTY_")) :
$key);
1992 $db = CIBlockProperty::GetPropertyEnum($realKey,
false,
array(
"IBLOCK_ID" =>
$arFields[
"IBLOCK_ID"]));
1993 while (
$ar = $db->GetNext())
1994 $arV[
$ar[
"XML_ID"]] =
$ar[
"ID"];
1998 if (array_key_exists($value, $arV))
1999 $value = $arV[$value];
2002 elseif ($arDocumentFields[
$key][
"Type"] ==
"F")
2005 $value = CFile::MakeFileArray($value);
2007 elseif ($arDocumentFields[
$key][
"Type"] ==
"S:HTML")
2010 $value =
array(
"VALUE" => $value);
2026 if (mb_substr(
$key, 0, mb_strlen(
"PROPERTY_")) ==
"PROPERTY_")
2028 $realKey = mb_substr(
$key, mb_strlen(
"PROPERTY_"));
2034 if (
count($arFieldsPropertyValues) > 0)
2035 $arFields[
"PROPERTY_VALUES"] = $arFieldsPropertyValues;
2038 $id = $iblockElement->Add(
$arFields,
false,
true,
true);
2039 if (!$id || $id <= 0)
2040 throw new Exception($iblockElement->LAST_ERROR);
2052 $documentType = trim($documentType);
2053 if ($documentType ==
'')
2056 $iblockId = intval(mb_substr($documentType, mb_strlen(
"type_")));
2069 while ($arGroup = $dbGroupsList->Fetch())
2070 $arResult[$arGroup[
"ID"]] = $arGroup[
"NAME"];
2077 $group = mb_strtolower($group);
2078 if ($group ==
"author")
2080 $documentId = intval($documentId);
2081 if ($documentId <= 0)
2084 $db = CIBlockElement::GetList(
array(),
array(
"ID" => $documentId,
"SHOW_NEW"=>
"Y"),
false,
false,
array(
"ID",
"IBLOCK_ID",
"CREATED_BY"));
2085 if (
$ar = $db->Fetch())
2091 if ((
string)intval($group) !== (
string)$group)
2094 $group = (int)$group;
2100 $dbUsersList = CUser::GetList(
2103 [
'GROUPS_ID' => $group,
'ACTIVE' =>
'Y',
'IS_REAL_USER' =>
true],
2104 [
'FIELDS' => [
'ID']]
2106 while ($arUser = $dbUsersList->Fetch())
2115 $iblockId = intval(mb_substr($documentType, mb_strlen(
"type_")));
2124 <?= $objectName ?>.GetGUIFieldEdit =
function(field, value, showAddButton, inputName)
2126 alert(
"Deprecated method GetGUIFieldEdit used");
2128 if (!this.arDocumentFields[field])
2131 if (typeof showAddButton ==
"undefined")
2132 showAddButton =
false;
2134 if (typeof inputName ==
"undefined")
2137 var type = this.arDocumentFields[field][
"Type"];
2139 var bAddSelection =
false;
2140 var bAddButton =
true;
2145 s +=
'<input type="text" size="10" id="id_' + field +
'" name="' + inputName +
'" value="' + this.HtmlSpecialChars(value) +
'">';
2147 else if (type ==
"L")
2149 s +=
'<select name="' + inputName +
'_1">';
2150 s +=
'<option value=""></option>';
2151 for (k in this.arDocumentFields[field][
"Options"])
2153 s +=
'<option value="' + this.arDocumentFields[field][
"Options"][k][0] +
'"' + (value == this.arDocumentFields[field][
"Options"][k][0] ?
" selected" :
"") +
'>' + this.arDocumentFields[field][
"Options"][k][1] +
'</option>';
2154 if (value == this.arDocumentFields[field][
"Options"][k][0])
2158 bAddSelection =
true;
2160 else if (type ==
"F")
2162 s +=
'<input type="file" id="id_' + field +
'_1" name="' + inputName +
'">';
2163 bAddSelection =
true;
2166 else if (type ==
"B")
2168 s +=
'<select name="' + inputName +
'_1" id="id_' + name +
'">';
2169 s +=
'<option value=""></option>';
2170 s +=
'<option value="Y"' + (value ==
"Y" ?
" selected" :
"") +
'><?= GetMessage("BPVDX_YES") ?></option>';
2171 s +=
'<option value="N"' + (value ==
"N" ?
" selected" :
"") +
'><?= GetMessage("BPVDX_NO") ?></option>';
2173 bAddSelection =
true;
2174 if (value ==
"Y" || value ==
"N")
2177 else if (type ==
"S:DateTime")
2179 s +=
'<span style="white-space:nowrap;">';
2180 s +=
'<input type="text" name="' + inputName +
'" id="id_' + field +
'" size="10" value="' + this.HtmlSpecialChars(value) +
'">';
2181 s +=
'<a href="javascript:void(0);" title="<?= GetMessage("BPVDX_CALENDAR") ?>">';
2182 s +=
'<img src="<?= ADMIN_THEMES_PATH ?>/<?= ADMIN_THEME_ID ?>/images/calendar/icon.gif" alt="<?= GetMessage("BPVDX_CALENDAR") ?>" class="calendar-icon" onclick="jsAdminCalendar.Show(this, \'' + inputName +
'\', \
'\', \
'\',
' + ((type == "datetime") ? 'true' : 'false') + ', <?= time() + date(
"Z") + CTimeZone::GetOffset() ?>);
" onmouseover="this.className+=\
' calendar-icon-hover\';" onmouseout="this.className = this.className.replace(/\s*calendar-icon-hover/ig, \'\');">';
2191 s +=
'<input type="text" size="40" id="id_' + field +
'" name="' + inputName +
'" value="' + this.HtmlSpecialChars(value) +
'">';
2195 s +=
'<br /><input type="text" id="id_' + field +
'" name="' + inputName +
'" value="' + this.HtmlSpecialChars(value) +
'">';
2197 if (bAddButton && showAddButton)
2198 s +=
'<input type="button" value="..." onclick="BPAShowSelector(\'id_' + field +
'\', \
'' + type +
'\');
">';
2203 <?= $objectName ?>.SetGUIFieldEdit = function(field)
2205 alert("Deprecated method SetGUIFieldEdit used
");
2208 <?= $objectName ?>.GetGUIFieldEditSimple = function(type, value, name)
2210 alert("Deprecated method GetGUIFieldEditSimple used
");
2212 if (typeof name == "undefined
" || name.length <= 0)
2213 name = "BPVDDefaultValue
";
2215 if (typeof value == "undefined
")
2219 var obj = document.getElementById('id_' + name);
2223 value = obj.options[obj.selectedIndex].value;
2234 else if (type == "B
")
2236 s += '<select name="' + name + '" id="id_
' + name + '">';
2237 s += '<option value=""></option>';
2238 s += '<option value="Y
"' + (value == "Y
" ? " selected" : "") + '><?= GetMessage("BPVDX_YES
") ?></option>';
2239 s += '<option value="N
"' + (value == "N
" ? " selected" : "") + '><?= GetMessage("BPVDX_NO
") ?></option>';
2242 else if (type == "S:UserID
")
2244 s += '<input type="text
" size="10
" id="id_
' + name + '" name="' + name + '" value="' + this.HtmlSpecialChars(value) + '">';
2245 s += '<input type="button
" value="...
" onclick="BPAShowSelector(\
'id_' + name +
'\', \
'user\')">';
2249 s +=
'<input type="text" size="10" id="id_' + name +
'" name="' + name +
'" value="' + this.HtmlSpecialChars(value) +
'">';
2255 <?= $objectName ?>.SetGUIFieldEditSimple =
function(type, name)
2257 alert(
"Deprecated method SetGUIFieldEditSimple used");
2259 if (typeof name ==
"undefined" || name.length <= 0)
2260 name =
"BPVDDefaultValue";
2265 var obj = document.getElementById(
'id_' + name);
2268 if (obj.type.substr(0,
"select".length) ==
"select")
2269 s = obj.options[obj.selectedIndex].value;
2280 $str = ob_get_contents();
2286 public static function getGUIFieldEdit($documentType, $formName, $fieldName, $fieldValue, $arDocumentField =
null, $bAllowSelection =
false)
2288 return self::GetFieldInputControl(
2291 array(
"Form" => $formName,
"Field" => $fieldName),
2297 public static function setGUIFieldEdit($documentType, $fieldName, $arRequest, &$arErrors, $arDocumentField =
null)
2299 return self::GetFieldInputValue($documentType, $arDocumentField,
array(
"Field" => $fieldName), $arRequest, $arErrors);
2304 $documentType =
null;
2306 if ($fieldType ==
"S:UserID")
2308 static $arCache =
array();
2309 if (!array_key_exists($documentId, $arCache))
2311 if (mb_substr($documentId, 0, mb_strlen(
"type_")) ==
"type_")
2312 $arCache[$documentId] = $documentId;
2314 $arCache[$documentId] = self::GetDocumentType($documentId);
2316 $documentType = $arCache[$documentId];
2319 if (is_null($arFieldType) || !is_array($arFieldType) ||
count($arFieldType) <= 0)
2320 $arFieldType =
array();
2321 $arFieldType[
"Type"] = $fieldType;
2323 return self::GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue);
2326 public static function setPermissions($documentId, $workflowId, $arPermissions, $bRewrite =
true)
2328 $documentId = intval($documentId);
2329 if ($documentId <= 0)
2335 CBPDocument::OnDocumentDelete(
array(
"bizproc",
"CBPVirtualDocument",
$arFields[
"ID"]), $arErrorsTmp);
while($arIBType=$dbIBlockType->Fetch()) $dbIBlock
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static GetListEx($arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
static GetNavChain($IBLOCK_ID, $SECTION_ID, $arSelect=array(), $arrayResult=false)
static GetOptionInt($module_id, $name, $def="", $site=false)
static isExpression($text)
static getDocumentFieldTypes($documentType)
static addDocumentField($documentType, $arFields)
static getDocument($documentId)
static getAllowableUserGroups($documentType, $withExtended=false)
static getFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
static createDocument($parentDocumentId, $arFields)
static setGUIFieldEdit($documentType, $fieldName, $arRequest, &$arErrors, $arDocumentField=null)
static getDocumentTypeName($documentType)
static getUsersFromUserGroup($group, $documentId)
static getGUIFieldEdit($documentType, $formName, $fieldName, $fieldValue, $arDocumentField=null, $bAllowSelection=false)
static setPermissions($documentId, $workflowId, $arPermissions, $bRewrite=true)
static getJSFunctionsForFields($documentType, $objectName, $arDocumentFields=array(), $arDocumentFieldTypes=array())
static getDocumentFields($documentType)
static getList($arOrder=array("SORT"=> "ASC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
static getFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
static getFieldInputControlOptions($documentType, &$arFieldType, $jsFunctionName, &$value)
static getFieldValuePrintable($documentId, $fieldName, $fieldType, $fieldValue, $arFieldType)
static getAllowableOperations($documentType)
static canUserOperateDocumentType($operation, $userId, $documentType, $arParameters=array())
static onAfterIBlockElementDelete($arFields)
static updateDocument($documentId, $arFields)
static getDocumentAdminPage($documentId)
static getDocumentType($documentId)
static getFieldInputControl($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection=false, $publicMode=false)
static canUserOperateDocument($operation, $userId, $documentId, $arParameters=array())
static isExtendedPermsSupported($documentType)
static GetDocumentFieldTypes($documentType)
static GetDocumentFields($documentType)
static GetUsersFromUserGroup($group, $documentId)
static GetIBlockTypes($arTop=false)
</td ></tr ></table ></td ></tr ><?endif?><? $propertyIndex=0;foreach( $arGlobalProperties as $propertyCode=> $propertyValue
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
HTMLToTxt($str, $strSiteUrl="", $aDelete=[], $maxlen=70)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetMessage($name, $aReplace=null)
$GLOBALS['____1690880296']
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
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."%"
if( $site[ 'SERVER_NAME']==='') if($site['SERVER_NAME']==='') $arProperties