CAllCrmDeal::GetStartStageID

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmDeal
  4. GetStartStageID
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_deal.php
  • Класс: \CAllCrmDeal
  • Вызов: CAllCrmDeal::GetStartStageID
static function GetStartStageID($categoryID = 0, $permissionTypeID = 0, CCrmPerms $userPermissions = null)
{
	$categoryID = (int)$categoryID;
	$stageIDs = array_keys(self::GetStages($categoryID));
	if(empty($stageIDs))
	{
		return '';
	}

	$permissionType = Bitrix\Crm\Security\EntityPermissionType::resolveName($permissionTypeID);
	if($permissionType === '')
	{
		return $stageIDs[0];
	}

	if($userPermissions === null)
	{
		$userPermissions = CCrmPerms::GetCurrentUserPermissions();
	}

	$permissionEntity = DealCategory::convertToPermissionEntityType($categoryID);
	foreach($stageIDs as $stageID)
	{
		$permission = $userPermissions->GetPermType($permissionEntity, $permissionType, array("STAGE_ID{$stageID}"));
		if($permission !== BX_CRM_PERM_NONE)
		{
			return $stageID;
		}
	}
	return '';
}

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