} else {
                        LocalRedirect("/bitrix/admin/workflow_list.php?lang=" . LANGUAGE_ID . "&set_default=Y&strError=" . urlencode($strError) . "&strNote=" . urlencode($strNote));
                    }
                } elseif (strlen($apply) > 0) {
                    LocalRedirect("/bitrix/admin/workflow_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $ID . "&strError=" . urlencode($strError) . "&strNote=" . urlencode($strNote) . "&" . $tabControl->ActiveTabParam() . (strlen($return_url) ? "&return_url=" . urlencode($return_url) : ""));
                }
            }
        }
    } else {
        if ($e = $APPLICATION->GetException()) {
            $message = new CAdminMessage(GetMessage("FLOW_ERROR"), $e);
        }
    }
}
if ($ID > 0 && !$message) {
    CWorkflow::Lock($ID);
}
$arDocFiles = array();
ClearVars();
$workflow = CWorkflow::GetByID($ID);
if (!$workflow->ExtractFields()) {
    $ID = 0;
    if (is_file($DOC_ROOT . $fname)) {
        $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . $fname);
        $arContent = ParseFileContent($filesrc);
        $str_TITLE = $arContent["TITLE"];
        $str_BODY = $arContent["CONTENT"];
        $get_content = "Y";
    } elseif (strlen($template) > 0) {
        for ($i = 0; $i < count($arTemplates); $i++) {
            if ($arTemplates[$i]["file"] == $template) {