CCrmOwnerType::ResolveID

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmOwnerType
  4. ResolveID
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_owner_type.php
  • Класс: \CCrmOwnerType
  • Вызов: CCrmOwnerType::ResolveID
static function ResolveID($name): int
{
	$name = mb_strtoupper(trim((string)$name));
	if($name === '')
	{
		return self::Undefined;
	}

	switch($name)
	{
		case CCrmOwnerTypeAbbr::Lead:
		case self::LeadName:
			return self::Lead;

		case CCrmOwnerTypeAbbr::Deal:
		case self::DealName:
			return self::Deal;

		case CCrmOwnerTypeAbbr::Contact:
		case self::ContactName:
			return self::Contact;

		case CCrmOwnerTypeAbbr::Company:
		case self::CompanyName:
			return self::Company;

		case CCrmOwnerTypeAbbr::Invoice:
		case self::InvoiceName:
			return self::Invoice;

		case self::ActivityName:
			return self::Activity;

		case CCrmOwnerTypeAbbr::Quote:
		case self::QuoteName:
			return self::Quote;

		case CCrmOwnerTypeAbbr::Order:
		case self::OrderName:
			return self::Order;

		case CCrmOwnerTypeAbbr::OrderPayment:
		case self::OrderPaymentName:
			return self::OrderPayment;

		case CCrmOwnerTypeAbbr::OrderShipment:
		case self::OrderShipmentName:
			return self::OrderShipment;

		case CCrmOwnerTypeAbbr::Requisite:
		case self::RequisiteName:
			return self::Requisite;

		case CCrmOwnerTypeAbbr::DealCategory:
		case self::DealCategoryName:
			return self::DealCategory;

		case self::DealRecurringName:
			return self::DealRecurring;

		case self::InvoiceRecurringName:
			return self::InvoiceRecurring;

		case CCrmOwnerTypeAbbr::CustomActivityType:
		case self::CustomActivityTypeName:
			return self::CustomActivityType;

		case self::CallListTypeName:
			return self::CallList;

		case CCrmOwnerTypeAbbr::SuspendedLead:
		case self::SuspendedLeadName:
			return self::SuspendedLead;

		case CCrmOwnerTypeAbbr::SuspendedDeal:
		case self::SuspendedDealName:
			return self::SuspendedDeal;

		case self::SuspendedContactName:
			return self::SuspendedContact;

		case self::SuspendedCompanyName:
			return self::SuspendedCompany;

		case self::SuspendedQuoteName:
			return self::SuspendedQuote;

		case self::SuspendedInvoiceName:
			return self::SuspendedInvoice;

		case self::SuspendedOrderName:
			return self::SuspendedOrder;

		case self::SuspendedActivityName:
			return self::SuspendedActivity;

		case self::ScoringName:
			return self::Scoring;

		case CCrmOwnerTypeAbbr::SmartInvoice:
		case self::SmartInvoiceName:
			return self::SmartInvoice;

		case CCrmOwnerTypeAbbr::SuspendedSmartInvoice:
		case self::SuspendedSmartInvoiceName:
			return self::SuspendedSmartInvoice;

		case CCrmOwnerTypeAbbr::SmartDocument:
		case self::SmartDocumentName:
			return self::SmartDocument;

		case CCrmOwnerTypeAbbr::SuspendedSmartDocument:
		case self::SuspendedSmartDocumentName:
			return self::SuspendedSmartDocument;

		case self::StoreDocumentName:
			return self::StoreDocument;

		case self::ShipmentDocumentName:
			return self::ShipmentDocument;

		case CCrmOwnerTypeAbbr::System:
		case self::SystemName:
			return self::System;

		case self::AgentContractDocumentName:
			return self::AgentContractDocument;

		default:
			if (CCrmOwnerTypeAbbr::isDynamicTypeAbbreviation($name) || CCrmOwnerTypeAbbr::isSuspendedDynamicTypeAbbreviation($name))
			{
				$name = CCrmOwnerTypeAbbr::ResolveName($name);
			}

			$isSuspendedDynamicType = false;
			$isDynamicType = preg_match('/^'.static::DynamicTypePrefixName.'(\d+)$/', $name, $matches);
			if(!$isDynamicType)
			{
				$isSuspendedDynamicType = preg_match('/^'.static::SuspendedDynamicTypePrefixName.'(\d+)$/', $name, $matches);
			}
			if($isDynamicType || $isSuspendedDynamicType)
			{
				return $matches[1];
			}

			return self::Undefined;
	}
}

Добавить комментарий