Esempio n. 1
0
 public function GetFieldInputValuePrintable($parameterDocumentType, $fieldType, $fieldValue)
 {
     list($moduleId, $entity, $documentType) = CBPHelper::ParseDocumentId($parameterDocumentType);
     if (strlen($moduleId) > 0) {
         CModule::IncludeModule($moduleId);
     }
     $arFieldType = FieldType::normalizeProperty($fieldType);
     if ((string) $arFieldType["Type"] == "") {
         return "";
     }
     $fieldTypeObject = $this->getFieldTypeObject($parameterDocumentType, $arFieldType);
     if ($fieldTypeObject) {
         return $fieldTypeObject->formatValue($fieldValue, 'printable');
     }
     if (class_exists($entity)) {
         if (method_exists($entity, "GetFieldInputValuePrintable")) {
             return call_user_func_array(array($entity, "GetFieldInputValuePrintable"), array($documentType, $arFieldType, $fieldValue));
         }
         if (method_exists($entity, "GetFieldValuePrintable")) {
             return call_user_func_array(array($entity, "GetFieldValuePrintable"), array(null, "", $arFieldType["Type"], $fieldValue, $arFieldType));
         }
     }
     return CBPHelper::GetFieldInputValuePrintable($parameterDocumentType, $arFieldType, $fieldValue);
 }
Esempio n. 2
0
 public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
 {
     $arErrors = array();
     $runtime = CBPRuntime::GetRuntime();
     $arProperties = array("FieldValue" => array());
     /** @var CBPDocumentService $documentService */
     $documentService = $runtime->GetService("DocumentService");
     $arNewFieldsMap = array();
     if (array_key_exists("new_field_name", $arCurrentValues) && is_array($arCurrentValues["new_field_name"])) {
         $arNewFieldKeys = array_keys($arCurrentValues["new_field_name"]);
         foreach ($arNewFieldKeys as $k) {
             $code = trim($arCurrentValues["new_field_code"][$k]);
             $arFieldsTmp = array("name" => $arCurrentValues["new_field_name"][$k], "code" => $code, "type" => $arCurrentValues["new_field_type"][$k], "multiple" => $arCurrentValues["new_field_mult"][$k], "required" => $arCurrentValues["new_field_req"][$k], "options" => $arCurrentValues["new_field_options"][$k]);
             $newCode = $documentService->AddDocumentField($documentType, $arFieldsTmp);
             $property = FieldType::normalizeProperty($arFieldsTmp);
             $property['Code'] = $newCode;
             $property['Name'] = $arFieldsTmp['name'];
             $arNewFieldsMap[$code] = $property;
         }
     }
     $arDocumentFields = $documentService->GetDocumentFields($documentType);
     foreach ($arCurrentValues as $key => $value) {
         if (strpos($key, 'document_field_') !== 0) {
             continue;
         }
         $fieldKey = array_key_exists($value, $arNewFieldsMap) ? $arNewFieldsMap[$value]['Code'] : $value;
         if (!isset($arDocumentFields[$fieldKey]) || !$arDocumentFields[$fieldKey]["Editable"]) {
             continue;
         }
         $property = array_key_exists($value, $arNewFieldsMap) ? $arNewFieldsMap[$value] : $arDocumentFields[$fieldKey];
         $r = $documentService->GetFieldInputValue($documentType, $property, $value, $arCurrentValues, $arErrors);
         if (count($arErrors) > 0) {
             return false;
         }
         if (CBPHelper::getBool($property['Required']) && CBPHelper::isEmptyValue($r)) {
             $arErrors[] = array("code" => "NotExist", "parameter" => $fieldKey, "message" => GetMessage("BPSFA_ARGUMENT_NULL", array('#PARAM#' => $property['Name'])));
             return false;
         }
         $arProperties["FieldValue"][$fieldKey] = $r;
     }
     $arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
     if (count($arErrors) > 0) {
         return false;
     }
     $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
     $arCurrentActivity["Properties"] = $arProperties;
     return true;
 }