# Убираем номера телефонов из названий сущностей

В современных CRM-системах, таких как Битрикс24, важной задачей становится обеспечение конфиденциальности клиентских данных. Одной из острых проблем является отображение номеров телефонов клиентов в названиях сущностей, что может приводить к несанкционированному доступу к информации. Чтобы предотвратить такие ситуации, возникает необходимость скрывать номера телефонов в названиях, оставляя доступ к полной информации только тем пользователям, которым это необходимо. Для этого воспользуемся кодом ниже.\
\
Нужно привести файл /opt/itgrix\_bx/customizer/actions/post\_registration.php к виду:

```php
<?php
/**
 * @var string $action "post_registration"
 *
 * Подробное описание в документации Itgrix:
 * https://docs.itgrix.ru/custom_bx
 *
 * Вывод в лог можно сделать так:
 *   $this->logDebug($message);
 * Функции для вывода с другим уровнем логирования: logInfo, logWarn, logError.
 *
 * Запросы в Битрикс24 реализованы в классе Bitrix (lib/crm.php)
 * Подробности и примеры в документации Itgrix:
 * https://docs.itgrix.ru/custom_bx/zaprosy-v-bitriks-iz-kastomizacii
 *
 * Дла запросов в БД Asterisk предусмотрены функции (lib/Utils.php):
 *   Utils::mysqliQuery($sql, $getResult);   - запрос через php-mysqli
 *   Utils::mysqlClcQuery($sql, $getResult); - запрос через MySQL Command-Line Client
 */

// Нужно вернуть только state, остальное игнорируется

$this->logDebug('params: ' . json_encode($params));

$newFields = array();
function makeErrorRetval($data) {
    return array(
        'state' => 'error',
        'data'  => $data,
    );
}

if (isset($params['call_full']['registration']['created_lead_id']) &&
    !empty($params['call_full']['registration']['created_lead_id'])) {

    $leadId = $params['call_full']['registration']['created_lead_id'];
    $this->logDebug('created_lead_id: ' . $leadId);

    $this->logDebug('type: ' . json_encode($params['call_full']['channel']['type']));

   	$wasAnswered = isset($params['call_full']['channel']['was_answered'])
   	    && $params['call_full']['channel']['was_answered'];

	if ($params['call_full']['channel']['type'] == 'incoming') {
	    $type = 'Входящий ';

        if (!$wasAnswered) {
            $type .= 'пропущенный ';
        }
    } else if ($params['call_full']['channel']['type'] == 'outgoing') {
        $type = 'Исходящий ';

        if (!$wasAnswered) {
            $type .= 'неотвеченный ';
        }
    }

	$newFields = array(
		'TITLE' => $type . 'звонок', //изменяем название
	);
	$this->logDebug('newFields: ' . json_encode($newFields, JSON_UNESCAPED_UNICODE));

	$updateResult = Bitrix::updateLead($leadId, $newFields, array());
    if ($updateResult === false) {
        return makeErrorRetval(sprintf("Failed to update lead ID '%s'", $leadId));
    }
} else {
	$this->logDebug("No lead was created, do nothing");
}

return array(
    'state' => 'success',
);

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.itgrix.ru/custom_bx/ubiraem-nomera-telefonov-iz-nazvanii-sushnostei.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
