public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arAllowableOperations = $documentService->GetAllowableOperations($documentType);
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"]) && array_key_exists("Permission", $arCurrentActivity["Properties"])) {
             foreach ($arAllowableOperations as $operationKey => $operationValue) {
                 $current = $documentService->toExternalOperations($documentType, $arCurrentActivity["Properties"]["Permission"]);
                 $arCurrentValues["permission_" . $operationKey] = CBPHelper::UsersArrayToString($current[$operationKey], $arWorkflowTemplate, $documentType);
             }
         }
         $arCurrentValues['set_mode'] = CBPSetPermissionsMode::Clear;
         $arCurrentValues['set_scope'] = CBPSetPermissionsMode::ScopeWorkflow;
         // old style override
         if (array_key_exists("Rewrite", $arCurrentActivity["Properties"]) && $arCurrentActivity["Properties"]["Rewrite"] == "N") {
             $arCurrentValues['set_mode'] = CBPSetPermissionsMode::Hold;
         }
         if (array_key_exists("SetMode", $arCurrentActivity["Properties"]) && $arCurrentActivity["Properties"]["SetMode"] !== false) {
             $arCurrentValues["set_mode"] = $arCurrentActivity["Properties"]["SetMode"];
         }
         if (array_key_exists("SetScope", $arCurrentActivity["Properties"])) {
             $arCurrentValues["set_scope"] = $arCurrentActivity["Properties"]["SetScope"];
         }
         $arCurrentValues['is_extended_mode'] = $documentService->isExtendedPermsSupported($documentType);
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arAllowableOperations" => $arAllowableOperations, "arCurrentValues" => $arCurrentValues, "formName" => $formName));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("MessageUserFrom" => "message_user_from", "MessageUserTo" => "message_user_to", "MessageText" => "message_text");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "MessageUserFrom" || $k == "MessageUserTo") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arAllowableOperations = $documentService->GetAllowableOperations($documentType);
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"]) && array_key_exists("Permission", $arCurrentActivity["Properties"])) {
             foreach ($arAllowableOperations as $operationKey => $operationValue) {
                 $arCurrentValues["permission_" . $operationKey] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"]["Permission"][$operationKey], $arWorkflowTemplate, $documentType);
             }
         }
         if (array_key_exists("Rewrite", $arCurrentActivity["Properties"])) {
             $arCurrentValues["rewrite"] = $arCurrentActivity["Properties"]["Rewrite"] == "N" ? "N" : "Y";
         } else {
             $arCurrentValues["rewrite"] = "Y";
         }
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arAllowableOperations" => $arAllowableOperations, "arCurrentValues" => $arCurrentValues, "formName" => $formName));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "", $form = null, $siteId = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("AbsenceUser" => "absence_user", "AbsenceName" => "absence_name", "AbsenceDesrc" => "absence_desrc", "AbsenceFrom" => "absence_from", "AbsenceTo" => "absence_to", "AbsenceState" => "absence_state", "AbsenceFinishState" => "absence_finish_state", "AbsenceType" => "absence_type");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "AbsenceUser") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     $absenceIblockId = COption::GetOptionInt("intranet", 'iblock_absence', 0, $siteId);
     $arAbsenceTypes = array();
     $dbTypeRes = CIBlockPropertyEnum::GetList(array("SORT" => "ASC", "VALUE" => "ASC"), array('IBLOCK_ID' => $absenceIblockId, 'PROPERTY_ID' => 'ABSENCE_TYPE'));
     while ($arTypeValue = $dbTypeRes->GetNext()) {
         $arAbsenceTypes[$arTypeValue['XML_ID']] = $arTypeValue['VALUE'];
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, "arAbsenceTypes" => $arAbsenceTypes));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("Users" => "review_users", "ApproveType" => "approve_type", "OverdueDate" => "review_overdue_date", "Name" => "review_name", "Description" => "review_description", "Parameters" => "review_parameters", "StatusMessage" => "status_message", "SetStatusMessage" => "set_status_message", "TaskButtonMessage" => "task_button_message", "CommentLabelMessage" => "comment_label_message", "ShowComment" => "show_comment", "TimeoutDuration" => "timeout_duration", "TimeoutDurationType" => "timeout_duration_type", "AccessControl" => "access_control");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "Users") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
                     } elseif ($k == "TimeoutDuration") {
                         $arCurrentValues["timeout_duration"] = $arCurrentActivity["Properties"]["TimeoutDuration"];
                         if (!preg_match('#^{=[A-Za-z0-9_]+:[A-Za-z0-9_]+}$#i', $arCurrentValues["timeout_duration"]) && !array_key_exists("TimeoutDurationType", $arCurrentActivity["Properties"])) {
                             $arCurrentValues["timeout_duration"] = intval($arCurrentValues["timeout_duration"]);
                             $arCurrentValues["timeout_duration_type"] = "s";
                             if ($arCurrentValues["timeout_duration"] % (3600 * 24) == 0) {
                                 $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / (3600 * 24);
                                 $arCurrentValues["timeout_duration_type"] = "d";
                             } elseif ($arCurrentValues["timeout_duration"] % 3600 == 0) {
                                 $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / 3600;
                                 $arCurrentValues["timeout_duration_type"] = "h";
                             } elseif ($arCurrentValues["timeout_duration"] % 60 == 0) {
                                 $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / 60;
                                 $arCurrentValues["timeout_duration_type"] = "m";
                             }
                         }
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     if (!is_array($arCurrentValues) || !array_key_exists($arMap[$k], $arCurrentValues)) {
                         $arCurrentValues[$arMap[$k]] = "";
                     }
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     if (strlen($arCurrentValues['status_message']) <= 0) {
         $arCurrentValues['status_message'] = GetMessage("BPAR_ACT_INFO");
     }
     if (strlen($arCurrentValues['comment_label_message']) <= 0) {
         $arCurrentValues['comment_label_message'] = GetMessage("BPAR_ACT_COMMENT");
     }
     if (strlen($arCurrentValues['task_button_message']) <= 0) {
         $arCurrentValues['task_button_message'] = GetMessage("BPAR_ACT_BUTTON2");
     }
     if (strlen($arCurrentValues["timeout_duration_type"]) <= 0) {
         $arCurrentValues["timeout_duration_type"] = "s";
     }
     $documentService = $runtime->GetService("DocumentService");
     $arDocumentFields = $documentService->GetDocumentFields($documentType);
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "arDocumentFields" => $arDocumentFields, "formName" => $formName));
 }
 public static function GetPropertiesDialog($documentType, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $defaultValue, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arDocumentFieldsTmp = $documentService->GetDocumentFields($documentType);
     $arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         if (is_array($defaultValue)) {
             $i = 0;
             foreach ($defaultValue as $value) {
                 if (strlen($arCurrentValues["field_condition_count"]) > 0) {
                     $arCurrentValues["field_condition_count"] .= ",";
                 }
                 $arCurrentValues["field_condition_count"] .= $i;
                 $arCurrentValues["field_condition_field_" . $i] = $value[0];
                 $arCurrentValues["field_condition_condition_" . $i] = $value[1];
                 $arCurrentValues["field_condition_value_" . $i] = $value[2];
                 $arCurrentValues["field_condition_joiner_" . $i] = $value[3];
                 if ($arDocumentFieldsTmp[$arCurrentValues["field_condition_field_" . $i]]["BaseType"] == "user" && $arDocumentFieldsTmp[$arCurrentValues["field_condition_field_" . $i]]["Type"] != 'S:employee') {
                     if (!is_array($arCurrentValues["field_condition_value_" . $i])) {
                         $arCurrentValues["field_condition_value_" . $i] = array($arCurrentValues["field_condition_value_" . $i]);
                     }
                     $arCurrentValues["field_condition_value_" . $i] = CBPHelper::UsersArrayToString($arCurrentValues["field_condition_value_" . $i], $arWorkflowTemplate, $documentType);
                 }
                 $i++;
             }
         }
     } else {
         $arFieldConditionCount = explode(",", $arCurrentValues["field_condition_count"]);
         foreach ($arFieldConditionCount as $i) {
             if (intval($i) . "!" != $i . "!") {
                 continue;
             }
             $i = intval($i);
             if (!array_key_exists("field_condition_field_" . $i, $arCurrentValues) || strlen($arCurrentValues["field_condition_field_" . $i]) <= 0) {
                 continue;
             }
             $arErrors = array();
             $arCurrentValues["field_condition_value_" . $i] = $documentService->GetFieldInputValue($documentType, $arDocumentFieldsTmp[$arCurrentValues["field_condition_field_" . $i]], "field_condition_value_" . $i, $arCurrentValues, $arErrors);
         }
     }
     $arDocumentFields = array();
     foreach ($arDocumentFieldsTmp as $key => $value) {
         //if (!$value["Filterable"])
         //	continue;
         $arDocumentFields[$key] = $value;
     }
     $javascriptFunctions = $documentService->GetJSFunctionsForFields($documentType, "objFieldsFC", $arDocumentFields, $arFieldTypes);
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arDocumentFields" => $arDocumentFields, "arCurrentValues" => $arCurrentValues, "formName" => $formName, "arFieldTypes" => $arFieldTypes, "javascriptFunctions" => $javascriptFunctions, 'documentService' => $documentService, 'documentType' => $documentType));
 }
