• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_product_row.php
  • Класс: \CAllCrmProductRow
  • Вызов: CAllCrmProductRow::CheckFields
static function CheckFields($sAction, &$arFields, $ID)
{
	if($sAction == 'ADD')
	{
		if (!isset($arFields['OWNER_ID']))
		{
			self::RegisterError('Could not find Owner ID.');
			return false;
		}

		if (!isset($arFields['OWNER_TYPE']))
		{
			self::RegisterError('Could not find Owner Type.');
			return false;
		}

		if (!isset($arFields['PRODUCT_ID']))
		{
			self::RegisterError('Could not find Product ID.');
			return false;
		}

		if (!isset($arFields['PRICE']))
		{
			self::RegisterError('Could not find Price.');
			return false;
		}

		if (!isset($arFields['QUANTITY']))
		{
			self::RegisterError('Could not find Quantity.');
			return false;
		}

		$discountTypeID = isset($arFields['DISCOUNT_TYPE_ID'])
			&& \Bitrix\Crm\Discount::isDefined($arFields['DISCOUNT_TYPE_ID'])
			? intval($arFields['DISCOUNT_TYPE_ID']) : \Bitrix\Crm\Discount::UNDEFINED;

		if($discountTypeID !== \Bitrix\Crm\Discount::UNDEFINED
			&& !\Bitrix\Crm\Discount::isDefined($discountTypeID))
		{
			self::RegisterError("Discount type ID (DISCOUNT_TYPE_ID) '{$discountTypeID}' is not supported in current context.");
		}
		else if($discountTypeID === \Bitrix\Crm\Discount::MONETARY && !isset($arFields['DISCOUNT_SUM']))
		{
			self::RegisterError("Discount Sum (DISCOUNT_SUM) is required if Monetary Discount Type (DISCOUNT_TYPE_ID) is defined.");
		}
		else if($discountTypeID === \Bitrix\Crm\Discount::PERCENTAGE && !isset($arFields['DISCOUNT_RATE']))
		{
			self::RegisterError("Discount Rate (DISCOUNT_RATE) is required if Percentage Discount Type (DISCOUNT_TYPE_ID) is defined.");
		}
	}
	else//if($sAction == 'UPDATE')
	{
		if(!self::Exists($ID))
		{
			self::RegisterError("Could not find Product Row($ID).");
			return false;
		}
	}

	return true;
}