3use Bitrix\HumanResources\Compatibility\Utils\DepartmentBackwardAccessCode;
4use Bitrix\HumanResources\Service\Container;
5use Bitrix\HumanResources\Type\MemberEntityType;
6use Bitrix\HumanResources\Type\MemberSubordinateRelationType;
17 private static $serverName;
23 if (self::$cAccess ===
null)
27 return self::$cAccess;
30 private static function usersArrayToStringInternal($arUsers, $arWorkflowTemplate, $arAllowableUserGroups, $appendId =
true)
32 if (is_array($arUsers))
36 $keys = array_keys($arUsers);
37 foreach ($keys as
$key)
39 $r[
$key] = self::UsersArrayToStringInternal($arUsers[
$key], $arWorkflowTemplate, $arAllowableUserGroups, $appendId);
44 $keys = array_keys($r);
45 if ($keys[0] == 0 && $keys[1] == 1 && is_string($r[0]) && is_string($r[1]))
47 if (in_array($r[0],
array(
"Document",
"Template",
"Variable",
"User"))
48 || preg_match(
'#^A\d+_\d+_\d+_\d+$#i', $r[0])
49 || is_array($arWorkflowTemplate) && CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $r[0]) !=
null
52 return '{=' . $r[0] .
':' . $r[1] .
'}';
57 return implode(
", ", $r);
61 if (array_key_exists(mb_strtolower($arUsers), $arAllowableUserGroups))
63 return $arAllowableUserGroups[mb_strtolower($arUsers)];
72 if (mb_substr($arUsers, 0, mb_strlen(
"user_")) ==
"user_")
74 $userId = intval(mb_substr($arUsers, mb_strlen(
"user_")));
84 "NAV_PARAMS" =>
false,
96 if (
$ar = $db->Fetch())
103 return str_replace(
",",
" ",
$str);
106 else if (str_starts_with($arUsers,
'group_'))
108 $str = self::getExtendedGroupName($arUsers, $appendId);
110 return str_replace([
',',
';'], [
' ',
' '],
$str);
113 return str_replace(
",",
" ", $arUsers);
117 public static function usersArrayToString($users, $arWorkflowTemplate, $documentType, $appendId =
true)
119 if (static::isEmptyValue($users))
124 $uniqueUsers = is_array($users) ? [] : $users;
125 if (is_array($users))
127 foreach ($users as
$user)
129 if (is_string(
$user))
135 $uniqueUsers[] =
$user;
139 $uniqueUsers = array_values($uniqueUsers);
142 $arAllowableUserGroups = [];
143 $arAllowableUserGroupsTmp = CBPDocument::GetAllowableUserGroups($documentType);
144 foreach ($arAllowableUserGroupsTmp as $k1 => $v1)
146 $arAllowableUserGroups[mb_strtolower($k1)] = str_replace(
",",
" ", $v1);
149 return self::UsersArrayToStringInternal($uniqueUsers, $arWorkflowTemplate, $arAllowableUserGroups, $appendId);
152 public static function usersStringToArray($strUsers, $documentType, &$arErrors, $callbackFunction =
null)
156 $strUsers = trim($strUsers);
159 return ($callbackFunction !=
null) ? [[], []] : [];
164 return ($callbackFunction !=
null) ? [[$strUsers], []] : [$strUsers];
168 $strUsers = str_replace(
";",
",", $strUsers);
169 $arUsersTmp = explode(
",", $strUsers);
170 foreach ($arUsersTmp as
$user)
179 $arAllowableUserGroups =
null;
183 foreach ($arUsers as
$user)
185 $bCorrectUser =
false;
186 $bNotFoundUser =
true;
189 $bCorrectUser =
true;
194 if ($arAllowableUserGroups ==
null)
196 $arAllowableUserGroups = [];
197 $arAllowableUserGroupsTmp = CBPDocument::GetAllowableUserGroups($documentType);
198 foreach ($arAllowableUserGroupsTmp as $k1 => $v1)
200 $arAllowableUserGroups[mb_strtolower($k1)] = mb_strtolower($v1);
204 if (array_key_exists(mb_strtolower(
$user), $arAllowableUserGroups))
206 $bCorrectUser =
true;
209 elseif (($k1 = array_search(mb_strtolower(
$user), $arAllowableUserGroups)) !==
false)
211 $bCorrectUser =
true;
216 $bCorrectUser =
true;
220 preg_match(
'/^(D|DR)(\d+)$/',
$code, $match)
224 $departmentId = $match[2];
226 Container::getNodeRepository()
228 DepartmentBackwardAccessCode::makeById((
int)$departmentId)
233 $code =
'hr' . ($match[1] ===
'DR' ?
'r' :
'') . $node->id;
241 $ar = self::SearchUserByName(
$user);
245 $bCorrectUser =
true;
250 $bNotFoundUser =
false;
252 'code' =>
'Ambiguous',
253 'message' => str_replace(
260 elseif ($callbackFunction !=
null)
262 $s = call_user_func_array($callbackFunction, [
$user]);
266 $bCorrectUser =
true;
277 'code' =>
'NotFound',
278 'message' => str_replace(
288 return ($callbackFunction !=
null) ? [
$result, $resultAlt] :
$result;
291 private static function searchUserByName(
$user)
308 if (preg_match(
'#\[(\d+)\]#i',
$user, $arMatches))
310 $userId = intval($arMatches[1]);
327 'NAV_PARAMS' =>
false,
335 if (preg_match(
'#\((.+?)\)#i',
$user, $arMatches))
337 $userLogin = $arMatches[1];
338 $user = trim(str_replace(
"(".$userLogin.
")",
"",
$user));
343 if (preg_match(
"#<(.+?)>#i",
$user, $arMatches))
347 $userEmail = $arMatches[1];
348 $user = trim(Str_Replace(
"<".$userEmail.
">",
"",
$user));
353 $arUserTmp = explode(
" ",
$user);
354 foreach ($arUserTmp as $s)
362 if ($userLogin <>
'')
364 $arUser[] = $userLogin;
372 while ($arUsers = $dbUsers->GetNext())
383 $period = intval($period);
385 $days = intval($period / 86400);
386 $period = $period - $days * 86400;
388 $hours = intval($period / 3600);
389 $period = $period -
$hours * 3600;
391 $minutes = intval($period / 60);
392 $period = $period - $minutes * 60;
394 $seconds = intval($period);
400 array(
"#VAL#",
"#UNIT#"),
408 array(
"#VAL#",
"#UNIT#"),
416 array(
"#VAL#",
"#UNIT#"),
424 array(
"#VAL#",
"#UNIT#"),
433 private static function makeWord(
$val, $arWords)
457 if (mb_substr(
$key, 0, 1) ==
"!")
464 if (mb_substr(
$key, 0, 1) ==
"+")
470 if (mb_substr(
$key, 0, 2) ==
">=")
473 $strOperation =
">=";
483 $strOperation =
"<=";
499 $strOperation =
"LIKE";
504 $strOperation =
"QUERY";
511 return array(
"FIELD" =>
$key,
"NEGATIVE" => $strNegative,
"OPERATION" => $strOperation,
"OR_NULL" => $strOrNull);
524 $arOrder = array_change_key_case($arOrder, CASE_UPPER);
526 $arGroupByFunct =
array(
"COUNT",
"AVG",
"MIN",
"MAX",
"SUM");
528 $arAlreadyJoined = [];
531 if (is_array($arGroupBy) &&
count($arGroupBy)>0)
533 $arSelectFields = $arGroupBy;
534 foreach ($arGroupBy as
$key =>
$val)
540 if ($strSqlGroupBy <>
'')
541 $strSqlGroupBy .=
", ";
547 foreach ($toJoin as $join)
549 if (in_array($join, $arAlreadyJoined))
553 if ($strSqlFrom <>
'')
557 $strSqlFrom .= $join;
558 $arAlreadyJoined[] = $join;
569 if (is_array($arGroupBy) &&
count($arGroupBy)==0)
571 $strSqlSelect =
"COUNT(%%_DISTINCT_%% ".$arFields[$arFieldsKeys[0]][
"FIELD"].
") as CNT ";
575 if (isset($arSelectFields) && !is_array($arSelectFields) && is_string($arSelectFields) && $arSelectFields <>
'' && array_key_exists($arSelectFields,
$arFields))
576 $arSelectFields =
array($arSelectFields);
578 if (!isset($arSelectFields)
579 || !is_array($arSelectFields)
580 ||
count($arSelectFields)<=0
581 || in_array(
"*", $arSelectFields))
583 for (
$i = 0, $cnt =
count($arFieldsKeys);
$i < $cnt;
$i++)
585 if (isset(
$arFields[$arFieldsKeys[
$i]][
"WHERE_ONLY"])
586 &&
$arFields[$arFieldsKeys[
$i]][
"WHERE_ONLY"] ==
"Y")
591 if ($strSqlSelect <>
'')
592 $strSqlSelect .=
", ";
594 if (
$arFields[$arFieldsKeys[
$i]][
"TYPE"] ==
"datetime")
596 if (array_key_exists($arFieldsKeys[
$i], $arOrder))
597 $strSqlSelect .=
$arFields[$arFieldsKeys[
$i]][
"FIELD"].
" as ".$arFieldsKeys[
$i].
"_X1, ";
599 $strSqlSelect .=
$DB->DateToCharFunction(
$arFields[$arFieldsKeys[
$i]][
"FIELD"],
"FULL").
" as ".$arFieldsKeys[
$i];
603 if (array_key_exists($arFieldsKeys[
$i], $arOrder))
604 $strSqlSelect .=
$arFields[$arFieldsKeys[
$i]][
"FIELD"].
" as ".$arFieldsKeys[
$i].
"_X1, ";
606 $strSqlSelect .=
$DB->DateToCharFunction(
$arFields[$arFieldsKeys[
$i]][
"FIELD"],
"SHORT").
" as ".$arFieldsKeys[
$i];
609 $strSqlSelect .=
$arFields[$arFieldsKeys[
$i]][
"FIELD"].
" as ".$arFieldsKeys[
$i];
614 foreach ($toJoin as $join)
616 if (in_array($join, $arAlreadyJoined))
618 if ($strSqlFrom <>
'')
620 $strSqlFrom .= $join;
621 $arAlreadyJoined[] = $join;
628 foreach ($arOrder as $by =>
$order)
632 && !in_array($by, $arSelectFields)
635 $arSelectFields[] = $by;
638 foreach ($arSelectFields as
$key =>
$val)
644 if ($strSqlSelect <>
'')
645 $strSqlSelect .=
", ";
647 if (in_array(
$key, $arGroupByFunct))
655 if (array_key_exists(
$val, $arOrder))
662 if (array_key_exists(
$val, $arOrder))
673 foreach ($toJoin as $join)
675 if (in_array($join, $arAlreadyJoined))
677 if ($strSqlFrom <>
'')
679 $strSqlFrom .= $join;
680 $arAlreadyJoined[] = $join;
687 if ($strSqlGroupBy <>
'')
689 if ($strSqlSelect <>
'')
690 $strSqlSelect .=
", ";
691 $strSqlSelect .=
"COUNT(%%_DISTINCT_%% ".$arFields[$arFieldsKeys[0]][
"FIELD"].
") as CNT";
694 $strSqlSelect =
"%%_DISTINCT_%% ".$strSqlSelect;
706 for (
$i = 0, $cnt =
count($filter_keys);
$i < $cnt;
$i++)
709 if (!is_array($vals))
710 $vals =
array($vals);
713 $key_res = CBPHelper::GetFilterOperation(
$key);
714 $key = $key_res[
"FIELD"];
715 $strNegative = $key_res[
"NEGATIVE"];
716 $strOperation = $key_res[
"OPERATION"];
717 $strOrNull = $key_res[
"OR_NULL"];
721 $arSqlSearch_tmp =
array();
722 for ($j = 0, $cntj =
count($vals); $j < $cntj; $j++)
728 $arSqlSearch_tmp1 = call_user_func_array(
732 if ($arSqlSearch_tmp1 !==
false)
733 $arSqlSearch_tmp[] = $arSqlSearch_tmp1;
739 if ((intval(
$val) == 0) && (mb_strpos($strOperation,
"=") !== False))
740 $arSqlSearch_tmp[] =
"(".$arFields[
$key][
"FIELD"].
" IS ".(($strNegative ==
"Y") ?
"NOT " :
"").
"NULL) ".(($strNegative ==
"Y") ?
"AND" :
"OR").
" ".(($strNegative ==
"Y") ?
"NOT " :
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" 0)";
742 $arSqlSearch_tmp[] = (($strNegative ==
"Y") ?
" ".$arFields[
$key][
"FIELD"].
" IS NULL OR NOT " :
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" ".intval(
$val).
" )";
748 if ((DoubleVal(
$val) == 0) && (mb_strpos($strOperation,
"=") !== False))
749 $arSqlSearch_tmp[] =
"(".$arFields[
$key][
"FIELD"].
" IS ".(($strNegative ==
"Y") ?
"NOT " :
"").
"NULL) ".(($strNegative ==
"Y") ?
"AND" :
"OR").
" ".(($strNegative ==
"Y") ?
"NOT " :
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" 0)";
751 $arSqlSearch_tmp[] = (($strNegative ==
"Y") ?
" ".$arFields[
$key][
"FIELD"].
" IS NULL OR NOT " :
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" ".DoubleVal(
$val).
" )";
755 if ($strOperation ==
"QUERY")
761 if ((
$val ==
'') && (mb_strpos($strOperation,
"=") !== False))
762 $arSqlSearch_tmp[] =
"(".$arFields[
$key][
"FIELD"].
" IS ".(($strNegative ==
"Y") ?
"NOT " :
"").
"NULL) ".(($strNegative ==
"Y") ?
"AND NOT" :
"OR").
" (".
$DB->Length(
$arFields[
$key][
"FIELD"]).
" <= 0) ".(($strNegative ==
"Y") ?
"AND NOT" :
"OR").
" (".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" '".
$DB->ForSql(
$val).
"' )";
764 $arSqlSearch_tmp[] = (($strNegative ==
"Y") ?
" ".$arFields[
$key][
"FIELD"].
" IS NULL OR NOT " :
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" '".
$DB->ForSql(
$val).
"' )";
770 $arSqlSearch_tmp[] = ($strNegative==
"Y"?
"NOT":
"").
"(".
$arFields[
$key][
"FIELD"].
" IS NULL)";
772 $arSqlSearch_tmp[] = ($strNegative==
"Y"?
" ".$arFields[
$key][
"FIELD"].
" IS NULL OR NOT ":
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" ".
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"FULL").
")";
777 $arSqlSearch_tmp[] = ($strNegative==
"Y"?
"NOT":
"").
"(".
$arFields[
$key][
"FIELD"].
" IS NULL)";
779 $arSqlSearch_tmp[] = ($strNegative==
"Y"?
" ".$arFields[
$key][
"FIELD"].
" IS NULL OR NOT ":
"").
"(".
$arFields[
$key][
"FIELD"].
" ".$strOperation.
" ".
$DB->CharToDateFunction(
$DB->ForSql(
$val),
"SHORT").
")";
787 foreach ($toJoin as $join)
789 if (in_array($join, $arAlreadyJoined))
791 if ($strSqlFrom <>
'')
793 $strSqlFrom .= $join;
794 $arAlreadyJoined[] = $join;
798 $strSqlSearch_tmp =
"";
799 for ($j = 0, $cntj =
count($arSqlSearch_tmp); $j < $cntj; $j++)
802 $strSqlSearch_tmp .= ($strNegative==
"Y" ?
" AND " :
" OR ");
803 $strSqlSearch_tmp .=
"(".$arSqlSearch_tmp[$j].
")";
805 if ($strOrNull ==
"Y")
807 if ($strSqlSearch_tmp <>
'')
808 $strSqlSearch_tmp .= ($strNegative==
"Y" ?
" AND " :
" OR ");
809 $strSqlSearch_tmp .=
"(".$arFields[
$key][
"FIELD"].
" IS ".($strNegative==
"Y" ?
"NOT " :
"").
"NULL)";
811 if ($strSqlSearch_tmp <>
'')
812 $strSqlSearch_tmp .= ($strNegative==
"Y" ?
" AND " :
" OR ");
814 $strSqlSearch_tmp .=
"(".$arFields[
$key][
"FIELD"].
" ".($strNegative==
"Y" ?
"<>" :
"=").
" 0)";
816 $strSqlSearch_tmp .=
"(".$arFields[
$key][
"FIELD"].
" ".($strNegative==
"Y" ?
"<>" :
"=").
" '')";
819 if ($strSqlSearch_tmp !=
"")
820 $arSqlSearch[] =
"(".$strSqlSearch_tmp.
")";
824 for (
$i = 0, $cnt =
count($arSqlSearch);
$i < $cnt;
$i++)
826 if ($strSqlWhere <>
'')
827 $strSqlWhere .=
" AND ";
828 $strSqlWhere .=
"(".$arSqlSearch[
$i].
")";
833 $arSqlOrder = Array();
834 foreach ($arOrder as $by =>
$order)
836 $by = mb_strtoupper($by);
847 $arSqlOrder[] =
" ".$by.
"_X1 ".
$order.
" ";
849 $arSqlOrder[] =
" ".$arFields[$by][
"FIELD"].
" ".
$order.
" ";
854 foreach ($toJoin as $join)
856 if (in_array($join, $arAlreadyJoined))
858 if ($strSqlFrom <>
'')
860 $strSqlFrom .= $join;
861 $arAlreadyJoined[] = $join;
869 for (
$i = 0, $cnt =
count($arSqlOrder);
$i < $cnt;
$i++)
871 if ($strSqlOrderBy <>
'')
872 $strSqlOrderBy .=
", ";
874 $strSqlOrderBy .= $arSqlOrder[
$i];
879 "SELECT" => $strSqlSelect,
880 "FROM" => $strSqlFrom,
881 "WHERE" => $strSqlWhere,
882 "GROUPBY" => $strSqlGroupBy,
883 "ORDERBY" => $strSqlOrderBy,
889 if (!is_array($parameterDocumentId))
891 $parameterDocumentId =
array($parameterDocumentId);
898 $cnt =
count($parameterDocumentId);
901 $documentId = $parameterDocumentId[2];
902 $entity = $parameterDocumentId[1];
907 $documentId = $parameterDocumentId[1];
908 $entity = $parameterDocumentId[0];
913 $documentId = is_scalar($documentId) ? trim($documentId) :
'';
915 if ($documentId ===
'')
935 if (!is_array($parameterDocumentId))
937 $parameterDocumentId =
array($parameterDocumentId);
944 $cnt =
count($parameterDocumentId);
947 $documentId = $parameterDocumentId[2];
948 $entity = $parameterDocumentId[1];
953 $documentId = $parameterDocumentId[1];
954 $entity = $parameterDocumentId[0];
965 if (is_array($documentId))
968 foreach ($documentId as $v)
977 if (
count($documentId) <= 0)
984 $documentId = trim($documentId);
985 if ($documentId ==
'')
989 $documentId =
array($documentId);
1007 $newResult[] = CBPHelper::ConvertUserToPrintableForm($r);
1012 $newResult = CBPHelper::ConvertUserToPrintableForm(
$result);
1019 $newResult =
array();
1023 $dbImg = CFile::GetByID($r);
1024 if ($arImg = $dbImg->Fetch())
1026 $newResult[] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$r.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
1033 $dbImg = CFile::GetByID(
$result);
1034 if ($arImg = $dbImg->Fetch())
1036 $newResult =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".
$result.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
1050 if (mb_substr(
$userId, 0, mb_strlen(
"user_")) ==
"user_")
1055 if (empty($nameTemplate))
1057 $nameTemplate = COption::GetOptionString(
"bizproc",
"name_template", CSite::GetNameFormat(
false),
SITE_ID);
1062 $db = CUser::GetList(
1065 [
"ID_EQUAL_EXACT" =>
$userId],
1067 "NAV_PARAMS" =>
false,
1080 if (
$ar = $db->Fetch())
1082 $str = CUser::FormatName($nameTemplate,
$ar,
true, $htmlSpecialChars);
1084 $str = str_replace(
",",
" ",
$str);
1102 return ob_get_clean();
1108 "string" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_STRING"),
"BaseType" =>
"string"),
1109 "text" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_TEXT"),
"BaseType" =>
"text"),
1110 "int" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_INT"),
"BaseType" =>
"int"),
1111 "double" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DOUBLE"),
"BaseType" =>
"double"),
1112 "select" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_SELECT"),
"BaseType" =>
"select"),
1113 "internalselect" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_INTERNALSELECT_1"),
"BaseType" =>
"internalselect"),
1114 "bool" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_BOOL"),
"BaseType" =>
"bool"),
1115 "date" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DATA"),
"BaseType" =>
"date"),
1116 "datetime" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_DATETIME"),
"BaseType" =>
"datetime"),
1117 "user" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_USER"),
"BaseType" =>
"user"),
1118 "file" =>
array(
"Name" =>
GetMessage(
"BPCGHLP_PROP_FILE"),
"BaseType" =>
"file"),
1127 public static function getGUIFieldEdit($documentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection)
1129 return self::GetFieldInputControl(
1132 array(
"Form" => $formName,
"Field" => $fieldName),
1138 public static function getFieldInputControl($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection =
false)
1140 if (!is_array($fieldValue) || is_array($fieldValue) && CBPHelper::IsAssociativeArray($fieldValue))
1142 $fieldValue =
array($fieldValue);
1147 if ($arFieldType[
"Type"] ==
"select")
1149 $fieldValueTmp = $fieldValue;
1151 <
select id=
"id_<?= $arFieldName["Field"] ?>" name=
"<?= $arFieldName["Field"].($arFieldType["Multiple
"] ? "[]
" : "") ?>"<?= ($arFieldType[
"Multiple"] ?
' size="5" multiple' :
'') ?>>
1153 if (!$arFieldType[
"Required"])
1154 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
1155 foreach ($arFieldType[
"Options"] as
$k => $v)
1157 $ind = array_search(
$k, $fieldValueTmp);
1158 echo
'<option value="'.htmlspecialcharsbx(
$k).
'"'.($ind !==
false ?
' selected' :
'').
'>'.
htmlspecialcharsbx($v).
'</option>';
1160 unset($fieldValueTmp[$ind]);
1165 if ($bAllowSelection)
1168 <br /><input type=
"text" id=
"id_<?= $arFieldName["Field"] ?>_text" name=
"<?= $arFieldName["Field"] ?>_text" value=
"<?
1169 if (count($fieldValueTmp) > 0)
1171 $a = array_values($fieldValueTmp);
1172 echo htmlspecialcharsbx($a[0]);
1178 elseif ($arFieldType[
"Type"] ==
"user")
1180 $fieldValue = CBPHelper::UsersArrayToString($fieldValue,
null, $documentType);
1185 if (!array_key_exists(
"CBPVirtualDocumentCloneRowPrinted",
$GLOBALS) && $arFieldType[
"Multiple"])
1187 $GLOBALS[
"CBPVirtualDocumentCloneRowPrinted"] = 1;
1191 function CBPVirtualDocumentCloneRow(tableID)
1193 var tbl = document.getElementById(tableID);
1194 var cnt = tbl.rows.length;
1195 var oRow = tbl.insertRow(cnt);
1196 var oCell = oRow.insertCell(0);
1197 var sHTML = tbl.rows[cnt - 1].cells[0].innerHTML;
1201 var s = sHTML.indexOf(
'[n', p);
1204 var e = sHTML.indexOf(
']', s);
1207 var n = parseInt(sHTML.substr(s + 2, e - s));
1208 sHTML = sHTML.substr(0, s) +
'[n' + (++n) +
']' + sHTML.substr(e + 1);
1214 var s = sHTML.indexOf(
'__n', p);
1217 var e = sHTML.indexOf(
'_', s + 2);
1220 var n = parseInt(sHTML.substr(s + 3, e - s));
1221 sHTML = sHTML.substr(0, s) +
'__n' + (++n) +
'_' + sHTML.substr(e + 1);
1224 oCell.innerHTML = sHTML;
1225 var patt =
new RegExp(
'<' +
'script' +
'>[^\000]*?<' +
'\/' +
'script' +
'>',
'ig');
1226 var code = sHTML.match(patt);
1229 for (var i = 0; i < code.length; i++)
1233 var s = code[i].substring(8, code[i].length - 9);
1234 jsUtils.EvalGlobal(s);
1244 if ($arFieldType[
"Multiple"])
1245 echo
'<table width="100%" border="0" cellpadding="2" cellspacing="2" id="CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table">';
1247 if ($bAllowSelection)
1249 $arFieldType[
"BaseType"] =
"string";
1251 static $arDocumentTypes =
null;
1252 if (is_null($arDocumentTypes))
1253 $arDocumentTypes = self::GetDocumentFieldTypes($documentType);
1255 if (array_key_exists($arFieldType[
"Type"], $arDocumentTypes))
1256 $arFieldType[
"BaseType"] = $arDocumentTypes[$arFieldType[
"Type"]][
"BaseType"];
1259 $fieldValueTmp = $fieldValue;
1262 foreach ($fieldValue as
$key => $value)
1265 $fieldNameId =
'id_'.$arFieldName[
"Field"].
'__n'.$ind.
'_';
1266 $fieldNameName = $arFieldName[
"Field"].($arFieldType[
"Multiple"] ?
"[n".$ind.
"]" :
"");
1268 if ($arFieldType[
"Multiple"])
1271 switch ($arFieldType[
"Type"])
1275 unset($fieldValueTmp[
$key]);
1276 ?><input type=
"text" size=
"10" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
1279 unset($fieldValueTmp[
$key]);
1280 ?><input type=
"file" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?
1283 if (in_array($value,
array(
"Y",
"N")))
1284 unset($fieldValueTmp[
$key]);
1286 <
select id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>">
1288 if (!$arFieldType[
"Required"])
1289 echo
'<option value="">['.GetMessage(
"BPCGHLP_NOT_SET").
']</option>';
1291 <option value=
"Y"<?= (in_array(
"Y", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_YES") ?></option>
1292 <option value=
"N"<?= (in_array(
"N", $fieldValue) ?
' selected' :
'') ?>><?=
GetMessage(
"BPCGHLP_NO") ?></option>
1297 unset($fieldValueTmp[
$key]);
1298 ?><textarea rows=
"5" cols=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>"><?=
htmlspecialcharsbx($value) ?></textarea><?
1306 unset($fieldValueTmp[
$key]);
1311 unset($fieldValueTmp[
$key]);
1312 ?><input type=
"text" size=
"40" id=
"<?= $fieldNameId ?>" name=
"<?= $fieldNameName ?>" value=
"<?= htmlspecialcharsbx($value) ?>"><?
1315 if ($bAllowSelection)
1317 if (!in_array($arFieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")))
1323 if ($arFieldType[
"Multiple"])
1327 if ($arFieldType[
"Multiple"])
1330 if ($arFieldType[
"Multiple"])
1331 echo
'<input type="button" value="'.GetMessage(
"BPCGHLP_ADD").
'" onclick="CBPVirtualDocumentCloneRow(\'CBPVirtualDocument_'.$arFieldName[
"Field"].
'_Table\')"/><br />';
1333 if ($bAllowSelection)
1335 if (in_array($arFieldType[
"Type"],
array(
"file",
"bool",
"date",
"datetime")))
1338 <input type=
"text" id=
"id_<?= $arFieldName["Field"] ?>_text" name=
"<?= $arFieldName["Field"] ?>_text" value=
"<?
1339 if (count($fieldValueTmp) > 0)
1341 $a = array_values($fieldValueTmp);
1342 echo htmlspecialcharsbx($a[0]);
1350 $s = ob_get_contents();
1356 public static function getFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
1360 if ($arFieldType[
"Type"] ==
"user")
1362 $value = $arRequest[$arFieldName[
"Field"]];
1365 $result = CBPHelper::UsersStringToArray($value, $documentType, $arErrors);
1366 if (
count($arErrors) > 0)
1368 foreach ($arErrors as $e)
1375 elseif (array_key_exists($arFieldName[
"Field"], $arRequest) || array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
1378 if (array_key_exists($arFieldName[
"Field"], $arRequest))
1380 $arValue = $arRequest[$arFieldName[
"Field"]];
1381 if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue))
1383 $arValue =
array($arValue);
1386 if (array_key_exists($arFieldName[
"Field"].
"_text", $arRequest))
1388 $arValue[] = $arRequest[$arFieldName[
"Field"].
"_text"];
1391 foreach ($arValue as $value)
1395 if ($arFieldType[
"Type"] ==
"int")
1399 $value = str_replace(
" ",
"", $value);
1400 if ($value.
"|" == intval($value).
"|")
1402 $value = intval($value);
1407 $arErrors[] =
array(
1408 "code" =>
"ErrorValue",
1410 "parameter" => $arFieldName[
"Field"],
1419 elseif ($arFieldType[
"Type"] ==
"double")
1423 $value = str_replace(
" ",
"", str_replace(
",",
".", $value));
1424 if ($value.
"|" == doubleval($value).
"|")
1426 $value = doubleval($value);
1431 $arErrors[] =
array(
1432 "code" =>
"ErrorValue",
1433 "message" =>
GetMessage(
"BPCGWTL_INVALID11"),
1434 "parameter" => $arFieldName[
"Field"],
1443 elseif ($arFieldType[
"Type"] ==
"select")
1445 if (!is_array($arFieldType[
"Options"]) ||
count($arFieldType[
"Options"]) <= 0 || $value ==
'')
1449 elseif (!array_key_exists($value, $arFieldType[
"Options"]))
1452 $arErrors[] =
array(
1453 "code" =>
"ErrorValue",
1454 "message" =>
GetMessage(
"BPCGWTL_INVALID35"),
1455 "parameter" => $arFieldName[
"Field"],
1459 elseif ($arFieldType[
"Type"] ==
"bool")
1461 if ($value !==
"Y" && $value !==
"N")
1463 if ($value ===
true)
1467 elseif ($value ===
false)
1473 $value = mb_strtolower($value);
1474 if (in_array($value,
array(
"y",
"yes",
"true",
"1")))
1478 elseif (in_array($value,
array(
"n",
"no",
"false",
"0")))
1485 $arErrors[] =
array(
1486 "code" =>
"ErrorValue",
1487 "message" =>
GetMessage(
"BPCGWTL_INVALID45"),
1488 "parameter" => $arFieldName[
"Field"],
1498 elseif ($arFieldType[
"Type"] ==
"file")
1500 if (array_key_exists(
"name", $value) && $value[
"name"] <>
'')
1502 if (!array_key_exists(
"MODULE_ID", $value) || $value[
"MODULE_ID"] ==
'')
1503 $value[
"MODULE_ID"] =
"bizproc";
1505 $value = CFile::SaveFile($value,
"bizproc_wf");
1509 $arErrors[] =
array(
1510 "code" =>
"ErrorValue",
1511 "message" =>
GetMessage(
"BPCGWTL_INVALID915"),
1512 "parameter" => $arFieldName[
"Field"],
1523 if (!is_array($value) && $value ==
'')
1533 if (!$arFieldType[
"Multiple"])
1548 switch ($arFieldType[
'Type'])
1551 $result = CBPHelper::UsersArrayToString($fieldValue,
null, $documentType);
1555 if (is_array($fieldValue))
1558 foreach ($fieldValue as $r)
1568 if (is_array($fieldValue))
1571 foreach ($fieldValue as $r)
1574 $dbImg = CFile::GetByID($r);
1575 if ($arImg = $dbImg->Fetch())
1576 $result[] =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$r.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
1581 $fieldValue = intval($fieldValue);
1582 $dbImg = CFile::GetByID($fieldValue);
1583 if ($arImg = $dbImg->Fetch())
1584 $result =
"[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg[
"FILE_NAME"]).
"&i=".$fieldValue.
"]".
htmlspecialcharsbx($arImg[
"ORIGINAL_NAME"]).
"[/url]";
1588 if (isset($arFieldType[
"Options"][$fieldValue]))
1589 $result = $arFieldType[
"Options"][$fieldValue];
1597 public static function setGUIFieldEdit($documentType, $fieldName, $arRequest, &$arErrors, $arDocumentField =
null)
1599 return self::GetFieldInputValue($documentType, $arDocumentField,
array(
"Field" => $fieldName), $arRequest, $arErrors);
1611 if (is_array(
$text))
1627 $arPattern = $arReplace = [];
1629 $arPattern[] =
"/\[(code|quote)(.*?)\]/isu";
1630 $arReplace[] =
"\n>================== \\1 ===================\n";
1632 $arPattern[] =
"/\[\/(code|quote)(.*?)\]/isu";
1633 $arReplace[] =
"\n>===========================================\n";
1635 $arPattern[] =
"/<WBR[\s\/]?>/isu";
1638 $arPattern[] =
"/^(\r|\n)+?(.*)$/";
1639 $arReplace[] =
"\\2";
1641 $arPattern[] =
"/\[b\](.+?)\[\/b\]/isu";
1642 $arReplace[] =
"\\1";
1644 $arPattern[] =
"/\[i\](.+?)\[\/i\]/isu";
1645 $arReplace[] =
"\\1";
1647 $arPattern[] =
"/\[u\](.+?)\[\/u\]/isu";
1648 $arReplace[] =
"_\\1_";
1650 $arPattern[] =
"/\[s\](.+?)\[\/s\]/isu";
1651 $arReplace[] =
"_\\1_";
1653 $arPattern[] =
"/\[(\/?)(color|font|size)([^\]]*)\]/isu";
1662 $arPattern[] =
"/\[img\](.+?)\[\/img\]/isu";
1663 $arReplace[] =
"(IMAGE: \\1)";
1665 $arPattern[] =
"/\[video([^\]]*)\](.+?)\[\/video[\s]*\]/isu";
1666 $arReplace[] =
"(VIDEO: \\2)";
1668 $arPattern[] =
"/\[(\/?)list\]/isu";
1669 $arReplace[] =
"\n";
1671 $text = preg_replace($arPattern, $arReplace,
$text);
1674 $dbSite = CSite::GetByID(
$siteId);
1675 $arSite = $dbSite->Fetch();
1676 static::$serverName = $arSite[
"SERVER_NAME"];
1677 if (static::$serverName ==
'')
1679 if (defined(
"SITE_SERVER_NAME") && SITE_SERVER_NAME <>
'')
1681 static::$serverName = SITE_SERVER_NAME;
1685 static::$serverName = COption::GetOptionString(
"main",
"server_name",
"");
1689 $text = preg_replace_callback(
1690 "/\[url\]([^\]]+?)\[\/url\]/iu",
1691 array(
"CBPHelper",
"__ConvertAnchorTag"),
1694 $text = preg_replace_callback(
1695 "/\[url\s*=\s*([^\]]+?)\s*\](.*?)\[\/url\]/isu",
1696 array(
"CBPHelper",
"__ConvertAnchorTag"),
1706 $textParser->allow = [
1720 'CUT_ANCHOR' =>
'N',
1724 return $textParser->convertText(
$text);
1733 $serverName = static::$serverName;
1736 $scheme = \CMain::IsHTTPS() ?
'https' :
'http';
1738 if (mb_substr(
$url, 0, 1) !=
"/" && !preg_match(
"/^(http|news|https|ftp|aim|mailto)\:\/\//iu",
$url))
1740 if (!preg_match(
"/^(http|https|news|ftp|aim):\/\/[-_:.a-z0-9@]+/iu",
$url))
1741 $url = $serverName.$url;
1742 if (!preg_match(
"/^(http|news|https|ftp|aim|mailto)\:\/\//iu",
$url))
1745 $url = str_replace(
' ',
'%20',
$url);
1764 $arKeys = array_keys(
$ar);
1767 foreach ($arKeys as
$key)
1770 if (
$key.
"!" !== $ind.
"!")
1772 if (mb_substr(
$key, 0, 1) ===
'n')
1775 if (($indn === 0) && (
"".
$key ===
"n1"))
1778 if (
"".
$key !==
"n".$indn)
1799 if (!is_array($value))
1801 $value =
array($value);
1804 $l = mb_strlen(
"user_");
1805 $runtime = CBPRuntime::GetRuntime();
1806 $documentService = $runtime->GetService(
"DocumentService");
1808 foreach ($value as $v)
1810 if (mb_substr($v, 0,
$l) ==
"user_")
1816 $arDSUsers = self::extractUsersFromExtendedGroup($v);
1817 if ($arDSUsers ===
false)
1819 $arDSUsers = $documentService->GetUsersFromUserGroup($v,
$activity->GetDocumentId());
1821 foreach ($arDSUsers as $v1)
1842 if (isset($cache[
$code]))
1844 return $cache[
$code];
1847 if (!str_starts_with(
$code,
'group_'))
1852 $code = mb_strtoupper(mb_substr(
$code, mb_strlen(
'group_')));
1853 $userService = CBPRuntime::getRuntime()->getUserService();
1855 if (str_starts_with(
$code,
'G'))
1857 $groupId = (int)mb_substr(
$code, 1);
1858 $cache[
$code] = $userService->extractUsersFromGroup($groupId);
1860 return $cache[
$code];
1863 if (preg_match(
'/^(U|IU|SU)([0-9]+)$/i',
$code, $match))
1865 return [(int)$match[2]];
1870 $cache[
$code] = $userService->extractUsersFromAllDepartments();
1872 return $cache[
$code];
1875 if (preg_match(
'/^(D|DR)(\d+)$/',
$code, $match))
1877 $cache[
$code] = $userService->extractUsersFromDepartment($match[2], $match[1] ===
'DR');
1879 return $cache[
$code];
1882 if (preg_match(
'/^SG([0-9]+)_?([AEK])?$/',
$code, $match))
1884 $groupId = (int)$match[1];
1885 $role = $match[2] ??
'K';
1886 $cache[
$code] = $userService->extractUsersFromSocNetGroup($groupId, $role);
1888 return $cache[
$code];
1891 if (preg_match(
'/^(HR|HRR)(\d+)$/',
$code, $match))
1893 $nodeId = (int)$match[2];
1894 $cache[
$code] = $userService->extractUsersFromHrNode($nodeId, $match[1] ===
'HRR');
1896 return $cache[
$code];
1902 public static function extractUsers($arUsersDraft, $documentId, $bFirst =
false)
1906 if (!is_array($arUsersDraft))
1908 $arUsersDraft =
array($arUsersDraft);
1911 $l = mb_strlen(
"user_");
1912 $documentService = CBPRuntime::GetRuntime(
true)->getDocumentService();
1914 foreach ($arUsersDraft as
$user)
1916 if (!is_scalar(
$user))
1921 if (mb_substr(
$user, 0,
$l) ===
"user_")
1936 if ($parsed && $parsed[
'object'] ===
'Document')
1938 $document = $documentService->GetDocument($documentId,
select: [$parsed[
'field']]);
1939 if ($document && $document[$parsed[
'field']])
1941 foreach ((
array) $document[$parsed[
'field']] as $docUser)
1943 if (mb_substr($docUser, 0,
$l) ===
"user_")
1945 $user = intval(mb_substr($docUser,
$l));
1961 $users = self::extractUsersFromExtendedGroup(
$user);
1962 if ($users ===
false)
1964 $users = $documentService->GetUsersFromUserGroup(
$user, $documentId);
1966 foreach ($users as $u)
1969 if (($u > 0) && !in_array($u,
$result))
1996 return static::extractUsers($userGroups, $documentId,
true);
2012 && in_array(
$ar[0], [
"Variable",
"Document",
"Template",
"Workflow",
"User",
"System"])
2013 && is_string(
$ar[1])
2022 if (!is_array(
$val))
2024 if (trim(
$val) !==
"")
2029 foreach (self::MakeArrayFlat(
$val) as $val1)
2039 if (!is_array($array))
2052 if (is_array($mixed))
2054 return implode(
', ', static::flatten($mixed));
2057 return (
string)$mixed;
2064 || $value ===
'false'
2065 || (is_int($value) && ($value == 0))
2066 || (is_scalar($value) && mb_strtoupper($value) ==
'N')
2072 return (
bool)$value;
2079 return ($value !==
null && $value !==
'' && $value !==
false);
2089 (is_array($value) &&
count(array_filter($value,
$filter)) === 0)
2100 if ($arMatches[
'object'] ==
"User")
2102 if (
$GLOBALS[
"USER"]->IsAuthorized())
2103 $result =
"user_".$GLOBALS[
"USER"]->GetID();
2105 elseif ($arMatches[
'object'] ==
"System")
2107 if (mb_strtolower($arMatches[
'field']) ===
"now")
2108 $result = date(
$GLOBALS[
"DB"]->DateFormatToPHP(CSite::GetDateFormat(
"FULL")));
2109 elseif (mb_strtolower($arMatches[
'field']) ==
"date")
2110 $result = date(
$GLOBALS[
"DB"]->DateFormatToPHP(CSite::GetDateFormat(
"SHORT")));
2119 if (is_array($value) && !CBPHelper::IsAssociativeArray($value))
2121 foreach ($value as &$v)
2123 if (mb_substr($v, 0, 5) ==
"user_")
2124 $v = mb_substr($v, 5);
2127 elseif (is_string($value))
2129 if (mb_substr($value, 0, 5) ==
"user_")
2130 $value = mb_substr($value, 5);
2144 if (!isset(self::$groupsCache[
$userId]))
2146 self::$groupsCache[
$userId] = [];
2147 $access = static::getAccessProvider();
2148 $userCodes = $access::GetUserCodesArray(
$userId);
2150 foreach ($userCodes as
$code)
2152 self::$groupsCache[
$userId][] =
'group_' . mb_strtolower(
$code);
2153 if ($canUseHrModule && preg_match(
'/^(d|dr)(\d+)$/', mb_strtolower(
$code), $match))
2155 $node = Container::getNodeRepository()->getByAccessCode(
$code);
2158 self::$groupsCache[
$userId][] =
'group_' . ($match[1] ===
'dr' ?
'hrr' :
'hr') . $node->id;
2164 return self::$groupsCache[
$userId];
2174 if (str_starts_with($group,
'group_'))
2176 $group = mb_substr($group, mb_strlen(
'group_'));
2180 preg_match(
'/^(d|dr)(\d+)$/', $group, $match)
2184 $departmentId = $match[2];
2186 Container::getNodeRepository()
2187 ->getByAccessCode(DepartmentBackwardAccessCode::makeById((
int)$departmentId))
2191 return ($node->name ??
'') . ($appendId ?
' [HR' . ($match[1] ===
'dr' ?
'R' :
'') . $node->id .
']' :
'');
2195 if (preg_match(
'/^(hr|hrr)(\d+)$/', $group, $match))
2197 $groupId = $match[2];
2201 $nodeRepository = Container::getNodeRepository();
2202 $node = $nodeRepository->getById((
int)$groupId);
2203 $groupName = $node->name ??
'';
2206 return $groupName . ($appendId ?
' [' . mb_strtoupper($group) .
']' :
'');
2209 $group = mb_strtoupper($group);
2210 $access = static::getAccessProvider();
2212 $groupName =
$arNames[$group][
'name'] ??
null;
2214 return $groupName . ($appendId ?
' [' . $group .
']' :
'');
2224 $users = (
array)$users;
2225 foreach ($users as &
$user)
2227 if (!is_scalar(
$user))
2230 if (mb_strpos(
$user,
'user_') === 0)
2232 $user =
'group_u'.mb_substr(
$user, mb_strlen(
'user_'));
2236 $user =
'group_g'.$user;
2252 $users = (
array)$users;
2255 foreach ($users as
$user)
2257 if (!is_scalar(
$user))
2260 if (mb_strpos(
$user,
'group_u') === 0)
2262 $converted[] =
'user_'.mb_substr(
$user, mb_strlen(
'group_u'));
2266 $converted[] = mb_substr(
$user, mb_strlen(
'group_g'));
2272 $extracted = self::extractUsersFromExtendedGroup(
$user);
2273 if ($extracted !==
false)
2275 foreach ($extracted as $exUser)
2277 $converted[] =
'user_'.$exUser;
2283 $converted[] =
$user;
2290 $forumId = COption::GetOptionString(
'bizproc',
'forum_id', 0);
2291 if (!$forumId && CModule::includeModule(
'forum'))
2293 $defaultSiteId = CSite::GetDefSite();
2295 'NAME' =>
'Bizproc Workflow',
2296 'XML_ID' =>
'bizproc_workflow',
2297 'SITES' =>
array($defaultSiteId =>
'/'),
2299 'DEDUPLICATION' =>
'N',
2301 COption::SetOptionString(
"bizproc",
"forum_id", $forumId);
2304 return (
int)$forumId;
2309 return CModule::IncludeModule(
'bitrix24') ? static::DISTR_B24 : static::DISTR_BOX;
2321 if (Loader::IncludeModule(
'humanresources'))
2323 $headNodes = Container::getNodeMemberRepository()->findAllByEntityIdAndEntityType(
2325 MemberEntityType::USER,
2327 $subNodes = Container::getNodeMemberRepository()->findAllByEntityIdAndEntityType(
2329 MemberEntityType::USER,
2332 foreach ($headNodes as $headNode)
2334 foreach ($subNodes as $subNode)
2336 $relation = Container::getNodeMemberService()->getMemberSubordination(
2340 if ($relation === MemberSubordinateRelationType::RELATION_HIGHER)
2349 return self::checkUserSubordinationDeprecated((
int)$headUserId, (
int)$subUserId);
2356 private static function checkUserSubordinationDeprecated(
int $headUserId,
int $subUserId): bool
2358 if ($headUserId && $subUserId)
2360 $headDepts = (
array) CIntranetUtils::GetSubordinateDepartments($headUserId,
true);
2361 if (!empty($headDepts))
2363 $subDepts = (
array) CIntranetUtils::GetUserDepartments($subUserId);
2364 return (
sizeof(array_intersect($headDepts, $subDepts)) > 0);
2374 'controlId' => $controlId,
2375 'baseType' => $baseType,
2379 $additional =
array();
2382 $additional[] =
'style="'.htmlspecialcharsbx(
$options[
'style']).
'"';
2385 $additional[] =
'title="'.htmlspecialcharsbx(
$options[
'title']).
'"';
2387 return '<input type="button" value="..." onclick="BPAShowSelector(\''
2391 .' data-role="bp-selector-button
" data-bp-selector-props="'.htmlspecialcharsbx($selectorProps).'" '.implode(' ', $additional).'>';
2394 public static function decodeTemplatePostData(&$data)
2397 'arWorkflowTemplate',
2398 'arWorkflowParameters',
2399 'arWorkflowGlobalVariables',
2400 'arWorkflowVariables',
2401 'arWorkflowGlobalConstants',
2402 'arWorkflowConstants',
2404 'documentCategories',
2405 'workflowTemplateSettings',
2408 foreach ($jsonParams as $k)
2410 if (!isset($data[$k]) || !is_array($data[$k]))
2412 $data[$k] = isset($data[$k]) ? (array) CUtil::JsObjectToPhp($data[$k]) : array();
2417 public static function makeTimestamp($date, bool $appendOffset = false)
2424 if (is_array($date))
2426 $date = current(static::flatten($date));
2429 //serialized date string
2430 if (is_string($date) && Bizproc\BaseType\Value\DateTime::isSerialized($date))
2432 $date = new Bizproc\BaseType\Value\DateTime($date);
2435 if ($date instanceof Bizproc\BaseType\Value\Date)
2437 return $date->getTimestamp() + ($appendOffset ? $date->getOffset() : 0);
2440 if ($date instanceof Main\Type\Date)
2442 return $date->getTimestamp();
2445 if ($date instanceof Bitrix\Bizproc\BaseType\Value\Time)
2447 $time = $date->toSystemObject();
2448 $currentDate = new \Bitrix\Main\Type\DateTime();
2450 return $time->setDate(
2451 $currentDate->format('Y'),
2452 $currentDate->format('m'),
2453 $currentDate->format('d')
2457 if (intval($date) . '!' === $date . '!')
2462 if (($result = MakeTimeStamp($date, FORMAT_DATETIME)) === false)
2464 if (($result = MakeTimeStamp($date, FORMAT_DATE)) === false)
2466 if (($result = MakeTimeStamp($date, 'YYYY-MM-DD HH:MI:SS')) === false)
2468 $result = MakeTimeStamp($date, 'YYYY-MM-DD');
2473 return (int) $result;
2476 public static function isWorkTimeAvailable(): bool
2479 Loader::includeModule('bitrix24')
2480 && !Bitrix24\Feature::isFeatureEnabled('bizproc_timeman')
2486 if (Loader::includeModule('intranet'))
2488 $workTime = \Bitrix\Intranet\Site\Sections\TimemanSection::getWorkTime();
2490 return $workTime['available'] && Loader::includeModule('timeman');
2496 public static function hasStringRepresentation($value): bool
2498 return (is_scalar($value) || (is_object($value) && method_exists($value, '__toString')));
2501 public static function isEqualDocument(array $documentA, array $documentB): bool
2504 (string)$documentA[0] === (string)$documentB[0]
2505 && (string)$documentA[1] === (string)$documentB[1]
2506 && (string)$documentA[2] === (string)$documentB[2]
2513 public static function isWorkflowFinished(string $workflowId): bool
2517 throw new CBPArgumentNullException('workflowId');
2520 $runtime = CBPRuntime::getRuntime();
2521 if ($runtime->hasWorkflow($workflowId))
2523 return $runtime->getWorkflow($workflowId)->isFinished();
2526 return !Bizproc\WorkflowInstanceTable::exists($workflowId);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static includeModule($moduleName)
static isValidModule(string $moduleName)
static encode($data, $options=null)
static CalendarDate($sFieldName, $sValue="", $size="10", $bTime=false)
static GetList($by='', $order='', $arFilter=[], $arParams=[])
static SearchUserByName($arName, $email='', $bLoginMode=false)
static FormatName($NAME_TEMPLATE, $arUser, $bUseLogin=false, $bHTMLSpec=true, $enabledEmptyNameStub=true)
static parseExpression($exp)
static isExpression($text)
static getAccessProvider()
static checkUserSubordination(mixed $headUserId, mixed $subUserId)
static getGUIFieldEdit($documentType, $formName, $fieldName, $fieldValue, $arDocumentField, $bAllowSelection)
static convertParameterValues($val)
static extractFirstUser($userGroups, $documentId)
static convertToSimpleGroups($users, $extractUsers=false)
static getFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors)
static convertBBtoText(string $text)
static getFieldValuePrintable($fieldName, $fieldType, $result)
static parseDocumentIdArray($parameterDocumentId)
static isAssociativeArray($ar)
static setGUIFieldEdit($documentType, $fieldName, $arRequest, &$arErrors, $arDocumentField=null)
static getExtendedGroupName($group, $appendId=true)
static convertToExtendedGroups($users)
static renderControlSelectorButton($controlId, $baseType='string', array $options=null)
static usersArrayToString($users, $arWorkflowTemplate, $documentType, $appendId=true)
static extractUsersFromUserGroups($value, $activity)
static parseDocumentId($parameterDocumentId)
static formatTimePeriod($period)
static extractUsersFromExtendedGroup($code)
static getJSFunctionsForFields($objectName, $arDocumentFields, $arDocumentFieldTypes)
static __ConvertAnchorTag($url, $text='', $serverName='')
static getDocumentFieldTypes()
static isEmptyValue($value)
static convertTextForMail($text, $siteId=false)
static getFieldInputControl($documentType, $arFieldType, $arFieldName, $fieldValue, $bAllowSelection=false)
static prepareSql(&$arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields)
static getFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
static getUserExtendedGroups($userId)
static convertUserToPrintableForm($userId, $nameTemplate="", $htmlSpecialChars=true)
static usersStringToArray($strUsers, $documentType, &$arErrors, $callbackFunction=null)
static makeArrayFlat($ar)
static getFilterOperation($key)
static stripUserPrefix($value)
static extractUsers($arUsersDraft, $documentId, $bFirst=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(!is_array($deviceNotifyCodes)) $access
DelDuplicateSort(&$arSort)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
GetMessage($name, $aReplace=null)
check_email($email, $strict=false, $domainCheck=false)
$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."%"