Exemple #7
0
 public static function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
 {
     $result = $fieldValue;
     switch ($arFieldType['Type']) {
         case "user":
             $result = CBPHelper::UsersArrayToString($fieldValue, null, $documentType);
             break;
         case "bool":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $result[] = strtoupper($r) == "Y" ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
                 }
             } else {
                 $result = strtoupper($fieldValue) == "Y" ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
             }
             break;
         case "file":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $r = intval($r);
                     $dbImg = CFile::GetByID($r);
                     if ($arImg = $dbImg->Fetch()) {
                         $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $fieldValue = intval($fieldValue);
                 $dbImg = CFile::GetByID($fieldValue);
                 if ($arImg = $dbImg->Fetch()) {
                     $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                 }
             }
             break;
         case "select":
             if (isset($arFieldType["Options"][$fieldValue])) {
                 $result = $arFieldType["Options"][$fieldValue];
             }
             break;
     }
     return $result;
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "", $popupWindow = null)
 {
     $runtime = CBPRuntime::GetRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arMap = array("Users" => "requested_users", "OverdueDate" => "requested_overdue_date", "Name" => "requested_name", "Description" => "requested_description", "Parameters" => "requested_parameters", "RequestedInformation" => "requested_information", "TaskButtonMessage" => "task_button_message", "CommentLabelMessage" => "comment_label_message", "ShowComment" => "show_comment", "StatusMessage" => "status_message", "SetStatusMessage" => "set_status_message", 'AccessControl' => 'access_control', "TimeoutDuration" => "timeout_duration", "TimeoutDurationType" => "timeout_duration_type");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "Users") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     $arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);
     $arDocumentFields = $documentService->GetDocumentFields($documentType);
     $ar = array();
     $j = -1;
     if (array_key_exists("requested_information", $arCurrentValues) && is_array($arCurrentValues["requested_information"])) {
         for ($i = 0, $cnt = count($arCurrentValues["requested_information"]) + 1; $i < $cnt; $i++) {
             if (strlen($arCurrentValues["requested_information"][$i]["Name"]) <= 0) {
                 continue;
             }
             $j++;
             $ar[$j] = $arCurrentValues["requested_information"][$i];
             $ar[$j]["Required"] = $ar[$j]["Required"] ? "Y" : "N";
             $ar[$j]["Multiple"] = $ar[$j]["Multiple"] ? "Y" : "N";
         }
     }
     $arCurrentValues["requested_information"] = $ar;
     if (strlen($arCurrentValues['comment_label_message']) <= 0) {
         $arCurrentValues['comment_label_message'] = GetMessage("BPRIA_ACT_COMMENT");
     }
     if (strlen($arCurrentValues['task_button_message']) <= 0) {
         $arCurrentValues['task_button_message'] = GetMessage("BPRIA_ACT_BUTTON1");
     }
     if (strlen($arCurrentValues['status_message']) <= 0) {
         $arCurrentValues['status_message'] = GetMessage("BPRIA_ACT_INFO");
     }
     if (strlen($arCurrentValues["timeout_duration_type"]) <= 0) {
         $arCurrentValues["timeout_duration_type"] = "s";
     }
     $javascriptFunctions = $documentService->GetJSFunctionsForFields($documentType, "objFields", $arDocumentFields, $arFieldTypes);
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "arDocumentFields" => $arDocumentFields, "arFieldTypes" => $arFieldTypes, "javascriptFunctions" => $javascriptFunctions, "formName" => $formName, "popupWindow" => &$popupWindow));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("MailUserFrom" => "mail_user_from", "MailCrmEntityToArray" => "mail_crm_entity_to", "MailCrmEntityAddressType" => "mail_crm_entity_address_type", "MailSubject" => "mail_subject", "MailText" => "mail_text", "MailMessageType" => "mail_message_type", "MailCharset" => "mail_charset", "DirrectMail" => "dirrect_mail", "MailSite" => "mail_site");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "MailUserFrom") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k . "Array"], $arWorkflowTemplate, $documentType);
                         if (strlen($arCurrentValues[$arMap[$k]]) > 0 && strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= ", ";
                         }
                         if (strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= $arCurrentActivity["Properties"][$k];
                         }
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     if ($arCurrentValues['dirrect_mail'] != "Y" && $arCurrentValues['dirrect_mail'] != "N") {
         $arCurrentValues['dirrect_mail'] = "Y";
     }
     global $USER_FIELD_MANAGER;
     $arUserFieldType = $USER_FIELD_MANAGER->GetUserType('crm');
     $mailCrmEntityTo = is_array($arCurrentValues) && isset($arCurrentValues['mail_crm_entity_to']) && is_array($arCurrentValues['mail_crm_entity_to']) ? $arCurrentValues['mail_crm_entity_to'] : array();
     $arCurrentValues['mail_crm_entity_to_text'] = '';
     $entityKeyCount = count($mailCrmEntityTo);
     if ($entityKeyCount > 0 && !CCrmEntityHelper::IsEntityKey($mailCrmEntityTo[$entityKeyCount - 1])) {
         $arCurrentValues['mail_crm_entity_to_text'] = array_pop($mailCrmEntityTo);
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, 'crmEntityToUserField' => array('ENTITY_ID' => 'CRM_' . $documentType[2], 'FIELD_NAME' => 'mail_crm_entity_to', 'USER_TYPE_ID' => 'crm', 'SORT' => 100, 'MULTIPLE' => 'Y', 'MANDATORY' => 'Y', 'EDIT_IN_LIST' => 'Y', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $mailCrmEntityTo, 'USER_TYPE' => $arUserFieldType, 'SETTINGS' => array('LEAD' => 'Y', 'CONTACT' => 'Y', 'COMPANY' => 'Y', 'DEAL' => 'N')), 'crmEntityAddressTypes' => CCrmFieldMulti::GetEntityTypeList('EMAIL', false)));
 }
