...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/attribute/fieldattributemanager.php
- Класс: Bitrix\Crm\Attribute\FieldAttributeManager
- Вызов: FieldAttributeManager::processPhaseDeletion
static function processPhaseDeletion($phaseID, $entityTypeID, $entityScope, array $phases = []) { $phaseID = (int)$phaseID; $entityTypeID = (int)$entityTypeID; $entityScope = (string)$entityScope; if (!is_array($phases)) { $phases = []; } // The state of the phases must be before deletion $phases = static::sortPhasesBySortAscAndIdDesc($phases); // Find prev and next phases [$prevPhaseId, $nextPhaseId] = static::findNeighborPhases($phaseID, $phases); // Preparation of actions for deleting or changing attributes, // the extreme phase of which coincides with the status to be deleted. // If the range includes one status, then the attribute is removed. // If the range includes more than one status, the range is reduced, // so that the deleted status is not included in it. $actions = []; $res = FieldAttributeTable::getList( [ 'filter' => [ '=ENTITY_TYPE_ID' => $entityTypeID, '=ENTITY_SCOPE' => $entityScope, '=TYPE_ID' => FieldAttributeType::REQUIRED, [ 'LOGIC' => 'OR', '=START_PHASE' => $phaseID, '=FINISH_PHASE' => $phaseID, ] ] ] ); while ($row = $res->fetch()) { $isStartPhase = $row['START_PHASE'] === $phaseID; $isFinishPhase = $row['FINISH_PHASE'] === $phaseID; if ( $row['START_PHASE'] === $row['FINISH_PHASE'] || ($isStartPhase && $nextPhaseId === null) || ($isFinishPhase && $prevPhaseId === null) ) { $actions[] = [ 'type' => 'delete', 'params' => [ 'id' => (int)$row['ID'], ], ]; } else { $updateFields = []; if ($isStartPhase) { $updateFields = [ 'START_PHASE' => $nextPhaseId ]; } else if ($isFinishPhase) { $updateFields = [ 'FINISH_PHASE' => $prevPhaseId, ]; } if (!empty($updateFields)) { $actions[] = [ 'type' => 'update', 'params' => [ 'id' => (int)$row['ID'], 'fields' => $updateFields, ], ]; } } } foreach ($actions as $action) { if ($action['type'] === 'update') { FieldAttributeTable::update($action['params']['id'], $action['params']['fields']); } else if ($action['type'] === 'delete') { FieldAttributeTable::delete($action['params']['id']); } } }