• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/persontype.php
  • Класс: BitrixSaleControllerPersonType
  • Вызов: PersonType::addAction
public function addAction(array $fields)
{
	$r = new Result();

	$personTypeId = 0;
	$salePersonType = new CSalePersonType();

	if(isset($fields['ID']))
		unset($fields['ID']);

	if(isset($fields['CODE']))
		$r = $this->isCodeUniq($fields['CODE']);

	if($r->isSuccess())
	{
		$personTypeId = $salePersonType->Add($fields);
		if ((int)$personTypeId<=0)
		{
			if ($ex = self::getApplication()->GetException())
			{
				self::getApplication()->ResetException();
				self::getApplication()->ThrowException($ex->GetString(), 200750000006);

				$r->addError(new Error($ex->GetString(), $ex->GetID()));
			}
			else
				$r->addError(new Error('add person type error', 200750000001));
		}
	}

	if($r->isSuccess())
	{
		return ['PERSON_TYPE'=>$this->get($personTypeId)];
	}
	else
	{
		$this->addErrors($r->getErrors());
		return null;
	}
}