Exemple #10
0
 function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
 {
     $result = $fieldValue;
     switch ($arFieldType['Type']) {
         case "user":
             if (!is_array($fieldValue)) {
                 $fieldValue = array($fieldValue);
             }
             $result = CBPHelper::UsersArrayToString($fieldValue, null, array("iblock", "CIBlockDocument", $documentType));
             break;
         case "bool":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
                 }
             } else {
                 $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
             }
             break;
         case "file":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $r = intval($r);
                     $dbImg = CFile::GetByID($r);
                     if ($arImg = $dbImg->Fetch()) {
                         $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $fieldValue = intval($fieldValue);
                 $dbImg = CFile::GetByID($fieldValue);
                 if ($arImg = $dbImg->Fetch()) {
                     $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "&h=" . md5($arImg["SUBDIR"]) . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                 }
             }
             break;
         case "select":
             if (is_array($arFieldType["Options"])) {
                 if (is_array($fieldValue)) {
                     $result = array();
                     foreach ($fieldValue as $r) {
                         if (array_key_exists($r, $arFieldType["Options"])) {
                             $result[] = $arFieldType["Options"][$r];
                         }
                     }
                 } else {
                     if (array_key_exists($fieldValue, $arFieldType["Options"])) {
                         $result = $arFieldType["Options"][$fieldValue];
                     }
                 }
             }
             break;
     }
     if (strpos($arFieldType['Type'], ":") !== false) {
         if ($arFieldType["Type"] == "S:employee") {
             $fieldValue = CBPHelper::StripUserPrefix($fieldValue);
         }
         $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2));
         if (array_key_exists("GetPublicViewHTML", $arCustomType)) {
             if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $value) {
                     $r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), ""));
                     $result[] = HTMLToTxt($r);
                 }
             } else {
                 $result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), ""));
                 $result = HTMLToTxt($result);
             }
         }
     }
     return $result;
 }
		</td>
	</tr>
	<?php 
