当前位置: 首页>>代码示例>>PHP>>正文


PHP CCrmContact::GetByID方法代码示例

本文整理汇总了PHP中CCrmContact::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCrmContact::GetByID方法的具体用法?PHP CCrmContact::GetByID怎么用?PHP CCrmContact::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCrmContact的用法示例。


在下文中一共展示了CCrmContact::GetByID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ResolveEntityInfo

 private static function ResolveEntityInfo($typeID, $ID)
 {
     $typeID = intval($typeID);
     $ID = intval($ID);
     if (!(CCrmOwnerType::IsDefined($typeID) && $ID > 0)) {
         return array('TYPE_ID' => $typeID, 'TYPE_NAME' => CCrmOwnerType::ResolveName($typeID), 'ID' => $ID);
     }
     $fields = null;
     if ($typeID === CCrmOwnerType::Lead) {
         $fields = CCrmLead::GetByID($ID, false);
     } elseif ($typeID === CCrmOwnerType::Contact) {
         $fields = CCrmContact::GetByID($ID, false);
     } elseif ($typeID === CCrmOwnerType::Company) {
         $fields = CCrmCompany::GetByID($ID, false);
     } elseif ($typeID === CCrmOwnerType::Deal) {
         $fields = CCrmDeal::GetByID($ID, false);
     }
     return array('TYPE_ID' => $typeID, 'TYPE_NAME' => CCrmOwnerType::ResolveName($typeID), 'ID' => $ID, 'FIELDS' => $fields);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:19,代码来源:template_mapper.php

示例2: PrepareCommunicationInfo

 public static function PrepareCommunicationInfo(&$arComm, $arFields = null)
 {
     if (!isset($arComm['ENTITY_SETTINGS'])) {
         if (!self::PrepareCommunicationSettings($arComm, $arFields)) {
             $arComm['TITLE'] = '';
             $arComm['DESCRIPTION'] = '';
             return false;
         }
     }
     $title = '';
     $description = '';
     $fullNameFormat = \Bitrix\Crm\Format\PersonNameFormatter::getFormat();
     $entityTypeID = isset($arComm['ENTITY_TYPE_ID']) ? intval($arComm['ENTITY_TYPE_ID']) : CCrmOwnerType::Undefined;
     if ($entityTypeID === CCrmOwnerType::Lead) {
         $name = '';
         $secondName = '';
         $lastName = '';
         $leadTitle = '';
         if (is_array($arComm['ENTITY_SETTINGS'])) {
             $settings = $arComm['ENTITY_SETTINGS'];
             $name = isset($settings['NAME']) ? $settings['NAME'] : '';
             $secondName = isset($settings['SECOND_NAME']) ? $settings['SECOND_NAME'] : '';
             $lastName = isset($settings['LAST_NAME']) ? $settings['LAST_NAME'] : '';
             $leadTitle = isset($settings['LEAD_TITLE']) ? $settings['LEAD_TITLE'] : '';
         } else {
             $arEntity = CCrmLead::GetByID($arComm['ENTITY_ID']);
             if ($arEntity) {
                 $name = isset($arEntity['NAME']) ? $arEntity['NAME'] : '';
                 $secondName = isset($arEntity['SECOND_NAME']) ? $arEntity['SECOND_NAME'] : '';
                 $lastName = isset($arEntity['LAST_NAME']) ? $arEntity['LAST_NAME'] : '';
                 $leadTitle = isset($arEntity['TITLE']) ? $arEntity['TITLE'] : '';
             }
         }
         if ($name === '' && $secondName === '' && $lastName === '') {
             $title = $leadTitle;
             //$description = '';
         } else {
             $title = CUser::FormatName($fullNameFormat, array('LOGIN' => '', 'NAME' => $name, 'SECOND_NAME' => $secondName, 'LAST_NAME' => $lastName), false, false);
             $description = $leadTitle;
         }
     } elseif ($entityTypeID === CCrmOwnerType::Contact) {
         // Empty TYPE is person to person communiation, empty ENTITY_ID is unbound communication - no method to build title
         if (!($arComm['TYPE'] === '' && intval($arComm['ENTITY_ID']) === 0)) {
             $name = '';
             $secondName = '';
             $lastName = '';
             $companyTitle = '';
             if (is_array($arComm['ENTITY_SETTINGS'])) {
                 $settings = $arComm['ENTITY_SETTINGS'];
                 $name = isset($settings['NAME']) ? $settings['NAME'] : '';
                 $secondName = isset($settings['SECOND_NAME']) ? $settings['SECOND_NAME'] : '';
                 $lastName = isset($settings['LAST_NAME']) ? $settings['LAST_NAME'] : '';
                 $companyTitle = isset($settings['COMPANY_TITLE']) ? $settings['COMPANY_TITLE'] : '';
             } else {
                 $arEntity = CCrmContact::GetByID($arComm['ENTITY_ID']);
                 if ($arEntity) {
                     $name = isset($arEntity['NAME']) ? $arEntity['NAME'] : '';
                     $secondName = isset($arEntity['SECOND_NAME']) ? $arEntity['SECOND_NAME'] : '';
                     $lastName = isset($arEntity['LAST_NAME']) ? $arEntity['LAST_NAME'] : '';
                     $companyTitle = isset($arEntity['COMPANY_TITLE']) ? $arEntity['COMPANY_TITLE'] : '';
                 }
             }
             $title = CUser::FormatName($fullNameFormat, array('LOGIN' => '', 'NAME' => $name, 'SECOND_NAME' => $secondName, 'LAST_NAME' => $lastName), false, false);
             $description = $companyTitle;
         }
     } elseif ($entityTypeID === CCrmOwnerType::Company) {
         if (is_array($arComm['ENTITY_SETTINGS'])) {
             $settings = $arComm['ENTITY_SETTINGS'];
             $title = isset($settings['COMPANY_TITLE']) ? $settings['COMPANY_TITLE'] : '';
         } else {
             $arEntity = CCrmCompany::GetByID($arComm['ENTITY_ID']);
             if ($arEntity) {
                 $title = isset($arEntity['TITLE']) ? $arEntity['TITLE'] : '';
             }
         }
     }
     $arComm['TITLE'] = $title;
     $arComm['DESCRIPTION'] = $description;
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:80,代码来源:crm_activity.php

示例3: RewriteClientFields

 public static function RewriteClientFields(&$arFields, $bDualFields = true)
 {
     $arCompany = $companyEMail = $companyPhone = null;
     $arContact = $contactEMail = $contactPhone = null;
     $companyId = isset($arFields['COMPANY_ID']) ? intval($arFields['COMPANY_ID']) : 0;
     $contactId = isset($arFields['CONTACT_ID']) ? intval($arFields['CONTACT_ID']) : 0;
     if ($companyId > 0) {
         $arCompany = CCrmCompany::GetByID($companyId);
         // Get multifields values (EMAIL and PHONE)
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('COMPANY', $companyId, 'EMAIL', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $companyEMail = $arFieldsMulti[0]['VALUE'];
         }
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('COMPANY', $companyId, 'PHONE', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $companyPhone = $arFieldsMulti[0]['VALUE'];
         }
         unset($arFieldsMulti);
     }
     if ($contactId > 0) {
         $arContact = CCrmContact::GetByID($contactId);
         // Get multifields values (EMAIL and PHONE)
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('CONTACT', $contactId, 'EMAIL', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $contactEMail = $arFieldsMulti[0]['VALUE'];
         }
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('CONTACT', $contactId, 'PHONE', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $contactPhone = $arFieldsMulti[0]['VALUE'];
         }
         unset($arFieldsMulti);
     }
     if ($companyId > 0) {
         if (is_array($arCompany) && count($arCompany) > 0) {
             foreach (self::$clientFields as $k) {
                 $v = '';
                 if ($k === 'CLIENT_TITLE') {
                     if (isset($arCompany['TITLE'])) {
                         $v = $arCompany['TITLE'];
                     }
                 } elseif ($k === 'CLIENT_CONTACT' && $contactId > 0) {
                     if (isset($arContact['FULL_NAME'])) {
                         $v = $arContact['FULL_NAME'];
                     }
                 } elseif ($k === 'CLIENT_ADDR') {
                     $v = Bitrix\Crm\Format\CompanyAddressFormatter::format($arCompany, array('TYPE_ID' => \Bitrix\Crm\EntityAddress::Registered));
                 } elseif ($k === 'CLIENT_EMAIL') {
                     $v = $contactEMail != '' ? $contactEMail : $companyEMail;
                 } elseif ($k === 'CLIENT_PHONE') {
                     $v = $contactPhone != '' ? $contactPhone : $companyPhone;
                 }
                 if ($bDualFields) {
                     $arFields['~' . $k] = $v;
                 }
                 $arFields[$k] = $bDualFields ? htmlspecialcharsbx($v) : $v;
             }
         }
     } elseif ($contactId > 0) {
         if (is_array($arContact) && count($arContact) > 0) {
             foreach (self::$clientFields as $k) {
                 $v = '';
                 if ($k === 'CLIENT_TITLE') {
                     if (isset($arContact['FULL_NAME'])) {
                         $v = $arContact['FULL_NAME'];
                     }
                 } elseif ($k === 'CLIENT_CONTACT' && $contactId > 0) {
                     $v = '';
                 } elseif ($k === 'CLIENT_ADDR') {
                     $v = Bitrix\Crm\Format\ContactAddressFormatter::format($arContact);
                 } elseif ($k === 'CLIENT_EMAIL') {
                     $v = $contactEMail;
                 } elseif ($k === 'CLIENT_PHONE') {
                     $v = $contactPhone;
                 }
                 if ($bDualFields) {
                     $arFields['~' . $k] = $v;
                 }
                 $arFields[$k] = $bDualFields ? htmlspecialcharsbx($v) : $v;
             }
         }
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:82,代码来源:crm_quote.php

示例4: GetCrmEntityCommunications

function GetCrmEntityCommunications($entityType, $entityID, $communicationType)
{
    $fullNameFormat = \Bitrix\Crm\Format\PersonNameFormatter::getFormat();
    if ($entityType === 'LEAD') {
        $data = array('ownerEntityType' => 'LEAD', 'ownerEntityId' => $entityID, 'entityType' => 'LEAD', 'entityId' => $entityID, 'entityTitle' => "{$entityType}_{$entityID}", 'entityDescription' => '', 'tabId' => 'main', 'communications' => array());
        $entity = CCrmLead::GetByID($entityID);
        if (!$entity) {
            return array('ERROR' => 'Invalid data');
        }
        // Prepare title
        $name = isset($entity['NAME']) ? $entity['NAME'] : '';
        $secondName = isset($entity['SECOND_NAME']) ? $entity['SECOND_NAME'] : '';
        $lastName = isset($entity['LAST_NAME']) ? $entity['LAST_NAME'] : '';
        if ($name !== '' || $secondName !== '' || $lastName !== '') {
            $data['entityTitle'] = CUser::FormatName($fullNameFormat, array('LOGIN' => '', 'NAME' => $name, 'SECOND_NAME' => $secondName, 'LAST_NAME' => $lastName), false, false);
            $data['entityDescription'] = isset($entity['TITLE']) ? $entity['TITLE'] : '';
        } else {
            $data['entityTitle'] = isset($entity['TITLE']) ? $entity['TITLE'] : '';
            $data['entityDescription'] = '';
        }
        // Try to load entity communications
        if (!CCrmActivity::CheckReadPermission(CCrmOwnerType::ResolveID($entityType), $entityID)) {
            return array('ERROR' => GetMessage('CRM_PERMISSION_DENIED'));
        }
        if ($communicationType !== '') {
            $dbResFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => $entityType, 'ELEMENT_ID' => $entityID, 'TYPE_ID' => $communicationType));
            while ($arField = $dbResFields->Fetch()) {
                if (empty($arField['VALUE'])) {
                    continue;
                }
                $comm = array('type' => $communicationType, 'value' => $arField['VALUE']);
                $data['communications'][] = $comm;
            }
        }
        return array('DATA' => array('TABS' => array(array('id' => 'lead', 'title' => GetMessage('CRM_COMMUNICATION_TAB_LEAD'), 'active' => true, 'items' => array($data)))));
    } elseif ($entityType === 'DEAL') {
        $entity = CCrmDeal::GetByID($entityID);
        if (!$entity) {
            return array('ERROR' => 'Invalid data');
        }
        $dealData = array();
        // Prepare company data
        $entityCompanyData = null;
        $entityCompanyID = isset($entity['COMPANY_ID']) ? intval($entity['COMPANY_ID']) : 0;
        $entityCompany = $entityCompanyID > 0 ? CCrmCompany::GetByID($entityCompanyID) : null;
        if (is_array($entityCompany)) {
            $entityCompanyData = array('ownerEntityType' => 'DEAL', 'ownerEntityId' => $entityID, 'entityType' => 'COMPANY', 'entityId' => $entityCompanyID, 'entityTitle' => isset($entityCompany['TITLE']) ? $entityCompany['TITLE'] : '', 'entityDescription' => '', 'communications' => array());
            if ($communicationType !== '') {
                $entityCompanyComms = CCrmActivity::PrepareCommunications('COMPANY', $entityCompanyID, $communicationType);
                foreach ($entityCompanyComms as &$entityCompanyComm) {
                    $comm = array('type' => $entityCompanyComm['TYPE'], 'value' => $entityCompanyComm['VALUE']);
                    $entityCompanyData['communications'][] = $comm;
                }
                unset($entityCompanyComm);
            }
        }
        // Try to get contact of deal
        $entityContactID = isset($entity['CONTACT_ID']) ? intval($entity['CONTACT_ID']) : 0;
        if ($entityContactID > 0) {
            $entityContact = CCrmContact::GetByID($entityContactID);
            if (is_array($entityContact)) {
                $item = array('ownerEntityType' => 'DEAL', 'ownerEntityId' => $entityID, 'entityType' => 'CONTACT', 'entityId' => $entityContactID, 'entityTitle' => CUser::FormatName($fullNameFormat, array('LOGIN' => '', 'NAME' => $entityContact['NAME'], 'LAST_NAME' => $entityContact['LAST_NAME'], 'SECOND_NAME' => $entityContact['SECOND_NAME']), false, false), 'tabId' => 'deal', 'communications' => array());
                $entityCompany = isset($entityContact['COMPANY_ID']) ? CCrmCompany::GetByID($entityContact['COMPANY_ID']) : null;
                if ($entityCompany && isset($entityCompany['TITLE'])) {
                    $item['entityDescription'] = $entityCompany['TITLE'];
                }
                if ($communicationType !== '') {
                    $entityContactComms = CCrmActivity::PrepareCommunications('CONTACT', $entityContactID, $communicationType);
                    foreach ($entityContactComms as &$entityContactComm) {
                        $comm = array('type' => $entityContactComm['TYPE'], 'value' => $entityContactComm['VALUE']);
                        $item['communications'][] = $comm;
                    }
                    unset($entityContactComm);
                }
                if ($communicationType === '' || !empty($item['communications'])) {
                    $dealData["CONTACT_{$entityContactID}"] = $item;
                }
            }
        }
        if ($entityCompanyData && !empty($entityCompanyData['communications'])) {
            $dealData['COMPANY_' . $entityCompanyID] = $entityCompanyData;
            $dealData['COMPANY_' . $entityCompanyID]['tabId'] = 'deal';
        }
        // Try to get previous communications
        $entityComms = CCrmActivity::GetCommunicationsByOwner('DEAL', $entityID, $communicationType);
        foreach ($entityComms as &$entityComm) {
            CCrmActivity::PrepareCommunicationInfo($entityComm);
            $key = "{$entityComm['ENTITY_TYPE']}_{$entityComm['ENTITY_ID']}";
            if (!isset($dealData[$key])) {
                $dealData[$key] = array('ownerEntityType' => 'DEAL', 'ownerEntityId' => $entityID, 'entityType' => CCrmOwnerType::ResolveName($entityComm['ENTITY_TYPE_ID']), 'entityId' => $entityComm['ENTITY_ID'], 'entityTitle' => isset($entityComm['TITLE']) ? $entityComm['TITLE'] : '', 'entityDescription' => isset($entityComm['DESCRIPTION']) ? $entityComm['DESCRIPTION'] : '', 'tabId' => 'deal', 'communications' => array());
            }
            if ($communicationType !== '') {
                $commFound = false;
                foreach ($dealData[$key]['communications'] as &$comm) {
                    if ($comm['value'] === $entityComm['VALUE']) {
                        $commFound = true;
                        break;
                    }
                }
                unset($comm);
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:ajax.php

示例5: unset

             unset($item);
         } else {
             $companyComms = CCrmActivity::PrepareCommunications(CCrmOwnerType::CompanyName, $companyID, $commType);
             foreach ($companyComms as &$comm) {
                 $item['COMMUNICATIONS'][] = array('TYPE' => $comm['TYPE'], 'VALUE' => $comm['VALUE']);
             }
             unset($comm);
             if (!empty($item['COMMUNICATIONS'])) {
                 $items[$companyKey] =& $item;
             }
             unset($item);
         }
     }
 }
 $contactID = isset($entity['UF_CONTACT_ID']) ? intval($entity['UF_CONTACT_ID']) : 0;
 $contact = $contactID > 0 ? CCrmContact::GetByID($contactID, true) : null;
 if (is_array($contact)) {
     $info = array('ENTITY_TYPE_ID' => CCrmOwnerType::Contact, 'ENTITY_ID' => $contactID);
     if (CCrmActivity::PrepareCommunicationInfo($info, $contact)) {
         $contactKey = "CONTACT_{$contactID}";
         $item = array('OWNER_ID' => $contactID, 'OWNER_TYPE_ID' => CCrmOwnerType::Contact, 'TITLE' => $info['TITLE'], 'DESCRIPTION' => $info['DESCRIPTION'], 'IMAGE_URL' => CCrmMobileHelper::PrepareContactImageUrl($contact, array('WIDTH' => 40, 'HEIGHT' => 40)), 'COMMUNICATIONS' => array());
         if ($commType === 'PERSON') {
             $items[$contactKey] =& $item;
             unset($item);
         } else {
             $contactComms = CCrmActivity::PrepareCommunications('CONTACT', $contactID, $commType);
             foreach ($contactComms as &$comm) {
                 $item['COMMUNICATIONS'][] = array('TYPE' => $comm['TYPE'], 'VALUE' => $comm['VALUE']);
             }
             unset($comm);
             if (!empty($item['COMMUNICATIONS'])) {
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例6: __RewritePayerInfo

 public static function __RewritePayerInfo($companyId, $contactId, &$arInvoiceProperties)
 {
     $arCompany = $companyEMail = $companyPhone = null;
     $arContact = $contactEMail = $contactPhone = null;
     if ($companyId > 0) {
         $arCompany = CCrmCompany::GetByID($companyId);
         // Get multifields values (EMAIL and PHONE)
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('COMPANY', $companyId, 'EMAIL', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $companyEMail = $arFieldsMulti[0]['VALUE'];
         }
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('COMPANY', $companyId, 'PHONE', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $companyPhone = $arFieldsMulti[0]['VALUE'];
         }
         unset($arFieldsMulti);
     }
     if ($contactId > 0) {
         $arContact = CCrmContact::GetByID($contactId);
         // Get multifields values (EMAIL and PHONE)
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('CONTACT', $contactId, 'EMAIL', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $contactEMail = $arFieldsMulti[0]['VALUE'];
         }
         $arFieldsMulti = CCrmFieldMulti::GetEntityFields('CONTACT', $contactId, 'PHONE', true, false);
         if (is_array($arFieldsMulti) && isset($arFieldsMulti[0]['VALUE'])) {
             $contactPhone = $arFieldsMulti[0]['VALUE'];
         }
         unset($arFieldsMulti);
     }
     if ($companyId > 0) {
         if (is_array($arCompany) && count($arCompany) > 0) {
             foreach ($arInvoiceProperties as $propertyKey => $property) {
                 $curVal = $arInvoiceProperties[$propertyKey]['VALUE'];
                 if ($property['FIELDS']['CODE'] === 'COMPANY' || $property['FIELDS']['CODE'] === 'COMPANY_NAME') {
                     if (isset($arCompany['TITLE'])) {
                         $curVal = $arCompany['TITLE'];
                     }
                 } elseif ($property['FIELDS']['CODE'] === 'CONTACT_PERSON' && $contactId > 0) {
                     if (isset($arContact['FULL_NAME'])) {
                         $curVal = $arContact['FULL_NAME'];
                     }
                 } elseif ($property['FIELDS']['CODE'] === 'COMPANY_ADR') {
                     $curVal = Bitrix\Crm\Format\CompanyAddressFormatter::format($arCompany, array('TYPE_ID' => \Bitrix\Crm\EntityAddress::Registered));
                 } elseif ($property['FIELDS']['CODE'] === 'INN') {
                     $todo = 'todo';
                     // TODO:
                 } elseif ($property['FIELDS']['CODE'] === 'KPP') {
                     $todo = 'todo';
                     // TODO:
                 } elseif ($property['FIELDS']['CODE'] === 'EMAIL') {
                     $curVal = $contactEMail != '' ? $contactEMail : $companyEMail;
                 } elseif ($property['FIELDS']['CODE'] === 'PHONE') {
                     $curVal = $contactPhone != '' ? $contactPhone : $companyPhone;
                 }
                 $arInvoiceProperties[$propertyKey]['VALUE'] = $curVal;
             }
         }
     } elseif ($contactId > 0) {
         if (is_array($arContact) && count($arContact) > 0) {
             foreach ($arInvoiceProperties as $propertyKey => $property) {
                 $curVal = $arInvoiceProperties[$propertyKey]['VALUE'];
                 if ($property['FIELDS']['CODE'] === 'FIO') {
                     if (isset($arContact['FULL_NAME'])) {
                         $curVal = $arContact['FULL_NAME'];
                     }
                 } elseif ($property['FIELDS']['CODE'] === 'EMAIL') {
                     $curVal = $contactEMail;
                 } elseif ($property['FIELDS']['CODE'] === 'PHONE') {
                     $curVal = $contactPhone;
                 } elseif ($property['FIELDS']['CODE'] === 'ADDRESS') {
                     $curVal = Bitrix\Crm\Format\ContactAddressFormatter::format($arContact);
                 }
                 $arInvoiceProperties[$propertyKey]['VALUE'] = $curVal;
             }
         }
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:78,代码来源:crm_invoice.php

示例7: TryInternalizeCrmEntityID

 private static function TryInternalizeCrmEntityID($type, $value, &$ID)
 {
     if (preg_match('/^\\[([A-Z]+)\\]/i', $value, $m) > 0) {
         $valueType = CCrmOwnerType::Undefined;
         $prefix = strtoupper($m[1]);
         if ($prefix === 'L') {
             $valueType = CCrmOwnerType::Lead;
         } elseif ($prefix === 'C') {
             $valueType = CCrmOwnerType::Contact;
         } elseif ($prefix === 'CO') {
             $valueType = CCrmOwnerType::Company;
         } elseif ($prefix === 'D') {
             $valueType = CCrmOwnerType::Deal;
         }
         if ($valueType !== CCrmOwnerType::Undefined && $valueType !== $type) {
             return false;
         }
         $value = substr($value, strlen($m[0]));
     }
     // 1. Try to interpret data as entity ID
     // 2. Try to interpret data as entity name
     if ($type === CCrmOwnerType::Lead) {
         if (is_numeric($value)) {
             $arEntity = CCrmLead::GetByID($value);
             if ($arEntity) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         }
         $rsEntities = CCrmLead::GetList(array(), array('=TITLE' => $value), array('ID'));
         while ($arEntity = $rsEntities->Fetch()) {
             $ID = intval($arEntity['ID']);
             return true;
         }
     } elseif ($type === CCrmOwnerType::Contact) {
         if (is_numeric($value)) {
             $arEntity = CCrmContact::GetByID($value);
             if ($arEntity) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         }
         // Try to interpret value as FULL_NAME
         $rsEntities = CCrmContact::GetListEx(array(), array('=FULL_NAME' => $value), false, false, array('ID'));
         while ($arEntity = $rsEntities->Fetch()) {
             $ID = intval($arEntity['ID']);
             return true;
         }
         if (preg_match('/\\s*([^\\s]+)\\s+([^\\s]+)\\s*/', $value, $match) > 0) {
             // Try to interpret value as '#NAME# #LAST_NAME#'
             $rsEntities = CCrmContact::GetListEx(array(), array('=NAME' => $match[1], '=LAST_NAME' => $match[2]), false, false, array('ID'));
             while ($arEntity = $rsEntities->Fetch()) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
             // Try to interpret value as '#LAST_NAME# #NAME#'
             $rsEntities = CCrmContact::GetListEx(array(), array('=LAST_NAME' => $match[1], '=NAME' => $match[2]), false, false, array('ID'));
             while ($arEntity = $rsEntities->Fetch()) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         } else {
             // Try to interpret value as '#LAST_NAME#'
             $rsEntities = CCrmContact::GetListEx(array(), array('=LAST_NAME' => $value), false, false, array('ID'));
             while ($arEntity = $rsEntities->Fetch()) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         }
     } elseif ($type === CCrmOwnerType::Company) {
         if (is_numeric($value)) {
             $arEntity = CCrmCompany::GetByID($value);
             if ($arEntity) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         }
         $rsEntities = CCrmCompany::GetList(array(), array('=TITLE' => $value), array('ID'));
         while ($arEntity = $rsEntities->Fetch()) {
             $ID = intval($arEntity['ID']);
             return true;
         }
     } elseif ($type === CCrmOwnerType::Deal) {
         if (is_numeric($value)) {
             $arEntity = CCrmDeal::GetByID($value);
             if ($arEntity) {
                 $ID = intval($arEntity['ID']);
                 return true;
             }
         }
         $rsEntities = CCrmDeal::GetList(array(), array('=TITLE' => $value), array('ID'));
         while ($arEntity = $rsEntities->Fetch()) {
             $ID = intval($arEntity['ID']);
             return true;
         }
     }
     return false;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:98,代码来源:crm_usertype.php


注:本文中的CCrmContact::GetByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。