CBPDocument::AddShowParameterInit: Bitrix method

      
<?php 
//  CBPDocument :: AddShowParameterInit()
//  /dist/bitrix/modules/bizproc/classes/general/document.php:821

    
public static function AddShowParameterInit($module$type$document_type$entity ""$document_id '')
    {
        
$GLOBALS["BP_AddShowParameterInit_".$module."_".$entity."_".$document_type] = 1;
        
CUtil::InitJSCore(array("window""ajax"));
?>
<script src="/bitrix/js/bizproc/bizproc.js"></script>
<script>
    function BPAShowSelector(id, type, mode, arCurValues, arDocumentType)
    {
        <?if($type=="only_users"):?>
        var def_mode = "only_users";
        <?else:?>
        var def_mode = "";
        <?endif?>

        if (!mode)
            mode = def_mode;
        var module = '<?=CUtil::JSEscape($module)?>';
        var entity = '<?=CUtil::JSEscape($entity)?>';
        var documentType = '<?=CUtil::JSEscape($document_type)?>';
        var documentId = '<?=CUtil::JSEscape($document_id)?>';

        /*if (arDocumentType && arDocumentType.length == 3)
        {
            module = arDocumentType[0];
            entity = arDocumentType[1];
            documentType = arDocumentType[2];
        }*/

        var loadAccessLib = (typeof BX.Access === 'undefined');

        if (mode == "only_users")
        {
            if (BX.getClass('BX.Bizproc.UserSelector') && BX.Bizproc.UserSelector.canUse())
            {
                var controlNode = BX(id);
                if (controlNode.__userSelector)
                {
                    controlNode.__userSelector.onBindClick();
                    return;
                }

                BX.Bizproc.UserSelector.loadData(function()
                {
                    controlNode.__userSelector = new BX.Bizproc.UserSelector({
                        bindTo: controlNode,
                        addCallback: function(user)
                        {
                            var prefix = '';
                            if (controlNode.value.length > 0 && !/;\s*$/.test(controlNode.value))
                            {
                                prefix = '; ';
                            }

                            controlNode.value += prefix + user['name'] + ' ['+user['id']+']; ';
                        }
                    });
                    controlNode.__userSelector.onBindClick();
                });
                controlNode.__userSelector = true;
                return;
            }

            BX.WindowManager.setStartZIndex(1150);
            (new BX.CDialog({
                'content_url': '/bitrix/admin/'+module
                    +'_bizproc_selector.php?mode=public&bxpublic=Y&lang=<?=LANGUAGE_ID?>&entity='
                    +entity
                    +(loadAccessLib? '&load_access_lib=Y':''),
                'content_post': {
                    'document_type': documentType,
                    'document_id': documentId,
                    'fieldName': id,
                    'fieldType': type,
                    'only_users': 'Y',
                    'sessid': '<?= bitrix_sessid() ?>'
                },
                'height': 400,
                'width': 485
            })).Show();
        }
        else
        {
            if (typeof arWorkflowConstants === 'undefined')
                arWorkflowConstants = {};

            var workflowTemplateNameCur = workflowTemplateName;
            var workflowTemplateDescriptionCur = workflowTemplateDescription;
            var workflowTemplateAutostartCur = workflowTemplateAutostart;
            var arWorkflowParametersCur = arWorkflowParameters;
            var arWorkflowVariablesCur = arWorkflowVariables;
            var arWorkflowConstantsCur = arWorkflowConstants;
            var arWorkflowTemplateCur = Array(rootActivity.Serialize());

            if (arCurValues)
            {
                if (arCurValues['workflowTemplateName'])
                    workflowTemplateNameCur = arCurValues['workflowTemplateName'];
                if (arCurValues['workflowTemplateDescription'])
                    workflowTemplateDescriptionCur = arCurValues['workflowTemplateDescription'];
                if (arCurValues['workflowTemplateAutostart'])
                    workflowTemplateAutostartCur = arCurValues['workflowTemplateAutostart'];
                if (arCurValues['arWorkflowParameters'])
                    arWorkflowParametersCur = arCurValues['arWorkflowParameters'];
                if (arCurValues['arWorkflowVariables'])
                    arWorkflowVariablesCur = arCurValues['arWorkflowVariables'];
                if (arCurValues['arWorkflowConstants'])
                    arWorkflowConstantsCur = arCurValues['arWorkflowConstants'];
                if (arCurValues['arWorkflowTemplate'])
                    arWorkflowTemplateCur = arCurValues['arWorkflowTemplate'];
            }

            var p = {
                'document_type': documentType,
                'document_id': documentId,
                'fieldName': id,
                'fieldType': type,
                'selectorMode': mode,
                'workflowTemplateName': workflowTemplateNameCur,
                'workflowTemplateDescription': workflowTemplateDescriptionCur,
                'workflowTemplateAutostart': workflowTemplateAutostartCur,
                'sessid': '<?= bitrix_sessid() ?>'
            };

            JSToPHPHidd(p, arWorkflowParametersCur, 'arWorkflowParameters');
            JSToPHPHidd(p, arWorkflowVariablesCur, 'arWorkflowVariables');
            JSToPHPHidd(p, arWorkflowConstantsCur, 'arWorkflowConstants');
            JSToPHPHidd(p, arWorkflowTemplateCur, 'arWorkflowTemplate');

            (new BX.CDialog({
                'content_url': '/bitrix/admin/'
                    +module+'_bizproc_selector.php?mode=public&bxpublic=Y&lang=<?=LANGUAGE_ID?>&entity='
                    +entity
                    +(loadAccessLib? '&load_access_lib=Y':''),
                'content_post': p,
                'height': 425,
                'width': 485
            })).Show();
        }
    }
</script>
<?
    
}