$tabControl->BeginNextTab();
$permissions = $_POST['arWorkflowTemplate'][0]['Properties']['Permission'];
if (!empty($arAllowableOperations)) {
    foreach ($arAllowableOperations as $op_id => $op_name) {
        $parameterKeyExt = 'P' . $op_id;
        ?>
<tr>
	<td valign="top"><?php 
        echo htmlspecialcharsbx($op_name);
        ?>
:</td>
	<td valign="top"><?php 
        $usersP = htmlspecialcharsbx(CBPHelper::UsersArrayToString($permissions[$op_id], $_POST['arWorkflowTemplate'], array(MODULE_ID, ENTITY, $_POST['document_type'])));
        ?>
	<textarea name="<?php 
        echo $parameterKeyExt;
        ?>
" id="id_<?php 
        echo $parameterKeyExt;
        ?>
" rows="4" cols="50"><?php 
        echo $usersP;
        ?>
</textarea>
	<input type="button" value="..." onclick="BPAShowSelector('id_<?php 
        echo $parameterKeyExt;
        ?>
', 'user', 'all', {'arWorkflowParameters': WFSAllData['P'], 'arWorkflowVariables': WFSAllData['V'], 'arWorkflowConstants': WFSAllData['C']});" style="vertical-align: top; margin-left: 2px"/>
Exemple #12
0
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     $documentService = $runtime->GetService("DocumentService");
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"]) && array_key_exists("Fields", $arCurrentActivity["Properties"]) && is_array($arCurrentActivity["Properties"]["Fields"])) {
             foreach ($arCurrentActivity["Properties"]["Fields"] as $k => $v) {
                 $arCurrentValues[$k] = $v;
                 if (in_array($k, array("CREATED_BY", "RESPONSIBLE_ID", "ACCOMPLICES", "AUDITORS"))) {
                     if (!is_array($arCurrentValues[$k])) {
                         $arCurrentValues[$k] = array($arCurrentValues[$k]);
                     }
                     $ar = array();
                     foreach ($arCurrentValues[$k] as $val) {
                         if (intval($val) . "!" == $val . "!") {
                             $val = "user_" . $val;
                         }
                         $ar[] = $val;
                     }
                     $arCurrentValues[$k] = CBPHelper::UsersArrayToString($ar, $arWorkflowTemplate, $documentType);
                 }
                 if ('UF_TASK_WEBDAV_FILES' == $k && is_array($arCurrentValues[$k]) && CModule::IncludeModule("disk") && \Bitrix\Disk\Configuration::isSuccessfullyConverted()) {
                     foreach ($arCurrentValues[$k] as $key => $fileId) {
                         if (!empty($fileId) && is_string($fileId) && substr($fileId, 0, 1) != 'n') {
                             $item = \Bitrix\Disk\Internals\FileTable::getList(array('select' => array('ID'), 'filter' => array('=XML_ID' => $fileId, 'TYPE' => \Bitrix\Disk\Internals\FileTable::TYPE_FILE)))->fetch();
                             if ($item) {
                                 $arCurrentValues[$k][$key] = 'n' . $item['ID'];
                             }
                         }
                     }
                     unset($fileId);
                 }
             }
         }
         $arCurrentValues["HOLD_TO_CLOSE"] = $arCurrentActivity["Properties"]["HoldToClose"] ? "Y" : "N";
         $arCurrentValues["AUTO_LINK_TO_CRM_ENTITY"] = $arCurrentActivity["Properties"]["AUTO_LINK_TO_CRM_ENTITY"] ? "Y" : "N";
     } else {
         foreach (static::$arAllowedTasksFieldNames as $field) {
             if ((!is_array($arCurrentValues[$field]) && strlen($arCurrentValues[$field]) <= 0 || is_array($arCurrentValues[$field]) && count($arCurrentValues[$field]) <= 0) && strlen($arCurrentValues[$field . "_text"]) > 0) {
                 $arCurrentValues[$field] = $arCurrentValues[$field . "_text"];
             }
         }
     }
     $arDocumentFields = self::__GetFields();
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, "documentType" => $documentType, "popupWindow" => &$popupWindow, "arDocumentFields" => $arDocumentFields));
 }
	public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
	{
		$runtime = CBPRuntime::GetRuntime();

		$arMap = array(
			"GroupName" => "group_name",
			"OwnerId" => "owner_id",
			"Users" => 'users'
		);

		if (!is_array($arCurrentValues))
		{
			$arCurrentActivity = &CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
			if (is_array($arCurrentActivity["Properties"]))
			{
				foreach ($arMap as $k => $v)
				{
					if (array_key_exists($k, $arCurrentActivity["Properties"]))
					{
						if ($k == "OwnerId" || $k == "Users")
							$arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
						else
							$arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
					}
					else
					{
						$arCurrentValues[$arMap[$k]] = "";
					}
				}
			}
			else
			{
				foreach ($arMap as $k => $v)
					$arCurrentValues[$arMap[$k]] = "";
			}
		}

		return $runtime->ExecuteResourceFile(
			__FILE__,
			"properties_dialog.php",
			array(
				"arCurrentValues" => $arCurrentValues,
				"formName" => $formName,
			)
		);
	}
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $currentParent =& CBPWorkflowTemplateLoader::FindParentActivityByName($arWorkflowTemplate, $activityName);
     $c = count($currentParent['Children']);
     $allowSetStatus = $c == 1 || $currentParent['Children'][$c - 1]["Type"] == 'SetStateActivity';
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"]) && array_key_exists("Permission", $arCurrentActivity["Properties"])) {
             $arCurrentValues["permission"] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"]["Permission"], $arWorkflowTemplate, $documentType);
         }
         if ($c > 1 && $currentParent['Children'][$c - 1]["Type"] == 'SetStateActivity') {
             $arCurrentValues["setstate"] = $currentParent['Children'][$c - 1]["Properties"]["TargetStateName"];
         }
     }
     $arStates = array();
     if ($allowSetStatus) {
         $arStates = CBPWorkflowTemplateLoader::GetStatesOfTemplate($arWorkflowTemplate);
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, "allowSetStatus" => $allowSetStatus, "arStates" => $arStates));
 }
