- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/entitymanagefacility.php
- Класс: Bitrix\Crm\EntityManageFacility
- Вызов: EntityManageFacility::registerCompany
public function registerCompany(array &$fields, $updateSearch = true, $options = array())
{
$this->registeredId = null;
$this->registeredTypeId = \CCrmOwnerType::Company;
$this->isBpRun = false;
if ($this->canAddCompany())
{
if (!isset($fields['TITLE']) || !$fields['TITLE'])
{
$fields['TITLE'] = (isset($fields['COMPANY_TITLE']) && $fields['COMPANY_TITLE']) ? $fields['COMPANY_TITLE'] : '';
}
// use entity configuration setting when create
if (!isset($fields['OPENED']) || empty($fields['OPENED']))
{
$fields['OPENED'] = Settings\CompanySettings::getCurrent()->getOpenedFlag() ? 'Y' : 'N';
}
$company = new \CCrmCompany(false);
$this->registeredId = $company->add($fields, $updateSearch, $options);
$this->registeredEntities->addIdentificator(
$this->registeredTypeId,
$this->registeredId,
true
);
if (!$this->registeredId)
{
$this->errors[] = $company->LAST_ERROR;
}
else
{
$this->traceEntity($this->registeredTypeId, $this->registeredId);
}
}
elseif ($this->canUpdate())
{
$this->updateClientFields($fields, true, $updateSearch, $options);
}
if ($this->isAutomationRun)
{
$this->runAutomation();
}
return !empty($this->registeredId);
}