CCrmTax::setVatMode

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmTax
  4. setVatMode
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_tax.php
  • Класс: \CCrmTax
  • Вызов: CCrmTax::setVatMode
static function setVatMode()
{
	if(!Loader::includeModule('catalog'))
		return false;

	if(self::isVatMode())
		return true;

	$count = 0;
	$strActiveVats = COption::GetOptionString("crm", "crmSaveActiveVats", '');

	if( $strActiveVats <> '')
	{
		$arActiveVats = explode(',', $strActiveVats);

		foreach ($arActiveVats as $vatId)
		{
			$result = Catalog\Model\Vat::update(
				(int)$vatId,
				[
					'ACTIVE' => 'Y',
				]
			);
			if ($result->isSuccess())
			{
				$count++;
			}
		}
	}
	else
	{
		$dbVats = Catalog\Model\Vat::getList([
			'select' => [
				'ID',
			],
			'filter' => [
				'!=ACTIVE' => 'Y',
			],
		]);
		while ($arVat = $dbVats->fetch())
		{
			$result = Catalog\Model\Vat::update(
				(int)$arVat['ID'],
				[
					'ACTIVE' => 'Y',
				]
			);
			if ($result->isSuccess())
			{
				$count++;
			}
		}
	}

	COption::SetOptionString("crm", "vatModeSetted", 'Y');
	self::$bVatMode = true;

	return $count;
}

Добавить комментарий