Exemple #15
0
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     $arMap = array("MailUserFrom" => "mail_user_from", "MailUserTo" => "mail_user_to", "MailSubject" => "mail_subject", "MailText" => "mail_text", "MailMessageType" => "mail_message_type", "MailCharset" => "mail_charset", "DirrectMail" => "dirrect_mail", "MailSite" => "mail_site");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "MailUserFrom" || $k == "MailUserTo") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k . "Array"], $arWorkflowTemplate, $documentType);
                         if (strlen($arCurrentValues[$arMap[$k]]) > 0 && strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= ", ";
                         }
                         if (strlen($arCurrentActivity["Properties"][$k]) > 0) {
                             $arCurrentValues[$arMap[$k]] .= $arCurrentActivity["Properties"][$k];
                         }
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     if ($arCurrentValues['dirrect_mail'] != "Y" && $arCurrentValues['dirrect_mail'] != "N") {
         $arCurrentValues['dirrect_mail'] = "Y";
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName));
 }
 function GetFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
 {
     if ($storage = self::needProxyToDiskByDocType($documentType)) {
         return self::proxyToDisk(__FUNCTION__, array(\Bitrix\Disk\BizProcDocumentCompatible::generateDocumentType($storage->getId()), $arFieldType, $fieldValue));
     }
     $result = $fieldValue;
     switch ($arFieldType['Type']) {
         case "user":
             if (!is_array($fieldValue)) {
                 $fieldValue = array($fieldValue);
             }
             $result = CBPHelper::UsersArrayToString($fieldValue, null, array("webdav", "CIBlockDocumentWebdavSocnet", $documentType));
             break;
         case "bool":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
                 }
             } else {
                 $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO");
             }
             break;
         case "file":
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $r = intval($r);
                     $dbImg = CFile::GetByID($r);
                     if ($arImg = $dbImg->Fetch()) {
                         $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $fieldValue = intval($fieldValue);
                 $dbImg = CFile::GetByID($fieldValue);
                 if ($arImg = $dbImg->Fetch()) {
                     $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                 }
             }
             break;
         case "select":
             if (is_array($arFieldType["Options"])) {
                 if (is_array($fieldValue)) {
                     $result = array();
                     foreach ($fieldValue as $r) {
                         if (array_key_exists($r, $arFieldType["Options"])) {
                             $result[] = $arFieldType["Options"][$r];
                         }
                     }
                 } else {
                     if (array_key_exists($fieldValue, $arFieldType["Options"])) {
                         $result = $arFieldType["Options"][$fieldValue];
                     }
                 }
             }
             break;
     }
     if (strpos($arFieldType['Type'], ":") !== false) {
         $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType['Type'], 2));
         if (array_key_exists("GetPublicViewHTML", $arCustomType)) {
             if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $value) {
                     $r = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value), ""));
                     $result[] = HTMLToTxt($r);
                 }
             } else {
                 $result = call_user_func_array($arCustomType["GetPublicViewHTML"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $fieldValue), ""));
                 $result = HTMLToTxt($result);
             }
         }
     }
     return $result;
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "", $popupWindow = null)
 {
     $runtime = CBPRuntime::GetRuntime();
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     $documentService = $runtime->GetService("DocumentService");
     $arDocumentFieldsTmp = $documentService->GetDocumentFields($documentType);
     $arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"]) && array_key_exists("Fields", $arCurrentActivity["Properties"]) && is_array($arCurrentActivity["Properties"]["Fields"])) {
             foreach ($arCurrentActivity["Properties"]["Fields"] as $k => $v) {
                 $arCurrentValues[$k] = $v;
                 if ($arDocumentFieldsTmp[$k]["BaseType"] == "user") {
                     if (!is_array($arCurrentValues[$k])) {
                         $arCurrentValues[$k] = array($arCurrentValues[$k]);
                     }
                     $ar = array();
                     foreach ($arCurrentValues[$k] as $v) {
                         if (intval($v) . "!" == $v . "!") {
                             $v = "user_" . $v;
                         }
                         $ar[] = $v;
                     }
                     $arCurrentValues[$k] = CBPHelper::UsersArrayToString($ar, $arWorkflowTemplate, $documentType);
                 }
             }
         }
     } else {
         foreach ($arDocumentFieldsTmp as $key => $value) {
             if (!$value["Editable"]) {
                 continue;
             }
             $arErrors = array();
             $arCurrentValues[$key] = $documentService->GetFieldInputValue($documentType, $value, $key, $arCurrentValues, $arErrors);
         }
     }
     $arDocumentFields = array();
     $defaultFieldValue = "";
     foreach ($arDocumentFieldsTmp as $key => $value) {
         if (!$value["Editable"]) {
             continue;
         }
         $arDocumentFields[$key] = $value;
         if (strlen($defaultFieldValue) <= 0) {
             $defaultFieldValue = $key;
         }
         /*if ($value["BaseType"] == "select" || $value["BaseType"] == "bool")
         		{
         			if (array_key_exists($key."_text", $arCurrentValues)
         				&& ($value["Multiple"] && count($arCurrentValues[$key."_text"]) > 0
         					|| !$value["Multiple"] && strlen($arCurrentValues[$key."_text"]) > 0)
         				)
         			{
         				$arCurrentValues[$key] = $arCurrentValues[$key."_text"];
         			}
         		}*/
     }
     $javascriptFunctions = $documentService->GetJSFunctionsForFields($documentType, "objFieldsCD", $arDocumentFields, $arFieldTypes);
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "arDocumentFields" => $arDocumentFields, "formName" => $formName, "defaultFieldValue" => $defaultFieldValue, "arFieldTypes" => $arFieldTypes, "javascriptFunctions" => $javascriptFunctions, "documentType" => $documentType, "popupWindow" => &$popupWindow));
 }
 public static function GetPropertiesDialog($documentType, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $defaultValue, $arCurrentValues = null, $formName = "")
 {
     if (count($arWorkflowParameters) <= 0 && count($arWorkflowVariables) <= 0) {
         return null;
     }
     $runtime = CBPRuntime::GetRuntime();
     $documentService = $runtime->GetService("DocumentService");
     $arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array();
         if (is_array($defaultValue)) {
             $i = 0;
             foreach ($defaultValue as $value) {
                 if (strlen($arCurrentValues["variable_condition_count"]) > 0) {
                     $arCurrentValues["variable_condition_count"] .= ",";
                 }
                 $arCurrentValues["variable_condition_count"] .= $i;
                 $arCurrentValues["variable_condition_field_" . $i] = $value[0];
                 $arCurrentValues["variable_condition_condition_" . $i] = $value[1];
                 $arCurrentValues["variable_condition_value_" . $i] = $value[2];
                 if (array_key_exists($value[0], $arWorkflowParameters)) {
                     if ($arFieldTypes[$arWorkflowParameters[$value[0]]["Type"]]["BaseType"] == "user") {
                         if (!is_array($arCurrentValues["variable_condition_value_" . $i])) {
                             $arCurrentValues["variable_condition_value_" . $i] = array($arCurrentValues["variable_condition_value_" . $i]);
                         }
                         $arCurrentValues["variable_condition_value_" . $i] = CBPHelper::UsersArrayToString($arCurrentValues["variable_condition_value_" . $i], $arWorkflowTemplate, $documentType);
                     }
                 } elseif (array_key_exists($value[0], $arWorkflowVariables)) {
                     if ($arFieldTypes[$arWorkflowVariables[$value[0]]["Type"]]["BaseType"] == "user") {
                         if (!is_array($arCurrentValues["variable_condition_value_" . $i])) {
                             $arCurrentValues["variable_condition_value_" . $i] = array($arCurrentValues["variable_condition_value_" . $i]);
                         }
                         $arCurrentValues["variable_condition_value_" . $i] = CBPHelper::UsersArrayToString($arCurrentValues["variable_condition_value_" . $i], $arWorkflowTemplate, $documentType);
                     }
                 }
                 $i++;
             }
         }
     } else {
         $arVariableConditionCount = explode(",", $arCurrentValues["variable_condition_count"]);
         foreach ($arVariableConditionCount as $i) {
             if (intval($i) . "!" != $i . "!") {
                 continue;
             }
             $i = intval($i);
             if (!array_key_exists("variable_condition_field_" . $i, $arCurrentValues) || strlen($arCurrentValues["variable_condition_field_" . $i]) <= 0) {
                 continue;
             }
             $n = $arCurrentValues["variable_condition_field_" . $i];
             $arErrors = array();
             $arCurrentValues["variable_condition_value_" . $i] = $documentService->GetFieldInputValue($documentType, array_key_exists($n, $arWorkflowParameters) ? $arWorkflowParameters[$n] : $arWorkflowVariables[$n], "variable_condition_value_" . $i, $arCurrentValues, $arErrors);
         }
     }
     $javascriptFunctions = $documentService->GetJSFunctionsForFields($documentType, "objFieldsPVC", $arWorkflowParameters + $arWorkflowVariables, $arFieldTypes);
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "arProperties" => $arWorkflowParameters, "arVariables" => $arWorkflowVariables, "formName" => $formName, "arFieldTypes" => $arFieldTypes, "javascriptFunctions" => $javascriptFunctions));
 }
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentValues = array("user_type" => "", "user_parameter" => "", "reserve_user_parameter" => "", "max_level" => 1, "skip_absent" => "Y");
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             $arCurrentValues["user_type"] = $arCurrentActivity["Properties"]["UserType"];
             $arCurrentValues["max_level"] = $arCurrentActivity["Properties"]["MaxLevel"];
             $arCurrentValues["user_parameter"] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"]["UserParameter"], $arWorkflowTemplate, $documentType);
             $arCurrentValues["reserve_user_parameter"] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"]["ReserveUserParameter"], $arWorkflowTemplate, $documentType);
             $arCurrentValues["skip_absent"] = array_key_exists("SkipAbsent", $arCurrentActivity["Properties"]) ? $arCurrentActivity["Properties"]["SkipAbsent"] : ($arCurrentActivity["Properties"]["UserType"] == "boss" ? "N" : "Y");
         }
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName));
 }
