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);
484 [
$moduleId,
$entity, $documentType] = CBPHelper::ParseDocumentId($parameterDocumentType);
491 $documentFieldsString =
"";
492 foreach ($arDocumentFields as $fieldKey => $arFieldValue)
494 if ($documentFieldsString <>
'')
495 $documentFieldsString .=
",";
497 $documentFieldsString .=
"'".Cutil::JSEscape($fieldKey).
"':{";
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").
"',";
504 $documentFieldsString .=
"'Options':";
505 if (array_key_exists(
"Options", $arFieldValue))
507 if (is_array($arFieldValue[
"Options"]))
509 $documentFieldsString .=
"{";
511 foreach ($arFieldValue[
"Options"] as
$k => $v)
519 $documentFieldsString .=
",";
520 $documentFieldsString .=
"'".CUtil::JSEscape(
$k).
"':'".CUtil::JSEscape($v).
"'";
523 $documentFieldsString .=
"}";
527 $documentFieldsString .=
"'".CUtil::JSEscape($arFieldValue[
"Options"]).
"'";
532 $documentFieldsString .=
"''";
535 if (isset($arFieldValue[
"Options"]) && CBPHelper::IsAssociativeArray($arFieldValue[
"Options"]))
537 $documentFieldsString .=
", 'OptionsSort':";
538 $documentFieldsString .= CUtil::PhpToJSObject(array_keys($arFieldValue[
"Options"]));
541 if(isset($arFieldValue[
"Settings"]) && is_array($arFieldValue[
"Settings"]))
543 $documentFieldsString .=
", 'Settings':";
544 $documentFieldsString .= CUtil::PhpToJSObject($arFieldValue[
"Settings"]);
547 $documentFieldsString .=
"}";
550 $fieldTypesString =
"";
552 foreach ($arDocumentFieldTypes as $typeKey => $arTypeValue)
555 if ($fieldTypesString <>
'')
556 $fieldTypesString .=
",";
558 $fieldTypesString .=
"'".CUtil::JSEscape($typeKey).
"':{";
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.
"";
565 $fieldTypesString .=
"}";
568 $documentTypeString = CUtil::PhpToJSObject($parameterDocumentType);
575$objectName.arDocumentFields = { $documentFieldsString };
576$objectName.arFieldTypes = { $fieldTypesString };
578$objectName.AddField =
function(fldCode, fldName, fldType, fldMultiple, fldOptions)
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;
587$objectName._PrepareResponse =
function(v)
589 v = v.replace(/^\s+|\s+$/g,
'');
590 while (v.length > 0 && v.charCodeAt(0) == 65279)
601$objectName.GetFieldInputControl4Type =
function(type, value, name, subtypeFunctionName, func)
603 this.GetFieldInputControlInternal(
609 var p = v.indexOf(
'<!--__defaultOptionsValue:');
612 p = p +
'<!--__defaultOptionsValue:'.length;
613 var p1 = v.indexOf(
'-->', p);
614 type[
'Options'] = v.substring(p, p1);
619 p = v.indexOf(
'<!--__modifyOptionsPromt:');
622 p = p +
'<!--__modifyOptionsPromt:'.length;
623 p1 = v.indexOf(
'-->', p);
624 newPromt = v.substring(p, p1);
635$objectName.GetFieldInputControl4Subtype =
function(type, value, name, func)
637 $objectName.GetFieldInputControlInternal(type, value, name, func,
false,
'',
'');
640$objectName.GetFieldInputControl =
function(type, value, name, func, als)
642 $objectName.GetFieldInputControlInternal(type, value, name, func, als,
'',
'');
645$objectName.GetFieldInputControlInternal =
function(type, value, name, func, als, subtypeFunctionName, mode)
647 if (typeof name ==
"undefined" || name.length <= 0)
648 name =
"BPVDDefaultValue";
650 if (typeof type !=
"object")
651 type = {
'Type' : type,
'Multiple' : 0,
'Required' : 0,
'Options' :
null};
653 if (typeof name !=
"object")
654 name = {
'Field' : name,
'Form' :
null};
657 '/bitrix/tools/bizproc_get_field.php',
659 'DocumentType' : $documentTypeString,
664 'rnd' : Math.random(),
666 'Func' : subtypeFunctionName,
667 'sessid' :
'$bitrixSessId'
673$objectName.GetFieldValueByTagName =
function(tag, name, form)
675 var fieldValues = {};
678 if (form && (form.length > 0))
680 var obj = document.getElementById(form);
683 for (var i in document.forms)
685 if (document.forms[i].name == form)
687 obj = document.forms[i];
696 ar = obj.getElementsByTagName(tag);
700 ar = document.getElementsByTagName(tag);
705 if (ar[i] && ar[i].name && (ar[i].name.length >= name.length) && (ar[i].name.substr(0, name.length) == name))
707 if (ar[i].type.substr(0,
"select".length) ==
"select")
711 var newName = ar[i].name.replace(/\[\]/g,
"");
712 for (var j = 0; j < ar[i].options.length; j++)
716 if ((typeof(fieldValues[newName]) !=
'object') || !(fieldValues[newName] instanceof Array))
718 if (fieldValues[newName])
719 fieldValues[newName] = [fieldValues[newName]];
721 fieldValues[newName] = [];
723 fieldValues[newName][fieldValues[newName].length] = ar[i].options[j].value;
731 const name = ar[i].name;
732 const value = ar[i].options[ar[i].selectedIndex].value;
734 if (name.indexOf(
"[]", 0) >= 0)
736 const newName = name.replace(/\[\]/g,
"");
737 if ((typeof(fieldValues[newName]) !==
'object') || !(fieldValues[newName] instanceof Array))
739 if (fieldValues[newName])
741 fieldValues[newName] = [fieldValues[newName]];
745 fieldValues[newName] = [];
749 fieldValues[newName][fieldValues[newName].length] = value;
753 fieldValues[name] = value;
760 if (ar[i].name.indexOf(
"[]", 0) >= 0)
762 var newName = ar[i].name.replace(/\[\]/g,
"");
764 if ((typeof(fieldValues[newName]) !=
'object') || !(fieldValues[newName] instanceof Array))
766 if (fieldValues[newName])
767 fieldValues[newName] = [fieldValues[newName]];
769 fieldValues[newName] = [];
772 fieldValues[newName][fieldValues[newName].length] = ar[i].value;
776 fieldValues[ar[i].name] = ar[i].value;
785$objectName.GetFieldInputValue =
function(type, name, func)
787 if (typeof name ==
"undefined" || name.length <= 0)
788 name =
"BPVDDefaultValue";
790 if (typeof type !=
"object")
791 type = {
'Type' : type,
'Multiple' : 0,
'Required' : 0,
'Options' :
null};
793 if (typeof name !=
"object")
794 name = {
'Field' : name,
'Form' :
null};
797 'DocumentType' : $documentTypeString,
800 'rnd' : Math.random(),
801 'sessid' :
'$bitrixSessId'
806 var objForm = document.getElementById(name[
'Form']);
809 for (var i in document.forms)
811 if (document.forms[i].name == name[
'Form'])
813 objForm = document.forms[i];
821 BX.ajax.prepareForm(objForm, s);
825 if (type !=
null && type[
'Type'] !=
"F")
827 var ar = this.GetFieldValueByTagName(
'input', name[
'Field'], name[
'Form']);
830 ar = this.GetFieldValueByTagName(
'select', name[
'Field'], name[
'Form']);
833 ar = this.GetFieldValueByTagName(
'textarea', name[
'Field'], name[
'Form']);
836 ar = this.GetFieldValueByTagName(
'hidden', name[
'Field'], name[
'Form']);
841 BX.ajax.post(
'/bitrix/tools/bizproc_set_field.php', s,
function(v){v = $objectName._PrepareResponse(v); func(v);});
844$objectName.HtmlSpecialChars =
function(string, quote)
846 string =
string.toString();
847 string =
string.replace(/&/g,
'&');
848 string =
string.replace(/</g,
'<');
849 string =
string.replace(/>/g,
'>');
850 string =
string.replace(/
"/g, '"');
853 string = string.replace(/'/g, ''');
858$objectName.GetGUITypeEdit = function(type)
863$objectName.SetGUITypeEdit = function(type)
868function __dump_bx(arr, limitLevel, txt)
870 if (limitLevel == undefined)
872 if (txt == undefined)
876 alert(txt+__dumpInternal_bx(arr, 0, limitLevel));
878function __dumpInternal_bx(arr, level, limitLevel) {
879 var dumped_text = "";
880 if(!level) level = 0;
881 if (level > limitLevel)
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);
892 dumped_text += level_padding + "'" + item + "' =>
'" + value + "'\\n
";
896 dumped_text = "===>
"+arr+"<===(
"+typeof(arr)+")
";
905 if (class_exists($entity) && method_exists($entity, "GetJSFunctionsForFields
"))
907 $result .= call_user_func_array(array($entity, "GetJSFunctionsForFields
"), array($documentType, $objectName, $arDocumentFields, $arDocumentFieldTypes));
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);
916 $result .= CBPHelper::GetJSFunctionsForFields($objectName, $arDocumentFields, $arDocumentFieldTypes);