...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_quote.php
- Класс: \CAllCrmQuote
- Вызов: CAllCrmQuote::CheckFields
public function CheckFields(&$arFields, $ID = false, $options = array()) { global $APPLICATION, $USER_FIELD_MANAGER, $DB; $this->LAST_ERROR = ''; /*if (($ID == false || isset($arFields['TITLE'])) && empty($arFields['TITLE'])) $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_IS_MISSING', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_TITLE')))."
\n";*/ if (isset($arFields['TITLE']) && mb_strlen($arFields['TITLE']) > 255) { $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_TITLE')))."
\n"; } if ($ID !== false && isset($arFields['QUOTE_NUMBER'])) { /*if (strlen($arFields['QUOTE_NUMBER']) <= 0) { $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_IS_MISSING', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_QUOTE_NUMBER_MSGVER_1')))."
\n"; } else*/ if (mb_strlen($arFields['QUOTE_NUMBER']) > 100) { $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_QUOTE_NUMBER_MSGVER_1')))."
\n"; } else { $dbres = $DB->Query("SELECT ID, QUOTE_NUMBER FROM b_crm_quote WHERE QUOTE_NUMBER = '".$DB->ForSql($arFields["QUOTE_NUMBER"])."'", true); if ($arRes = $dbres->GetNext()) { if (is_array($arRes) && $arRes["ID"] != $ID) { $this->LAST_ERROR .= GetMessage('CRM_ERROR_QUOTE_NUMBER_EXISTS_MSGVER_1')."
\n"; } } unset($arRes, $dbres); } } if (!empty($arFields['BEGINDATE']) && !CheckDateTime($arFields['BEGINDATE'])) $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_BEGINDATE')))."
\n"; if (!empty($arFields['CLOSEDATE']) && !CheckDateTime($arFields['CLOSEDATE'])) $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_CLOSEDATE')))."
\n"; if(is_string($arFields['OPPORTUNITY']) && $arFields['OPPORTUNITY'] !== '') { $arFields['OPPORTUNITY'] = str_replace(array(',', ' '), array('.', ''), $arFields['OPPORTUNITY']); //HACK: MSSQL returns '.00' for zero value if(mb_strpos($arFields['OPPORTUNITY'], '.') === 0) { $arFields['OPPORTUNITY'] = '0'.$arFields['OPPORTUNITY']; } if (!preg_match('/^\d{1,}(\.\d{1,})?$/', $arFields['OPPORTUNITY'])) { $this->LAST_ERROR .= GetMessage('CRM_QUOTE_FIELD_OPPORTUNITY_INVALID')."
\n"; } } // storage type id if(!isset($arFields['STORAGE_TYPE_ID']) || $arFields['STORAGE_TYPE_ID'] === CCrmQuoteStorageType::Undefined || !CCrmQuoteStorageType::IsDefined($arFields['STORAGE_TYPE_ID'])) { $arFields['STORAGE_TYPE_ID'] = self::GetDefaultStorageTypeID(); } foreach (self::$clientFields as $fieldName) { if (isset($arFields[$fieldName]) && mb_strlen($arFields[$fieldName]) > 255) $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', ['%FIELD_NAME%' => self::GetFieldCaption($fieldName)])."
\n"; } unset($fieldName); // check person type $personTypeId = 0; if (isset($arFields['PERSON_TYPE_ID'])) $personTypeId = intval($arFields['PERSON_TYPE_ID']); $arPersonTypes = CCrmPaySystem::getPersonTypeIDs(); $arPersonTypeEnum = array(); if (isset($arPersonTypes['CONTACT'])) $arPersonTypeEnum[] = intval($arPersonTypes['CONTACT']); if (isset($arPersonTypes['COMPANY'])) $arPersonTypeEnum[] = intval($arPersonTypes['COMPANY']); if ($personTypeId <= 0 || !in_array($personTypeId, $arPersonTypeEnum, true)) $this->LAST_ERROR .= GetMessage('CRM_ERROR_FIELD_INCORRECT', array('%FIELD_NAME%' => GetMessage('CRM_QUOTE_FIELD_PERSON_TYPE_ID')))."
\n"; unset($personTypeId, $arPersonTypes, $arPersonTypeEnum); if(!is_array($options)) { $options = array(); } $enableUserFieldCheck = !(isset($options['DISABLE_USER_FIELD_CHECK']) && $options['DISABLE_USER_FIELD_CHECK'] === true); if ($enableUserFieldCheck) { // We have to prepare field data before check (issue #22966) CCrmEntityHelper::NormalizeUserFields($arFields, self::$sUFEntityID, $USER_FIELD_MANAGER, array('IS_NEW' => ($ID == false))); $enableRequiredUserFieldCheck = !(isset($options['DISABLE_REQUIRED_USER_FIELD_CHECK']) && $options['DISABLE_REQUIRED_USER_FIELD_CHECK'] === true); if(!$USER_FIELD_MANAGER->CheckFields(self::$sUFEntityID, $ID, $arFields, false, $enableRequiredUserFieldCheck)) { $e = $APPLICATION->GetException(); $this->LAST_ERROR .= $e->GetString(); } } if ($this->LAST_ERROR <> '') return false; return true; }