Exemple #20
0
 protected static function PreparePrintableValue($arDocumentID, $fieldName, $arFieldType, $fieldValue)
 {
     global $USER_FIELD_MANAGER, $APPLICATION;
     if (empty($arDocumentID)) {
         throw new CBPArgumentNullException('documentId');
     }
     $result = $fieldValue;
     switch ($arFieldType['Type']) {
         case 'date':
         case 'datetime':
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $_fieldValue) {
                     $result[] = empty($_fieldValue) ? FormatDate('x', MakeTimeStamp($_fieldValue)) : '';
                 }
             } else {
                 $result = !empty($fieldValue) ? FormatDate('x', MakeTimeStamp($fieldValue)) : '';
             }
             break;
         case 'user':
             if (!is_array($fieldValue)) {
                 $fieldValue = array($fieldValue);
             }
             $result = CBPHelper::UsersArrayToString($fieldValue, null, $arDocumentID["DOCUMENT_TYPE"]);
             break;
         case 'bool':
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $result[] = strtoupper($r) != "N" && !empty($r) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO');
                 }
             } else {
                 $result = strtoupper($fieldValue) != "N" && !empty($fieldValue) ? GetMessage('BPVDX_YES') : GetMessage('BPVDX_NO');
             }
             break;
         case 'file':
             if (is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $r) {
                     $r = intval($r);
                     $dbImg = CFile::GetByID($r);
                     if ($arImg = $dbImg->Fetch()) {
                         $result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $r . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $fieldValue = intval($fieldValue);
                 $dbImg = CFile::GetByID($fieldValue);
                 if ($arImg = $dbImg->Fetch()) {
                     $result = "[url=/bitrix/tools/bizproc_show_file.php?f=" . htmlspecialcharsbx($arImg["FILE_NAME"]) . "&i=" . $fieldValue . "]" . htmlspecialcharsbx($arImg["ORIGINAL_NAME"]) . "[/url]";
                 }
             }
             break;
         case 'select':
             if (is_array($arFieldType["Options"])) {
                 if (is_array($fieldValue)) {
                     $result = array();
                     foreach ($fieldValue as $r) {
                         if (array_key_exists($r, $arFieldType["Options"])) {
                             $result[] = $arFieldType["Options"][$r];
                         }
                     }
                 } else {
                     if (array_key_exists($fieldValue, $arFieldType["Options"])) {
                         $result = $arFieldType["Options"][$fieldValue];
                     }
                 }
             }
             break;
         case 'web':
         case 'im':
         case 'email':
         case 'phone':
             $result = array();
             if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue)) {
                 $fieldValue = $fieldValue[0];
             }
             if (is_array($fieldValue) && is_array($fieldValue[strtoupper($arFieldType['Type'])])) {
                 foreach ($fieldValue[strtoupper($arFieldType['Type'])] as $val) {
                     if (!empty($val)) {
                         $result[] = CCrmFieldMulti::GetEntityNameByComplex(strtoupper($arFieldType['Type']) . '_' . $val['VALUE_TYPE'], false) . ': ' . $val['VALUE'];
                     }
                 }
             }
             break;
     }
     if (strpos($arFieldType['Type'], 'UF:') === 0) {
         $sType = str_replace('UF:', '', $arFieldType['Type']);
         if ($sType === 'crm') {
             $options = isset($arFieldType['Options']) && is_array($arFieldType['Options']) ? $arFieldType['Options'] : array();
             $defaultTypeName = '';
             foreach ($options as $typeName => $flag) {
                 if ($flag === 'Y') {
                     $defaultTypeName = $typeName;
                     break;
                 }
             }
             if ($defaultTypeName === '') {
                 $defaultTypeName = 'LEAD';
             }
             if (isset($arFieldType['Multiple']) && $arFieldType['Multiple'] > 0 && is_array($fieldValue)) {
                 $result = array();
                 foreach ($fieldValue as $value) {
                     $result[] = self::PrepareCrmUserTypeValueView($value, $defaultTypeName);
                 }
             } else {
                 $result = self::PrepareCrmUserTypeValueView($fieldValue, $defaultTypeName);
             }
         } else {
             $arUserFieldType = $USER_FIELD_MANAGER->GetUserType($sType);
             $arUserField = array('ENTITY_ID' => 'CRM_LEAD', 'FIELD_NAME' => 'UF_XXXXXXX', 'USER_TYPE_ID' => $sType, 'SORT' => 100, 'MULTIPLE' => $arFieldType['Multiple'] ? 'Y' : 'N', 'MANDATORY' => $arFieldType['Required'] ? 'Y' : 'N', 'EDIT_FORM_LABEL' => $arUserFieldType['DESCRIPTION'], 'VALUE' => $fieldValue, 'USER_TYPE' => $arUserFieldType);
             if ($arFieldType['Type'] == 'UF:iblock_element' || $arFieldType['Type'] == 'UF:iblock_section') {
                 $arUserField['SETTINGS']['IBLOCK_ID'] = $arFieldType['Options'];
             } elseif ($arFieldType['Type'] == 'UF:crm_status') {
                 $arUserField['SETTINGS']['ENTITY_TYPE'] = $arFieldType['Options'];
             }
             ob_start();
             $APPLICATION->IncludeComponent('bitrix:system.field.view', $sType, array('arUserField' => $arUserField, 'bVarsFromForm' => false, 'form_name' => "", 'FILE_MAX_HEIGHT' => 400, 'FILE_MAX_WIDTH' => 400, 'FILE_SHOW_POPUP' => true), false, array('HIDE_ICONS' => 'Y'));
             $result = ob_get_contents();
             $result = HTMLToTxt($result);
             ob_end_clean();
         }
     }
     return $result;
 }
    public static function GetPropertiesDialog($documentType, $activityName, $workflowTemplate, $workflowParameters, $workflowVariables, $currentValues = null, $formName = "")
    {
        $runtime = CBPRuntime::GetRuntime();
        $map = array('AuthUserId', 'SetStatusMessage', 'StatusMessage', 'UseSubscription', 'TimeoutDuration', 'TimeoutDurationType');
        $activityData = self::getRestActivityData();
        $properties = isset($activityData['PROPERTIES']) && is_array($activityData['PROPERTIES']) ? $activityData['PROPERTIES'] : array();
        foreach ($properties as $name => $property) {
            if (!in_array($name, $map)) {
                $map[] = $name;
            }
        }
        if (!is_array($currentValues)) {
            $currentValues = array();
            $currentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($workflowTemplate, $activityName);
            if (is_array($currentActivity['Properties'])) {
                foreach ($map as $k) {
                    if (array_key_exists($k, $currentActivity['Properties'])) {
                        if ($k == 'AuthUserId') {
                            $currentValues[strtolower($k)] = CBPHelper::UsersArrayToString('user_' . $currentActivity['Properties'][$k], $workflowTemplate, $documentType);
                        } else {
                            $currentValues[strtolower($k)] = $currentActivity['Properties'][$k];
                        }
                    } else {
                        if (!is_array($currentValues) || !array_key_exists($map[$k], $currentValues)) {
                            $currentValues[strtolower($k)] = "";
                        }
                    }
                }
            } else {
                foreach ($map as $k) {
                    $currentValues[strtolower($k)] = "";
                }
            }
        }
        if (strlen($currentValues['statusmessage']) <= 0) {
            $currentValues['statusmessage'] = Loc::getMessage('BPRA_DEFAULT_STATUS_MESSAGE');
        }
        if (strlen($currentValues["timeoutdurationtype"]) <= 0) {
            $currentValues["timeoutdurationtype"] = "s";
        }
        if ((int) $currentValues["authuserid"] <= 0) {
            $currentValues["authuserid"] = CBPHelper::UsersArrayToString('user_' . $activityData['AUTH_USER_ID'], $workflowTemplate, $documentType);
        }
        if (!empty($activityData['USE_SUBSCRIPTION'])) {
            $currentValues['usesubscription'] = $activityData['USE_SUBSCRIPTION'];
        }
        /** @var CBPDocumentService $documentService */
        $documentService = $runtime->GetService("DocumentService");
        $activityDocumentType = is_array($activityData['DOCUMENT_TYPE']) ? $activityData['DOCUMENT_TYPE'] : $documentType;
        foreach ($properties as $name => $property) {
            $required = CBPHelper::getBool($property['REQUIRED']);
            $value = !CBPHelper::isEmptyValue($currentValues[strtolower($name)]) ? $currentValues[strtolower($name)] : $property['DEFAULT'];
            ?>
			<tr>
				<td align="right" width="40%" valign="top">
					<span class="<?php 
            echo $required ? 'adm-required-field' : '';
            ?>
">
						<?php 
            echo htmlspecialcharsbx(RestActivityTable::getLocalization($property['NAME'], LANGUAGE_ID));
            ?>
:
					</span>
					<?php 
            if (isset($property['DESCRIPTION'])) {
                ?>
					<br/><?php 
                echo htmlspecialcharsbx(RestActivityTable::getLocalization($property['DESCRIPTION'], LANGUAGE_ID));
                ?>
					<?php 
            }
            ?>
				</td>
				<td width="60%">
					<?php 
            echo $documentService->getFieldInputControl($activityDocumentType, $property, array('Field' => strtolower($name), 'Form' => $formName), $value, true, false);
            ?>
				</td>
			</tr>

		<?php 
        }
        if (static::checkAdminPermissions()) {
            ?>
			<tr>
				<td align="right" width="40%" valign="top"><span class=""><?php 
            echo Loc::getMessage("BPRA_PD_USER_ID");
            ?>
:</span></td>
				<td width="60%">
					<?php 
            echo CBPDocument::ShowParameterField("user", 'authuserid', $currentValues['authuserid'], array('rows' => '1'));
            ?>
				</td>
			</tr>
		<?php 
        }
        ?>
			<tr>
				<td align="right"><?php 
        echo Loc::getMessage("BPRA_PD_SET_STATUS_MESSAGE");
        ?>
:</td>
				<td>
					<select name="setstatusmessage">
						<option value="Y"<?php 
        echo $currentValues["setstatusmessage"] == "Y" ? " selected" : "";
        ?>
><?php 
        echo Loc::getMessage("BPRA_PD_YES");
        ?>
</option>
						<option value="N"<?php 
        echo $currentValues["setstatusmessage"] == "N" ? " selected" : "";
        ?>
><?php 
        echo Loc::getMessage("BPRA_PD_NO");
        ?>
</option>
					</select>
				</td>
			</tr>
			<tr>
				<td align="right"><?php 
        echo Loc::getMessage("BPRA_PD_STATUS_MESSAGE");
        ?>
:</td>
				<td valign="top"><?php 
        echo CBPDocument::ShowParameterField("string", 'statusmessage', $currentValues['statusmessage'], array('size' => '45'));
        ?>
</td>
			</tr>
			<tr>
				<td align="right"><?php 
        echo Loc::getMessage("BPRA_PD_USE_SUBSCRIPTION");
        ?>
:</td>
				<td>
					<select name="usesubscription" <?php 
        echo !empty($activityData['USE_SUBSCRIPTION']) ? 'disabled' : '';
        ?>
>
						<option value="Y"<?php 
        echo $currentValues["usesubscription"] == 'Y' ? " selected" : "";
        ?>
><?php 
        echo Loc::getMessage("BPRA_PD_YES");
        ?>
</option>
						<option value="N"<?php 
        echo $currentValues["usesubscription"] == 'N' ? " selected" : "";
        ?>
><?php 
        echo Loc::getMessage("BPRA_PD_NO");
        ?>
</option>
					</select>
				</td>
			</tr>
			<?php 
        if ($activityData['USE_SUBSCRIPTION'] != 'N') {
            ?>
			<tr>
				<td align="right"><?php 
            echo Loc::getMessage("BPRA_PD_TIMEOUT_DURATION");
            ?>
:<br/><?php 
            echo Loc::getMessage("BPRA_PD_TIMEOUT_DURATION_HINT");
            ?>
</td>
				<td valign="top">
					<input type="text" name="timeoutduration" id="id_timeoutduration" value="<?php 
            echo htmlspecialcharsbx($currentValues["timeoutduration"]);
            ?>
" size="20" />
					<input type="button" value="..." onclick="BPAShowSelector('id_timeoutduration', 'int');" />
					<select name="timeoutdurationtype">
						<option value="s"<?php 
            echo $currentValues["timeoutdurationtype"] == "s" ? " selected" : "";
            ?>
><?php 
            echo Loc::getMessage("BPRA_PD_TIME_S");
            ?>
</option>
						<option value="m"<?php 
            echo $currentValues["timeoutdurationtype"] == "m" ? " selected" : "";
            ?>
><?php 
            echo Loc::getMessage("BPRA_PD_TIME_M");
            ?>
</option>
						<option value="h"<?php 
            echo $currentValues["timeoutdurationtype"] == "h" ? " selected" : "";
            ?>
><?php 
            echo Loc::getMessage("BPRA_PD_TIME_H");
            ?>
</option>
						<option value="d"<?php 
            echo $currentValues["timeoutdurationtype"] == "d" ? " selected" : "";
            ?>
><?php 
            echo Loc::getMessage("BPRA_PD_TIME_D");
            ?>
</option>
					</select>
				</td>
			</tr>
			<?php 
        }
    }
