FieldAttributeManager::processPhaseModification

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. FieldAttributeManager
  4. processPhaseModification
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/attribute/fieldattributemanager.php
  • Класс: Bitrix\Crm\Attribute\FieldAttributeManager
  • Вызов: FieldAttributeManager::processPhaseModification
static function processPhaseModification($phaseID, $entityTypeID, $entityScope, array $phases)
{
	if(!is_int($entityTypeID))
	{
		$entityTypeID = (int)$entityTypeID;
	}

	$connection = Main\HttpApplication::getConnection();
	$helper = $connection->getSqlHelper();

	$scopeSql = $helper->forSql($entityScope);
	$phaseSql = $helper->forSql($phaseID);

	$dbResult = $connection->query(
		"SELECT * FROM b_crm_field_attr "
		. "WHERE ENTITY_TYPE_ID = {$entityTypeID} AND ENTITY_SCOPE = '{$scopeSql}' "
		. "AND (START_PHASE = '{$phaseSql}' OR FINISH_PHASE = '{$phaseSql}')"
	);

	while($fields = $dbResult->fetch())
	{
		$startPhaseID = $fields['START_PHASE'];
		$finishPhaseID = $fields['FINISH_PHASE'];

		if($startPhaseID === $finishPhaseID)
		{
			continue;
		}

		$startPhase = isset($phases[$startPhaseID]) ? $phases[$startPhaseID] : null;
		$finishPhase = isset($phases[$finishPhaseID]) ? $phases[$finishPhaseID] : null;
		if(!(is_array($startPhase) && is_array($finishPhase)))
		{
			continue;
		}

		$startPhaseSort = isset($startPhase['SORT']) ? (int)$startPhase['SORT'] : 0;
		$finishPhaseSort = isset($finishPhase['SORT']) ? (int)$finishPhase['SORT'] : 0;
		if($startPhaseSort > $finishPhaseSort)
		{
			FieldAttributeTable::delete($fields['ID']);
		}
	}
}

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