Exemple #22
0
 public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
 {
     $runtime = CBPRuntime::GetRuntime();
     if (!CModule::IncludeModule("socialnetwork")) {
         return;
     }
     $arMap = array("TaskType" => "task_type", "TaskOwnerId" => "task_owner_id", "TaskCreatedBy" => "task_created_by", "TaskActiveFrom" => "task_active_from", "TaskActiveTo" => "task_active_to", "TaskName" => "task_name", "TaskDetailText" => "task_detail_text", "TaskPriority" => "task_priority", "TaskAssignedTo" => "task_assigned_to", "TaskTrackers" => "task_trackers", "TaskForumId" => "task_forum_id");
     if (!is_array($arWorkflowParameters)) {
         $arWorkflowParameters = array();
     }
     if (!is_array($arWorkflowVariables)) {
         $arWorkflowVariables = array();
     }
     if (!is_array($arCurrentValues)) {
         $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
         if (is_array($arCurrentActivity["Properties"])) {
             foreach ($arMap as $k => $v) {
                 if (array_key_exists($k, $arCurrentActivity["Properties"])) {
                     if ($k == "TaskCreatedBy" || $k == "TaskAssignedTo" || $k == "TaskTrackers") {
                         $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
                     } else {
                         $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
                     }
                 } else {
                     $arCurrentValues[$arMap[$k]] = "";
                 }
             }
         } else {
             foreach ($arMap as $k => $v) {
                 $arCurrentValues[$arMap[$k]] = "";
             }
         }
     }
     $arGroups = array();
     $db = CSocNetGroup::GetList(array("NAME" => "ASC"), array("ACTIVE" => "Y"), false, false, array("ID", "NAME"));
     while ($ar = $db->GetNext()) {
         $arGroups[$ar["ID"]] = $ar["NAME"];
     }
     $arTaskPriority = array();
     $db = CIBlockProperty::GetPropertyEnum("TaskPriority");
     while ($ar = $db->GetNext()) {
         $arTaskPriority[$ar["ID"]] = $ar["VALUE"];
     }
     $arForums = array();
     if (CModule::IncludeModule("forum")) {
         $db = CForumNew::GetListEx();
         while ($ar = $db->GetNext()) {
             $arForums[$ar["ID"]] = "[" . $ar["ID"] . "] " . $ar["NAME"];
         }
     }
     return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "formName" => $formName, "arGroups" => $arGroups, "arTaskPriority" => $arTaskPriority, "arForums" => $arForums));
 }